namespace OINA.Extender.Testharness { using System; using System.Drawing; using System.Windows.Forms; using OINA.Extender.Controls.Styles; /// /// ImageViewerVisualSettings Form /// public partial class ImageViewerVisualSettings : Form { /// /// Gets or sets the color of ImageViewer background. /// public static Color BackgroundColor { get { return ColorConverter.Convert(ImageViewerStyle.BackgroundColor); } set { ImageViewerStyle.BackgroundColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of ImageViewer Heads and ScaleBar Foreground Color. /// public static Color ForegroundColor { get { return ColorConverter.Convert(ImageViewerStyle.ForegroundColor); } set { ImageViewerStyle.ForegroundColor = ColorConverter.Convert(value); } } /// /// Initializes a new instance of the class. /// public ImageViewerVisualSettings() { this.InitializeComponent(); this.InitializeComboBoxes(); this.UpdateDisplay(); this.cbBackgroundColor.SelectedValueChanged += this.OnBackgroundColorChanged; this.cbForegroundColor.SelectedValueChanged += this.OnForegroundColorChanged; this.cbHeaderFontSize.SelectedValueChanged += this.OnHeaderFontSizeChanged; this.cbHeaderFontFamily.SelectedValueChanged += this.OnHeaderFontFamilyChanged; this.cbScaleBarFontSize.SelectedValueChanged += this.OnScaleBarFontSizeChanged; } /// /// InitialComboBox /// private void InitializeComboBoxes() { this.cbBackgroundColor.DataSource = ColorConverter.GetSystemDrawingColors(); this.cbForegroundColor.DataSource = ColorConverter.GetSystemDrawingColors(); this.cbHeaderFontFamily.DataSource = System.Windows.Media.Fonts.SystemFontFamilies; this.cbHeaderFontSize.DataSource = new[] { 12d, 14d, 16d, 18d }; this.cbScaleBarFontSize.DataSource = new[] { 8d, 10d, 12d, 14d }; } /// /// Handles the SelectedValueChanged event of the CbBackgroundColor control. /// /// The source of the event. /// The instance containing the event data. private void OnBackgroundColorChanged(object sender, EventArgs e) { if (this.cbBackgroundColor.SelectedValue != null) { BackgroundColor = (Color)this.cbBackgroundColor.SelectedValue; this.backgroundPanel.BackColor = BackgroundColor; } } /// /// Handles the SelectedValueChanged event of the cbForegroundColor control. /// /// The source of the event. /// The instance containing the event data. private void OnForegroundColorChanged(object sender, EventArgs e) { if (this.cbForegroundColor.SelectedValue != null) { ForegroundColor = (Color)this.cbForegroundColor.SelectedValue; this.foregroundColorPanel.BackColor = ForegroundColor; } } /// /// Handles the SelectedValueChanged event of the CbHeaderFontSize control. /// /// The source of the event. /// The instance containing the event data. private void OnHeaderFontSizeChanged(object sender, EventArgs e) { if (this.cbHeaderFontSize.SelectedValue != null) { ImageViewerStyle.HeaderFontSize = (double)this.cbHeaderFontSize.SelectedValue; } } /// /// Handles the SelectedValueChanged event of the CbHeaderFontFamily control. /// /// The source of the event. /// The instance containing the event data. private void OnHeaderFontFamilyChanged(object sender, EventArgs e) { if (this.cbHeaderFontFamily.SelectedValue != null) { ImageViewerStyle.HeaderFontFamily = this.cbHeaderFontFamily.SelectedValue as System.Windows.Media.FontFamily; } } /// /// Handles the SelectedValueChanged event of the CbScaleBarFontSize control. /// /// The source of the event. /// The instance containing the event data. private void OnScaleBarFontSizeChanged(object sender, EventArgs e) { if (this.cbScaleBarFontSize.SelectedValue != null) { ImageViewerStyle.ScaleBarFontSize = (double)this.cbScaleBarFontSize.SelectedValue; } } /// /// Handles the click event of the BtResetStyle button. /// /// The source of the event. /// The instance containing the event data. private void OnResetStyle(object sender, EventArgs e) { ImageViewerStyle.ResetStyles(); this.UpdateDisplay(); } /// /// Updates the display on loading or resetting styleres /// private void UpdateDisplay() { this.backgroundPanel.BackColor = BackgroundColor; this.foregroundColorPanel.BackColor = ForegroundColor; ColorConverter.PickColourComboItem(this.cbBackgroundColor, BackgroundColor); ColorConverter.PickColourComboItem(this.cbForegroundColor, ForegroundColor); this.cbHeaderFontFamily.SelectedIndex = -1; this.cbHeaderFontFamily.SelectedItem = ImageViewerStyle.HeaderFontFamily; this.cbHeaderFontSize.SelectedItem = ImageViewerStyle.HeaderFontSize; this.cbScaleBarFontSize.SelectedItem = ImageViewerStyle.ScaleBarFontSize; } } }