DetailDialogVisualSettings.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. namespace OINA.Extender.Testharness
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Reflection;
  8. using System.Windows.Forms;
  9. using OINA.Extender.Controls.Styles;
  10. /// <summary>
  11. /// Interaction logic for DetailDialogVisualSettings
  12. /// </summary>
  13. public partial class DetailDialogVisualSettings : Form
  14. {
  15. /// <summary>
  16. /// Gets or sets the color of the dialog background.
  17. /// </summary>
  18. /// <value>
  19. /// The color of the dialog background.
  20. /// </value>
  21. public System.Windows.Media.Color DialogBackgroundColor
  22. {
  23. get
  24. {
  25. return DetailsDialogStyle.DialogBackgroundColor;
  26. }
  27. set
  28. {
  29. DetailsDialogStyle.DialogBackgroundColor = value;
  30. this.backgroundColorPanel.BackColor = ColorConverter.Convert(value);
  31. }
  32. }
  33. /// <summary>
  34. /// Gets or sets the color of the header text.
  35. /// </summary>
  36. /// <value>
  37. /// The color of the header text.
  38. /// </value>
  39. public System.Windows.Media.Color HeaderTextColor
  40. {
  41. get
  42. {
  43. return DetailsDialogStyle.HeaderTextColor;
  44. }
  45. set
  46. {
  47. DetailsDialogStyle.HeaderTextColor = value;
  48. this.headerColorPanel.BackColor = ColorConverter.Convert(value);
  49. }
  50. }
  51. /// <summary>
  52. /// Gets or sets the color of the details text.
  53. /// </summary>
  54. /// <value>
  55. /// The color of the details text.
  56. /// </value>
  57. public System.Windows.Media.Color DetailsTextColor
  58. {
  59. get
  60. {
  61. return DetailsDialogStyle.DetailsTextColor;
  62. }
  63. set
  64. {
  65. DetailsDialogStyle.DetailsTextColor = value;
  66. this.detailColorPanel.BackColor = ColorConverter.Convert(value);
  67. }
  68. }
  69. /// <summary>
  70. /// Gets or sets the header text font family.
  71. /// </summary>
  72. /// <value>
  73. /// The header text font family.
  74. /// </value>
  75. public System.Windows.Media.FontFamily HeaderTextFontFamily
  76. {
  77. get
  78. {
  79. return DetailsDialogStyle.HeaderTextFontFamily;
  80. }
  81. set
  82. {
  83. DetailsDialogStyle.HeaderTextFontFamily = value;
  84. }
  85. }
  86. /// <summary>
  87. /// Gets or sets the header text font style.
  88. /// </summary>
  89. /// <value>
  90. /// The header text font style.
  91. /// </value>
  92. public System.Windows.FontStyle HeaderTextFontStyle
  93. {
  94. get
  95. {
  96. return DetailsDialogStyle.HeaderTextFontStyle;
  97. }
  98. set
  99. {
  100. DetailsDialogStyle.HeaderTextFontStyle = value;
  101. }
  102. }
  103. /// <summary>
  104. /// Gets or sets the size of the header text.
  105. /// </summary>
  106. /// <value>
  107. /// The size of the header text.
  108. /// </value>
  109. public double HeaderTextSize
  110. {
  111. get
  112. {
  113. return DetailsDialogStyle.HeaderTextSize;
  114. }
  115. set
  116. {
  117. DetailsDialogStyle.HeaderTextSize = value;
  118. }
  119. }
  120. /// <summary>
  121. /// Gets or sets the details text font family.
  122. /// </summary>
  123. /// <value>
  124. /// The details text font family.
  125. /// </value>
  126. public System.Windows.Media.FontFamily DetailsTextFontFamily
  127. {
  128. get
  129. {
  130. return DetailsDialogStyle.DetailsTextFontFamily;
  131. }
  132. set
  133. {
  134. DetailsDialogStyle.DetailsTextFontFamily = value;
  135. }
  136. }
  137. /// <summary>
  138. /// Gets or sets the details text font style.
  139. /// </summary>
  140. /// <value>
  141. /// The details text font style.
  142. /// </value>
  143. public System.Windows.FontStyle DetailsTextFontStyle
  144. {
  145. get
  146. {
  147. return DetailsDialogStyle.DetailsTextFontStyle;
  148. }
  149. set
  150. {
  151. DetailsDialogStyle.DetailsTextFontStyle = value;
  152. }
  153. }
  154. /// <summary>
  155. /// Gets or sets the size of the details text.
  156. /// </summary>
  157. /// <value>
  158. /// The size of the details text.
  159. /// </value>
  160. public double DetailsTextSize
  161. {
  162. get
  163. {
  164. return DetailsDialogStyle.DetailsTextSize;
  165. }
  166. set
  167. {
  168. DetailsDialogStyle.DetailsTextSize = value;
  169. }
  170. }
  171. /// <summary>
  172. /// The are combos binding
  173. /// </summary>
  174. private bool areCombosBinding;
  175. /// <summary>
  176. /// Initializes a new instance of the <see cref="DetailDialogVisualSettings"/> class.
  177. /// </summary>
  178. public DetailDialogVisualSettings()
  179. {
  180. this.areCombosBinding = true;
  181. this.InitializeComponent();
  182. this.backgroundColorComboBox.DataSource = typeof(System.Windows.Media.Colors).GetProperties();
  183. this.backgroundColorComboBox.DisplayMember = @"Name";
  184. this.headerColorComboBox.DataSource = typeof(System.Windows.Media.Colors).GetProperties();
  185. this.headerColorComboBox.DisplayMember = @"Name";
  186. this.detailColorComboBox.DataSource = typeof(System.Windows.Media.Colors).GetProperties();
  187. this.detailColorComboBox.DisplayMember = @"Name";
  188. this.headerFontFamilyComboBox.DataSource = System.Windows.Media.Fonts.SystemFontFamilies.ToList();
  189. this.headerFontStyleComboBox.DataSource = new System.Windows.FontStyle[]
  190. {
  191. System.Windows.FontStyles.Normal,
  192. System.Windows.FontStyles.Italic,
  193. System.Windows.FontStyles.Oblique
  194. };
  195. this.detailFontFamilyComboBox.DataSource = System.Windows.Media.Fonts.SystemFontFamilies.ToList();
  196. this.detailFontStyleComboBox.DataSource = new System.Windows.FontStyle[]
  197. {
  198. System.Windows.FontStyles.Normal,
  199. System.Windows.FontStyles.Italic,
  200. System.Windows.FontStyles.Oblique
  201. };
  202. this.areCombosBinding = false;
  203. this.UpdateUI();
  204. }
  205. /// <summary>
  206. /// Handles the SelectedValueChanged event of the ComboBox control.
  207. /// </summary>
  208. /// <param name="sender">The source of the event.</param>
  209. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  210. private void ComboBox_SelectedValueChanged(object sender, EventArgs e)
  211. {
  212. ComboBox combo = sender as ComboBox;
  213. if (this.areCombosBinding || combo == null)
  214. {
  215. return;
  216. }
  217. if (combo.Name.Contains(@"header"))
  218. {
  219. this.HeaderTextFontFamily = (System.Windows.Media.FontFamily)this.headerFontFamilyComboBox.SelectedItem;
  220. if (combo.Name.Contains(@"Style")
  221. && this.headerFontStyleComboBox.SelectedIndex != -1
  222. && ((System.Windows.FontStyle)this.headerFontStyleComboBox.SelectedItem) != this.HeaderTextFontStyle)
  223. {
  224. this.HeaderTextFontStyle = (System.Windows.FontStyle)this.headerFontStyleComboBox.SelectedItem;
  225. }
  226. }
  227. else if (combo.Name.Contains(@"detail"))
  228. {
  229. this.DetailsTextFontFamily = (System.Windows.Media.FontFamily)this.detailFontFamilyComboBox.SelectedItem;
  230. if (combo.Name.Contains(@"Style")
  231. && this.detailFontStyleComboBox.SelectedIndex != -1
  232. && ((System.Windows.FontStyle)this.detailFontStyleComboBox.SelectedItem) != this.DetailsTextFontStyle)
  233. {
  234. this.DetailsTextFontStyle = (System.Windows.FontStyle)this.detailFontStyleComboBox.SelectedItem;
  235. }
  236. }
  237. }
  238. /// <summary>
  239. /// Updates the UI.
  240. /// </summary>
  241. private void UpdateUI()
  242. {
  243. this.headerFontFamilyComboBox.SelectedItem = this.HeaderTextFontFamily;
  244. this.detailFontFamilyComboBox.SelectedItem = this.DetailsTextFontFamily;
  245. this.headerFontStyleComboBox.SelectedItem = this.HeaderTextFontStyle;
  246. this.detailFontStyleComboBox.SelectedItem = this.DetailsTextFontStyle;
  247. PropertyInfo[] info = typeof(System.Windows.Media.Colors).GetProperties();
  248. this.backgroundColorComboBox.SelectedItem = info.FirstOrDefault(p => ((System.Windows.Media.Color)p.GetValue(null, null)) == this.DialogBackgroundColor);
  249. this.headerColorComboBox.SelectedItem = info.FirstOrDefault(p => ((System.Windows.Media.Color)p.GetValue(null, null)) == this.HeaderTextColor);
  250. this.detailColorComboBox.SelectedItem = info.FirstOrDefault(p => ((System.Windows.Media.Color)p.GetValue(null, null)) == this.DetailsTextColor);
  251. this.backgroundColorPanel.BackColor = ColorConverter.Convert(this.DialogBackgroundColor);
  252. this.headerColorPanel.BackColor = ColorConverter.Convert(this.HeaderTextColor);
  253. this.detailColorPanel.BackColor = ColorConverter.Convert(this.DetailsTextColor);
  254. this.headerSizeNumericUpDown.Value = (int)this.HeaderTextSize;
  255. this.detailSizeNumericUpDown.Value = (int)this.DetailsTextSize;
  256. }
  257. /// <summary>
  258. /// Called when [reset styles button click].
  259. /// </summary>
  260. /// <param name="sender">The sender.</param>
  261. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  262. private void OnResetStylesButtonClick(object sender, EventArgs e)
  263. {
  264. DetailsDialogStyle.ResetStyles();
  265. this.UpdateUI();
  266. }
  267. /// <summary>
  268. /// Handles the SelectedValueChanged event of the backgroundColorComboBox control.
  269. /// </summary>
  270. /// <param name="sender">The source of the event.</param>
  271. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  272. private void OnBackgroundColorComboBoxSelectedValueChanged(object sender, EventArgs e)
  273. {
  274. if (this.areCombosBinding || this.backgroundColorComboBox.SelectedIndex == -1)
  275. {
  276. return;
  277. }
  278. PropertyInfo info = this.backgroundColorComboBox.SelectedItem as PropertyInfo;
  279. System.Windows.Media.Color selectedColor = info != null ? (System.Windows.Media.Color)info.GetValue(null, null) : new System.Windows.Media.Color();
  280. this.backgroundColorPanel.BackColor = ColorConverter.Convert(selectedColor);
  281. this.DialogBackgroundColor = selectedColor;
  282. }
  283. /// <summary>
  284. /// Handles the SelectedValueChanged event of the headerColorComboBox control.
  285. /// </summary>
  286. /// <param name="sender">The source of the event.</param>
  287. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  288. private void OnHeaderColorComboBoxSelectedValueChanged(object sender, EventArgs e)
  289. {
  290. if (this.areCombosBinding || this.headerColorComboBox.SelectedIndex == -1)
  291. {
  292. return;
  293. }
  294. PropertyInfo info = this.headerColorComboBox.SelectedItem as PropertyInfo;
  295. System.Windows.Media.Color selectedColor = info != null ? (System.Windows.Media.Color)info.GetValue(null, null) : new System.Windows.Media.Color();
  296. this.headerColorPanel.BackColor = ColorConverter.Convert(selectedColor);
  297. this.HeaderTextColor = selectedColor;
  298. }
  299. /// <summary>
  300. /// Handles the SelectedValueChanged event of the detailColorComboBox control.
  301. /// </summary>
  302. /// <param name="sender">The source of the event.</param>
  303. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  304. private void OnDetailColorComboBoxSelectedValueChanged(object sender, EventArgs e)
  305. {
  306. if (this.areCombosBinding || this.detailColorComboBox.SelectedIndex == -1)
  307. {
  308. return;
  309. }
  310. PropertyInfo info = this.detailColorComboBox.SelectedItem as PropertyInfo;
  311. System.Windows.Media.Color selectedColor = info != null ? (System.Windows.Media.Color)info.GetValue(null, null) : new System.Windows.Media.Color();
  312. this.detailColorPanel.BackColor = ColorConverter.Convert(selectedColor);
  313. this.DetailsTextColor = selectedColor;
  314. }
  315. /// <summary>
  316. /// Handles the ValueChanged event of the headerSizeNumericUpDown control.
  317. /// </summary>
  318. /// <param name="sender">The source of the event.</param>
  319. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  320. private void OnHeaderSizeNumericUpDownValueChanged(object sender, EventArgs e)
  321. {
  322. this.HeaderTextSize = (double)this.headerSizeNumericUpDown.Value;
  323. }
  324. /// <summary>
  325. /// Handles the ValueChanged event of the detailSizeNumericUpDown control.
  326. /// </summary>
  327. /// <param name="sender">The source of the event.</param>
  328. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  329. private void OnDetailSizeNumericUpDownValueChanged(object sender, EventArgs e)
  330. {
  331. this.DetailsTextSize = (double)this.detailSizeNumericUpDown.Value;
  332. }
  333. }
  334. }