![](https://img-blog.csdnimg.cn/20190918140053667.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
winform自定义控件GDI绘图
文章平均质量分 62
winform进阶-Gdi绘图创建自定义控件
优惠券已抵扣
余额抵扣
还需支付
¥9.90
¥99.00
购买须知?
本专栏为图文内容,最终完结不会低于15篇文章。
订阅专栏,享有专栏所有文章阅读权限。
本专栏为虚拟商品,基于网络商品和虚拟商品的性质和特征,专栏一经购买无正当理由不予退款,不支持升级,敬请谅解。
c#上位机
硕士,高级软件工程师,精通c#上位机开发,《C#串口通信从入门到精通》,《C# Modbus通信从入门到精通》,《winform控件从入门到精通》专栏作者,持续专注上位机软件开发,立志成为上位机软件开发领域领路人!
展开
-
手把手教你绘制winform自定义控件
【代码】绘制自定义控件。原创 2024-02-18 15:11:05 · 224 阅读 · 0 评论 -
winform自定义控件(gdi+)(4)———UITypeEditor
1、UITypeEditorEditStyle.None2、 UITypeEditorEditStyle.Modal3、UITypeEditorEditStyle.DropDown原创 2021-08-12 13:58:26 · 1925 阅读 · 2 评论 -
winform自定义控件(gdi+)(3)———自定义类型属性
前言:假如自定义控件中需要一些自定义类型的属性,那么如果直接使用时,会出现下面的情况此处自定义一个结构体public struct ThreeDimensionPoint{public int X { get; set; }public int Y { get; set; }public int Z { get; set; }}属性定义如下:[CategoryAttribute(“自定义项目”), DescriptionAttribute(“三维坐标”), ReadOnly(false原创 2021-08-12 12:01:54 · 1359 阅读 · 0 评论 -
winform自定义控件(gdi+)(1)———设置透明背景色
本文详细讲解了如何在winform中设置控件的背景色为透明色原创 2021-08-11 13:17:31 · 3188 阅读 · 0 评论 -
winform自定义控件(gdi+)(2)———系统自带类型属性
前言:我们在自定义控件的时候,难免需要给自定义控件类添加一系列的属性,如下:[CategoryAttribute("自定义项目"), DescriptionAttribute("曲线类型")]public Jerk jerk { get; set; } = Jerk.S;[CategoryAttribute("自定义项目"), DescriptionAttribute("控件坐标点")]public Point MyControlPoint { get; set; }[CategoryA原创 2021-08-12 11:35:53 · 1047 阅读 · 0 评论 -
c#绘制扇形,圆角矩形,多边形
class Class1 : Control{public Class1(){this.SetStyle(ControlStyles.ResizeRedraw, true);//空间大小改变时,控件会重绘} protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); Graphics graphics = this.CreateGraphics(); g原创 2020-08-29 16:30:51 · 2725 阅读 · 0 评论 -
c#利用GDI画圆形控件
如下:1、如何解决调用DrawString时报“参数无效”的问题?2、如何在改变控件尺寸时,圆的直径也跟着改变?3、如何只在圆内响应单机事件,但是不在圆外控件内的那部分响应单机事件?4、如何在最小化窗体后,控件的圆以及圆内的文字实现重新的绘制?本博客将会解决上述四个问题,如下:class MyControl : Control { public MyControl() { //this.BackColor = Color.Ye原创 2020-08-22 22:46:54 · 3610 阅读 · 3 评论 -
C#GDI绘图——Color的四种获取方式
1、直接获取Color类的属性1)代码方式btnColor.BackColor = Color.Red;2 )控件设置,web这一栏的颜色和Color类的属颜色属性一致2、调用FromArgb方法获取rgb的值1)代码方式btnColor.BackColor = Color.FromArgb(0, 255, 0);2)控件设置在自定义一栏使用数字设置或者直接选中某种颜色3、调用FromKnownColor方法1)代码方式btnColor.BackColor = Color.FromK原创 2020-09-23 14:52:14 · 1986 阅读 · 0 评论 -
winform自定义控件(gdi+)(8)——钢笔工具Pen的用法
1\原创 2020-09-26 18:43:17 · 4317 阅读 · 0 评论 -
winform自定义控件(gdi+)(9)——Brush类的用法
顶顶顶顶原创 2020-09-26 18:46:30 · 2446 阅读 · 0 评论 -
winform自定义控件(gdi+)(10)——font类的用法
1、FontStyle(指定应用到文本的字形信息,粗体、斜体等)for (int i = 0; i < 6; i++){TextBox textBox = new TextBox();Font font = default;textBox.Location = new Point(30 * i, 30 * i);switch (i){case 0:font = new Font(textBox1.Font, FontStyle.Regular);//常规break;case 1:原创 2021-04-02 16:42:01 · 1463 阅读 · 0 评论 -
winform自定义控件(gdi+)(5)———数据类型Point
1、字段Empty代码: Point point1111 = Point .Empty; Console.WriteLine($"{point1111.IsEmpty} ,x={point1111.X},y={point1111.Y }");输出:True ,x=0,y=0说明:该字段就是表示一个 Point,其 X 和 Y 值设为零。2、属性1)IsEmpty该属性的作用是:如果 X 和 Y 均为 0,则为 true;否则为 false,代码:Point point1 = new原创 2021-08-19 09:22:46 · 708 阅读 · 0 评论 -
winform自定义控件(gdi+)(6)———数据类型Rectangle
Rectangle rect = new Rectangle(0, 0,100,100); Console.WriteLine(rect .Left ); Console.WriteLine(rect.Right ); Console.WriteLine(rect.Top ); Console.WriteLine(rect.Bottom ); Console.WriteLine(rect.Width ); C原创 2021-08-19 13:44:01 · 941 阅读 · 0 评论 -
winform自定义控件(gdi+)(7)——Matrix类的用法
1、属性1)Elements代码: Matrix myMatrix = new Matrix(); myMatrix.Elements.ToList().ForEach((item)=> { Console.WriteLine(item); });输出:100100说明:该属性包含了这个Matrix对象的六个元素,初始化时,这个矩阵是一个3*3的单位矩阵,前四个元素是矩阵中线性变换的参数(包括缩放和旋转),后两个是矩阵中用于平移变换的参数,2)原创 2021-08-24 11:59:56 · 865 阅读 · 0 评论 -
winform自定义控件(gdi+)(11)——绘制文本(DrawString)
fffff原创 2021-08-25 14:33:15 · 1421 阅读 · 0 评论 -
winform自定义控件(gdi+)(12)——测量文本大小(MeasureString)
1、MeasureString(String, Font)代码: string measureString = "Measure String"; Font stringFont1 = new Font("Arial", 60); SizeF layoutSize = new SizeF(200.0F, 50.0F); // Measure string. SizeF stringSize = new原创 2021-08-26 08:40:20 · 804 阅读 · 0 评论 -
winform自定义控件(gdi+)(13)——StringFormat
1、属性1)Alignment代码:Rectangle displayRectangle =new Rectangle(new Point(40, 40), new Size(80, 40)); StringFormat format1 = new StringFormat(); StringFormat format2 = new StringFormat(); StringFormat format3 = new StringFormat();原创 2021-08-30 14:59:24 · 559 阅读 · 0 评论 -
winform自定义控件(gdi+)(14)——绘制图像(DrawImage)
1、显示图像 Graphics g = e.Graphics; Bitmap bmp = new Bitmap("1.jpg"); g.DrawImage(bmp,0,0);//屏幕上图像的大小为屏幕分辨率和图像分辨率的比值 Console.WriteLine(g.DpiX ); Console.WriteLine(g.DpiY ); Console.WriteLine(bmp.H原创 2021-09-08 16:52:40 · 2483 阅读 · 4 评论 -
winform自定义控件(gdi+)(15)——GraphicsPath
1、属性GraphicsPath path = new GraphicsPath();path.FillMode = FillMode.Winding ;//指示填充的模式,参考这篇博客两种不同的填充模式PathData pathData = path.PathData;//指示路径的数据PointF[] pointFs = path.PathPoints;//指示路径的点byte[] types = path.PathTypes;//指示路径上每个点的类型1)FillMode2)PathDa原创 2021-09-10 09:50:01 · 1460 阅读 · 0 评论 -
winform自定义控件(gdi+)(16)——Region
一、利用GraphicsPath对象创建的路径来创建区域代码: Graphics g = e.Graphics; GraphicsPath gp = new GraphicsPath(); gp.AddLine(10, 10, 10, 50); gp.AddLine(10, 50, 50, 50); gp.AddLine(50, 50, 50, 10); gp.StartFigure原创 2021-09-15 11:07:23 · 1035 阅读 · 0 评论 -
winform自定义控件(gdi+)(17)——指定剪切区域(控制绘制部分图形)
SetClip(指定剪切区域)代码: protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; Rectangle rect1 = new Rectangle(10,10,80,50); g.DrawRectangle(Pens.Black ,rect1); g.SetClip(rect1);//设原创 2021-09-15 15:52:08 · 543 阅读 · 0 评论 -
winform自定义控件(gdi+)(19)——图像变换(缩放,平移,旋转)
1、缩放代码: protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; g.FillRectangle(Brushes .White ,this.ClientRectangle ); Rectangle rectangle = new Rectangle(10, 10, 50, 50); g.D原创 2021-09-15 16:43:45 · 2271 阅读 · 0 评论 -
winform自定义控件(gdi+)(18)——使绘图图面失效,继而重绘
protected override void OnPaint(PaintEventArgs e) { Graphics g = e.Graphics; if (isTrue) { g.FillRectangle(Brushes.White, this.ClientRectangle); } else {原创 2021-09-15 16:01:54 · 903 阅读 · 0 评论 -
Gdi在form窗体画图的正确方式
public partial class Form1 : Form { int index = 0; public Form1() { InitializeComponent(); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); // 禁止擦除背原创 2021-12-14 13:12:07 · 363 阅读 · 0 评论