CustomControlsForm.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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.Resources.ResourceManager resources = new System.Resources.ResourceManager(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(16, 160);
  78. this.cTextBox.Name = "cTextBox";
  79. this.cTextBox.Size = new System.Drawing.Size(120, 20);
  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(200, 64);
  87. this.toggleButton1.Name = "toggleButton1";
  88. this.toggleButton1.TabIndex = 6;
  89. this.toggleButton1.Text = "Toggle Button";
  90. this.toggleButton1.Click += new System.EventHandler(this.toggleButton1_Click);
  91. //
  92. // pushButton1
  93. //
  94. this.pushButton1.Image = ((System.Drawing.Image)(resources.GetObject("pushButton1.Image")));
  95. this.pushButton1.Location = new System.Drawing.Point(200, 32);
  96. this.pushButton1.Name = "pushButton1";
  97. this.pushButton1.TabIndex = 5;
  98. this.pushButton1.Text = "Push Button";
  99. this.pushButton1.Click += new System.EventHandler(this.pushButton1_Click);
  100. //
  101. // dropDownColorPicker1
  102. //
  103. this.dropDownColorPicker1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  104. this.dropDownColorPicker1.Location = new System.Drawing.Point(16, 64);
  105. this.dropDownColorPicker1.Name = "dropDownColorPicker1";
  106. this.dropDownColorPicker1.TabIndex = 1;
  107. this.dropDownColorPicker1.Text = "White";
  108. this.dropDownColorPicker1.ValueChanged += new System.EventHandler(this.dropDownColorPicker1_ValueChanged);
  109. //
  110. // dropDownCalendar1
  111. //
  112. this.dropDownCalendar1.Location = new System.Drawing.Point(16, 32);
  113. this.dropDownCalendar1.MaxDate = new System.DateTime(9998, 12, 31, 0, 0, 0, 0);
  114. this.dropDownCalendar1.MinDate = new System.DateTime(1753, 1, 1, 0, 0, 0, 0);
  115. this.dropDownCalendar1.Name = "dropDownCalendar1";
  116. this.dropDownCalendar1.TabIndex = 0;
  117. this.dropDownCalendar1.Text = "12-10-2003";
  118. this.dropDownCalendar1.Value = new System.DateTime(2003, 10, 12, 0, 0, 0, 0);
  119. this.dropDownCalendar1.DateChanged += new System.EventHandler(this.dropDownCalendar1_DateChanged);
  120. //
  121. // dropDownBool1
  122. //
  123. this.dropDownBool1.FalseValueString = "Disabled";
  124. this.dropDownBool1.Location = new System.Drawing.Point(16, 96);
  125. this.dropDownBool1.Name = "dropDownBool1";
  126. this.dropDownBool1.SelectedIndex = 0;
  127. this.dropDownBool1.TabIndex = 2;
  128. this.dropDownBool1.Text = "Enabled";
  129. this.dropDownBool1.TrueValueString = "Enabled";
  130. this.dropDownBool1.ValueChanged += new System.EventHandler(this.dropDownBool1_ValueChanged);
  131. //
  132. // dropDownListBox1
  133. //
  134. this.dropDownListBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
  135. this.dropDownListBox1.Location = new System.Drawing.Point(16, 128);
  136. this.dropDownListBox1.Name = "dropDownListBox1";
  137. this.dropDownListBox1.TabIndex = 3;
  138. this.dropDownListBox1.ItemSelected += new CustomControls.Win32Controls.DropDownListBox.ItemSelectedEventHandler(this.dropDownListBox1_ItemSelected);
  139. //
  140. // dropDownListBoxButton1
  141. //
  142. this.dropDownListBoxButton1.Image = ((System.Drawing.Image)(resources.GetObject("dropDownListBoxButton1.Image")));
  143. this.dropDownListBoxButton1.Location = new System.Drawing.Point(200, 96);
  144. this.dropDownListBoxButton1.Name = "dropDownListBoxButton1";
  145. this.dropDownListBoxButton1.TabIndex = 7;
  146. this.dropDownListBoxButton1.Text = "DD Button";
  147. this.dropDownListBoxButton1.ItemSelected += new CustomControls.Win32Controls.DropDownListBoxButton.ItemSelectedEventHandler(this.dropDownListBoxButton1_ItemSelected);
  148. //
  149. // CustomControlsForm
  150. //
  151. this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  152. this.BackColor = System.Drawing.SystemColors.Control;
  153. this.ClientSize = new System.Drawing.Size(320, 197);
  154. this.Controls.Add(this.cTextBox);
  155. this.Controls.Add(this.dropDownListBoxButton1);
  156. this.Controls.Add(this.dropDownListBox1);
  157. this.Controls.Add(this.toggleButton1);
  158. this.Controls.Add(this.pushButton1);
  159. this.Controls.Add(this.dropDownColorPicker1);
  160. this.Controls.Add(this.dropDownCalendar1);
  161. this.Controls.Add(this.dropDownBool1);
  162. this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
  163. this.Name = "CustomControlsForm";
  164. this.Text = "CustomControls";
  165. ((System.ComponentModel.ISupportInitialize)(this.dropDownColorPicker1)).EndInit();
  166. ((System.ComponentModel.ISupportInitialize)(this.dropDownCalendar1)).EndInit();
  167. ((System.ComponentModel.ISupportInitialize)(this.dropDownBool1)).EndInit();
  168. ((System.ComponentModel.ISupportInitialize)(this.dropDownListBox1)).EndInit();
  169. ((System.ComponentModel.ISupportInitialize)(this.dropDownListBoxButton1)).EndInit();
  170. this.ResumeLayout(false);
  171. }
  172. #endregion
  173. private void dropDownCalendar1_DateChanged(object sender, System.EventArgs e)
  174. {
  175. this.Text=this.dropDownCalendar1.Value.ToShortDateString();
  176. }
  177. private void dropDownColorPicker1_ValueChanged(object sender, System.EventArgs e)
  178. {
  179. this.Text=this.dropDownColorPicker1.Value.Name;
  180. CustomControls.BaseClasses.AppColors.SetDefaultColors(this.dropDownColorPicker1.Value);
  181. this.Refresh();
  182. }
  183. private void dropDownBool1_ValueChanged(object sender, System.EventArgs e)
  184. {
  185. this.Text=this.dropDownBool1.Value.ToString();
  186. foreach(Control c in this.Controls )
  187. {
  188. if(c!=sender)
  189. {
  190. c.Enabled=this.dropDownBool1.Value;
  191. }
  192. }
  193. }
  194. private void pushButton1_Click(object sender, System.EventArgs e)
  195. {
  196. this.Text="Push Button Click";
  197. }
  198. private void toggleButton1_Click(object sender, System.EventArgs e)
  199. {
  200. this.Text="ToggleButton is pushed= " + (!this.toggleButton1.Pushed).ToString();
  201. }
  202. private void dropDownListBoxButton1_ItemSelected(object sender, CustomControls.HelperClasses.ItemSelectedEventArgs e)
  203. {
  204. if(e.SelectedItem!=null)
  205. {
  206. this.Text=e.SelectedItem.ToString();
  207. }
  208. }
  209. private void dropDownListBox1_ItemSelected(object sender, CustomControls.HelperClasses.ItemSelectedEventArgs e)
  210. {
  211. if(e.SelectedItem!=null)
  212. {
  213. this.Text=e.SelectedItem.ToString();
  214. CustomControls.BaseClasses.AppColors.SetDefaultColors(Color.FromName(e.SelectedItem.ToString()));
  215. this.Refresh();
  216. }
  217. }
  218. }
  219. }