当前位置:   article > 正文

(五十二)c#Winform自定义控件-LED数字_c# 模拟led显示数字

c# 模拟led显示数字

前提

入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章。

GitHub:https://github.com/kwwwvagaa/NetWinformControl

码云:https://gitee.com/kwwwvagaa/net_winform_custom_control.git

如果觉得写的还行,请点个 star 支持一下吧

欢迎前来交流探讨: 企鹅群568015492 企鹅群568015492

麻烦博客下方点个【推荐】,谢谢

NuGet

Install-Package HZH_Controls

目录

https://blog.csdn.net/kwwwvagaa/article/details/100586547

用处及效果

 

 

准备工作

使用GID+画的,不了解的话请自行百度

开始

添加一个类UCLEDNum ,继承UserControl

将数字拆分为单独的字,然后根据显示位置进行画出来,将显示位置定义为如下所示

复制代码

  1. /* 显示位置序号
  2. * ****1***
  3. * * *
  4. * 6 2
  5. * * *
  6. * ****7***
  7. * * *
  8. * 5 3
  9. * * *
  10. * ****4***
  11. */

复制代码

从上面可以看出,定义了1-7的位置,然后定义一个数字对应的显示列表

复制代码

  1. 1 private static Dictionary<char, int[]> m_nums = new Dictionary<char, int[]>();
  2. 2 static UCLEDNum()
  3. 3 {
  4. 4 m_nums['0'] = new int[] { 1, 2, 3, 4, 5, 6 };
  5. 5 m_nums['1'] = new int[] { 2, 3 };
  6. 6 m_nums['2'] = new int[] { 1, 2, 5, 4, 7 };
  7. 7 m_nums['3'] = new int[] { 1, 2, 7, 3, 4 };
  8. 8 m_nums['4'] = new int[] { 2, 3, 6, 7 };
  9. 9 m_nums['5'] = new int[] { 1, 6, 7, 3, 4 };
  10. 10 m_nums['6'] = new int[] { 1, 6, 5, 4, 3, 7 };
  11. 11 m_nums['7'] = new int[] { 1, 2, 3 };
  12. 12 m_nums['8'] = new int[] { 1, 2, 3, 4, 5, 6, 7 };
  13. 13 m_nums['9'] = new int[] { 1, 2, 3, 4, 7, 6 };
  14. 14 m_nums['-'] = new int[] { 7 };
  15. 15 m_nums[':'] = new int[0];
  16. 16 m_nums['.'] = new int[0];
  17. 17 }

复制代码

你看到了还有“-”,“:”,“.”这3个符号,是为了时间和数字时候使用

然后定义一个矩形区域来用作绘画区域,并且在SizeChanged事件中赋值

  1. Rectangle m_drawRect = Rectangle.Empty;
  2. void LEDNum_SizeChanged(object sender, EventArgs e)
  3. {
  4. m_drawRect = new Rectangle(1, 1, this.Width - 2, this.Height - 2);
  5. }

然后就是几个属性

复制代码

  1. 1 private char m_value = '0';
  2. 2
  3. 3 [Description("值"), Category("自定义")]
  4. 4 public char Value
  5. 5 {
  6. 6 get { return m_value; }
  7. 7 set
  8. 8 {
  9. 9 if (!m_nums.ContainsKey(value))
  10. 10 {
  11. 11 return;
  12. 12 }
  13. 13 if (m_value != value)
  14. 14 {
  15. 15 m_value = value;
  16. 16 Refresh();
  17. 17 }
  18. 18 }
  19. 19 }
  20. 20
  21. 21 private int m_lineWidth = 8;
  22. 22
  23. 23 [Description("线宽度,为了更好的显示效果,请使用偶数"), Category("自定义")]
  24. 24 public int LineWidth
  25. 25 {
  26. 26 get { return m_lineWidth; }
  27. 27 set
  28. 28 {
  29. 29 m_lineWidth = value;
  30. 30 Refresh();
  31. 31 }
  32. 32 }
  33. 33
  34. 34 [Description("颜色"), Category("自定义")]
  35. 35 public override System.Drawing.Color ForeColor
  36. 36 {
  37. 37 get
  38. 38 {
  39. 39 return base.ForeColor;
  40. 40 }
  41. 41 set
  42. 42 {
  43. 43 base.ForeColor = value;
  44. 44 }
  45. 45 }

复制代码

最重要的重绘

复制代码

  1. 1 protected override void OnPaint(PaintEventArgs e)
  2. 2 {
  3. 3 base.OnPaint(e);
  4. 4 e.Graphics.SetGDIHigh();
  5. 5 if (m_value == '.')
  6. 6 {
  7. 7 Rectangle r2 = new Rectangle(m_drawRect.Left + (m_drawRect.Width - m_lineWidth) / 2, m_drawRect.Bottom - m_lineWidth * 2, m_lineWidth, m_lineWidth);
  8. 8 e.Graphics.FillRectangle(new SolidBrush(ForeColor), r2);
  9. 9 }
  10. 10 else if (m_value == ':')
  11. 11 {
  12. 12 Rectangle r1 = new Rectangle(m_drawRect.Left + (m_drawRect.Width - m_lineWidth) / 2, m_drawRect.Top + (m_drawRect.Height / 2 - m_lineWidth) / 2, m_lineWidth, m_lineWidth);
  13. 13 e.Graphics.FillRectangle(new SolidBrush(ForeColor), r1);
  14. 14 Rectangle r2 = new Rectangle(m_drawRect.Left + (m_drawRect.Width - m_lineWidth) / 2, m_drawRect.Top + (m_drawRect.Height / 2 - m_lineWidth) / 2 + m_drawRect.Height / 2, m_lineWidth, m_lineWidth);
  15. 15 e.Graphics.FillRectangle(new SolidBrush(ForeColor), r2);
  16. 16 }
  17. 17 else
  18. 18 {
  19. 19 int[] vs = m_nums[m_value];
  20. 20 if (vs.Contains(1))
  21. 21 {
  22. 22 GraphicsPath path = new GraphicsPath();
  23. 23 path.AddLines(new Point[]
  24. 24 {
  25. 25 new Point(m_drawRect.Left + 2, m_drawRect.Top),
  26. 26 new Point(m_drawRect.Right - 2, m_drawRect.Top),
  27. 27 new Point(m_drawRect.Right - m_lineWidth-2, m_drawRect.Top+m_lineWidth),
  28. 28 new Point(m_drawRect.Left + m_lineWidth+2, m_drawRect.Top+m_lineWidth),
  29. 29 new Point(m_drawRect.Left + 2, m_drawRect.Top)
  30. 30 });
  31. 31 path.CloseAllFigures();
  32. 32 e.Graphics.FillPath(new SolidBrush(ForeColor), path);
  33. 33 }
  34. 34
  35. 35 if (vs.Contains(2))
  36. 36 {
  37. 37 GraphicsPath path = new GraphicsPath();
  38. 38 path.AddLines(new Point[]
  39. 39 {
  40. 40 new Point(m_drawRect.Right, m_drawRect.Top),
  41. 41 new Point(m_drawRect.Right, m_drawRect.Top+(m_drawRect.Height-m_lineWidth-4)/2),
  42. 42 new Point(m_drawRect.Right-m_lineWidth/2, m_drawRect.Top+(m_drawRect.Height-m_lineWidth-4)/2+m_lineWidth/2),
  43. 43 new Point(m_drawRect.Right-m_lineWidth, m_drawRect.Top+(m_drawRect.Height-m_lineWidth-4)/2),
  44. 44 new Point(m_drawRect.Right-m_lineWidth, m_drawRect.Top+m_lineWidth),
  45. 45 new Point(m_drawRect.Right, m_drawRect.Top)
  46. 46 });
  47. 47 path.CloseAllFigures();
  48. 48 e.Graphics.FillPath(new SolidBrush(ForeColor), path);
  49. 49 }
  50. 50
  51. 51 if (vs.Contains(3))
  52. 52 {
  53. 53 GraphicsPath path = new GraphicsPath();
  54. 54 path.AddLines(new Point[]
  55. 55 {
  56. 56 new Point(m_drawRect.Right, m_drawRect.Bottom-(m_drawRect.Height-m_lineWidth-4)/2),
  57. 57 new Point(m_drawRect.Right, m_drawRect.Bottom),
  58. 58 new Point(m_drawRect.Right-m_lineWidth, m_drawRect.Bottom-m_lineWidth),
  59. 59 new Point(m_drawRect.Right-m_lineWidth, m_drawRect.Bottom-(m_drawRect.Height-m_lineWidth-4)/2),
  60. 60 new Point(m_drawRect.Right-m_lineWidth/2, m_drawRect.Bottom-(m_drawRect.Height-m_lineWidth-4)/2-m_lineWidth/2),
  61. 61 new Point(m_drawRect.Right, m_drawRect.Bottom-(m_drawRect.Height-m_lineWidth-4)/2),
  62. 62 });
  63. 63 path.CloseAllFigures();
  64. 64 e.Graphics.FillPath(new SolidBrush(ForeColor), path);
  65. 65 }
  66. 66
  67. 67 if (vs.Contains(4))
  68. 68 {
  69. 69 GraphicsPath path = new GraphicsPath();
  70. 70 path.AddLines(new Point[]
  71. 71 {
  72. 72 new Point(m_drawRect.Left + 2, m_drawRect.Bottom),
  73. 73 new Point(m_drawRect.Right - 2, m_drawRect.Bottom),
  74. 74 new Point(m_drawRect.Right - m_lineWidth-2, m_drawRect.Bottom-m_lineWidth),
  75. 75 new Point(m_drawRect.Left + m_lineWidth+2, m_drawRect.Bottom-m_lineWidth),
  76. 76 new Point(m_drawRect.Left + 2, m_drawRect.Bottom)
  77. 77 });
  78. 78 path.CloseAllFigures();
  79. 79 e.Graphics.FillPath(new SolidBrush(ForeColor), path);
  80. 80 }
  81. 81
  82. 82 if (vs.Contains(5))
  83. 83 {
  84. 84 GraphicsPath path = new GraphicsPath();
  85. 85 path.AddLines(new Point[]
  86. 86 {
  87. 87 new Point(m_drawRect.Left, m_drawRect.Bottom-(m_drawRect.Height-m_lineWidth-4)/2),
  88. 88 new Point(m_drawRect.Left, m_drawRect.Bottom),
  89. 89 new Point(m_drawRect.Left+m_lineWidth, m_drawRect.Bottom-m_lineWidth),
  90. 90 new Point(m_drawRect.Left+m_lineWidth, m_drawRect.Bottom-(m_drawRect.Height-m_lineWidth-4)/2),
  91. 91 new Point(m_drawRect.Left+m_lineWidth/2, m_drawRect.Bottom-(m_drawRect.Height-m_lineWidth-4)/2-m_lineWidth/2),
  92. 92 new Point(m_drawRect.Left, m_drawRect.Bottom-(m_drawRect.Height-m_lineWidth-4)/2),
  93. 93 });
  94. 94 path.CloseAllFigures();
  95. 95 e.Graphics.FillPath(new SolidBrush(ForeColor), path);
  96. 96 }
  97. 97
  98. 98
  99. 99 if (vs.Contains(6))
  100. 100 {
  101. 101 GraphicsPath path = new GraphicsPath();
  102. 102 path.AddLines(new Point[]
  103. 103 {
  104. 104 new Point(m_drawRect.Left, m_drawRect.Top),
  105. 105 new Point(m_drawRect.Left, m_drawRect.Top+(m_drawRect.Height-m_lineWidth-4)/2),
  106. 106 new Point(m_drawRect.Left+m_lineWidth/2, m_drawRect.Top+(m_drawRect.Height-m_lineWidth-4)/2+m_lineWidth/2),
  107. 107 new Point(m_drawRect.Left+m_lineWidth, m_drawRect.Top+(m_drawRect.Height-m_lineWidth-4)/2),
  108. 108 new Point(m_drawRect.Left+m_lineWidth, m_drawRect.Top+m_lineWidth),
  109. 109 new Point(m_drawRect.Left, m_drawRect.Top)
  110. 110 });
  111. 111 path.CloseAllFigures();
  112. 112 e.Graphics.FillPath(new SolidBrush(ForeColor), path);
  113. 113 }
  114. 114
  115. 115 if (vs.Contains(7))
  116. 116 {
  117. 117 GraphicsPath path = new GraphicsPath();
  118. 118 path.AddLines(new Point[]
  119. 119 {
  120. 120 new Point(m_drawRect.Left+m_lineWidth/2, m_drawRect.Height/2+1),
  121. 121 new Point(m_drawRect.Left+m_lineWidth, m_drawRect.Height/2-m_lineWidth/2+1),
  122. 122 new Point(m_drawRect.Right-m_lineWidth, m_drawRect.Height/2-m_lineWidth/2+1),
  123. 123 new Point(m_drawRect.Right-m_lineWidth/2, m_drawRect.Height/2+1),
  124. 124 new Point(m_drawRect.Right-m_lineWidth, m_drawRect.Height/2+m_lineWidth/2+1),
  125. 125 new Point(m_drawRect.Left+m_lineWidth, m_drawRect.Height/2+m_lineWidth/2+1),
  126. 126 new Point(m_drawRect.Left+m_lineWidth/2, m_drawRect.Height/2+1)
  127. 127 });
  128. 128 path.CloseAllFigures();
  129. 129 e.Graphics.FillPath(new SolidBrush(ForeColor), path);
  130. 130 }
  131. 131 }
  132. 132 }

复制代码

完工,看下完整代码和效果

 View Code

 

 

 以上就是单个字符的了

 

=======================分割线==========================

下面对数字控件处理

添加一个用户控件UCLEDNums

添加一点属性

复制代码

  1. 1 private string m_value;
  2. 2
  3. 3 [Description("值"), Category("自定义")]
  4. 4 public string Value
  5. 5 {
  6. 6 get { return m_value; }
  7. 7 set
  8. 8 {
  9. 9 m_value = value;
  10. 10 ReloadValue();
  11. 11 }
  12. 12 }
  13. 13
  14. 14 private int m_lineWidth = 8;
  15. 15
  16. 16 [Description("线宽度,为了更好的显示效果,请使用偶数"), Category("自定义")]
  17. 17 public int LineWidth
  18. 18 {
  19. 19 get { return m_lineWidth; }
  20. 20 set
  21. 21 {
  22. 22 m_lineWidth = value;
  23. 23 foreach (UCLEDNum c in this.Controls)
  24. 24 {
  25. 25 c.LineWidth = value;
  26. 26 }
  27. 27 }
  28. 28 }
  29. 29
  30. 30 [Description("颜色"), Category("自定义")]
  31. 31 public override System.Drawing.Color ForeColor
  32. 32 {
  33. 33 get
  34. 34 {
  35. 35 return base.ForeColor;
  36. 36 }
  37. 37 set
  38. 38 {
  39. 39 base.ForeColor = value;
  40. 40 foreach (UCLEDNum c in this.Controls)
  41. 41 {
  42. 42 c.ForeColor = value;
  43. 43 }
  44. 44 }
  45. 45 }
  46. 46
  47. 47 public override RightToLeft RightToLeft
  48. 48 {
  49. 49 get
  50. 50 {
  51. 51 return base.RightToLeft;
  52. 52 }
  53. 53 set
  54. 54 {
  55. 55 base.RightToLeft = value;
  56. 56 ReloadValue();
  57. 57 }
  58. 58 }

复制代码

加载控件的函数

复制代码

  1. 1 private void ReloadValue()
  2. 2 {
  3. 3 try
  4. 4 {
  5. 5 ControlHelper.FreezeControl(this, true);
  6. 6 this.Controls.Clear();
  7. 7 foreach (var item in m_value)
  8. 8 {
  9. 9 UCLEDNum uc = new UCLEDNum();
  10. 10 if (RightToLeft == System.Windows.Forms.RightToLeft.Yes)
  11. 11 uc.Dock = DockStyle.Right;
  12. 12 else
  13. 13 uc.Dock = DockStyle.Left;
  14. 14 uc.Value = item;
  15. 15 uc.ForeColor = ForeColor;
  16. 16 uc.LineWidth = m_lineWidth;
  17. 17 this.Controls.Add(uc);
  18. 18 if (RightToLeft == System.Windows.Forms.RightToLeft.Yes)
  19. 19 uc.SendToBack();
  20. 20 else
  21. 21 uc.BringToFront();
  22. 22 }
  23. 23 }
  24. 24 finally
  25. 25 {
  26. 26 ControlHelper.FreezeControl(this, false);
  27. 27 }
  28. 28 }

复制代码

完整代码及效果

 View Code

 View Code

 

 

 =======================分割线==========================

下面是日期类控件了,这里偷懒,分成3个控件,分别是日期控件,时间控件,日期时间控件

先说日期控件,

添加一个用户控件UCLEDData

添加属性

复制代码

  1. 1 private DateTime m_value;
  2. 2
  3. 3 [Description("值"), Category("自定义")]
  4. 4 public DateTime Value
  5. 5 {
  6. 6 get { return m_value; }
  7. 7 set
  8. 8 {
  9. 9 m_value = value;
  10. 10 string str = value.ToString("yyyy-MM-dd");
  11. 11 for (int i = 0; i < str.Length; i++)
  12. 12 {
  13. 13 ((UCLEDNum)this.tableLayoutPanel1.Controls.Find("D" + (i + 1), false)[0]).Value = str[i];
  14. 14 }
  15. 15 }
  16. 16 }
  17. 17
  18. 18 private int m_lineWidth = 8;
  19. 19
  20. 20 [Description("线宽度,为了更好的显示效果,请使用偶数"), Category("自定义")]
  21. 21 public int LineWidth
  22. 22 {
  23. 23 get { return m_lineWidth; }
  24. 24 set
  25. 25 {
  26. 26 m_lineWidth = value;
  27. 27 foreach (UCLEDNum c in this.tableLayoutPanel1.Controls)
  28. 28 {
  29. 29 c.LineWidth = value;
  30. 30 }
  31. 31 }
  32. 32 }
  33. 33
  34. 34 [Description("颜色"), Category("自定义")]
  35. 35 public override System.Drawing.Color ForeColor
  36. 36 {
  37. 37 get
  38. 38 {
  39. 39 return base.ForeColor;
  40. 40 }
  41. 41 set
  42. 42 {
  43. 43 base.ForeColor = value;
  44. 44 foreach (UCLEDNum c in this.tableLayoutPanel1.Controls)
  45. 45 {
  46. 46 c.ForeColor = value;
  47. 47 }
  48. 48 }
  49. 49 }

复制代码

完整代码

 View Code

 View Code

 =======================分割线==========================

时间控件

添加一个用户控件UCLEDTime

添加属性

复制代码

  1. 1 private DateTime m_value;
  2. 2
  3. 3 [Description("值"), Category("自定义")]
  4. 4 public DateTime Value
  5. 5 {
  6. 6 get { return m_value; }
  7. 7 set
  8. 8 {
  9. 9 m_value = value;
  10. 10 string str = value.ToString("HH:mm:ss");
  11. 11 for (int i = 0; i < str.Length; i++)
  12. 12 {
  13. 13 ((UCLEDNum)this.tableLayoutPanel1.Controls.Find("D" + (i + 1), false)[0]).Value = str[i];
  14. 14 }
  15. 15 }
  16. 16 }
  17. 17
  18. 18 private int m_lineWidth = 8;
  19. 19
  20. 20 [Description("线宽度,为了更好的显示效果,请使用偶数"), Category("自定义")]
  21. 21 public int LineWidth
  22. 22 {
  23. 23 get { return m_lineWidth; }
  24. 24 set
  25. 25 {
  26. 26 m_lineWidth = value;
  27. 27 foreach (UCLEDNum c in this.tableLayoutPanel1.Controls)
  28. 28 {
  29. 29 c.LineWidth = value;
  30. 30 }
  31. 31 }
  32. 32 }
  33. 33
  34. 34 [Description("颜色"), Category("自定义")]
  35. 35 public override System.Drawing.Color ForeColor
  36. 36 {
  37. 37 get
  38. 38 {
  39. 39 return base.ForeColor;
  40. 40 }
  41. 41 set
  42. 42 {
  43. 43 base.ForeColor = value;
  44. 44 foreach (UCLEDNum c in this.tableLayoutPanel1.Controls)
  45. 45 {
  46. 46 c.ForeColor = value;
  47. 47 }
  48. 48 }
  49. 49 }

复制代码

全部代码

 View Code

 View Code

 =======================分割线==========================

日期时间控件

添加一个用户控件UCLEDDataTime

添加属性

复制代码

  1. 1 private DateTime m_value;
  2. 2
  3. 3 [Description("值"), Category("自定义")]
  4. 4 public DateTime Value
  5. 5 {
  6. 6 get { return m_value; }
  7. 7 set
  8. 8 {
  9. 9 m_value = value;
  10. 10 string str = value.ToString("yyyy-MM-dd HH:mm:ss");
  11. 11 for (int i = 0; i < str.Length; i++)
  12. 12 {
  13. 13 if (i == 10)
  14. 14 continue;
  15. 15 ((UCLEDNum)this.tableLayoutPanel1.Controls.Find("D" + (i + 1), false)[0]).Value = str[i];
  16. 16 }
  17. 17 }
  18. 18 }
  19. 19
  20. 20 private int m_lineWidth = 8;
  21. 21
  22. 22 [Description("线宽度,为了更好的显示效果,请使用偶数"), Category("自定义")]
  23. 23 public int LineWidth
  24. 24 {
  25. 25 get { return m_lineWidth; }
  26. 26 set
  27. 27 {
  28. 28 m_lineWidth = value;
  29. 29 foreach (UCLEDNum c in this.tableLayoutPanel1.Controls)
  30. 30 {
  31. 31 c.LineWidth = value;
  32. 32 }
  33. 33 }
  34. 34 }
  35. 35
  36. 36 [Description("颜色"), Category("自定义")]
  37. 37 public override System.Drawing.Color ForeColor
  38. 38 {
  39. 39 get
  40. 40 {
  41. 41 return base.ForeColor;
  42. 42 }
  43. 43 set
  44. 44 {
  45. 45 base.ForeColor = value;
  46. 46 foreach (UCLEDNum c in this.tableLayoutPanel1.Controls)
  47. 47 {
  48. 48 c.ForeColor = value;
  49. 49 }
  50. 50 }
  51. 51 }

复制代码

全部代码

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Drawing;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace HZH_Controls.Controls
  10. {
  11. public partial class UCLEDDataTime : UserControl
  12. {
  13. private DateTime m_value;
  14. [Description("值"), Category("自定义")]
  15. public DateTime Value
  16. {
  17. get { return m_value; }
  18. set
  19. {
  20. m_value = value;
  21. string str = value.ToString("yyyy-MM-dd HH:mm:ss");
  22. for (int i = 0; i < str.Length; i++)
  23. {
  24. if (i == 10)
  25. continue;
  26. ((UCLEDNum)this.tableLayoutPanel1.Controls.Find("D" + (i + 1), false)[0]).Value = str[i];
  27. }
  28. }
  29. }
  30. private int m_lineWidth = 8;
  31. [Description("线宽度,为了更好的显示效果,请使用偶数"), Category("自定义")]
  32. public int LineWidth
  33. {
  34. get { return m_lineWidth; }
  35. set
  36. {
  37. m_lineWidth = value;
  38. foreach (UCLEDNum c in this.tableLayoutPanel1.Controls)
  39. {
  40. c.LineWidth = value;
  41. }
  42. }
  43. }
  44. [Description("颜色"), Category("自定义")]
  45. public override System.Drawing.Color ForeColor
  46. {
  47. get
  48. {
  49. return base.ForeColor;
  50. }
  51. set
  52. {
  53. base.ForeColor = value;
  54. foreach (UCLEDNum c in this.tableLayoutPanel1.Controls)
  55. {
  56. c.ForeColor = value;
  57. }
  58. }
  59. }
  60. public UCLEDDataTime()
  61. {
  62. InitializeComponent();
  63. Value = DateTime.Now;
  64. }
  65. }
  66. }
  1. namespace HZH_Controls.Controls
  2. {
  3. partial class UCLEDDataTime
  4. {
  5. /// <summary>
  6. /// 必需的设计器变量。
  7. /// </summary>
  8. private System.ComponentModel.IContainer components = null;
  9. /// <summary>
  10. /// 清理所有正在使用的资源。
  11. /// </summary>
  12. /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
  13. protected override void Dispose(bool disposing)
  14. {
  15. if (disposing && (components != null))
  16. {
  17. components.Dispose();
  18. }
  19. base.Dispose(disposing);
  20. }
  21. #region 组件设计器生成的代码
  22. /// <summary>
  23. /// 设计器支持所需的方法 - 不要
  24. /// 使用代码编辑器修改此方法的内容。
  25. /// </summary>
  26. private void InitializeComponent()
  27. {
  28. this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
  29. this.D1 = new HZH_Controls.Controls.UCLEDNum();
  30. this.D2 = new HZH_Controls.Controls.UCLEDNum();
  31. this.D3 = new HZH_Controls.Controls.UCLEDNum();
  32. this.D4 = new HZH_Controls.Controls.UCLEDNum();
  33. this.D5 = new HZH_Controls.Controls.UCLEDNum();
  34. this.D6 = new HZH_Controls.Controls.UCLEDNum();
  35. this.D7 = new HZH_Controls.Controls.UCLEDNum();
  36. this.D8 = new HZH_Controls.Controls.UCLEDNum();
  37. this.D9 = new HZH_Controls.Controls.UCLEDNum();
  38. this.D10 = new HZH_Controls.Controls.UCLEDNum();
  39. this.D12 = new HZH_Controls.Controls.UCLEDNum();
  40. this.D13 = new HZH_Controls.Controls.UCLEDNum();
  41. this.D14 = new HZH_Controls.Controls.UCLEDNum();
  42. this.D15 = new HZH_Controls.Controls.UCLEDNum();
  43. this.D16 = new HZH_Controls.Controls.UCLEDNum();
  44. this.D17 = new HZH_Controls.Controls.UCLEDNum();
  45. this.D18 = new HZH_Controls.Controls.UCLEDNum();
  46. this.D19 = new HZH_Controls.Controls.UCLEDNum();
  47. this.tableLayoutPanel1.SuspendLayout();
  48. this.SuspendLayout();
  49. //
  50. // tableLayoutPanel1
  51. //
  52. this.tableLayoutPanel1.ColumnCount = 19;
  53. this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
  54. this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
  55. this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
  56. this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
  57. this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
  58. this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
  59. this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
  60. this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
  61. this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
  62. this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
  63. this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
  64. this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
  65. this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
  66. this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
  67. this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
  68. this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
  69. this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
  70. this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
  71. this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
  72. this.tableLayoutPanel1.Controls.Add(this.D1, 0, 0);
  73. this.tableLayoutPanel1.Controls.Add(this.D2, 1, 0);
  74. this.tableLayoutPanel1.Controls.Add(this.D3, 2, 0);
  75. this.tableLayoutPanel1.Controls.Add(this.D4, 3, 0);
  76. this.tableLayoutPanel1.Controls.Add(this.D5, 4, 0);
  77. this.tableLayoutPanel1.Controls.Add(this.D6, 5, 0);
  78. this.tableLayoutPanel1.Controls.Add(this.D7, 6, 0);
  79. this.tableLayoutPanel1.Controls.Add(this.D8, 7, 0);
  80. this.tableLayoutPanel1.Controls.Add(this.D9, 8, 0);
  81. this.tableLayoutPanel1.Controls.Add(this.D10, 9, 0);
  82. this.tableLayoutPanel1.Controls.Add(this.D12, 11, 0);
  83. this.tableLayoutPanel1.Controls.Add(this.D13, 12, 0);
  84. this.tableLayoutPanel1.Controls.Add(this.D14, 13, 0);
  85. this.tableLayoutPanel1.Controls.Add(this.D15, 14, 0);
  86. this.tableLayoutPanel1.Controls.Add(this.D16, 15, 0);
  87. this.tableLayoutPanel1.Controls.Add(this.D17, 16, 0);
  88. this.tableLayoutPanel1.Controls.Add(this.D18, 17, 0);
  89. this.tableLayoutPanel1.Controls.Add(this.D19, 18, 0);
  90. this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
  91. this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
  92. this.tableLayoutPanel1.Name = "tableLayoutPanel1";
  93. this.tableLayoutPanel1.RowCount = 1;
  94. this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
  95. this.tableLayoutPanel1.Size = new System.Drawing.Size(650, 58);
  96. this.tableLayoutPanel1.TabIndex = 1;
  97. //
  98. // D1
  99. //
  100. this.D1.Dock = System.Windows.Forms.DockStyle.Fill;
  101. this.D1.LineWidth = 8;
  102. this.D1.Location = new System.Drawing.Point(3, 3);
  103. this.D1.Name = "D1";
  104. this.D1.Size = new System.Drawing.Size(28, 52);
  105. this.D1.TabIndex = 0;
  106. this.D1.Value = '2';
  107. //
  108. // D2
  109. //
  110. this.D2.Dock = System.Windows.Forms.DockStyle.Fill;
  111. this.D2.LineWidth = 8;
  112. this.D2.Location = new System.Drawing.Point(37, 3);
  113. this.D2.Name = "D2";
  114. this.D2.Size = new System.Drawing.Size(28, 52);
  115. this.D2.TabIndex = 1;
  116. this.D2.Value = '0';
  117. //
  118. // D3
  119. //
  120. this.D3.Dock = System.Windows.Forms.DockStyle.Fill;
  121. this.D3.LineWidth = 8;
  122. this.D3.Location = new System.Drawing.Point(71, 3);
  123. this.D3.Name = "D3";
  124. this.D3.Size = new System.Drawing.Size(28, 52);
  125. this.D3.TabIndex = 2;
  126. this.D3.Value = '1';
  127. //
  128. // D4
  129. //
  130. this.D4.Dock = System.Windows.Forms.DockStyle.Fill;
  131. this.D4.LineWidth = 8;
  132. this.D4.Location = new System.Drawing.Point(105, 3);
  133. this.D4.Name = "D4";
  134. this.D4.Size = new System.Drawing.Size(28, 52);
  135. this.D4.TabIndex = 3;
  136. this.D4.Value = '9';
  137. //
  138. // D5
  139. //
  140. this.D5.Dock = System.Windows.Forms.DockStyle.Fill;
  141. this.D5.LineWidth = 8;
  142. this.D5.Location = new System.Drawing.Point(139, 3);
  143. this.D5.Name = "D5";
  144. this.D5.Size = new System.Drawing.Size(28, 52);
  145. this.D5.TabIndex = 4;
  146. this.D5.Value = '-';
  147. //
  148. // D6
  149. //
  150. this.D6.Dock = System.Windows.Forms.DockStyle.Fill;
  151. this.D6.LineWidth = 8;
  152. this.D6.Location = new System.Drawing.Point(173, 3);
  153. this.D6.Name = "D6";
  154. this.D6.Size = new System.Drawing.Size(28, 52);
  155. this.D6.TabIndex = 5;
  156. this.D6.Value = '0';
  157. //
  158. // D7
  159. //
  160. this.D7.Dock = System.Windows.Forms.DockStyle.Fill;
  161. this.D7.LineWidth = 8;
  162. this.D7.Location = new System.Drawing.Point(207, 3);
  163. this.D7.Name = "D7";
  164. this.D7.Size = new System.Drawing.Size(28, 52);
  165. this.D7.TabIndex = 6;
  166. this.D7.Value = '8';
  167. //
  168. // D8
  169. //
  170. this.D8.Dock = System.Windows.Forms.DockStyle.Fill;
  171. this.D8.LineWidth = 8;
  172. this.D8.Location = new System.Drawing.Point(241, 3);
  173. this.D8.Name = "D8";
  174. this.D8.Size = new System.Drawing.Size(28, 52);
  175. this.D8.TabIndex = 7;
  176. this.D8.Value = '-';
  177. //
  178. // D9
  179. //
  180. this.D9.Dock = System.Windows.Forms.DockStyle.Fill;
  181. this.D9.LineWidth = 8;
  182. this.D9.Location = new System.Drawing.Point(275, 3);
  183. this.D9.Name = "D9";
  184. this.D9.Size = new System.Drawing.Size(28, 52);
  185. this.D9.TabIndex = 8;
  186. this.D9.Value = '0';
  187. //
  188. // D10
  189. //
  190. this.D10.Dock = System.Windows.Forms.DockStyle.Fill;
  191. this.D10.LineWidth = 8;
  192. this.D10.Location = new System.Drawing.Point(309, 3);
  193. this.D10.Name = "D10";
  194. this.D10.Size = new System.Drawing.Size(28, 52);
  195. this.D10.TabIndex = 9;
  196. this.D10.Value = '1';
  197. //
  198. // D12
  199. //
  200. this.D12.Dock = System.Windows.Forms.DockStyle.Fill;
  201. this.D12.LineWidth = 8;
  202. this.D12.Location = new System.Drawing.Point(377, 3);
  203. this.D12.Name = "D12";
  204. this.D12.Size = new System.Drawing.Size(28, 52);
  205. this.D12.TabIndex = 10;
  206. this.D12.Value = '2';
  207. //
  208. // D13
  209. //
  210. this.D13.Dock = System.Windows.Forms.DockStyle.Fill;
  211. this.D13.LineWidth = 8;
  212. this.D13.Location = new System.Drawing.Point(411, 3);
  213. this.D13.Name = "D13";
  214. this.D13.Size = new System.Drawing.Size(28, 52);
  215. this.D13.TabIndex = 11;
  216. this.D13.Value = '3';
  217. //
  218. // D14
  219. //
  220. this.D14.Dock = System.Windows.Forms.DockStyle.Fill;
  221. this.D14.LineWidth = 8;
  222. this.D14.Location = new System.Drawing.Point(445, 3);
  223. this.D14.Name = "D14";
  224. this.D14.Size = new System.Drawing.Size(28, 52);
  225. this.D14.TabIndex = 12;
  226. this.D14.Value = ':';
  227. //
  228. // D15
  229. //
  230. this.D15.Dock = System.Windows.Forms.DockStyle.Fill;
  231. this.D15.LineWidth = 8;
  232. this.D15.Location = new System.Drawing.Point(479, 3);
  233. this.D15.Name = "D15";
  234. this.D15.Size = new System.Drawing.Size(28, 52);
  235. this.D15.TabIndex = 13;
  236. this.D15.Value = '0';
  237. //
  238. // D16
  239. //
  240. this.D16.Dock = System.Windows.Forms.DockStyle.Fill;
  241. this.D16.LineWidth = 8;
  242. this.D16.Location = new System.Drawing.Point(513, 3);
  243. this.D16.Name = "D16";
  244. this.D16.Size = new System.Drawing.Size(28, 52);
  245. this.D16.TabIndex = 14;
  246. this.D16.Value = '1';
  247. //
  248. // D17
  249. //
  250. this.D17.Dock = System.Windows.Forms.DockStyle.Fill;
  251. this.D17.LineWidth = 8;
  252. this.D17.Location = new System.Drawing.Point(547, 3);
  253. this.D17.Name = "D17";
  254. this.D17.Size = new System.Drawing.Size(28, 52);
  255. this.D17.TabIndex = 15;
  256. this.D17.Value = ':';
  257. //
  258. // D18
  259. //
  260. this.D18.Dock = System.Windows.Forms.DockStyle.Fill;
  261. this.D18.LineWidth = 8;
  262. this.D18.Location = new System.Drawing.Point(581, 3);
  263. this.D18.Name = "D18";
  264. this.D18.Size = new System.Drawing.Size(28, 52);
  265. this.D18.TabIndex = 16;
  266. this.D18.Value = '5';
  267. //
  268. // D19
  269. //
  270. this.D19.Dock = System.Windows.Forms.DockStyle.Fill;
  271. this.D19.LineWidth = 8;
  272. this.D19.Location = new System.Drawing.Point(615, 3);
  273. this.D19.Name = "D19";
  274. this.D19.Size = new System.Drawing.Size(32, 52);
  275. this.D19.TabIndex = 17;
  276. this.D19.Value = '3';
  277. //
  278. // UCLEDDataTime
  279. //
  280. this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
  281. this.Controls.Add(this.tableLayoutPanel1);
  282. this.Name = "UCLEDDataTime";
  283. this.Size = new System.Drawing.Size(650, 58);
  284. this.tableLayoutPanel1.ResumeLayout(false);
  285. this.ResumeLayout(false);
  286. }
  287. #endregion
  288. private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
  289. private UCLEDNum D1;
  290. private UCLEDNum D2;
  291. private UCLEDNum D3;
  292. private UCLEDNum D4;
  293. private UCLEDNum D5;
  294. private UCLEDNum D6;
  295. private UCLEDNum D7;
  296. private UCLEDNum D8;
  297. private UCLEDNum D9;
  298. private UCLEDNum D10;
  299. private UCLEDNum D12;
  300. private UCLEDNum D13;
  301. private UCLEDNum D14;
  302. private UCLEDNum D15;
  303. private UCLEDNum D16;
  304. private UCLEDNum D17;
  305. private UCLEDNum D18;
  306. private UCLEDNum D19;
  307. }
  308. }

最后的话

如果你喜欢的话,请到 https://gitee.com/kwwwvagaa/net_winform_custom_control 点个星星吧

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/955263
推荐阅读
相关标签
  

闽ICP备14008679号