C# Winform自定义控件GDI+实现住院病床控件

e1e7e9d11d69a750153335b9f5282f21.png

首先我们学习组件的开发,必须要了解winform的绘图是怎么绘制的,
以下知识建议先自行了解:
PaintEventArgs
Rectangle
GraphicsPath

我们使用GraphicsPath添加一个三角形路径

GraphicsPath graphicsPath = new GraphicsPath();
            graphicsPath.AddLine(new Point(0, 0), new Point(0, 50));
            graphicsPath.AddLine(new Point(0, 0), new Point(50, 0));
            graphicsPath.AddLine(new Point(0, 50), new Point(50, 0));
            graphicsPath.AddLine(new Point(50, 0), new Point(0, 50));
            graphicsPath.CloseFigure();

然后把三角形绘制出来

//绘制三角形
            e.Graphics.FillPath(new SolidBrush(Color.FromArgb(15, 93, 244)), graphicsPath);

然后我们添加分割线

//绘制下划线
            e.Graphics.DrawLine(new Pen(Color.FromArgb(15, 93, 244)), new Point(0, 50), new Point(this.Width, 50));

接着绘制序号

//绘制序号
            e.Graphics.DrawString(_sortNo.ToString().PadLeft(3,'0'), font, new SolidBrush(Color.White), new Point(0, 0));

床位一共有两种模式:

1:未使用空床情况

2:已使用情况

当未使用时 绘制空床

e.Graphics.DrawString("空床", font, new SolidBrush(Color.FromArgb(14, 43, 94)), new Point(this.Width / 2 - 24, this.Height / 2 - 12));

当已使用时绘制用户信息及其临床诊断以及护理类别

//绘制类别
                font = new Font("微软雅黑", 12, FontStyle.Bold);
                e.Graphics.DrawString(_UserType, font, new SolidBrush(Color.FromArgb(14, 43, 94)), new Point(this.Width / 2 - 12, 13));
                //绘制用户姓名
                font = new Font("微软雅黑", 24, FontStyle.Bold);
                e.Graphics.DrawString(_UserName, font, new SolidBrush(Color.FromArgb(14, 43, 94)), new Point(55, 63));

总结

本篇博客描述了c#Winform自定义控件GDI+实现住院病床控件

如果觉得还不错,请给个关注

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值