123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- namespace OINA.Extender.Testharness
- {
- using System;
- using System.Drawing;
- using System.Windows.Forms;
- using OINA.Extender.Controls.Styles;
- /// <summary>
- /// ImageViewerVisualSettings Form
- /// </summary>
- public partial class ImageViewerVisualSettings : Form
- {
- /// <summary>
- /// Gets or sets the color of ImageViewer background.
- /// </summary>
- public static Color BackgroundColor
- {
- get { return ColorConverter.Convert(ImageViewerStyle.BackgroundColor); }
- set { ImageViewerStyle.BackgroundColor = ColorConverter.Convert(value); }
- }
- /// <summary>
- /// Gets or sets the color of ImageViewer Heads and ScaleBar Foreground Color.
- /// </summary>
- public static Color ForegroundColor
- {
- get { return ColorConverter.Convert(ImageViewerStyle.ForegroundColor); }
- set { ImageViewerStyle.ForegroundColor = ColorConverter.Convert(value); }
- }
- /// <summary>
- /// Initializes a new instance of the <see cref="ImageViewerVisualSettings"/> class.
- /// </summary>
- 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;
- }
- /// <summary>
- /// InitialComboBox
- /// </summary>
- 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 };
- }
- /// <summary>
- /// Handles the SelectedValueChanged event of the CbBackgroundColor 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 OnBackgroundColorChanged(object sender, EventArgs e)
- {
- if (this.cbBackgroundColor.SelectedValue != null)
- {
- BackgroundColor = (Color)this.cbBackgroundColor.SelectedValue;
- this.backgroundPanel.BackColor = BackgroundColor;
- }
- }
- /// <summary>
- /// Handles the SelectedValueChanged event of the cbForegroundColor 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 OnForegroundColorChanged(object sender, EventArgs e)
- {
- if (this.cbForegroundColor.SelectedValue != null)
- {
- ForegroundColor = (Color)this.cbForegroundColor.SelectedValue;
- this.foregroundColorPanel.BackColor = ForegroundColor;
- }
- }
- /// <summary>
- /// Handles the SelectedValueChanged event of the CbHeaderFontSize 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 OnHeaderFontSizeChanged(object sender, EventArgs e)
- {
- if (this.cbHeaderFontSize.SelectedValue != null)
- {
- ImageViewerStyle.HeaderFontSize = (double)this.cbHeaderFontSize.SelectedValue;
- }
- }
- /// <summary>
- /// Handles the SelectedValueChanged event of the CbHeaderFontFamily 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 OnHeaderFontFamilyChanged(object sender, EventArgs e)
- {
- if (this.cbHeaderFontFamily.SelectedValue != null)
- {
- ImageViewerStyle.HeaderFontFamily = this.cbHeaderFontFamily.SelectedValue as System.Windows.Media.FontFamily;
- }
- }
- /// <summary>
- /// Handles the SelectedValueChanged event of the CbScaleBarFontSize 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 OnScaleBarFontSizeChanged(object sender, EventArgs e)
- {
- if (this.cbScaleBarFontSize.SelectedValue != null)
- {
- ImageViewerStyle.ScaleBarFontSize = (double)this.cbScaleBarFontSize.SelectedValue;
- }
- }
- /// <summary>
- /// Handles the click event of the BtResetStyle button.
- /// </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 OnResetStyle(object sender, EventArgs e)
- {
- ImageViewerStyle.ResetStyles();
- this.UpdateDisplay();
- }
- /// <summary>
- /// Updates the display on loading or resetting styleres
- /// </summary>
- 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;
- }
- }
- }
|