CustomControlsForm.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. namespace TestProject
  7. {
  8. /// <summary>
  9. /// Summary description for Form2.
  10. /// </summary>
  11. public class CustomControlsForm : System.Windows.Forms.Form
  12. {
  13. private CustomControls.Win32Controls.CTextBox cTextBox;
  14. private CustomControls.Win32Controls.ToggleButton toggleButton1;
  15. private CustomControls.Win32Controls.PushButton pushButton1;
  16. private CustomControls.Win32Controls.DropDownColorPicker dropDownColorPicker1;
  17. private CustomControls.Win32Controls.DropDownCalendar dropDownCalendar1;
  18. private CustomControls.Win32Controls.DropDownBool dropDownBool1;
  19. private CustomControls.Win32Controls.DropDownListBox dropDownListBox1;
  20. private CustomControls.Win32Controls.DropDownListBoxButton dropDownListBoxButton1;
  21. /// <summary>
  22. /// Required designer variable.
  23. /// </summary>
  24. private System.ComponentModel.Container components = null;
  25. public CustomControlsForm()
  26. {
  27. //
  28. // Required for Windows Form Designer support
  29. //
  30. InitializeComponent();
  31. this.dropDownListBox1.List.Items.AddRange(new string[] {"Highlight", "Black", "Green","FireBrick"});
  32. this.dropDownListBox1.SelectedIndex=0;
  33. this.dropDownListBoxButton1.List.Items.AddRange(new string[] {"First", "Second", "Third"});
  34. //
  35. // TODO: Add any constructor code after InitializeComponent call
  36. //
  37. }
  38. /// <summary>
  39. /// Clean up any resources being used.
  40. /// </summary>
  41. protected override void Dispose( bool disposing )
  42. {
  43. if( disposing )
  44. {
  45. if(components != null)
  46. {
  47. components.Dispose();
  48. }
  49. }
  50. base.Dispose( disposing );
  51. }
  52. #region Windows Form Designer generated code
  53. /// <summary>
  54. /// Required method for Designer support - do not modify
  55. /// the contents of this method with the code editor.
  56. /// </summary>
  57. private void InitializeComponent()
  58. {
  59. System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(CustomControlsForm));
  60. this.cTextBox = new CustomControls.Win32Controls.CTextBox();
  61. this.toggleButton1 = new CustomControls.Win32Controls.ToggleButton();
  62. this.pushButton1 = new CustomControls.Win32Controls.PushButton();
  63. this.dropDownColorPicker1 = new CustomControls.Win32Controls.DropDownColorPicker();
  64. this.dropDownCalendar1 = new CustomControls.Win32Controls.DropDownCalendar();
  65. this.dropDownBool1 = new CustomControls.Win32Controls.DropDownBool();
  66. this.dropDownListBox1 = new CustomControls.Win32Controls.DropDownListBox();
  67. this.dropDownListBoxButton1 = new CustomControls.Win32Controls.DropDownListBoxButton();
  68. ((System.ComponentModel.ISupportInitialize)(this.dropDownColorPicker1)).BeginInit();
  69. ((System.ComponentModel.ISupportInitialize)(this.dropDownCalendar1)).BeginInit();
  70. ((System.ComponentModel.ISupportInitialize)(this.dropDownBool1)).BeginInit();
  71. ((System.ComponentModel.ISupportInitialize)(this.dropDownListBox1)).BeginInit();
  72. ((System.ComponentModel.ISupportInitialize)(this.dropDownListBoxButton1)).BeginInit();
  73. this.SuspendLayout();
  74. //
  75. // cTextBox
  76. //
  77. this.cTextBox.Location = new System.Drawing.Point(19, 172);
  78. this.cTextBox.Name = "cTextBox";
  79. this.cTextBox.Size = new System.Drawing.Size(144, 21);
  80. this.cTextBox.TabIndex = 4;
  81. this.cTextBox.Text = "Custom Controls";
  82. //
  83. // toggleButton1
  84. //
  85. this.toggleButton1.Image = ((System.Drawing.Image)(resources.GetObject("toggleButton1.Image")));
  86. this.toggleButton1.Location = new System.Drawing.Point(240, 69);
  87. this.toggleButton1.Name = "toggleButton1";
  88. this.toggleButton1.Size = new System.Drawing.Size(120, 21);
  89. this.toggleButton1.TabIndex = 6;
  90. this.toggleButton1.Text = "Toggle Button";
  91. this.toggleButton1.Click += new System.EventHandler(this.toggleButton1_Click);
  92. //
  93. // pushButton1
  94. //
  95. this.pushButton1.Image = ((System.Drawing.Image)(resources.GetObject("pushButton1.Image")));
  96. this.pushButton1.Location = new System.Drawing.Point(240, 34);
  97. this.pushButton1.Name = "pushButton1";
  98. this.pushButton1.Size = new System.Drawing.Size(120, 22);
  99. this.pushButton1.TabIndex = 5;
  100. this.pushButton1.Text = "Push Button";
  101. this.pushButton1.Click += new System.EventHandler(this.pushButton1_Click);
  102. //
  103. // dropDownColorPicker1
  104. //
  105. this.dropDownColorPicker1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  106. this.dropDownColorPicker1.Location = new System.Drawing.Point(19, 69);
  107. this.dropDownColorPicker1.Name = "dropDownColorPicker1";
  108. this.dropDownColorPicker1.Size = new System.Drawing.Size(120, 20);
  109. this.dropDownColorPicker1.TabIndex = 1;
  110. this.dropDownColorPicker1.Text = "White";
  111. this.dropDownColorPicker1.ValueChanged += new System.EventHandler(this.dropDownColorPicker1_ValueChanged);
  112. //
  113. // dropDownCalendar1
  114. //
  115. this.dropDownCalendar1.Location = new System.Drawing.Point(19, 34);
  116. this.dropDownCalendar1.MaxDate = new System.DateTime(9998, 12, 31, 0, 0, 0, 0);
  117. this.dropDownCalendar1.MinDate = new System.DateTime(1753, 1, 1, 0, 0, 0, 0);
  118. this.dropDownCalendar1.Name = "dropDownCalendar1";
  119. this.dropDownCalendar1.Size = new System.Drawing.Size(120, 20);
  120. this.dropDownCalendar1.TabIndex = 0;
  121. this.dropDownCalendar1.Text = "2003/10/12";
  122. this.dropDownCalendar1.Value = new System.DateTime(2003, 10, 12, 0, 0, 0, 0);
  123. this.dropDownCalendar1.DateChanged += new System.EventHandler(this.dropDownCalendar1_DateChanged);
  124. //
  125. // dropDownBool1
  126. //
  127. this.dropDownBool1.FalseValueString = "Disabled";
  128. this.dropDownBool1.Location = new System.Drawing.Point(19, 103);
  129. this.dropDownBool1.Name = "dropDownBool1";
  130. this.dropDownBool1.SelectedIndex = 0;
  131. this.dropDownBool1.Size = new System.Drawing.Size(120, 20);
  132. this.dropDownBool1.TabIndex = 2;
  133. this.dropDownBool1.Text = "Enabled";
  134. this.dropDownBool1.TrueValueString = "Enabled";
  135. this.dropDownBool1.ValueChanged += new System.EventHandler(this.dropDownBool1_ValueChanged);
  136. //
  137. // dropDownListBox1
  138. //
  139. this.dropDownListBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  140. this.dropDownListBox1.Location = new System.Drawing.Point(19, 138);
  141. this.dropDownListBox1.Name = "dropDownListBox1";
  142. this.dropDownListBox1.Size = new System.Drawing.Size(120, 20);
  143. this.dropDownListBox1.TabIndex = 3;
  144. this.dropDownListBox1.ItemSelected += new CustomControls.Win32Controls.DropDownListBox.ItemSelectedEventHandler(this.dropDownListBox1_ItemSelected);
  145. //
  146. // dropDownListBoxButton1
  147. //
  148. this.dropDownListBoxButton1.Image = ((System.Drawing.Image)(resources.GetObject("dropDownListBoxButton1.Image")));
  149. this.dropDownListBoxButton1.Location = new System.Drawing.Point(240, 103);
  150. this.dropDownListBoxButton1.Name = "dropDownListBoxButton1";
  151. this.dropDownListBoxButton1.Size = new System.Drawing.Size(100, 20);
  152. this.dropDownListBoxButton1.TabIndex = 7;
  153. this.dropDownListBoxButton1.Text = "DD Button";
  154. this.dropDownListBoxButton1.ItemSelected += new CustomControls.Win32Controls.DropDownListBoxButton.ItemSelectedEventHandler(this.dropDownListBoxButton1_ItemSelected);
  155. //
  156. // CustomControlsForm
  157. //
  158. this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
  159. this.BackColor = System.Drawing.SystemColors.Control;
  160. this.ClientSize = new System.Drawing.Size(414, 431);
  161. this.Controls.Add(this.cTextBox);
  162. this.Controls.Add(this.dropDownListBoxButton1);
  163. this.Controls.Add(this.dropDownListBox1);
  164. this.Controls.Add(this.toggleButton1);
  165. this.Controls.Add(this.pushButton1);
  166. this.Controls.Add(this.dropDownColorPicker1);
  167. this.Controls.Add(this.dropDownCalendar1);
  168. this.Controls.Add(this.dropDownBool1);
  169. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  170. this.Name = "CustomControlsForm";
  171. this.Text = "CustomControls";
  172. ((System.ComponentModel.ISupportInitialize)(this.dropDownColorPicker1)).EndInit();
  173. ((System.ComponentModel.ISupportInitialize)(this.dropDownCalendar1)).EndInit();
  174. ((System.ComponentModel.ISupportInitialize)(this.dropDownBool1)).EndInit();
  175. ((System.ComponentModel.ISupportInitialize)(this.dropDownListBox1)).EndInit();
  176. ((System.ComponentModel.ISupportInitialize)(this.dropDownListBoxButton1)).EndInit();
  177. this.ResumeLayout(false);
  178. this.PerformLayout();
  179. }
  180. #endregion
  181. private void dropDownCalendar1_DateChanged(object sender, System.EventArgs e)
  182. {
  183. this.Text=this.dropDownCalendar1.Value.ToShortDateString();
  184. }
  185. private void dropDownColorPicker1_ValueChanged(object sender, System.EventArgs e)
  186. {
  187. this.Text=this.dropDownColorPicker1.Value.Name;
  188. CustomControls.BaseClasses.AppColors.SetDefaultColors(this.dropDownColorPicker1.Value);
  189. this.Refresh();
  190. }
  191. private void dropDownBool1_ValueChanged(object sender, System.EventArgs e)
  192. {
  193. this.Text=this.dropDownBool1.Value.ToString();
  194. foreach(Control c in this.Controls )
  195. {
  196. if(c!=sender)
  197. {
  198. c.Enabled=this.dropDownBool1.Value;
  199. }
  200. }
  201. }
  202. private void pushButton1_Click(object sender, System.EventArgs e)
  203. {
  204. this.Text="Push Button Click";
  205. }
  206. private void toggleButton1_Click(object sender, System.EventArgs e)
  207. {
  208. this.Text="ToggleButton is pushed= " + (!this.toggleButton1.Pushed).ToString();
  209. }
  210. private void dropDownListBoxButton1_ItemSelected(object sender, CustomControls.HelperClasses.ItemSelectedEventArgs e)
  211. {
  212. if(e.SelectedItem!=null)
  213. {
  214. this.Text=e.SelectedItem.ToString();
  215. }
  216. }
  217. private void dropDownListBox1_ItemSelected(object sender, CustomControls.HelperClasses.ItemSelectedEventArgs e)
  218. {
  219. if(e.SelectedItem!=null)
  220. {
  221. this.Text=e.SelectedItem.ToString();
  222. CustomControls.BaseClasses.AppColors.SetDefaultColors(Color.FromName(e.SelectedItem.ToString()));
  223. this.Refresh();
  224. }
  225. }
  226. }
  227. }