ElementComboVisualSettings.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. namespace OINA.Extender.Testharness
  2. {
  3. using System;
  4. using System.Drawing;
  5. using System.Windows.Forms;
  6. using OINA.Extender.Controls.Styles;
  7. /// <summary>
  8. /// The ElementCombo Visual settings form
  9. /// </summary>
  10. public partial class ElementComboVisualSettings : Form
  11. {
  12. /// <summary>
  13. /// Gets or sets the color of the ElementCombo background.
  14. /// </summary>
  15. private static Color BackgroundColor
  16. {
  17. get { return ColorConverter.Convert(ElementComboStyle.Background); }
  18. set { ElementComboStyle.Background = ColorConverter.Convert(value); }
  19. }
  20. /// <summary>
  21. /// Gets or sets the color of the ElementCombo foreground.
  22. /// </summary>
  23. private static Color ForegroundColor
  24. {
  25. get { return ColorConverter.Convert(ElementComboStyle.Foreground); }
  26. set { ElementComboStyle.Foreground = ColorConverter.Convert(value); }
  27. }
  28. /// <summary>
  29. /// Initializes a new instance of the <see cref="ElementComboVisualSettings"/> class.
  30. /// </summary>
  31. public ElementComboVisualSettings()
  32. {
  33. this.InitializeComponent();
  34. this.cbForegroundColor.DataSource = ColorConverter.GetSystemDrawingColors();
  35. this.cbBackgroundColor.DataSource = ColorConverter.GetSystemDrawingColors();
  36. this.cbFontSize.DataSource = new double[] { 8, 10, 12, 14, 16 };
  37. this.UpdateCombos();
  38. this.UpdatePanelColors();
  39. this.cbBackgroundColor.SelectedValueChanged += this.CbBackground_SelectedValueChanged;
  40. this.cbForegroundColor.SelectedValueChanged += this.CbForeground_SelectedValueChanged;
  41. this.cbFontSize.SelectedValueChanged += this.CbFontSize_SelectedValueChanged;
  42. }
  43. /// <summary>
  44. /// Handles the SelectedValueChanged event of the background combo.
  45. /// </summary>
  46. /// <param name="sender">The source of the event.</param>
  47. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  48. private void CbBackground_SelectedValueChanged(object sender, EventArgs e)
  49. {
  50. if (this.cbBackgroundColor.SelectedValue != null)
  51. {
  52. BackgroundColor = (Color)this.cbBackgroundColor.SelectedItem;
  53. this.UpdatePanelColors();
  54. }
  55. }
  56. /// <summary>
  57. /// Handles the SelectedValueChanged event of the Foreground Combo.
  58. /// </summary>
  59. /// <param name="sender">The source of the event.</param>
  60. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  61. private void CbForeground_SelectedValueChanged(object sender, EventArgs e)
  62. {
  63. if (this.cbForegroundColor.SelectedValue != null)
  64. {
  65. ForegroundColor = (Color)this.cbForegroundColor.SelectedItem;
  66. this.UpdatePanelColors();
  67. }
  68. }
  69. /// <summary>
  70. /// Handles the SelectedValueChanged event of the Font Size combo.
  71. /// </summary>
  72. /// <param name="sender">The source of the event.</param>
  73. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  74. private void CbFontSize_SelectedValueChanged(object sender, EventArgs e)
  75. {
  76. if (this.cbFontSize.SelectedValue != null)
  77. {
  78. ElementComboStyle.ComboFontSize = (double)this.cbFontSize.SelectedValue;
  79. }
  80. }
  81. /// <summary>
  82. /// Updates the panel colors.
  83. /// </summary>
  84. private void UpdatePanelColors()
  85. {
  86. this.backgroundColorPanel.BackColor = BackgroundColor;
  87. this.foregroundColorPanel.BackColor = ForegroundColor;
  88. }
  89. /// <summary>
  90. /// Updates the combo values.
  91. /// </summary>
  92. private void UpdateCombos()
  93. {
  94. ColorConverter.PickColourComboItem(this.cbForegroundColor, ForegroundColor);
  95. ColorConverter.PickColourComboItem(this.cbBackgroundColor, BackgroundColor);
  96. this.cbFontSize.SelectedItem = ElementComboStyle.ComboFontSize;
  97. }
  98. /// <summary>
  99. /// Handles the ResetStyle button event.
  100. /// </summary>
  101. /// <param name="sender">The source of the event.</param>
  102. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  103. private void BtResetStyle_Click(object sender, EventArgs e)
  104. {
  105. ElementComboStyle.ResetStyles();
  106. this.UpdateCombos();
  107. this.UpdatePanelColors();
  108. }
  109. }
  110. }