LabelNumericText.cs 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. using Infragistics.Win.UltraWinEditors;
  10. namespace Core.Mes.Client.Comm.Control
  11. {
  12. public partial class LabelNumericText : UserControl, LabelControlInterface
  13. {
  14. public LabelNumericText()
  15. {
  16. InitializeComponent();
  17. }
  18. [Browsable(true), Category("原始控件")]
  19. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  20. public Label Label
  21. {
  22. get
  23. {
  24. return this.label1;
  25. }
  26. }
  27. [Browsable(true), Category("原始控件")]
  28. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  29. public UltraNumericEditor UltraNumbericEditor
  30. {
  31. get
  32. {
  33. return this.ultraNumericEditor1;
  34. }
  35. }
  36. [Browsable(true), Category("原始系统控件")]
  37. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  38. public CheckBox CheckBox
  39. {
  40. get
  41. {
  42. return this.checkBox1;
  43. }
  44. }
  45. [Browsable(true), Category("外观")]
  46. [TypeConverter(typeof(StringConverter))]
  47. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  48. public object Value
  49. {
  50. get
  51. {
  52. return this.ultraNumericEditor1.Value;
  53. }
  54. set
  55. {
  56. if (value == DBNull.Value)
  57. {
  58. this.ultraNumericEditor1.Value = null;
  59. ultraNumericEditor1.Refresh();
  60. }
  61. else
  62. {
  63. this.ultraNumericEditor1.Value = value;
  64. }
  65. }
  66. }
  67. [Browsable(true), Category("外观")]
  68. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  69. public string Caption
  70. {
  71. get
  72. {
  73. return this.label1.Text;
  74. }
  75. set
  76. {
  77. this.label1.Text = value;
  78. }
  79. }
  80. [Browsable(true), Category("外观")]
  81. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  82. public bool CheckBoxVisible
  83. {
  84. get { return this.checkBox1.Visible; }
  85. set
  86. {
  87. this.checkBox1.Visible = value;
  88. }
  89. }
  90. [Browsable(true), Category("外观")]
  91. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  92. public bool Checked
  93. {
  94. get { return this.checkBox1.Checked; }
  95. set
  96. {
  97. this.checkBox1.Checked = value;
  98. }
  99. }
  100. [Browsable(true), Category("外观")]
  101. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  102. public bool NumericEnabled
  103. {
  104. get { return this.ultraNumericEditor1.Enabled; }
  105. set { this.ultraNumericEditor1.Enabled = value; }
  106. }
  107. [Browsable(true), Category("行为")]
  108. [TypeConverter(typeof(StringConverter))]
  109. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  110. public object MaxValue
  111. {
  112. get
  113. {
  114. return this.ultraNumericEditor1.MaxValue;
  115. }
  116. set
  117. {
  118. this.ultraNumericEditor1.MaxValue = value;
  119. }
  120. }
  121. [Browsable(true), Category("行为")]
  122. [TypeConverter(typeof(StringConverter))]
  123. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  124. public object MinValue
  125. {
  126. get
  127. {
  128. return this.ultraNumericEditor1.MinValue;
  129. }
  130. set
  131. {
  132. this.ultraNumericEditor1.MinValue = value;
  133. }
  134. }
  135. [Browsable(true), Category("行为")]
  136. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  137. public NumericType NumericType
  138. {
  139. get
  140. {
  141. return this.ultraNumericEditor1.NumericType;
  142. }
  143. set
  144. {
  145. this.ultraNumericEditor1.NumericType = value;
  146. }
  147. }
  148. [Browsable(true), Category("行为")]
  149. [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
  150. public bool Nullable
  151. {
  152. get
  153. {
  154. return this.ultraNumericEditor1.Nullable;
  155. }
  156. set
  157. {
  158. this.ultraNumericEditor1.Nullable = value;
  159. }
  160. }
  161. private void checkBox1_VisibleChanged(object sender, EventArgs e)
  162. {
  163. if (checkBox1.Visible == false)
  164. {
  165. label1.Location = checkBox1.Location;
  166. this.checkBox1.Checked = true;
  167. }
  168. else
  169. {
  170. int x = checkBox1.Location.X + checkBox1.Size.Width + 2;
  171. label1.Location = new Point(x, checkBox1.Location.Y);
  172. }
  173. }
  174. private void checkBox1_CheckedChanged(object sender, EventArgs e)
  175. {
  176. this.ultraNumericEditor1.Enabled = checkBox1.Checked;
  177. }
  178. private void ultraNumericEditor1_ValueChanged_1(object sender, EventArgs e)
  179. {
  180. if (DataBindings["Value"] != null)
  181. {
  182. DataBindings["Value"].WriteValue();
  183. }
  184. }
  185. private void label1_MouseClick(object sender, MouseEventArgs e)
  186. {
  187. if (checkBox1.Visible == true)
  188. {
  189. checkBox1.Checked = !checkBox1.Checked;
  190. }
  191. }
  192. }
  193. }