UCLEDDataTime.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. // ***********************************************************************
  2. // Assembly : HZH_Controls
  3. // Created : 09-02-2019
  4. //
  5. // ***********************************************************************
  6. // <copyright file="UCLEDDataTime.cs">
  7. // Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
  8. // </copyright>
  9. //
  10. // Blog: https://www.cnblogs.com/bfyx
  11. // GitHub:https://github.com/kwwwvagaa/NetWinformControl
  12. // gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
  13. //
  14. // If you use this code, please keep this note.
  15. // ***********************************************************************
  16. using System;
  17. using System.Collections.Generic;
  18. using System.ComponentModel;
  19. using System.Drawing;
  20. using System.Data;
  21. using System.Linq;
  22. using System.Text;
  23. using System.Windows.Forms;
  24. namespace HZH_Controls.Controls
  25. {
  26. /// <summary>
  27. /// Class UCLEDDataTime.
  28. /// Implements the <see cref="System.Windows.Forms.UserControl" />
  29. /// </summary>
  30. /// <seealso cref="System.Windows.Forms.UserControl" />
  31. public partial class UCLEDDataTime : UserControl
  32. {
  33. /// <summary>
  34. /// The m value
  35. /// </summary>
  36. private DateTime m_value;
  37. /// <summary>
  38. /// Gets or sets the value.
  39. /// </summary>
  40. /// <value>The value.</value>
  41. [Description("值"), Category("自定义")]
  42. public DateTime Value
  43. {
  44. get { return m_value; }
  45. set
  46. {
  47. m_value = value;
  48. string str = value.ToString("yyyy-MM-dd HH:mm:ss");
  49. for (int i = 0; i < str.Length; i++)
  50. {
  51. if (i == 10)
  52. continue;
  53. ((UCLEDNum)this.tableLayoutPanel1.Controls.Find("D" + (i + 1), false)[0]).Value = str[i];
  54. }
  55. }
  56. }
  57. /// <summary>
  58. /// The m line width
  59. /// </summary>
  60. private int m_lineWidth = 8;
  61. /// <summary>
  62. /// Gets or sets the width of the line.
  63. /// </summary>
  64. /// <value>The width of the line.</value>
  65. [Description("线宽度,为了更好的显示效果,请使用偶数"), Category("自定义")]
  66. public int LineWidth
  67. {
  68. get { return m_lineWidth; }
  69. set
  70. {
  71. m_lineWidth = value;
  72. foreach (UCLEDNum c in this.tableLayoutPanel1.Controls)
  73. {
  74. c.LineWidth = value;
  75. }
  76. }
  77. }
  78. /// <summary>
  79. /// 获取或设置控件的前景色。
  80. /// </summary>
  81. /// <value>The color of the fore.</value>
  82. /// <PermissionSet>
  83. /// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
  84. /// </PermissionSet>
  85. [Description("颜色"), Category("自定义")]
  86. public override System.Drawing.Color ForeColor
  87. {
  88. get
  89. {
  90. return base.ForeColor;
  91. }
  92. set
  93. {
  94. base.ForeColor = value;
  95. foreach (UCLEDNum c in this.tableLayoutPanel1.Controls)
  96. {
  97. c.ForeColor = value;
  98. }
  99. }
  100. }
  101. /// <summary>
  102. /// Initializes a new instance of the <see cref="UCLEDDataTime" /> class.
  103. /// </summary>
  104. public UCLEDDataTime()
  105. {
  106. InitializeComponent();
  107. Value = DateTime.Now;
  108. }
  109. }
  110. }