namespace OINA.Extender.Testharness { using System; using System.Drawing; using System.Windows.Forms; using OINA.Extender.Controls.Styles; /// /// The ElementCombo Visual settings form /// public partial class ElementComboVisualSettings : Form { /// /// Gets or sets the color of the ElementCombo background. /// private static Color BackgroundColor { get { return ColorConverter.Convert(ElementComboStyle.Background); } set { ElementComboStyle.Background = ColorConverter.Convert(value); } } /// /// Gets or sets the color of the ElementCombo foreground. /// private static Color ForegroundColor { get { return ColorConverter.Convert(ElementComboStyle.Foreground); } set { ElementComboStyle.Foreground = ColorConverter.Convert(value); } } /// /// Initializes a new instance of the class. /// public ElementComboVisualSettings() { this.InitializeComponent(); this.cbForegroundColor.DataSource = ColorConverter.GetSystemDrawingColors(); this.cbBackgroundColor.DataSource = ColorConverter.GetSystemDrawingColors(); this.cbFontSize.DataSource = new double[] { 8, 10, 12, 14, 16 }; this.UpdateCombos(); this.UpdatePanelColors(); this.cbBackgroundColor.SelectedValueChanged += this.CbBackground_SelectedValueChanged; this.cbForegroundColor.SelectedValueChanged += this.CbForeground_SelectedValueChanged; this.cbFontSize.SelectedValueChanged += this.CbFontSize_SelectedValueChanged; } /// /// Handles the SelectedValueChanged event of the background combo. /// /// The source of the event. /// The instance containing the event data. private void CbBackground_SelectedValueChanged(object sender, EventArgs e) { if (this.cbBackgroundColor.SelectedValue != null) { BackgroundColor = (Color)this.cbBackgroundColor.SelectedItem; this.UpdatePanelColors(); } } /// /// Handles the SelectedValueChanged event of the Foreground Combo. /// /// The source of the event. /// The instance containing the event data. private void CbForeground_SelectedValueChanged(object sender, EventArgs e) { if (this.cbForegroundColor.SelectedValue != null) { ForegroundColor = (Color)this.cbForegroundColor.SelectedItem; this.UpdatePanelColors(); } } /// /// Handles the SelectedValueChanged event of the Font Size combo. /// /// The source of the event. /// The instance containing the event data. private void CbFontSize_SelectedValueChanged(object sender, EventArgs e) { if (this.cbFontSize.SelectedValue != null) { ElementComboStyle.ComboFontSize = (double)this.cbFontSize.SelectedValue; } } /// /// Updates the panel colors. /// private void UpdatePanelColors() { this.backgroundColorPanel.BackColor = BackgroundColor; this.foregroundColorPanel.BackColor = ForegroundColor; } /// /// Updates the combo values. /// private void UpdateCombos() { ColorConverter.PickColourComboItem(this.cbForegroundColor, ForegroundColor); ColorConverter.PickColourComboItem(this.cbBackgroundColor, BackgroundColor); this.cbFontSize.SelectedItem = ElementComboStyle.ComboFontSize; } /// /// Handles the ResetStyle button event. /// /// The source of the event. /// The instance containing the event data. private void BtResetStyle_Click(object sender, EventArgs e) { ElementComboStyle.ResetStyles(); this.UpdateCombos(); this.UpdatePanelColors(); } } }