【C#学习】PictureBox控件

创建笔刷

SolidBrush sbrush = new SolidBrush(Color.White);

刷新

//disp is a Picture Control 
disp.Invalidate();

绘制点

//method1:use eclipse to replace point
Graphics g = disp.CreateGraphics();
g.FillEllipse(Brushes.Red, 10, 10, 2, 2);
//method2:use line to replace point
Graphics g = pictureBox1.CreateGraphics();
g.DrawLine(new Pen(Color.Red), 15, 15, 16, 16);//通过画线方法或其它方法

绘制实心点

float[] dashValues = { 1, 1, 5, 1 };

Pen blackPen = new Pen(Color.Green, 1);

blackPen.DashPattern = dashValues;

e.Graphics.DrawLine(blackPen, new Point(0, 0), new Point(0, 100));

绘制虚线

Pen blackPen = new Pen(Color.Green, 1);

e.Graphics.DrawLine(blackPen, new Point(0, 0), new Point(0, 100));

绘制直线

Graphics g = pictureBox1.CreateGraphics();
g.DrawLine(new Pen(Color.Red), 15, 15, 16, 16);//通过画线方法或其它方法

你可能感兴趣的:(编程技术,c#)