zoukankan      html  css  js  c++  java
  • WinForm------PanelControl控件中使用Pen类画角圆矩形方法

    private void rightPanel_Paint(object sender, PaintEventArgs e)
    {
        Graphics g = e.Graphics;
        Pen p = new Pen(Color.FromArgb(255,146,126,102));
        p.Width = 8;
        DrawRoundRect(g, p, 110 + nowPicture * 370, 122, 292, 200, 10);
    }
    
    public void DrawRoundRect(Graphics g, Pen p, float X, float Y, float width, float height, float radius)
    {
      GraphicsPath gp = new GraphicsPath();
                
      gp.AddLine(X + radius, Y, X + width - (radius * 2), Y);
      
      gp.AddArc(X + width - (radius * 2), Y, radius * 2, radius * 2, 270, 90);
    
      gp.AddLine(X + width, Y + radius, X + width, Y + height - (radius * 2));
    
      gp.AddArc(X + width - (radius * 2), Y + height - (radius * 2), radius * 2, radius * 2, 0, 90);
    
      gp.AddLine(X + width - (radius * 2), Y + height, X + radius, Y + height);
    
      gp.AddArc(X, Y + height - (radius * 2), radius * 2, radius * 2, 90, 90);
    
      gp.AddLine(X, Y + height - (radius * 2), X, Y + radius);
    
      gp.AddArc(X, Y, radius * 2, radius * 2, 180, 90);
    
      gp.CloseFigure();
    
      g.DrawPath(p, gp);
      gp.Dispose();
    }
  • 相关阅读:
    06软件构架实践阅读笔记之六
    05软件构架实践阅读笔记之五
    04软件构架实践阅读笔记之四
    03软件构架实践阅读笔记之三
    02软件构架实践阅读笔记之二
    01软件构架实践阅读笔记之一
    实训第四天
    实训第三天
    实训第二天
    实训第一天
  • 原文地址:https://www.cnblogs.com/tianhengblogs/p/6101865.html
Copyright © 2011-2022 走看看