[6656] | 1 | using System;
|
---|
| 2 | using System.Collections.Generic;
|
---|
| 3 | using System.ComponentModel;
|
---|
| 4 | using System.Drawing;
|
---|
| 5 | using System.Data;
|
---|
| 6 | using System.Linq;
|
---|
| 7 | using System.Text;
|
---|
| 8 | using System.Windows.Forms;
|
---|
| 9 | using System.Windows.Forms.DataVisualization.Charting;
|
---|
| 10 | using HeuristicLab.Common;
|
---|
| 11 |
|
---|
| 12 | namespace HeuristicLab.Problems.DataAnalysis.Symbolic.Views {
|
---|
| 13 | public partial class VariableTrackbar : UserControl {
|
---|
| 14 | private readonly string variableName;
|
---|
| 15 | private const double FACTOR = 1000;
|
---|
| 16 |
|
---|
| 17 | public double Value {
|
---|
| 18 | get { return trackBar.Value / FACTOR; }
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | public string VariableName {
|
---|
| 22 | get { return variableName; }
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | public VariableTrackbar(string variableName, IEnumerable<double> values) {
|
---|
| 26 | InitializeComponent();
|
---|
| 27 | this.variableName = variableName;
|
---|
| 28 | groupBox.Text = variableName;
|
---|
| 29 | var valuesArr = values.ToArray();
|
---|
| 30 | this.valueTextBox.Text = string.Format("{0:0.000e+00}", valuesArr.Median());
|
---|
| 31 | boxPlotChart.Series["DataSeries"].Points.Clear();
|
---|
| 32 | boxPlotChart.Series["DataSeries"].Points.DataBindY(valuesArr);
|
---|
| 33 | boxPlotChart.Series["BoxPlot"].ChartType = SeriesChartType.BoxPlot;
|
---|
| 34 | boxPlotChart.Series["BoxPlot"]["BoxPlotSeries"] = "DataSeries";
|
---|
| 35 | boxPlotChart.Series["BoxPlot"]["BoxPlotWhiskerPercentile"] = "5";
|
---|
| 36 | boxPlotChart.Series["BoxPlot"]["BoxPlotPercentile"] = "30";
|
---|
| 37 | boxPlotChart.Series["BoxPlot"]["BoxPlotShowAverage"] = "true";
|
---|
| 38 | boxPlotChart.Series["BoxPlot"]["BoxPlotShowMedian"] = "true";
|
---|
| 39 | boxPlotChart.Series["BoxPlot"]["BoxPlotShowUnusualValues"] = "true";
|
---|
| 40 | boxPlotChart.ChartAreas[0].AxisY.Minimum = valuesArr.Min() ;
|
---|
| 41 | boxPlotChart.ChartAreas[0].AxisY.Maximum = valuesArr.Max() ;
|
---|
| 42 |
|
---|
| 43 |
|
---|
| 44 | trackBar.Minimum = (int)Math.Round(valuesArr.Min() * FACTOR);
|
---|
| 45 | trackBar.Maximum = (int)Math.Round(valuesArr.Max() * FACTOR);
|
---|
| 46 | trackBar.Value = (int)Math.Round(valuesArr.Median() * FACTOR);
|
---|
| 47 | trackBar.TickStyle = TickStyle.None;
|
---|
| 48 | trackBar.Tag = variableName;
|
---|
| 49 | }
|
---|
| 50 |
|
---|
| 51 | private void TrackBarValueChanged(object sender, EventArgs e) {
|
---|
| 52 | valueTextBox.Text = string.Format("{0:0.000e+00}", trackBar.Value / FACTOR);
|
---|
| 53 | RaiseValueChanged(EventArgs.Empty);
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | public event EventHandler ValueChanged;
|
---|
| 57 | private void RaiseValueChanged(EventArgs e) {
|
---|
| 58 | var handler = ValueChanged;
|
---|
| 59 | if (handler != null) handler(this, e);
|
---|
| 60 | }
|
---|
| 61 | }
|
---|
| 62 | }
|
---|