#region License Information /* HeuristicLab * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL) * * This file is part of HeuristicLab. * * HeuristicLab is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * HeuristicLab is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with HeuristicLab. If not, see . */ #endregion using System; using System.Drawing; using System.Windows.Forms; using HeuristicLab.MainForm; using HeuristicLab.MainForm.WindowsForms; namespace HeuristicLab.Analysis.Views { [View("DataRow Visual Properties")] public partial class DataRowVisualPropertiesControl : UserControl { protected bool SuppressEvents { get; set; } private DataRowVisualProperties content; public DataRowVisualProperties Content { get { return content; } set { bool changed = (value != content); content = value; if (changed) OnContentChanged(); } } public DataRowVisualPropertiesControl() { InitializeComponent(); chartTypeComboBox.DataSource = Enum.GetValues(typeof(DataRowVisualProperties.DataRowChartType)); } protected virtual void OnContentChanged() { SuppressEvents = true; try { if (Content == null) { chartTypeComboBox.SelectedIndex = -1; colorButton.BackColor = SystemColors.Control; secondYAxisCheckBox.Checked = false; startIndexZeroCheckBox.Checked = false; binsNumericUpDown.Value = 1; exactBinsCheckBox.Checked = false; } else { chartTypeComboBox.SelectedItem = Content.ChartType; colorButton.BackColor = Content.Color; secondYAxisCheckBox.Checked = Content.SecondYAxis; startIndexZeroCheckBox.Checked = Content.StartIndexZero; binsNumericUpDown.Value = Content.Bins; exactBinsCheckBox.Checked = Content.ExactBins; } } finally { SuppressEvents = false; } SetEnabledStateOfControls(); } protected virtual void SetEnabledStateOfControls() { commonGroupBox.Enabled = Content != null; histoGramGroupBox.Enabled = Content != null && Content.ChartType == DataRowVisualProperties.DataRowChartType.Histogram; } #region Event Handlers private void chartTypeComboBox_SelectedValueChanged(object sender, EventArgs e) { if (!SuppressEvents && Content != null) { Content.ChartType = (DataRowVisualProperties.DataRowChartType)chartTypeComboBox.SelectedValue; SetEnabledStateOfControls(); } } private void colorButton_Click(object sender, EventArgs e) { if (colorDialog.ShowDialog() == DialogResult.OK) { Content.Color = colorDialog.Color; colorButton.BackColor = Content.Color; } } private void secondYAxisCheckBox_CheckedChanged(object sender, EventArgs e) { if (!SuppressEvents && Content != null) { Content.SecondYAxis = secondYAxisCheckBox.Checked; } } private void startIndexZeroCheckBox_CheckedChanged(object sender, EventArgs e) { if (!SuppressEvents && Content != null) { Content.StartIndexZero = startIndexZeroCheckBox.Checked; } } private void binsNumericUpDown_ValueChanged(object sender, EventArgs e) { if (!SuppressEvents && Content != null) { Content.Bins = (int)binsNumericUpDown.Value; } } private void exactBinsCheckBox_CheckedChanged(object sender, EventArgs e) { if (!SuppressEvents && Content != null) { Content.ExactBins = exactBinsCheckBox.Checked; } } #endregion } }