namespace OINA.Extender.Testharness { using System; using System.Drawing; using System.Windows; using System.Windows.Forms; using OINA.Extender.Controls; using OINA.Extender.Controls.Styles; /// /// SpectrumViewer Visual Settings form /// public partial class SpectrumViewerVisualSettings : Form { /// /// Gets or sets the color of the included element. /// private static Color SpectrumBackgroundColor { get { return ColorConverter.Convert(SpectrumViewerStyle.SpectrumBackgroundColor); } set { SpectrumViewerStyle.SpectrumBackgroundColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of the spectrum text. /// private static Color SpectrumTextColor { get { return ColorConverter.Convert(SpectrumViewerStyle.SpectrumLabelTextColor); } set { SpectrumViewerStyle.SpectrumLabelTextColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of Axis Foreground Color. /// private static Color AxisTextColor { get { return ColorConverter.Convert(SpectrumViewerStyle.AxisTextColor); } set { SpectrumViewerStyle.AxisTextColor = ColorConverter.Convert(value); } } /// /// Gets or sets a value indicating whether axis lines are shown. /// private static bool IsAxisLinesShown { get { return SpectrumViewerStyle.IsAxisLineVisible; } set { SpectrumViewerStyle.IsAxisLineVisible = value; } } /// /// Gets or sets the color of Axis Tick Brush Color. /// private static Color AxisColor { get { return ColorConverter.Convert(SpectrumViewerStyle.AxisColor); } set { SpectrumViewerStyle.AxisColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of Spectrum Visual Fill Color. /// private static Color SpectrumVisualFillColor { get { return ColorConverter.Convert(SpectrumViewerStyle.SpectrumVisualFillColor); } set { SpectrumViewerStyle.SpectrumVisualFillColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of Spectrum Label Chrome Border Brush Color. /// private static Color PeakLabelBorderColor { get { return ColorConverter.Convert(SpectrumViewerStyle.SpectrumPeakLabelBorderColor); } set { SpectrumViewerStyle.SpectrumPeakLabelBorderColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of Spectrum Label Chrome Background Color. /// private static Color PeakLabelBackgroundColor { get { return ColorConverter.Convert(SpectrumViewerStyle.SpectrumPeakLabelBackgroundColor); } set { SpectrumViewerStyle.SpectrumPeakLabelBackgroundColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of Spectrum Label View Foreground Color. /// private static Color PeakLabelTextColor { get { return ColorConverter.Convert(SpectrumViewerStyle.SpectrumPeakLabelTextColor); } set { SpectrumViewerStyle.SpectrumPeakLabelTextColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of Main Spectrum Label BackgroundColor. /// private static Color AlternatePeakLabelBackgroundColor { get { return ColorConverter.Convert(SpectrumViewerStyle.AlternatePeakLabelBackground); } set { SpectrumViewerStyle.AlternatePeakLabelBackground = ColorConverter.Convert(value); } } /// /// Gets or sets the color of Main Spectrum Label ForegroundColor. /// private static Color AlternatePeakLabelTextColor { get { return ColorConverter.Convert(SpectrumViewerStyle.AlternatePeakLabelTextColor); } set { SpectrumViewerStyle.AlternatePeakLabelTextColor = ColorConverter.Convert(value); } } /// /// Gets or sets the color of the quant results background. /// private static Color QuantResultsBackgroundColor { get { return ColorConverter.Convert(SpectrumViewerStyle.QuantResultsBackgroundColor); } set { SpectrumViewerStyle.QuantResultsBackgroundColor = ColorConverter.Convert(value); } } /// /// Gets or sets a value indicating whether the quant results is shown. /// private static bool ShowQuantResults { get { return SpectrumViewerStyle.ShowQuantResults; } set { SpectrumViewerStyle.ShowQuantResults = value; } } /// /// Initializes a new instance of the class. /// public SpectrumViewerVisualSettings() { this.InitializeComponent(); this.InitializeComboBoxes(); this.UpdateCombos(); this.UpdatePanels(); // *** Wire up events here manually or they all get fired when the combos are set with their initial values this.cbSpectrumBackgroundColor.SelectedValueChanged += this.CbSpectrumBackgroundColor_SelectedValueChanged; this.cbSpectrumTextColor.SelectedValueChanged += this.CbSpectrumForegroundColor_SelectedValueChanged; this.cbSpectrumVisualFillColor.SelectedValueChanged += this.CbSpectrumVisualFillColor_SelectedValueChanged; this.cbPeakLabelBorderColor.SelectedValueChanged += this.CbSpectrumLabelChromeBoderBrushColor_SelectedValueChanged; this.cbPeakLabelBackgroundColor.SelectedValueChanged += this.CbSpectrumLabelChromeBackgroundColor_SelectedValueChanged; this.cbPeakLabelTextColor.SelectedValueChanged += this.CbSpectrumLabelViewForegroundColor_SelectedValueChanged; this.cbAlternatePeakLabelBackgroundColor.SelectedValueChanged += this.CbAlternatePeakLabelBackgroundColor_SelectedValueChanged; this.cbAlternatePeakLabelTextColor.SelectedValueChanged += this.CbAlternatePeakLabelTextColor_SelectedValueChanged; this.cbAxisMinorTickLength.SelectedValueChanged += this.CbAxisMinorTickLength_SelectedValueChanged; this.cbAxisMajorThickLength.SelectedValueChanged += this.CbAxisMajorThickLength_SelectedValueChanged; this.cbAxisFontSize.SelectedValueChanged += this.CbAxisFontSize_SelectedValueChanged; this.cbAxisLabelMargin.SelectedValueChanged += this.CbAxisLabelMargin_SelectedValueChanged; this.cbAxisLineThickness.SelectedValueChanged += this.CbAxisLineThickness_SelectedValueChanged; this.cbAxisSubMinorTickLength.SelectedValueChanged += this.CbAxisSubMinorTickLength_SelectedValueChanged; this.cbAxisColor.SelectedValueChanged += this.CbAxisTickBrushColor_SelectedValueChanged; this.cbShowAxisLines.CheckedChanged += this.CbShowAxisLines_CheckedChanged; this.cbAxisTextColor.SelectedValueChanged += this.CbAxisForegroundColor_SelectedValueChanged; this.cbQuantResultsBackgroundColor.SelectedValueChanged += this.CbQuantResultsBackgroundColor_SelectedValueChanged; this.cbQuantResultsBackgroundOpacity.SelectedValueChanged += this.CbQuantResultsBackgroundOpacity_SelectedValueChanged; this.cbQuantResultsFormat.SelectedValueChanged += this.CbQuantResultsFormat_SelectedValueChanged; this.cbQuantResultsCategory.SelectedValueChanged += this.CbQuantResultsCategory_SelectedValueChanged; this.cbShowQuantResults.CheckedChanged += this.CbShowQuantResults_CheckedChanged; } /// /// Update combo boxs /// public void InitializeComboBoxes() { this.cbSpectrumBackgroundColor.DataSource = ColorConverter.GetSystemDrawingColors(); this.cbSpectrumTextColor.DataSource = ColorConverter.GetSystemDrawingColors(); this.cbSpectrumVisualFillColor.DataSource = ColorConverter.GetSystemDrawingColors(); this.cbPeakLabelBorderColor.DataSource = ColorConverter.GetSystemDrawingColors(); this.cbPeakLabelBackgroundColor.DataSource = ColorConverter.GetSystemDrawingColors(); this.cbPeakLabelTextColor.DataSource = ColorConverter.GetSystemDrawingColors(); this.cbAlternatePeakLabelBackgroundColor.DataSource = ColorConverter.GetSystemDrawingColors(); this.cbAlternatePeakLabelTextColor.DataSource = ColorConverter.GetSystemDrawingColors(); this.cbAxisTextColor.DataSource = ColorConverter.GetSystemDrawingColors(); this.cbAxisColor.DataSource = ColorConverter.GetSystemDrawingColors(); this.cbAxisFontSize.DataSource = new[] { 8d, 10d, 12d, 14d, 16d }; this.cbAxisLabelMargin.DataSource = new[] { new Thickness(1, 0, 1, 0), new Thickness(2, 0, 2, 0), new Thickness(3, 0, 3, 0) }; this.cbAxisMajorThickLength.DataSource = new[] { 4d, 6d, 8d }; this.cbAxisLineThickness.DataSource = new[] { 0.5d, 1d, 2d }; this.cbAxisSubMinorTickLength.DataSource = new[] { 1d, 3d, 5d }; this.cbAxisMinorTickLength.DataSource = new[] { 3d, 4.5d, 6d }; this.cbShowAxisLines.Checked = IsAxisLinesShown; this.cbQuantResultsBackgroundColor.DataSource = ColorConverter.GetSystemDrawingColors(); this.cbQuantResultsBackgroundOpacity.DataSource = new[] { 0.25, 0.5, 0.75, 1.0 }; this.cbQuantResultsFormat.DataSource = new[] { QuantResultFormat.Table, QuantResultFormat.Histogram }; this.cbQuantResultsCategory.DataSource = new[] { QuantResultCategory.WeightPercent, QuantResultCategory.AtomicPercent, QuantResultCategory.OxidePercent }; this.cbShowQuantResults.Checked = ShowQuantResults; } /// /// Updates the colour panels /// private void UpdatePanels() { this.spectrumBackgroundColorPanel.BackColor = SpectrumBackgroundColor; this.spectrumTextColorPanel.BackColor = SpectrumTextColor; this.axisForegroundColorPanel.BackColor = AxisTextColor; this.axisTickBrushColorPanel.BackColor = AxisColor; this.spectrumVisualFillColorPanel.BackColor = SpectrumVisualFillColor; this.spectrumLabelChromeBorderBrushColorPanel.BackColor = PeakLabelBorderColor; this.spectrumLabelChromeBackgroundColorPanel.BackColor = PeakLabelBackgroundColor; this.spectrumLabelViewForegroundColorPanel.BackColor = PeakLabelTextColor; this.alternatePeakLabelBackgroundColorPanel.BackColor = AlternatePeakLabelBackgroundColor; this.alternatePeakLabelTextColorPanel.BackColor = AlternatePeakLabelTextColor; this.quantResultsBackgroundColorPanel.BackColor = QuantResultsBackgroundColor; } /// /// Updates the combos to the set values /// private void UpdateCombos() { ColorConverter.PickColourComboItem(this.cbSpectrumBackgroundColor, SpectrumBackgroundColor); ColorConverter.PickColourComboItem(this.cbSpectrumTextColor, SpectrumTextColor); ColorConverter.PickColourComboItem(this.cbSpectrumVisualFillColor, SpectrumVisualFillColor); ColorConverter.PickColourComboItem(this.cbPeakLabelBorderColor, PeakLabelBorderColor); ColorConverter.PickColourComboItem(this.cbPeakLabelBackgroundColor, PeakLabelBackgroundColor); ColorConverter.PickColourComboItem(this.cbPeakLabelTextColor, PeakLabelTextColor); ColorConverter.PickColourComboItem(this.cbAlternatePeakLabelBackgroundColor, AlternatePeakLabelBackgroundColor); ColorConverter.PickColourComboItem(this.cbAlternatePeakLabelTextColor, AlternatePeakLabelTextColor); ColorConverter.PickColourComboItem(this.cbAxisTextColor, AxisTextColor); ColorConverter.PickColourComboItem(this.cbAxisColor, AxisColor); ColorConverter.PickColourComboItem(this.cbQuantResultsBackgroundColor, QuantResultsBackgroundColor); this.cbAxisMajorThickLength.SelectedItem = SpectrumViewerStyle.AxisMajorTickLength; this.cbAxisMinorTickLength.SelectedItem = SpectrumViewerStyle.AxisMinorTickLength; this.cbAxisSubMinorTickLength.SelectedItem = SpectrumViewerStyle.AxisSubMinorTickLength; this.cbAxisFontSize.SelectedItem = SpectrumViewerStyle.AxisFontSize; this.cbAxisLabelMargin.SelectedItem = SpectrumViewerStyle.AxisLabelMargin; this.cbAxisLineThickness.SelectedItem = SpectrumViewerStyle.AxisLineThickness; this.cbShowAxisLines.Checked = SpectrumViewerStyle.IsAxisLineVisible; this.cbQuantResultsBackgroundOpacity.SelectedItem = SpectrumViewerStyle.QuantResultsBackgroundOpacity; this.cbQuantResultsFormat.SelectedItem = SpectrumViewerStyle.QuantResultsFormat; this.cbQuantResultsCategory.SelectedItem = SpectrumViewerStyle.QuantResultsCategory; this.cbShowQuantResults.Checked = SpectrumViewerStyle.ShowQuantResults; } /// /// Handles the SelectedValueChanged event of the CbSpectrumBackgroundColor control. /// /// The source of the event. /// The instance containing the event data. private void CbSpectrumBackgroundColor_SelectedValueChanged(object sender, EventArgs e) { if (this.cbSpectrumBackgroundColor.SelectedValue != null) { SpectrumBackgroundColor = (Color)this.cbSpectrumBackgroundColor.SelectedValue; this.UpdatePanels(); } } /// /// Handles the SelectedValueChanged event of the CbSpectrumForegroundColor control. /// /// The source of the event. /// The instance containing the event data. private void CbSpectrumForegroundColor_SelectedValueChanged(object sender, EventArgs e) { if (this.cbSpectrumTextColor.SelectedValue != null) { SpectrumTextColor = (Color)this.cbSpectrumTextColor.SelectedValue; this.UpdatePanels(); } } /// /// Handles the SelectedValueChanged event of the CbAxisForegroundColor control. /// /// The source of the event. /// The instance containing the event data. private void CbAxisForegroundColor_SelectedValueChanged(object sender, EventArgs e) { if (this.cbAxisTextColor.SelectedValue != null) { AxisTextColor = (Color)this.cbAxisTextColor.SelectedValue; this.UpdatePanels(); } } /// /// Handles the SelectedValueChanged event of the CbAxisTickBrushColor control. /// /// The source of the event. /// The instance containing the event data. private void CbAxisTickBrushColor_SelectedValueChanged(object sender, EventArgs e) { if (this.cbAxisColor.SelectedValue != null) { AxisColor = (Color)this.cbAxisColor.SelectedValue; this.UpdatePanels(); } } /// /// Handles the SelectedValueChanged event of the CbSpectrumVisualFillColor control. /// /// The source of the event. /// The instance containing the event data. private void CbSpectrumVisualFillColor_SelectedValueChanged(object sender, EventArgs e) { if (this.cbSpectrumVisualFillColor.SelectedValue != null) { SpectrumVisualFillColor = (Color)this.cbSpectrumVisualFillColor.SelectedValue; this.UpdatePanels(); } } /// /// Handles the SelectedValueChanged event of the CbSpectrumLabelChromeBoderBrushColor control. /// /// The source of the event. /// The instance containing the event data. private void CbSpectrumLabelChromeBoderBrushColor_SelectedValueChanged(object sender, EventArgs e) { if (this.cbPeakLabelBorderColor.SelectedValue != null) { PeakLabelBorderColor = (Color)this.cbPeakLabelBorderColor.SelectedValue; this.UpdatePanels(); } } /// /// Handles the SelectedValueChanged event of the CbSpectrumLabelChromeBackgroundColor control. /// /// The source of the event. /// The instance containing the event data. private void CbSpectrumLabelChromeBackgroundColor_SelectedValueChanged(object sender, EventArgs e) { if (this.cbPeakLabelBackgroundColor.SelectedValue != null) { PeakLabelBackgroundColor = (Color)this.cbPeakLabelBackgroundColor.SelectedValue; this.UpdatePanels(); } } /// /// Handles the SelectedValueChanged event of the CbSpectrumLabelViewForegroundColor control. /// /// The source of the event. /// The instance containing the event data. private void CbSpectrumLabelViewForegroundColor_SelectedValueChanged(object sender, EventArgs e) { if (this.cbPeakLabelTextColor.SelectedValue != null) { PeakLabelTextColor = (Color)this.cbPeakLabelTextColor.SelectedValue; this.UpdatePanels(); } } /// /// Handles the SelectedValueChanged event of the CbAlternatePeakLabelBackgroundColor control. /// /// The source of the event. /// The instance containing the event data. private void CbAlternatePeakLabelBackgroundColor_SelectedValueChanged(object sender, EventArgs e) { if (this.cbAlternatePeakLabelBackgroundColor.SelectedValue != null) { AlternatePeakLabelBackgroundColor = (Color)this.cbAlternatePeakLabelBackgroundColor.SelectedValue; this.UpdatePanels(); } } /// /// Handles the SelectedValueChanged event of the CbAlternatePeakLabelTextColor control. /// /// The source of the event. /// The instance containing the event data. private void CbAlternatePeakLabelTextColor_SelectedValueChanged(object sender, EventArgs e) { if (this.cbAlternatePeakLabelTextColor.SelectedValue != null) { AlternatePeakLabelTextColor = (Color)this.cbAlternatePeakLabelTextColor.SelectedValue; this.UpdatePanels(); } } /// /// Handles the SelectedValueChanged event of the CbComparisonSpectrum14Color control. /// /// The source of the event. /// The instance containing the event data. private void CbAxisFontSize_SelectedValueChanged(object sender, EventArgs e) { if (this.cbAxisFontSize.SelectedValue != null) { SpectrumViewerStyle.AxisFontSize = (double)this.cbAxisFontSize.SelectedValue; } } /// /// Handles the btResetStyle button event. /// /// The source of the event. /// The instance containing the event data. private void BtResetStyle_Click(object sender, EventArgs e) { SpectrumViewerStyle.ResetStyles(); this.UpdatePanels(); this.UpdateCombos(); } /// /// Handles the SelectedValueChanged event of the CbComparisonSpectrum14Color control. /// /// The source of the event. /// The instance containing the event data. private void CbAxisLabelMargin_SelectedValueChanged(object sender, EventArgs e) { if (this.cbAxisLabelMargin.SelectedValue != null) { SpectrumViewerStyle.AxisLabelMargin = (Thickness)this.cbAxisLabelMargin.SelectedValue; } } /// /// Handles the SelectedValueChanged event of the CbComparisonSpectrum14Color control. /// /// The source of the event. /// The instance containing the event data. private void CbAxisMajorThickLength_SelectedValueChanged(object sender, EventArgs e) { if (this.cbAxisMajorThickLength.SelectedValue != null) { SpectrumViewerStyle.AxisMajorTickLength = (double)this.cbAxisMajorThickLength.SelectedValue; } } /// /// Handles the SelectedValueChanged event of the CbComparisonSpectrum14Color control. /// /// The source of the event. /// The instance containing the event data. private void CbAxisMinorTickLength_SelectedValueChanged(object sender, EventArgs e) { if (this.cbAxisMinorTickLength.SelectedValue != null) { SpectrumViewerStyle.AxisMinorTickLength = (double)this.cbAxisMinorTickLength.SelectedValue; } } /// /// Handles the SelectedValueChanged event of the CbComparisonSpectrum14Color control. /// /// The source of the event. /// The instance containing the event data. private void CbAxisSubMinorTickLength_SelectedValueChanged(object sender, EventArgs e) { if (this.cbAxisSubMinorTickLength.SelectedValue != null) { SpectrumViewerStyle.AxisSubMinorTickLength = (double)this.cbAxisSubMinorTickLength.SelectedValue; } } /// /// Handles the SelectedValueChanged event of the CbComparisonSpectrum14Color control. /// /// The source of the event. /// The instance containing the event data. private void CbAxisLineThickness_SelectedValueChanged(object sender, EventArgs e) { if (this.cbAxisLineThickness.SelectedValue != null) { SpectrumViewerStyle.AxisLineThickness = (double)this.cbAxisLineThickness.SelectedValue; } } /// /// Handles the CheckedChanged event of the cbShowAxisLines control. /// /// The source of the event. /// The instance containing the event data. private void CbShowAxisLines_CheckedChanged(object sender, EventArgs e) { IsAxisLinesShown = this.cbShowAxisLines.Checked; } /// /// Handles the SelectedValueChanged event of the CbQuantResultsBackgroundColor control. /// /// The source of the event. /// The instance containing the event data. private void CbQuantResultsBackgroundColor_SelectedValueChanged(object sender, EventArgs e) { if (this.cbQuantResultsBackgroundColor.SelectedValue != null) { QuantResultsBackgroundColor = (Color)this.cbQuantResultsBackgroundColor.SelectedValue; this.UpdatePanels(); } } /// /// Handles the SelectedValueChanged event of the CbQuantResultsBackgroundOpacity control. /// /// The source of the event. /// The instance containing the event data. private void CbQuantResultsBackgroundOpacity_SelectedValueChanged(object sender, EventArgs e) { if (this.cbQuantResultsBackgroundOpacity.SelectedValue != null) { SpectrumViewerStyle.QuantResultsBackgroundOpacity = (double)this.cbQuantResultsBackgroundOpacity.SelectedValue; } } /// /// Handles the SelectedValueChanged event of the CbQuantResultsFormat control. /// /// The source of the event. /// The instance containing the event data. private void CbQuantResultsFormat_SelectedValueChanged(object sender, EventArgs e) { if (this.cbQuantResultsFormat.SelectedValue != null) { SpectrumViewerStyle.QuantResultsFormat = (QuantResultFormat)this.cbQuantResultsFormat.SelectedValue; } } /// /// Handles the SelectedValueChanged event of the CbQuantResultsCategory control. /// /// The source of the event. /// The instance containing the event data. private void CbQuantResultsCategory_SelectedValueChanged(object sender, EventArgs e) { if (this.cbQuantResultsCategory.SelectedValue != null) { SpectrumViewerStyle.QuantResultsCategory = (QuantResultCategory)this.cbQuantResultsCategory.SelectedValue; } } /// /// Handles the CheckedChanged event of the CbShowQuantResults control. /// /// The source of the event. /// The instance containing the event data. private void CbShowQuantResults_CheckedChanged(object sender, EventArgs e) { ShowQuantResults = this.cbShowQuantResults.Checked; } } }