namespace OINA.Extender.Testharness { using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Reflection; using System.Windows.Forms; using OINA.Extender.Controls.Styles; /// /// Interaction logic for DetailDialogVisualSettings /// public partial class DetailDialogVisualSettings : Form { /// /// Gets or sets the color of the dialog background. /// /// /// The color of the dialog background. /// public System.Windows.Media.Color DialogBackgroundColor { get { return DetailsDialogStyle.DialogBackgroundColor; } set { DetailsDialogStyle.DialogBackgroundColor = value; this.backgroundColorPanel.BackColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of the header text. /// /// /// The color of the header text. /// public System.Windows.Media.Color HeaderTextColor { get { return DetailsDialogStyle.HeaderTextColor; } set { DetailsDialogStyle.HeaderTextColor = value; this.headerColorPanel.BackColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of the details text. /// /// /// The color of the details text. /// public System.Windows.Media.Color DetailsTextColor { get { return DetailsDialogStyle.DetailsTextColor; } set { DetailsDialogStyle.DetailsTextColor = value; this.detailColorPanel.BackColor = ColorConverter.Convert(value); } } /// /// Gets or sets the header text font family. /// /// /// The header text font family. /// public System.Windows.Media.FontFamily HeaderTextFontFamily { get { return DetailsDialogStyle.HeaderTextFontFamily; } set { DetailsDialogStyle.HeaderTextFontFamily = value; } } /// /// Gets or sets the header text font style. /// /// /// The header text font style. /// public System.Windows.FontStyle HeaderTextFontStyle { get { return DetailsDialogStyle.HeaderTextFontStyle; } set { DetailsDialogStyle.HeaderTextFontStyle = value; } } /// /// Gets or sets the size of the header text. /// /// /// The size of the header text. /// public double HeaderTextSize { get { return DetailsDialogStyle.HeaderTextSize; } set { DetailsDialogStyle.HeaderTextSize = value; } } /// /// Gets or sets the details text font family. /// /// /// The details text font family. /// public System.Windows.Media.FontFamily DetailsTextFontFamily { get { return DetailsDialogStyle.DetailsTextFontFamily; } set { DetailsDialogStyle.DetailsTextFontFamily = value; } } /// /// Gets or sets the details text font style. /// /// /// The details text font style. /// public System.Windows.FontStyle DetailsTextFontStyle { get { return DetailsDialogStyle.DetailsTextFontStyle; } set { DetailsDialogStyle.DetailsTextFontStyle = value; } } /// /// Gets or sets the size of the details text. /// /// /// The size of the details text. /// public double DetailsTextSize { get { return DetailsDialogStyle.DetailsTextSize; } set { DetailsDialogStyle.DetailsTextSize = value; } } /// /// The are combos binding /// private bool areCombosBinding; /// /// Initializes a new instance of the class. /// public DetailDialogVisualSettings() { this.areCombosBinding = true; this.InitializeComponent(); this.backgroundColorComboBox.DataSource = typeof(System.Windows.Media.Colors).GetProperties(); this.backgroundColorComboBox.DisplayMember = @"Name"; this.headerColorComboBox.DataSource = typeof(System.Windows.Media.Colors).GetProperties(); this.headerColorComboBox.DisplayMember = @"Name"; this.detailColorComboBox.DataSource = typeof(System.Windows.Media.Colors).GetProperties(); this.detailColorComboBox.DisplayMember = @"Name"; this.headerFontFamilyComboBox.DataSource = System.Windows.Media.Fonts.SystemFontFamilies.ToList(); this.headerFontStyleComboBox.DataSource = new System.Windows.FontStyle[] { System.Windows.FontStyles.Normal, System.Windows.FontStyles.Italic, System.Windows.FontStyles.Oblique }; this.detailFontFamilyComboBox.DataSource = System.Windows.Media.Fonts.SystemFontFamilies.ToList(); this.detailFontStyleComboBox.DataSource = new System.Windows.FontStyle[] { System.Windows.FontStyles.Normal, System.Windows.FontStyles.Italic, System.Windows.FontStyles.Oblique }; this.areCombosBinding = false; this.UpdateUI(); } /// /// Handles the SelectedValueChanged event of the ComboBox control. /// /// The source of the event. /// The instance containing the event data. private void ComboBox_SelectedValueChanged(object sender, EventArgs e) { ComboBox combo = sender as ComboBox; if (this.areCombosBinding || combo == null) { return; } if (combo.Name.Contains(@"header")) { this.HeaderTextFontFamily = (System.Windows.Media.FontFamily)this.headerFontFamilyComboBox.SelectedItem; if (combo.Name.Contains(@"Style") && this.headerFontStyleComboBox.SelectedIndex != -1 && ((System.Windows.FontStyle)this.headerFontStyleComboBox.SelectedItem) != this.HeaderTextFontStyle) { this.HeaderTextFontStyle = (System.Windows.FontStyle)this.headerFontStyleComboBox.SelectedItem; } } else if (combo.Name.Contains(@"detail")) { this.DetailsTextFontFamily = (System.Windows.Media.FontFamily)this.detailFontFamilyComboBox.SelectedItem; if (combo.Name.Contains(@"Style") && this.detailFontStyleComboBox.SelectedIndex != -1 && ((System.Windows.FontStyle)this.detailFontStyleComboBox.SelectedItem) != this.DetailsTextFontStyle) { this.DetailsTextFontStyle = (System.Windows.FontStyle)this.detailFontStyleComboBox.SelectedItem; } } } /// /// Updates the UI. /// private void UpdateUI() { this.headerFontFamilyComboBox.SelectedItem = this.HeaderTextFontFamily; this.detailFontFamilyComboBox.SelectedItem = this.DetailsTextFontFamily; this.headerFontStyleComboBox.SelectedItem = this.HeaderTextFontStyle; this.detailFontStyleComboBox.SelectedItem = this.DetailsTextFontStyle; PropertyInfo[] info = typeof(System.Windows.Media.Colors).GetProperties(); this.backgroundColorComboBox.SelectedItem = info.FirstOrDefault(p => ((System.Windows.Media.Color)p.GetValue(null, null)) == this.DialogBackgroundColor); this.headerColorComboBox.SelectedItem = info.FirstOrDefault(p => ((System.Windows.Media.Color)p.GetValue(null, null)) == this.HeaderTextColor); this.detailColorComboBox.SelectedItem = info.FirstOrDefault(p => ((System.Windows.Media.Color)p.GetValue(null, null)) == this.DetailsTextColor); this.backgroundColorPanel.BackColor = ColorConverter.Convert(this.DialogBackgroundColor); this.headerColorPanel.BackColor = ColorConverter.Convert(this.HeaderTextColor); this.detailColorPanel.BackColor = ColorConverter.Convert(this.DetailsTextColor); this.headerSizeNumericUpDown.Value = (int)this.HeaderTextSize; this.detailSizeNumericUpDown.Value = (int)this.DetailsTextSize; } /// /// Called when [reset styles button click]. /// /// The sender. /// The instance containing the event data. private void OnResetStylesButtonClick(object sender, EventArgs e) { DetailsDialogStyle.ResetStyles(); this.UpdateUI(); } /// /// Handles the SelectedValueChanged event of the backgroundColorComboBox control. /// /// The source of the event. /// The instance containing the event data. private void OnBackgroundColorComboBoxSelectedValueChanged(object sender, EventArgs e) { if (this.areCombosBinding || this.backgroundColorComboBox.SelectedIndex == -1) { return; } PropertyInfo info = this.backgroundColorComboBox.SelectedItem as PropertyInfo; System.Windows.Media.Color selectedColor = info != null ? (System.Windows.Media.Color)info.GetValue(null, null) : new System.Windows.Media.Color(); this.backgroundColorPanel.BackColor = ColorConverter.Convert(selectedColor); this.DialogBackgroundColor = selectedColor; } /// /// Handles the SelectedValueChanged event of the headerColorComboBox control. /// /// The source of the event. /// The instance containing the event data. private void OnHeaderColorComboBoxSelectedValueChanged(object sender, EventArgs e) { if (this.areCombosBinding || this.headerColorComboBox.SelectedIndex == -1) { return; } PropertyInfo info = this.headerColorComboBox.SelectedItem as PropertyInfo; System.Windows.Media.Color selectedColor = info != null ? (System.Windows.Media.Color)info.GetValue(null, null) : new System.Windows.Media.Color(); this.headerColorPanel.BackColor = ColorConverter.Convert(selectedColor); this.HeaderTextColor = selectedColor; } /// /// Handles the SelectedValueChanged event of the detailColorComboBox control. /// /// The source of the event. /// The instance containing the event data. private void OnDetailColorComboBoxSelectedValueChanged(object sender, EventArgs e) { if (this.areCombosBinding || this.detailColorComboBox.SelectedIndex == -1) { return; } PropertyInfo info = this.detailColorComboBox.SelectedItem as PropertyInfo; System.Windows.Media.Color selectedColor = info != null ? (System.Windows.Media.Color)info.GetValue(null, null) : new System.Windows.Media.Color(); this.detailColorPanel.BackColor = ColorConverter.Convert(selectedColor); this.DetailsTextColor = selectedColor; } /// /// Handles the ValueChanged event of the headerSizeNumericUpDown control. /// /// The source of the event. /// The instance containing the event data. private void OnHeaderSizeNumericUpDownValueChanged(object sender, EventArgs e) { this.HeaderTextSize = (double)this.headerSizeNumericUpDown.Value; } /// /// Handles the ValueChanged event of the detailSizeNumericUpDown control. /// /// The source of the event. /// The instance containing the event data. private void OnDetailSizeNumericUpDownValueChanged(object sender, EventArgs e) { this.DetailsTextSize = (double)this.detailSizeNumericUpDown.Value; } } }