BCDialogVisualSettings.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. namespace OINA.Extender.Testharness
  2. {
  3. using System;
  4. using System.Drawing;
  5. using System.Windows;
  6. using System.Windows.Forms;
  7. using OINA.Extender.Controls.Styles;
  8. using Media = System.Windows.Media;
  9. /// <summary>
  10. /// The PeriodicTable Visual settings form
  11. /// </summary>
  12. public partial class BCDialogVisualSettings : Form
  13. {
  14. /// <summary>
  15. /// Gets or sets the color of the header font.
  16. /// </summary>
  17. private static Color HeaderFontColor
  18. {
  19. get { return ColorConverter.Convert(BrightnessContrastDialogStyle.HeaderFontColor); }
  20. set { BrightnessContrastDialogStyle.HeaderFontColor = ColorConverter.Convert(value); }
  21. }
  22. /// <summary>
  23. /// Gets or sets the family of the header font.
  24. /// </summary>
  25. private static Media.FontFamily HeaderFontFamily
  26. {
  27. get { return BrightnessContrastDialogStyle.HeaderFontFamily; }
  28. set { BrightnessContrastDialogStyle.HeaderFontFamily = value; }
  29. }
  30. /// <summary>
  31. /// Gets or sets the size of the header font.
  32. /// </summary>
  33. private static double HeaderFontSize
  34. {
  35. get { return BrightnessContrastDialogStyle.HeaderFontSize; }
  36. set { BrightnessContrastDialogStyle.HeaderFontSize = value; }
  37. }
  38. /// <summary>
  39. /// Gets or sets the style of the header font.
  40. /// </summary>
  41. private static System.Windows.FontStyle HeaderFontStyle
  42. {
  43. get { return BrightnessContrastDialogStyle.HeaderFontStyle; }
  44. set { BrightnessContrastDialogStyle.HeaderFontStyle = value; }
  45. }
  46. /// <summary>
  47. /// Gets or sets the color of the background
  48. /// </summary>
  49. private static Color BackgroundColor
  50. {
  51. get { return ColorConverter.Convert(BrightnessContrastDialogStyle.BrightnessContrastDialogBackgroundColor); }
  52. set { BrightnessContrastDialogStyle.BrightnessContrastDialogBackgroundColor = ColorConverter.Convert(value); }
  53. }
  54. /// <summary>
  55. /// Gets or sets the color of the generic control background
  56. /// </summary>
  57. private static Color ControlBackgroundColor
  58. {
  59. get { return ColorConverter.Convert(BrightnessContrastDialogStyle.GenericControlBackgroundColor); }
  60. set { BrightnessContrastDialogStyle.GenericControlBackgroundColor = ColorConverter.Convert(value); }
  61. }
  62. /// <summary>
  63. /// Gets or sets the color of the plotter/combo background
  64. /// </summary>
  65. private static Color PlotterBackgroundColor
  66. {
  67. get { return ColorConverter.Convert(BrightnessContrastDialogStyle.PlotterBackgroundColor); }
  68. set { BrightnessContrastDialogStyle.PlotterBackgroundColor = ColorConverter.Convert(value); }
  69. }
  70. /// <summary>
  71. /// Gets or sets the color of the combo line color.
  72. /// </summary>
  73. private static Color ComboLineColor
  74. {
  75. get { return ColorConverter.Convert(BrightnessContrastDialogStyle.ComboLineColor); }
  76. set { BrightnessContrastDialogStyle.ComboLineColor = ColorConverter.Convert(value); }
  77. }
  78. /// <summary>
  79. /// Gets or sets the color of the plotter axis markers
  80. /// </summary>
  81. private static Color AxisMarkersColor
  82. {
  83. get { return ColorConverter.Convert(BrightnessContrastDialogStyle.AxisMarkersColor); }
  84. set { BrightnessContrastDialogStyle.AxisMarkersColor = ColorConverter.Convert(value); }
  85. }
  86. /// <summary>
  87. /// Gets or sets the color of the plotter axis markers
  88. /// </summary>
  89. private static Color AxisTicksColor
  90. {
  91. get { return ColorConverter.Convert(BrightnessContrastDialogStyle.AxisTicksColor); }
  92. set { BrightnessContrastDialogStyle.AxisTicksColor = ColorConverter.Convert(value); }
  93. }
  94. /// <summary>
  95. /// Gets or sets the color of the combo line color.
  96. /// </summary>
  97. private static Color PlotterLineColor
  98. {
  99. get { return ColorConverter.Convert(BrightnessContrastDialogStyle.PlotterLineColor); }
  100. set { BrightnessContrastDialogStyle.PlotterLineColor = ColorConverter.Convert(value); }
  101. }
  102. /// <summary>
  103. /// Initializes a new instance of the <see cref="PeriodicTableVisualSettings"/> class.
  104. /// </summary>
  105. public BCDialogVisualSettings()
  106. {
  107. this.InitializeComponent();
  108. this.UpdatePanelColors();
  109. this.InitializeCombos();
  110. this.UpdateCombos();
  111. this.HeaderFontColorComboBox.SelectedValueChanged += this.HeaderFontColorComboBox_SelectedValueChanged;
  112. this.HeaderFontSizeComboBox.SelectedValueChanged += this.HeaderFontSizeComboBoxComboBox_SelectedValueChanged;
  113. this.HeaderFontFamilyComboBox.SelectedValueChanged += this.HeaderFontFamilyComboBox_SelectedValueChanged;
  114. this.HeaderFontStyleComboBox.SelectedValueChanged += this.HeaderFontStyleComboBox_SelectedValueChanged;
  115. this.BackgroundColorComboBox.SelectedValueChanged += this.BackgroundColorComboBox_SelectedValueChanged;
  116. this.ControlBackgroundColorComboBox.SelectedValueChanged += this.ControlBackgroundColorComboBox_SelectedValueChanged;
  117. this.PlotterBackgroundColorComboBox.SelectedValueChanged += this.PlotterBackgroundColorComboBox_SelectedValueChanged;
  118. this.PlotterAxisColorComboBox.SelectedValueChanged += this.PlotterAxisColorComboBox_SelectedValueChanged;
  119. this.ComboLineColorComboBox.SelectedValueChanged += this.ComboLineColorComboBox_SelectedValueChanged;
  120. this.PlotterAxisTicksColorComboBox.SelectedValueChanged += this.PlotterAxisTicksColorComboBox_SelectedValueChanged;
  121. this.PlotterLineColorComboBox.SelectedValueChanged += this.PlotterLineColorComboBox_SelectedValueChanged;
  122. }
  123. /// <summary>
  124. /// Fills the combos with items
  125. /// </summary>
  126. private void InitializeCombos()
  127. {
  128. this.HeaderFontColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors();
  129. this.HeaderFontFamilyComboBox.DataSource = Media.Fonts.SystemFontFamilies;
  130. this.HeaderFontStyleComboBox.DataSource = new[] { FontStyles.Normal, FontStyles.Italic, FontStyles.Oblique };
  131. this.BackgroundColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors();
  132. this.ControlBackgroundColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors();
  133. this.PlotterBackgroundColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors();
  134. this.ComboLineColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors();
  135. this.PlotterAxisColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors();
  136. this.PlotterAxisTicksColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors();
  137. this.PlotterLineColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors();
  138. this.HeaderFontSizeComboBox.DataSource = new[] { 8d, 10d, 12d, 14d, 16d, 18d };
  139. }
  140. /// <summary>
  141. /// Updates the combos selected items on load and after resetting styles
  142. /// </summary>
  143. private void UpdateCombos()
  144. {
  145. ColorConverter.PickColourComboItem(this.HeaderFontColorComboBox, HeaderFontColor);
  146. this.HeaderFontSizeComboBox.SelectedItem = BrightnessContrastDialogStyle.HeaderFontSize;
  147. this.HeaderFontFamilyComboBox.SelectedItem = BrightnessContrastDialogStyle.HeaderFontFamily;
  148. this.HeaderFontStyleComboBox.SelectedItem = BrightnessContrastDialogStyle.HeaderFontStyle;
  149. ColorConverter.PickColourComboItem(this.BackgroundColorComboBox, BackgroundColor);
  150. ColorConverter.PickColourComboItem(this.ControlBackgroundColorComboBox, ControlBackgroundColor);
  151. ColorConverter.PickColourComboItem(this.PlotterBackgroundColorComboBox, PlotterBackgroundColor);
  152. ColorConverter.PickColourComboItem(this.ComboLineColorComboBox, ComboLineColor);
  153. ColorConverter.PickColourComboItem(this.PlotterAxisColorComboBox, AxisMarkersColor);
  154. ColorConverter.PickColourComboItem(this.PlotterAxisTicksColorComboBox, AxisTicksColor);
  155. ColorConverter.PickColourComboItem(this.PlotterLineColorComboBox, PlotterLineColor);
  156. }
  157. /// <summary>
  158. /// Updates the panel colors.
  159. /// </summary>
  160. private void UpdatePanelColors()
  161. {
  162. this.HeaderFontColorPanel.BackColor = HeaderFontColor;
  163. this.BackgroundColorPanel.BackColor = BackgroundColor;
  164. this.ControlBackgroundColorPanel.BackColor = ControlBackgroundColor;
  165. this.PlotterBackgroundColorPanel.BackColor = PlotterBackgroundColor;
  166. this.PlotterAxisColorPanel.BackColor = AxisMarkersColor;
  167. this.ComboLineColorPanel.BackColor = ComboLineColor;
  168. this.PlotterAxisTicksColorPanel.BackColor = AxisTicksColor;
  169. this.PlotterLineColorPanel.BackColor = PlotterLineColor;
  170. }
  171. /// <summary>
  172. /// Handles the SelectedValueChanged event of the HeaderFontColorComboBox control.
  173. /// </summary>
  174. /// <param name="sender">The source of the event.</param>
  175. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  176. private void HeaderFontColorComboBox_SelectedValueChanged(object sender, EventArgs e)
  177. {
  178. if (this.HeaderFontColorComboBox.SelectedValue != null)
  179. {
  180. HeaderFontColor = (Color)this.HeaderFontColorComboBox.SelectedValue;
  181. this.HeaderFontColorPanel.BackColor = HeaderFontColor;
  182. }
  183. }
  184. /// <summary>
  185. /// Handles the SelectedValueChanged event of the HeaderFontSizeComboBox control.
  186. /// </summary>
  187. /// <param name="sender">The source of the event.</param>
  188. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  189. private void HeaderFontSizeComboBoxComboBox_SelectedValueChanged(object sender, EventArgs e)
  190. {
  191. if (this.HeaderFontSizeComboBox.SelectedValue != null)
  192. {
  193. HeaderFontSize = (double)this.HeaderFontSizeComboBox.SelectedValue;
  194. }
  195. }
  196. /// <summary>
  197. /// Handles the SelectedValueChanged event of the HeaderFontFamilyComboBox control.
  198. /// </summary>
  199. /// <param name="sender">The source of the event.</param>
  200. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  201. private void HeaderFontFamilyComboBox_SelectedValueChanged(object sender, EventArgs e)
  202. {
  203. if (this.HeaderFontFamilyComboBox.SelectedValue != null)
  204. {
  205. HeaderFontFamily = (Media.FontFamily)this.HeaderFontFamilyComboBox.SelectedValue;
  206. }
  207. }
  208. /// <summary>
  209. /// Handles the SelectedValueChanged event of the HeaderFontStyleComboBox control.
  210. /// </summary>
  211. /// <param name="sender">The source of the event.</param>
  212. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  213. private void HeaderFontStyleComboBox_SelectedValueChanged(object sender, EventArgs e)
  214. {
  215. if (this.HeaderFontStyleComboBox.SelectedValue != null)
  216. {
  217. HeaderFontStyle = (System.Windows.FontStyle)this.HeaderFontStyleComboBox.SelectedValue;
  218. }
  219. }
  220. /// <summary>
  221. /// Handles the SelectedValueChanged event of the BackgroundColorComboBox control.
  222. /// </summary>
  223. /// <param name="sender">The source of the event.</param>
  224. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  225. private void BackgroundColorComboBox_SelectedValueChanged(object sender, EventArgs e)
  226. {
  227. if (this.BackgroundColorComboBox.SelectedValue != null)
  228. {
  229. BackgroundColor = (Color)this.BackgroundColorComboBox.SelectedValue;
  230. this.BackgroundColorPanel.BackColor = BackgroundColor;
  231. }
  232. }
  233. /// <summary>
  234. /// Handles the SelectedValueChanged event of the ControlBackgroundColorComboBox control.
  235. /// </summary>
  236. /// <param name="sender">The source of the event.</param>
  237. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  238. private void ControlBackgroundColorComboBox_SelectedValueChanged(object sender, EventArgs e)
  239. {
  240. if (this.ControlBackgroundColorComboBox.SelectedValue != null)
  241. {
  242. ControlBackgroundColor = (Color)this.ControlBackgroundColorComboBox.SelectedValue;
  243. this.ControlBackgroundColorPanel.BackColor = ControlBackgroundColor;
  244. }
  245. }
  246. /// <summary>
  247. /// Handles the SelectedValueChanged event of the PlotterBackgroundColorComboBox control.
  248. /// </summary>
  249. /// <param name="sender">The source of the event.</param>
  250. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  251. private void PlotterBackgroundColorComboBox_SelectedValueChanged(object sender, EventArgs e)
  252. {
  253. if (this.PlotterBackgroundColorComboBox.SelectedValue != null)
  254. {
  255. PlotterBackgroundColor = (Color)this.PlotterBackgroundColorComboBox.SelectedValue;
  256. this.PlotterBackgroundColorPanel.BackColor = PlotterBackgroundColor;
  257. }
  258. }
  259. /// <summary>
  260. /// Handles the SelectedValueChanged event of the ComboLineColorComboBox control.
  261. /// </summary>
  262. /// <param name="sender">The source of the event.</param>
  263. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  264. private void ComboLineColorComboBox_SelectedValueChanged(object sender, EventArgs e)
  265. {
  266. if (this.ComboLineColorComboBox.SelectedValue != null)
  267. {
  268. ComboLineColor = (Color)this.ComboLineColorComboBox.SelectedValue;
  269. this.ComboLineColorPanel.BackColor = ComboLineColor;
  270. }
  271. }
  272. /// <summary>
  273. /// Handles the SelectedValueChanged event of the PlotterAxisColorComboBox control.
  274. /// </summary>
  275. /// <param name="sender">The source of the event.</param>
  276. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  277. private void PlotterAxisColorComboBox_SelectedValueChanged(object sender, EventArgs e)
  278. {
  279. if (this.PlotterAxisColorComboBox.SelectedValue != null)
  280. {
  281. AxisMarkersColor = (Color)this.PlotterAxisColorComboBox.SelectedValue;
  282. this.PlotterAxisColorPanel.BackColor = AxisMarkersColor;
  283. }
  284. }
  285. /// <summary>
  286. /// Handles the SelectedValueChanged event of the PlotterAxisTicksColorComboBox control.
  287. /// </summary>
  288. /// <param name="sender">The source of the event.</param>
  289. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  290. private void PlotterAxisTicksColorComboBox_SelectedValueChanged(object sender, EventArgs e)
  291. {
  292. if (this.PlotterAxisTicksColorComboBox.SelectedValue != null)
  293. {
  294. AxisTicksColor = (Color)this.PlotterAxisTicksColorComboBox.SelectedValue;
  295. this.PlotterAxisTicksColorPanel.BackColor = AxisTicksColor;
  296. }
  297. }
  298. /// <summary>
  299. /// Handles the SelectedValueChanged event of the PlotterLineColorComboBox control.
  300. /// </summary>
  301. /// <param name="sender">The source of the event.</param>
  302. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  303. private void PlotterLineColorComboBox_SelectedValueChanged(object sender, EventArgs e)
  304. {
  305. if (this.PlotterLineColorComboBox.SelectedValue != null)
  306. {
  307. PlotterLineColor = (Color)this.PlotterLineColorComboBox.SelectedValue;
  308. this.PlotterLineColorPanel.BackColor = PlotterLineColor;
  309. }
  310. }
  311. /// <summary>
  312. /// Handles the Click event of the ResetStyleButton control.
  313. /// </summary>
  314. /// <param name="sender">The source of the event.</param>
  315. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  316. private void ResetStyleButton_Click(object sender, EventArgs e)
  317. {
  318. BrightnessContrastDialogStyle.ResetStyles();
  319. this.UpdatePanelColors();
  320. this.UpdateCombos();
  321. }
  322. }
  323. }