zoukankan      html  css  js  c++  java
  • C#GDI+ 的笔刷

    笔刷用Pen类表示,使用Pen后,必须释放资源。如下例

    private void Form1_Paint(object sender, PaintEventArgs e)
    {
        Graphics g = e.Graphics;
        g.FillRectangle(Brushes.White, this.ClientRectangle);
    
        Pen p = new Pen(Color.Black);
        g.DrawLine(p, 0, 0, 100, 100);
        p.Dispose();
    }
    

    可以设置Pen的线宽和对齐方式

    private void Form1_Paint(object sender, PaintEventArgs e)
    {
        Graphics g = e.Graphics;
        g.FillRectangle(Brushes.White, this.ClientRectangle);
    
        Pen p = new Pen(Color.Black,3);
        p.Alignment=.PenAlignment.Center;
        g.DrawRectangle(p,3,3,8,7);
        p.Dispose();
    }
    

    设置画笔的点划线属性用DashStyle属性

    private void Form1_Paint(object sender, PaintEventArgs e)
    {
        Graphics g = e.Graphics;
        g.FillRectangle(Brushes.White, this.ClientRectangle);
    
        Pen p = new Pen(Color.Black,2);
        p.DashStyle = DashStyle.Dash;
        g.DrawLine(p, 3, 3, 100, 3);
        p.Dispose();
    }
    
  • 相关阅读:
    服务器搭建Git
    BGP协议详解
    以太坊
    燃 * & *
    UML类图解析
    day8.文件操作
    python面试题汇总
    day5.字典
    day5.类型汇总
    day3,4总结程序
  • 原文地址:https://www.cnblogs.com/djcsch2001/p/2039472.html
Copyright © 2011-2022 走看看