namespace OINA.Extender.Testharness { using System; using System.Drawing; using System.Windows; using System.Windows.Forms; using OINA.Extender.Controls.Styles; /// /// The PeriodicTable Visual settings form /// public partial class PeriodicTableVisualSettings : Form { /// /// Gets or sets the background colour /// private static Color BackgroundColor { get { return ColorConverter.Convert(PeriodicTableStyle.BackgroundColor); } set { PeriodicTableStyle.BackgroundColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of the included element. /// private static Color IncludedElementColor { get { return ColorConverter.Convert(PeriodicTableStyle.ElementIncludeBackgroundColor); } set { PeriodicTableStyle.ElementIncludeBackgroundColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of the excluded element. /// private static Color ExcludedElementColor { get { return ColorConverter.Convert(PeriodicTableStyle.ElementExcludeBackgroundColor); } set { PeriodicTableStyle.ElementExcludeBackgroundColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of the idle element. /// private static Color IdleElementColor { get { return ColorConverter.Convert(PeriodicTableStyle.ElementIdleBackgroundColor); } set { PeriodicTableStyle.ElementIdleBackgroundColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of the element highlight. /// private static Color ElementHighlightColor { get { return ColorConverter.Convert(PeriodicTableStyle.ElementHighlightColor); } set { PeriodicTableStyle.ElementHighlightColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of the element border. /// private static Color ElementBorderColor { get { return ColorConverter.Convert(PeriodicTableStyle.ElementBorderColor); } set { PeriodicTableStyle.ElementBorderColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of the element font. /// private static Color ElementFontColor { get { return ColorConverter.Convert(PeriodicTableStyle.ElementFontColor); } set { PeriodicTableStyle.ElementFontColor = ColorConverter.Convert(value); } } /// /// Initializes a new instance of the class. /// public PeriodicTableVisualSettings() { this.InitializeComponent(); this.UpdatePanelColors(); this.InitializeCombos(); this.UpdateCombos(); this.backgroundColorComboBox.SelectedValueChanged += this.BackgroundColorComboBox_SelectedValueChanged; this.includedElementColorComboBox.SelectedValueChanged += this.IncludedElementColorComboBox_SelectedValueChanged; this.excludedElementsColorComboBox.SelectedValueChanged += this.ExcludedElementsColorComboBox_SelectedValueChanged; this.idleElementColorComboBox.SelectedValueChanged += this.UnsetElementColorComboBox_SelectedValueChanged; this.elementHighlightColorComboBox.SelectedValueChanged += this.ElementHighlightColorComboBox_SelectedValueChanged; this.elementBorderColorComboBox.SelectedValueChanged += this.ElementBorderColorComboBox_SelectedValueChanged; this.fontFamilyComboBox.SelectedValueChanged += this.FontFamilyComboBox_SelectedValueChanged; this.fontStyleComboBox.SelectedValueChanged += this.FontStyleComboBox_SelectedValueChanged; this.fontSizeComboBox.SelectedValueChanged += this.FontSizeComboBox_SelectedValueChanged; this.elementFontColorComboBox.SelectedIndexChanged += this.ElementFontColorComboBox_SelectedIndexChanged; } /// /// Fills the combos with items /// private void InitializeCombos() { this.backgroundColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors(); this.includedElementColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors(); this.excludedElementsColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors(); this.idleElementColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors(); this.elementBorderColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors(); this.elementHighlightColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors(); this.elementFontColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors(); this.fontFamilyComboBox.DataSource = System.Windows.Media.Fonts.SystemFontFamilies; this.fontFamilyComboBox.SelectedItem = PeriodicTableStyle.PeriodicTableFontFamily; this.fontSizeComboBox.SelectedItem = PeriodicTableStyle.PeriodicTableFontSize; this.fontStyleComboBox.DataSource = new[] { FontStyles.Normal, FontStyles.Italic, FontStyles.Oblique }; this.fontSizeComboBox.DataSource = new[] { 8d, 10d, 12d, 14d, 16d }; } /// /// Updates the combos selected items on load and after resetting styles /// private void UpdateCombos() { ColorConverter.PickColourComboItem(this.backgroundColorComboBox, BackgroundColor); ColorConverter.PickColourComboItem(this.includedElementColorComboBox, IncludedElementColor); ColorConverter.PickColourComboItem(this.excludedElementsColorComboBox, ExcludedElementColor); ColorConverter.PickColourComboItem(this.idleElementColorComboBox, IdleElementColor); ColorConverter.PickColourComboItem(this.elementBorderColorComboBox, ElementBorderColor); ColorConverter.PickColourComboItem(this.elementHighlightColorComboBox, ElementHighlightColor); this.fontFamilyComboBox.SelectedItem = PeriodicTableStyle.PeriodicTableFontFamily; this.fontStyleComboBox.SelectedItem = PeriodicTableStyle.PeriodicTableFontStyle; this.fontSizeComboBox.SelectedItem = PeriodicTableStyle.PeriodicTableFontSize; ColorConverter.PickColourComboItem(this.elementFontColorComboBox, ElementFontColor); } /// /// Updates the panel colors. /// private void UpdatePanelColors() { this.backgroundColorPanel.BackColor = BackgroundColor; this.includedElementsColorPanel.BackColor = IncludedElementColor; this.excludedElementsColorPanel.BackColor = ExcludedElementColor; this.unsetElementsColorPanel.BackColor = IdleElementColor; this.elementHighlightColorPanel.BackColor = ElementHighlightColor; this.elementBorderColorPanel.BackColor = ElementBorderColor; this.fontColorPanel.BackColor = ElementFontColor; } /// /// Handles the SelectedValueChanged event of the IncludedElementColorComboBox control. /// /// The source of the event. /// The instance containing the event data. private void BackgroundColorComboBox_SelectedValueChanged(object sender, EventArgs e) { if (this.backgroundColorComboBox.SelectedValue != null) { BackgroundColor = (Color)this.backgroundColorComboBox.SelectedValue; this.UpdatePanelColors(); } } /// /// Handles the SelectedValueChanged event of the IncludedElementColorComboBox control. /// /// The source of the event. /// The instance containing the event data. private void IncludedElementColorComboBox_SelectedValueChanged(object sender, EventArgs e) { if (this.includedElementColorComboBox.SelectedValue != null) { IncludedElementColor = (Color)this.includedElementColorComboBox.SelectedValue; this.UpdatePanelColors(); } } /// /// Handles the SelectedValueChanged event of the ExcludedElementsColorComboBox control. /// /// The source of the event. /// The instance containing the event data. private void ExcludedElementsColorComboBox_SelectedValueChanged(object sender, EventArgs e) { if (this.excludedElementsColorComboBox.SelectedValue != null) { ExcludedElementColor = (Color)this.excludedElementsColorComboBox.SelectedValue; this.UpdatePanelColors(); } } /// /// Handles the SelectedValueChanged event of the UnsetElementColorComboBox control. /// /// The source of the event. /// The instance containing the event data. private void UnsetElementColorComboBox_SelectedValueChanged(object sender, EventArgs e) { if (this.idleElementColorComboBox.SelectedValue != null) { IdleElementColor = (Color)this.idleElementColorComboBox.SelectedValue; this.UpdatePanelColors(); } } /// /// Handles the SelectedValueChanged event of the ElementHighlightColorComboBox control. /// /// The source of the event. /// The instance containing the event data. private void ElementHighlightColorComboBox_SelectedValueChanged(object sender, EventArgs e) { if (this.elementHighlightColorComboBox.SelectedValue != null) { ElementHighlightColor = (Color)this.elementHighlightColorComboBox.SelectedValue; this.UpdatePanelColors(); } } /// /// Handles the SelectedValueChanged event of the ElementBorderColorComboBox control. /// /// The source of the event. /// The instance containing the event data. private void ElementBorderColorComboBox_SelectedValueChanged(object sender, EventArgs e) { if (this.elementBorderColorComboBox.SelectedValue != null) { ElementBorderColor = (Color)this.elementBorderColorComboBox.SelectedValue; this.UpdatePanelColors(); } } /// /// Handles the SelectedIndexChanged event of the ElementFontColorComboBox control. /// /// The source of the event. /// The instance containing the event data. private void ElementFontColorComboBox_SelectedIndexChanged(object sender, EventArgs e) { if (this.elementFontColorComboBox.SelectedValue != null) { ElementFontColor = (Color)this.elementFontColorComboBox.SelectedValue; this.UpdatePanelColors(); } } /// /// Handles the SelectedValueChanged event of the FontFamilyComboBox control. /// /// The source of the event. /// The instance containing the event data. private void FontFamilyComboBox_SelectedValueChanged(object sender, EventArgs e) { if (this.fontFamilyComboBox.SelectedValue != null) { PeriodicTableStyle.PeriodicTableFontFamily = this.fontFamilyComboBox.SelectedValue as System.Windows.Media.FontFamily; } } /// /// Handles the SelectedValueChanged event of the FontStyleComboBox control. /// /// The source of the event. /// The instance containing the event data. private void FontStyleComboBox_SelectedValueChanged(object sender, EventArgs e) { if (this.fontStyleComboBox.SelectedValue != null) { PeriodicTableStyle.PeriodicTableFontStyle = (System.Windows.FontStyle)this.fontStyleComboBox.SelectedValue; } } /// /// Handles the SelectedValueChanged event of the FontSizeComboBox control. /// /// The source of the event. /// The instance containing the event data. private void FontSizeComboBox_SelectedValueChanged(object sender, EventArgs e) { if (this.fontSizeComboBox.SelectedValue != null) { PeriodicTableStyle.PeriodicTableFontSize = (double)this.fontSizeComboBox.SelectedValue; } } /// /// Handles the Click event of the ResetStyleButton control. /// /// The source of the event. /// The instance containing the event data. private void ResetStyleButton_Click(object sender, EventArgs e) { PeriodicTableStyle.ResetStyles(); this.UpdatePanelColors(); this.UpdateCombos(); } } }