From 9a44b4eade34fb746ce92ddb55833065926ad9ed Mon Sep 17 00:00:00 2001 From: lhiven <236881222@qq.com> Date: Tue, 13 Jun 2023 07:53:17 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8C=89=E9=92=AE=E5=9B=BE?= =?UTF-8?q?=E6=A0=87=E7=9A=84=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Rs.Controls/Resources/iconfont.ttf | Bin 6596 -> 7380 bytes Rs.Controls/RsButton.Designer.cs | 21 +++++++++++-- Rs.Controls/RsButton.cs | 47 ++++++++++++++++++++++++++++- 3 files changed, 65 insertions(+), 3 deletions(-) diff --git a/Rs.Controls/Resources/iconfont.ttf b/Rs.Controls/Resources/iconfont.ttf index bb43738bb9957a5a8999fbe08ddbacb7294a1b40..f11692dccd41224b0ad9998e39fa5ae6650a2180 100644 GIT binary patch delta 1456 zcmaKrZD?Cn7{{M;&wa_8c`+}2!?jJCrtdZ{P1>x>;wP&P#%gLnGTUp~HQAb^v#r+3 zOxG_?*g#1?jDa%rgWv>*!!I&qg8D(Fh$x63R7B5Q2rB4c2+j35_pTNdyqDiS&pGFL z&iVh(Nj{8zIq_0gb#nLUG5|Rb0CV}0x~#r7@hyOm2B4P3rDsnxj?_H>(mH_q^TL8U z-}7AXUCjL+i5GA{`GLNO@pYu9P+DEjQ0;eIuYvu{QYEhjw+D8x{s{JmO6vMD86|@_ z--`XNvRb-t!TI{+Re-iB+;nldva;&@ShN9j;2810d_8d33j}kKrxU?DvyREzU=?uy zCA@W-ud27&?dC<%PS0W21Ogw$hu3*)2gut5YCB|9(6ribWO_-k=rce>pn5cftp&HY zfCyh>O&@e&WMaT5lUNVyXQOP2W!Q06VrSSEyLyw|O4d)+OO0^jvZevt%?$iEv-YYm zT)QEdW(cloyaVumFIVkC2Ud_!!@XdKdq4&!IKYD{ZQw?KW>l+SqI}Io1yaS)yJmTd zd8o&LyJOSftX4<6(w19GJ@&}dz)<+{)pVjT*f~u_u`WnN6sOxe{ljAiX>elvi6?)| z&rKv#l_^iZS#sJFkB$ruPCcAGyqdi~7-&02%|xPgK|JQ`@OC&{y705~Ag%JVCKBm3 zlWtl~Hs5c4M5@hQfiz#B&u=%6HXjoBZyK~4^aJ_;9(q4a;D1o}6HCMs@d&r;;l^p$ zuh@xhKf-5X+%uIib<7n@kw_=OJOMTe3zLTqO)eDv*b6p_*^C+u&t$8gWM{%r9=)MB z6{pGJRDQMF)Bi};tLRuXeC5-kD1T z&3>^T7B@>LQ|WZ-WJ!a)$ZN6L+&0^HX1&?`cZpFw$ZJUd-$h2b@TS$$+_YG&7NURm z<7+1ACpYoderffO5I6A?fGRtjo)zNnVv)5ZBpc~RL=%d5rm JV$Id|&R^Y6P|E-S delta 695 zcmZ{gKWI}?6vn^%{xq+)rVWCW+G=>oBCU`j2$qUVgiMN|leB7RYXj}G0gKe3Mhb$1 zgXJl75G=Sks8n!}QXCvrL=+q{gdnH%5pXe!Ltnr9E)EX9%kTa<_q_9c=YBi;;q;?y z{TwdU0QC^S^_iejd-CqtTfi!it@*_}H%@vlegUorWTvWfmDzmp?sw)k$(bqxsg`}8 z`)!i12Foi&EB?)TZJvvZOEZmla0;DA1mJxJc5dy;~I8jzAf_b8JF>O!Us`mrQ1&vG%pdT$_Aq^Wrd(6O=(B3rY=916H6+A|y%1W$~)wJI`zH`qVbazr$ ey^G#UowvVX52-huRO5)sgkO*O3ZXx=rEmaElcV|o diff --git a/Rs.Controls/RsButton.Designer.cs b/Rs.Controls/RsButton.Designer.cs index 01cb300..e253d3c 100644 --- a/Rs.Controls/RsButton.Designer.cs +++ b/Rs.Controls/RsButton.Designer.cs @@ -30,12 +30,13 @@ { this.lblTips = new System.Windows.Forms.Label(); this.lbl = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); this.SuspendLayout(); // // lblTips // this.lblTips.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); - this.lblTips.BackColor = System.Drawing.Color.Transparent; + this.lblTips.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(192)))), ((int)(((byte)(192))))); this.lblTips.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.lblTips.ForeColor = System.Drawing.Color.White; this.lblTips.ImageIndex = 0; @@ -50,7 +51,7 @@ // this.lbl.Anchor = System.Windows.Forms.AnchorStyles.None; this.lbl.BackColor = System.Drawing.Color.Transparent; - this.lbl.Font = new System.Drawing.Font("Microsoft YaHei", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.lbl.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.lbl.ForeColor = System.Drawing.Color.White; this.lbl.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; this.lbl.Location = new System.Drawing.Point(0, 0); @@ -60,11 +61,26 @@ this.lbl.Text = "自定义按钮"; this.lbl.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; this.lbl.Click += new System.EventHandler(this.lbl_MouseClick); + this.lbl.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lbl_MouseDown); + this.lbl.MouseUp += new System.Windows.Forms.MouseEventHandler(this.lbl_MouseUp); + // + // label1 + // + this.label1.BackColor = System.Drawing.Color.Transparent; + this.label1.Dock = System.Windows.Forms.DockStyle.Left; + this.label1.ForeColor = System.Drawing.Color.White; + this.label1.Location = new System.Drawing.Point(0, 0); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(104, 84); + this.label1.TabIndex = 4; + this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.label1.Paint += new System.Windows.Forms.PaintEventHandler(this.label1_Paint); // // RsButton // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.label1); this.Controls.Add(this.lblTips); this.Controls.Add(this.lbl); this.Name = "RsButton"; @@ -77,5 +93,6 @@ private System.Windows.Forms.Label lblTips; public System.Windows.Forms.Label lbl; + private System.Windows.Forms.Label label1; } } diff --git a/Rs.Controls/RsButton.cs b/Rs.Controls/RsButton.cs index cedbad8..128c455 100644 --- a/Rs.Controls/RsButton.cs +++ b/Rs.Controls/RsButton.cs @@ -11,8 +11,26 @@ using System.Windows.Forms; namespace Rs.Controls { + public enum EButtonIcon + { + None, + EStop, + Reset, + Start, + Stop + } public partial class RsButton : ControlBase { + private EButtonIcon _ButtonType; + + public EButtonIcon ButtonType + { + get { return _ButtonType; } + set { _ButtonType = value; + + } + } + public RsButton() { InitializeComponent(); @@ -226,7 +244,6 @@ namespace Rs.Controls e.Graphics.CompositingQuality = CompositingQuality.HighQuality; e.Graphics.FillEllipse(new SolidBrush(m_tipsColor), new Rectangle(0, 0, lblTips.Width - 1, lblTips.Height - 1)); System.Drawing.SizeF sizeEnd = e.Graphics.MeasureString(TipsText, lblTips.Font); - e.Graphics.DrawString(TipsText, lblTips.Font, new SolidBrush(lblTips.ForeColor), new PointF((lblTips.Width - sizeEnd.Width) / 2, (lblTips.Height - sizeEnd.Height) / 2 + 1)); } @@ -256,5 +273,33 @@ namespace Rs.Controls if (this.BtnClick != null) BtnClick(this, e); } + + private void label1_Paint(object sender, PaintEventArgs e) + { + StringFormat sf = new StringFormat(); + sf.Alignment = StringAlignment.Center; + sf.LineAlignment = StringAlignment.Center; + FontFamily ff = IconFontHelper.PFCC.Families[0]; + Font font = new Font(ff, 40); + switch (ButtonType) + { + case EButtonIcon.None: + break; + case EButtonIcon.EStop: + e.Graphics.DrawString("\ue605", font,new SolidBrush(this.ForeColor), label1.ClientRectangle, sf); + break; + case EButtonIcon.Reset: + e.Graphics.DrawString("\ue600", font, new SolidBrush(this.ForeColor), label1.ClientRectangle, sf); + break; + case EButtonIcon.Start: + e.Graphics.DrawString("\ue6b0", font, new SolidBrush(this.ForeColor), label1.ClientRectangle, sf); + break; + case EButtonIcon.Stop: + e.Graphics.DrawString("\ue629", font, new SolidBrush(this.ForeColor), label1.ClientRectangle, sf); + break; + default: + break; + } + } } }