namespace OINA.Extender.Testharness { using System; using System.Drawing; using System.Windows; using System.Windows.Forms; using OINA.Extender.Controls.Styles; using Media = System.Windows.Media; /// /// The PeriodicTable Visual settings form /// public partial class BCDialogVisualSettings : Form { /// /// Gets or sets the color of the header font. /// private static Color HeaderFontColor { get { return ColorConverter.Convert(BrightnessContrastDialogStyle.HeaderFontColor); } set { BrightnessContrastDialogStyle.HeaderFontColor = ColorConverter.Convert(value); } } /// /// Gets or sets the family of the header font. /// private static Media.FontFamily HeaderFontFamily { get { return BrightnessContrastDialogStyle.HeaderFontFamily; } set { BrightnessContrastDialogStyle.HeaderFontFamily = value; } } /// /// Gets or sets the size of the header font. /// private static double HeaderFontSize { get { return BrightnessContrastDialogStyle.HeaderFontSize; } set { BrightnessContrastDialogStyle.HeaderFontSize = value; } } /// /// Gets or sets the style of the header font. /// private static System.Windows.FontStyle HeaderFontStyle { get { return BrightnessContrastDialogStyle.HeaderFontStyle; } set { BrightnessContrastDialogStyle.HeaderFontStyle = value; } } /// /// Gets or sets the color of the background /// private static Color BackgroundColor { get { return ColorConverter.Convert(BrightnessContrastDialogStyle.BrightnessContrastDialogBackgroundColor); } set { BrightnessContrastDialogStyle.BrightnessContrastDialogBackgroundColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of the generic control background /// private static Color ControlBackgroundColor { get { return ColorConverter.Convert(BrightnessContrastDialogStyle.GenericControlBackgroundColor); } set { BrightnessContrastDialogStyle.GenericControlBackgroundColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of the plotter/combo background /// private static Color PlotterBackgroundColor { get { return ColorConverter.Convert(BrightnessContrastDialogStyle.PlotterBackgroundColor); } set { BrightnessContrastDialogStyle.PlotterBackgroundColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of the combo line color. /// private static Color ComboLineColor { get { return ColorConverter.Convert(BrightnessContrastDialogStyle.ComboLineColor); } set { BrightnessContrastDialogStyle.ComboLineColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of the plotter axis markers /// private static Color AxisMarkersColor { get { return ColorConverter.Convert(BrightnessContrastDialogStyle.AxisMarkersColor); } set { BrightnessContrastDialogStyle.AxisMarkersColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of the plotter axis markers /// private static Color AxisTicksColor { get { return ColorConverter.Convert(BrightnessContrastDialogStyle.AxisTicksColor); } set { BrightnessContrastDialogStyle.AxisTicksColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of the combo line color. /// private static Color PlotterLineColor { get { return ColorConverter.Convert(BrightnessContrastDialogStyle.PlotterLineColor); } set { BrightnessContrastDialogStyle.PlotterLineColor = ColorConverter.Convert(value); } } /// /// Initializes a new instance of the class. /// public BCDialogVisualSettings() { this.InitializeComponent(); this.UpdatePanelColors(); this.InitializeCombos(); this.UpdateCombos(); this.HeaderFontColorComboBox.SelectedValueChanged += this.HeaderFontColorComboBox_SelectedValueChanged; this.HeaderFontSizeComboBox.SelectedValueChanged += this.HeaderFontSizeComboBoxComboBox_SelectedValueChanged; this.HeaderFontFamilyComboBox.SelectedValueChanged += this.HeaderFontFamilyComboBox_SelectedValueChanged; this.HeaderFontStyleComboBox.SelectedValueChanged += this.HeaderFontStyleComboBox_SelectedValueChanged; this.BackgroundColorComboBox.SelectedValueChanged += this.BackgroundColorComboBox_SelectedValueChanged; this.ControlBackgroundColorComboBox.SelectedValueChanged += this.ControlBackgroundColorComboBox_SelectedValueChanged; this.PlotterBackgroundColorComboBox.SelectedValueChanged += this.PlotterBackgroundColorComboBox_SelectedValueChanged; this.PlotterAxisColorComboBox.SelectedValueChanged += this.PlotterAxisColorComboBox_SelectedValueChanged; this.ComboLineColorComboBox.SelectedValueChanged += this.ComboLineColorComboBox_SelectedValueChanged; this.PlotterAxisTicksColorComboBox.SelectedValueChanged += this.PlotterAxisTicksColorComboBox_SelectedValueChanged; this.PlotterLineColorComboBox.SelectedValueChanged += this.PlotterLineColorComboBox_SelectedValueChanged; } /// /// Fills the combos with items /// private void InitializeCombos() { this.HeaderFontColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors(); this.HeaderFontFamilyComboBox.DataSource = Media.Fonts.SystemFontFamilies; this.HeaderFontStyleComboBox.DataSource = new[] { FontStyles.Normal, FontStyles.Italic, FontStyles.Oblique }; this.BackgroundColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors(); this.ControlBackgroundColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors(); this.PlotterBackgroundColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors(); this.ComboLineColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors(); this.PlotterAxisColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors(); this.PlotterAxisTicksColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors(); this.PlotterLineColorComboBox.DataSource = ColorConverter.GetSystemDrawingColors(); this.HeaderFontSizeComboBox.DataSource = new[] { 8d, 10d, 12d, 14d, 16d, 18d }; } /// /// Updates the combos selected items on load and after resetting styles /// private void UpdateCombos() { ColorConverter.PickColourComboItem(this.HeaderFontColorComboBox, HeaderFontColor); this.HeaderFontSizeComboBox.SelectedItem = BrightnessContrastDialogStyle.HeaderFontSize; this.HeaderFontFamilyComboBox.SelectedItem = BrightnessContrastDialogStyle.HeaderFontFamily; this.HeaderFontStyleComboBox.SelectedItem = BrightnessContrastDialogStyle.HeaderFontStyle; ColorConverter.PickColourComboItem(this.BackgroundColorComboBox, BackgroundColor); ColorConverter.PickColourComboItem(this.ControlBackgroundColorComboBox, ControlBackgroundColor); ColorConverter.PickColourComboItem(this.PlotterBackgroundColorComboBox, PlotterBackgroundColor); ColorConverter.PickColourComboItem(this.ComboLineColorComboBox, ComboLineColor); ColorConverter.PickColourComboItem(this.PlotterAxisColorComboBox, AxisMarkersColor); ColorConverter.PickColourComboItem(this.PlotterAxisTicksColorComboBox, AxisTicksColor); ColorConverter.PickColourComboItem(this.PlotterLineColorComboBox, PlotterLineColor); } /// /// Updates the panel colors. /// private void UpdatePanelColors() { this.HeaderFontColorPanel.BackColor = HeaderFontColor; this.BackgroundColorPanel.BackColor = BackgroundColor; this.ControlBackgroundColorPanel.BackColor = ControlBackgroundColor; this.PlotterBackgroundColorPanel.BackColor = PlotterBackgroundColor; this.PlotterAxisColorPanel.BackColor = AxisMarkersColor; this.ComboLineColorPanel.BackColor = ComboLineColor; this.PlotterAxisTicksColorPanel.BackColor = AxisTicksColor; this.PlotterLineColorPanel.BackColor = PlotterLineColor; } /// /// Handles the SelectedValueChanged event of the HeaderFontColorComboBox control. /// /// The source of the event. /// The instance containing the event data. private void HeaderFontColorComboBox_SelectedValueChanged(object sender, EventArgs e) { if (this.HeaderFontColorComboBox.SelectedValue != null) { HeaderFontColor = (Color)this.HeaderFontColorComboBox.SelectedValue; this.HeaderFontColorPanel.BackColor = HeaderFontColor; } } /// /// Handles the SelectedValueChanged event of the HeaderFontSizeComboBox control. /// /// The source of the event. /// The instance containing the event data. private void HeaderFontSizeComboBoxComboBox_SelectedValueChanged(object sender, EventArgs e) { if (this.HeaderFontSizeComboBox.SelectedValue != null) { HeaderFontSize = (double)this.HeaderFontSizeComboBox.SelectedValue; } } /// /// Handles the SelectedValueChanged event of the HeaderFontFamilyComboBox control. /// /// The source of the event. /// The instance containing the event data. private void HeaderFontFamilyComboBox_SelectedValueChanged(object sender, EventArgs e) { if (this.HeaderFontFamilyComboBox.SelectedValue != null) { HeaderFontFamily = (Media.FontFamily)this.HeaderFontFamilyComboBox.SelectedValue; } } /// /// Handles the SelectedValueChanged event of the HeaderFontStyleComboBox control. /// /// The source of the event. /// The instance containing the event data. private void HeaderFontStyleComboBox_SelectedValueChanged(object sender, EventArgs e) { if (this.HeaderFontStyleComboBox.SelectedValue != null) { HeaderFontStyle = (System.Windows.FontStyle)this.HeaderFontStyleComboBox.SelectedValue; } } /// /// Handles the SelectedValueChanged event of the BackgroundColorComboBox 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.BackgroundColorPanel.BackColor = BackgroundColor; } } /// /// Handles the SelectedValueChanged event of the ControlBackgroundColorComboBox control. /// /// The source of the event. /// The instance containing the event data. private void ControlBackgroundColorComboBox_SelectedValueChanged(object sender, EventArgs e) { if (this.ControlBackgroundColorComboBox.SelectedValue != null) { ControlBackgroundColor = (Color)this.ControlBackgroundColorComboBox.SelectedValue; this.ControlBackgroundColorPanel.BackColor = ControlBackgroundColor; } } /// /// Handles the SelectedValueChanged event of the PlotterBackgroundColorComboBox control. /// /// The source of the event. /// The instance containing the event data. private void PlotterBackgroundColorComboBox_SelectedValueChanged(object sender, EventArgs e) { if (this.PlotterBackgroundColorComboBox.SelectedValue != null) { PlotterBackgroundColor = (Color)this.PlotterBackgroundColorComboBox.SelectedValue; this.PlotterBackgroundColorPanel.BackColor = PlotterBackgroundColor; } } /// /// Handles the SelectedValueChanged event of the ComboLineColorComboBox control. /// /// The source of the event. /// The instance containing the event data. private void ComboLineColorComboBox_SelectedValueChanged(object sender, EventArgs e) { if (this.ComboLineColorComboBox.SelectedValue != null) { ComboLineColor = (Color)this.ComboLineColorComboBox.SelectedValue; this.ComboLineColorPanel.BackColor = ComboLineColor; } } /// /// Handles the SelectedValueChanged event of the PlotterAxisColorComboBox control. /// /// The source of the event. /// The instance containing the event data. private void PlotterAxisColorComboBox_SelectedValueChanged(object sender, EventArgs e) { if (this.PlotterAxisColorComboBox.SelectedValue != null) { AxisMarkersColor = (Color)this.PlotterAxisColorComboBox.SelectedValue; this.PlotterAxisColorPanel.BackColor = AxisMarkersColor; } } /// /// Handles the SelectedValueChanged event of the PlotterAxisTicksColorComboBox control. /// /// The source of the event. /// The instance containing the event data. private void PlotterAxisTicksColorComboBox_SelectedValueChanged(object sender, EventArgs e) { if (this.PlotterAxisTicksColorComboBox.SelectedValue != null) { AxisTicksColor = (Color)this.PlotterAxisTicksColorComboBox.SelectedValue; this.PlotterAxisTicksColorPanel.BackColor = AxisTicksColor; } } /// /// Handles the SelectedValueChanged event of the PlotterLineColorComboBox control. /// /// The source of the event. /// The instance containing the event data. private void PlotterLineColorComboBox_SelectedValueChanged(object sender, EventArgs e) { if (this.PlotterLineColorComboBox.SelectedValue != null) { PlotterLineColor = (Color)this.PlotterLineColorComboBox.SelectedValue; this.PlotterLineColorPanel.BackColor = PlotterLineColor; } } /// /// 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) { BrightnessContrastDialogStyle.ResetStyles(); this.UpdatePanelColors(); this.UpdateCombos(); } } }