LabelDateTimePicker.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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 Core.Mes.Client.Comm.Control
  10. {
  11. public partial class LabelDateTimePicker : UserControl, LabelControlInterface
  12. {
  13. public LabelDateTimePicker()
  14. {
  15. InitializeComponent();
  16. }
  17. [Browsable(true), Category("原始系统控件")]
  18. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  19. public Label Label
  20. {
  21. get
  22. {
  23. return this.label1;
  24. }
  25. }
  26. [Browsable(true), Category("原始系统控件")]
  27. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  28. public DateTimePicker DateTimePicker
  29. {
  30. get
  31. {
  32. return this.dateTimePicker1;
  33. }
  34. }
  35. [Browsable(true), Category("原始系统控件")]
  36. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  37. public CheckBox CheckBox
  38. {
  39. get
  40. {
  41. return this.checkBox1;
  42. }
  43. }
  44. [Browsable(true), Category("外观")]
  45. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  46. public string Caption
  47. {
  48. get
  49. {
  50. return this.label1.Text;
  51. }
  52. set
  53. {
  54. this.label1.Text = value;
  55. }
  56. }
  57. [Browsable(true), Category("外观")]
  58. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  59. public DateTime Value
  60. {
  61. get
  62. {
  63. return this.dateTimePicker1.Value;
  64. }
  65. set
  66. {
  67. this.dateTimePicker1.Value = value;
  68. }
  69. }
  70. [Browsable(true), Category("外观")]
  71. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  72. public bool CheckBoxVisible
  73. {
  74. get { return this.checkBox1.Visible; }
  75. set
  76. {
  77. this.checkBox1.Visible = value;
  78. }
  79. }
  80. [Browsable(true), Category("外观")]
  81. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  82. public bool Checked
  83. {
  84. get { return this.checkBox1.Checked; }
  85. set
  86. {
  87. this.checkBox1.Checked = value;
  88. }
  89. }
  90. [Browsable(true), Category("外观")]
  91. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  92. public bool DateTimeEnabled
  93. {
  94. get { return this.dateTimePicker1.Enabled; }
  95. set { this.dateTimePicker1.Enabled = value; }
  96. }
  97. private void checkBox1_VisibleChanged(object sender, EventArgs e)
  98. {
  99. if (checkBox1.Visible == false)
  100. {
  101. label1.Location = checkBox1.Location;
  102. this.checkBox1.Checked = true;
  103. }
  104. else
  105. {
  106. int x = checkBox1.Location.X + checkBox1.Size.Width + 2;
  107. label1.Location = new Point(x, checkBox1.Location.Y);
  108. }
  109. }
  110. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  111. {
  112. this.dateTimePicker1.Enabled = checkBox1.Checked;
  113. }
  114. private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
  115. {
  116. if (DataBindings["Value"] != null)
  117. {
  118. DataBindings["Value"].WriteValue();
  119. }
  120. }
  121. private void label1_MouseClick(object sender, MouseEventArgs e)
  122. {
  123. if (this.checkBox1.Visible == true)
  124. {
  125. this.checkBox1.Checked = !checkBox1.Checked;
  126. }
  127. }
  128. }
  129. }