// *********************************************************************** // Assembly : HZH_Controls // Created : 09-02-2019 // // *********************************************************************** // // Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com // // // Blog: https://www.cnblogs.com/bfyx // GitHub:https://github.com/kwwwvagaa/NetWinformControl // gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git // // If you use this code, please keep this note. // *********************************************************************** using System; using System.Collections.Generic; using System.ComponentModel; using System.Drawing; using System.Data; using System.Linq; using System.Text; using System.Windows.Forms; namespace HZH_Controls.Controls { /// /// Class UCLEDNums. /// Implements the /// /// public partial class UCLEDNums : UserControl { /// /// The m value /// private string m_value; /// /// Gets or sets the value. /// /// The value. [Description("值"), Category("自定义")] public string Value { get { return m_value; } set { m_value = value; ReloadValue(); } } /// /// The m line width /// private int m_lineWidth = 8; /// /// Gets or sets the width of the line. /// /// The width of the line. [Description("线宽度,为了更好的显示效果,请使用偶数"), Category("自定义")] public int LineWidth { get { return m_lineWidth; } set { m_lineWidth = value; foreach (UCLEDNum c in this.Controls) { c.LineWidth = value; } } } /// /// 获取或设置控件的前景色。 /// /// The color of the fore. /// /// /// [Description("颜色"), Category("自定义")] public override System.Drawing.Color ForeColor { get { return base.ForeColor; } set { base.ForeColor = value; foreach (UCLEDNum c in this.Controls) { c.ForeColor = value; } } } /// /// 获取或设置一个值,该值指示是否将控件的元素对齐以支持使用从右向左的字体的区域设置。 /// /// The right to left. /// /// /// /// /// /// public override RightToLeft RightToLeft { get { return base.RightToLeft; } set { base.RightToLeft = value; ReloadValue(); } } /// /// Reloads the value. /// private void ReloadValue() { try { ControlHelper.FreezeControl(this, true); this.Controls.Clear(); foreach (var item in m_value) { UCLEDNum uc = new UCLEDNum(); if (RightToLeft == System.Windows.Forms.RightToLeft.Yes) uc.Dock = DockStyle.Right; else uc.Dock = DockStyle.Left; uc.Value = item; uc.ForeColor = ForeColor; uc.LineWidth = m_lineWidth; this.Controls.Add(uc); if (RightToLeft == System.Windows.Forms.RightToLeft.Yes) uc.SendToBack(); else uc.BringToFront(); } } finally { ControlHelper.FreezeControl(this, false); } } /// /// Initializes a new instance of the class. /// public UCLEDNums() { InitializeComponent(); Value = "0.00"; } } }