绘制文本和图形
2013-04-13 20:30
267 查看
如何:在窗体上绘制文本
如何:更改 Windows 窗体控件上文本的颜色
如何:在 Windows 窗体上绘制图形
如何:在窗体上绘制曲线
如何:绘制空心形状
如何:在窗体上绘制直线
如何:在窗体上绘制实心矩形
如何:在窗体上绘制实心椭圆
如何:创建实心画笔 (Visual C#)
如何:创建钢笔 (Visual C#)
如何:设置钢笔的颜色 (Visual C#)
private void DrawString() { System.Drawing.Graphics formGraphics = this.CreateGraphics(); string drawString = "Sample Text"; System.Drawing.Font drawFont = new System.Drawing.Font( "Arial", 16); System.Drawing.SolidBrush drawBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black); float x = 150.0f; float y = 50.0f; formGraphics.DrawString(drawString, drawFont, drawBrush, x, y); drawFont.Dispose(); drawBrush.Dispose(); formGraphics.Dispose(); }
如何:更改 Windows 窗体控件上文本的颜色
label1.ForeColor=System.Drawing.Color.Pink;
如何:在 Windows 窗体上绘制图形
System.Drawing.Graphics graphics = this.CreateGraphics(); System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle( 100, 100, 200, 200); graphics.DrawEllipse(System.Drawing.Pens.Black, rectangle); graphics.DrawRectangle(System.Drawing.Pens.Red, rectangle);
如何:在窗体上绘制曲线
System.Drawing.Graphics formGraphics = this.CreateGraphics(); System.Drawing.Pen myPen; myPen = new System.Drawing.Pen(System.Drawing.Color.Black); // Draw head with an ellipse. formGraphics.DrawEllipse(myPen, 0, 0, 200, 200); // Draw winking eye with an arc. formGraphics.DrawArc(myPen, 40, 40, 40, 40, 180, -180); // Draw open eye with an ellipse. formGraphics.DrawEllipse(myPen, 120, 40, 40, 40); // Draw nose with a Bezier spline. formGraphics.DrawBezier(myPen, 100, 60, 120, 100, 90, 120, 80, 100); // Draw mouth with a canonical spline. Point[] apt = new Point[4]; apt[0] = new Point(60, 140); apt[1] = new Point(140, 140); apt[2] = new Point(100, 180); apt[3] = new Point(60, 140); formGraphics.DrawCurve(myPen, apt, 0, 3, 0.9f); myPen.Dispose(); formGraphics.Dispose();
如何:绘制空心形状
private void DrawEllipse() { System.Drawing.Pen myPen; myPen = new System.Drawing.Pen(System.Drawing.Color.Red); System.Drawing.Graphics formGraphics = this.CreateGraphics(); formGraphics.DrawEllipse(myPen, new Rectangle(0,0,200,300)); myPen.Dispose(); formGraphics.Dispose(); } private void DrawRectangle() { System.Drawing.Pen myPen; myPen = new System.Drawing.Pen(System.Drawing.Color.Red); System.Drawing.Graphics formGraphics = this.CreateGraphics(); formGraphics.DrawRectangle(myPen, new Rectangle(0,0,200,300)); myPen.Dispose(); formGraphics.Dispose(); }
如何:在窗体上绘制直线
System.Drawing.Pen myPen; myPen = new System.Drawing.Pen(System.Drawing.Color.Red); System.Drawing.Graphics formGraphics = this.CreateGraphics(); formGraphics.DrawLine(myPen, 0, 0, 200, 200); myPen.Dispose(); formGraphics.Dispose();
如何:在窗体上绘制实心矩形
System.Drawing.SolidBrush brush1 = new System.Drawing.SolidBrush(System.Drawing.Color.Red); System.Drawing.Graphics formGraphics = this.CreateGraphics(); formGraphics.FillRectangle(brush1, new System.Drawing.Rectangle(0,0,200,300)); brush1.Dispose(); formGraphics.Dispose();
如何:在窗体上绘制实心椭圆
System.Drawing.SolidBrush brush1 = new System.Drawing.SolidBrush(System.Drawing.Color.Red); System.Drawing.Graphics formGraphics = this.CreateGraphics(); formGraphics.FillEllipse(brush1, new System.Drawing.Rectangle(0,0,200,300)); brush1.Dispose(); formGraphics.Dispose();
如何:创建实心画笔 (Visual C#)
System.Drawing.SolidBrush myBrush; myBrush = new System.Drawing.SolidBrush(System.Drawing.Color.Black); myBrush.Dispose();
如何:创建钢笔 (Visual C#)
System.Drawing.Pen myPen; myPen = new System.Drawing.Pen(System.Drawing.Color.Black); myPen.Dispose();
如何:设置钢笔的颜色 (Visual C#)
myPen.Color = System.Drawing.Color.PeachPuff;
相关文章推荐
- Windows App开发之编辑文本与绘制图形
- 安卓案例:绘制文本图形图像
- 绘制图形和文本
- 【UWP通用应用开发】编辑文本、绘制图形、3D透视效果及绘制时钟实战
- java绘制图形和文本<一>
- Windows App开发之编辑文本与绘制图形
- Qt之图形(绘制文本)
- Qt之图形(绘制文本)
- Qt之图形(绘制文本)
- Qt之图形(绘制文本)
- HTML5利用Canvas绘制图形(使用图像、裁剪区域、使用文本。阴影效果和操作像素)
- android|图形图像 fontmetrics 文本绘制
- 图形的绘制,如何使用自定义画笔(颜色,线宽,线形)。如何为程序中添加选项菜单和选项设置对话框,如何使用标准颜色对话框,如何使用字体对话框,在选项对话框中实现预览功能。实现选项对话框和窗口类中的数据交换。如何改变对话框和控件的背景色,如何改变控件的文本颜色,
- OpenGL(一)二维图形的绘制:图元、多边形、颜色插值、文本、查询与错误、状态的保存
- Windows App开发之编辑文本与绘制图形
- 安卓突击:绘制图形和文本
- 用flash cs4 as 绘制图形、 绘制文本 、创建超链接文本
- 【Android开发】图形图像处理技术-绘制文本
- drawRect的绘制的使用(绘制文本字符、绘制图片、绘制图形)
- 使用asciiflow绘制文本图形,解决文本文档中无法嵌入图片问题