123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311 |
- namespace OINA.Extender.Testharness
- {
- using System;
- using System.Drawing;
- using System.Windows;
- using System.Windows.Forms;
- using OINA.Extender.Controls.Styles;
- /// <summary>
- /// The PeriodicTable Visual settings form
- /// </summary>
- public partial class PeriodicTableVisualSettings : Form
- {
- /// <summary>
- /// Gets or sets the background colour
- /// </summary>
- private static Color BackgroundColor
- {
- get { return ColorConverter.Convert(PeriodicTableStyle.BackgroundColor); }
- set { PeriodicTableStyle.BackgroundColor = ColorConverter.Convert(value); }
- }
- /// <summary>
- /// Gets or sets the color of the included element.
- /// </summary>
- private static Color IncludedElementColor
- {
- get { return ColorConverter.Convert(PeriodicTableStyle.ElementIncludeBackgroundColor); }
- set { PeriodicTableStyle.ElementIncludeBackgroundColor = ColorConverter.Convert(value); }
- }
- /// <summary>
- /// Gets or sets the color of the excluded element.
- /// </summary>
- private static Color ExcludedElementColor
- {
- get { return ColorConverter.Convert(PeriodicTableStyle.ElementExcludeBackgroundColor); }
- set { PeriodicTableStyle.ElementExcludeBackgroundColor = ColorConverter.Convert(value); }
- }
- /// <summary>
- /// Gets or sets the color of the idle element.
- /// </summary>
- private static Color IdleElementColor
- {
- get { return ColorConverter.Convert(PeriodicTableStyle.ElementIdleBackgroundColor); }
- set { PeriodicTableStyle.ElementIdleBackgroundColor = ColorConverter.Convert(value); }
- }
- /// <summary>
- /// Gets or sets the color of the element highlight.
- /// </summary>
- private static Color ElementHighlightColor
- {
- get { return ColorConverter.Convert(PeriodicTableStyle.ElementHighlightColor); }
- set { PeriodicTableStyle.ElementHighlightColor = ColorConverter.Convert(value); }
- }
- /// <summary>
- /// Gets or sets the color of the element border.
- /// </summary>
- private static Color ElementBorderColor
- {
- get { return ColorConverter.Convert(PeriodicTableStyle.ElementBorderColor); }
- set { PeriodicTableStyle.ElementBorderColor = ColorConverter.Convert(value); }
- }
- /// <summary>
- /// Gets or sets the color of the element font.
- /// </summary>
- private static Color ElementFontColor
- {
- get { return ColorConverter.Convert(PeriodicTableStyle.ElementFontColor); }
- set { PeriodicTableStyle.ElementFontColor = ColorConverter.Convert(value); }
- }
- /// <summary>
- /// Initializes a new instance of the <see cref="PeriodicTableVisualSettings"/> class.
- /// </summary>
- 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;
- }
- /// <summary>
- /// Fills the combos with items
- /// </summary>
- 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 };
- }
- /// <summary>
- /// Updates the combos selected items on load and after resetting styles
- /// </summary>
- 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);
- }
- /// <summary>
- /// Updates the panel colors.
- /// </summary>
- 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;
- }
- /// <summary>
- /// Handles the SelectedValueChanged event of the IncludedElementColorComboBox control.
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
- private void BackgroundColorComboBox_SelectedValueChanged(object sender, EventArgs e)
- {
- if (this.backgroundColorComboBox.SelectedValue != null)
- {
- BackgroundColor = (Color)this.backgroundColorComboBox.SelectedValue;
- this.UpdatePanelColors();
- }
- }
- /// <summary>
- /// Handles the SelectedValueChanged event of the IncludedElementColorComboBox control.
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
- private void IncludedElementColorComboBox_SelectedValueChanged(object sender, EventArgs e)
- {
- if (this.includedElementColorComboBox.SelectedValue != null)
- {
- IncludedElementColor = (Color)this.includedElementColorComboBox.SelectedValue;
- this.UpdatePanelColors();
- }
- }
- /// <summary>
- /// Handles the SelectedValueChanged event of the ExcludedElementsColorComboBox control.
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
- private void ExcludedElementsColorComboBox_SelectedValueChanged(object sender, EventArgs e)
- {
- if (this.excludedElementsColorComboBox.SelectedValue != null)
- {
- ExcludedElementColor = (Color)this.excludedElementsColorComboBox.SelectedValue;
- this.UpdatePanelColors();
- }
- }
- /// <summary>
- /// Handles the SelectedValueChanged event of the UnsetElementColorComboBox control.
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
- private void UnsetElementColorComboBox_SelectedValueChanged(object sender, EventArgs e)
- {
- if (this.idleElementColorComboBox.SelectedValue != null)
- {
- IdleElementColor = (Color)this.idleElementColorComboBox.SelectedValue;
- this.UpdatePanelColors();
- }
- }
- /// <summary>
- /// Handles the SelectedValueChanged event of the ElementHighlightColorComboBox control.
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
- private void ElementHighlightColorComboBox_SelectedValueChanged(object sender, EventArgs e)
- {
- if (this.elementHighlightColorComboBox.SelectedValue != null)
- {
- ElementHighlightColor = (Color)this.elementHighlightColorComboBox.SelectedValue;
- this.UpdatePanelColors();
- }
- }
- /// <summary>
- /// Handles the SelectedValueChanged event of the ElementBorderColorComboBox control.
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
- private void ElementBorderColorComboBox_SelectedValueChanged(object sender, EventArgs e)
- {
- if (this.elementBorderColorComboBox.SelectedValue != null)
- {
- ElementBorderColor = (Color)this.elementBorderColorComboBox.SelectedValue;
- this.UpdatePanelColors();
- }
- }
- /// <summary>
- /// Handles the SelectedIndexChanged event of the ElementFontColorComboBox control.
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
- private void ElementFontColorComboBox_SelectedIndexChanged(object sender, EventArgs e)
- {
- if (this.elementFontColorComboBox.SelectedValue != null)
- {
- ElementFontColor = (Color)this.elementFontColorComboBox.SelectedValue;
- this.UpdatePanelColors();
- }
- }
- /// <summary>
- /// Handles the SelectedValueChanged event of the FontFamilyComboBox control.
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
- private void FontFamilyComboBox_SelectedValueChanged(object sender, EventArgs e)
- {
- if (this.fontFamilyComboBox.SelectedValue != null)
- {
- PeriodicTableStyle.PeriodicTableFontFamily = this.fontFamilyComboBox.SelectedValue as System.Windows.Media.FontFamily;
- }
- }
- /// <summary>
- /// Handles the SelectedValueChanged event of the FontStyleComboBox control.
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
- private void FontStyleComboBox_SelectedValueChanged(object sender, EventArgs e)
- {
- if (this.fontStyleComboBox.SelectedValue != null)
- {
- PeriodicTableStyle.PeriodicTableFontStyle = (System.Windows.FontStyle)this.fontStyleComboBox.SelectedValue;
- }
- }
- /// <summary>
- /// Handles the SelectedValueChanged event of the FontSizeComboBox control.
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
- private void FontSizeComboBox_SelectedValueChanged(object sender, EventArgs e)
- {
- if (this.fontSizeComboBox.SelectedValue != null)
- {
- PeriodicTableStyle.PeriodicTableFontSize = (double)this.fontSizeComboBox.SelectedValue;
- }
- }
- /// <summary>
- /// Handles the Click event of the ResetStyleButton control.
- /// </summary>
- /// <param name="sender">The source of the event.</param>
- /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
- private void ResetStyleButton_Click(object sender, EventArgs e)
- {
- PeriodicTableStyle.ResetStyles();
- this.UpdatePanelColors();
- this.UpdateCombos();
- }
- }
- }
|