Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Views/StatisticsView.cs @ 10371

Last change on this file since 10371 was 10371, checked in by rstoll, 10 years ago

Forgot to add GetColumnTypeAsString

File size: 3.6 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Windows.Forms;
4using HeuristicLab.Core.Views;
5using HeuristicLab.MainForm;
6using HeuristicLab.MainForm.WindowsForms;
7
8namespace HeuristicLab.DataPreprocessing {
9
10  [View("Statistics View")]
11  [Content(typeof(StatisticsContent), false)]
12  public partial class StatisticsView : ItemView {
13
14    private List<List<string>> columnsRowsMatrix;
15    private readonly int COLUMNS = 5;
16
17    public new StatisticsContent Content {
18      get { return (StatisticsContent)base.Content; }
19      set { base.Content = value; }
20    }
21
22    public StatisticsView() {
23      InitializeComponent();
24    }
25
26    protected override void OnContentChanged() {
27      base.OnContentChanged();
28      if (Content == null) {
29        txtRows.Text = "";
30        txtColumns.Text = "";
31        txtNumericColumns.Text = "";
32        txtNominalColumns.Text = "";
33        txtMissingValuesTotal.Text = "";
34        dataGridView.Columns.Clear();
35      } else {
36        UpdateData();
37      }
38    }
39    private void UpdateData() {
40      var logic = Content.StatisticsLogic;
41      txtRows.Text = logic.GetRowCount().ToString();
42      txtColumns.Text = logic.GetColumnCount().ToString();
43      txtNumericColumns.Text = logic.GetNumericColumnCount().ToString();
44      txtNominalColumns.Text = logic.GetNominalColumnCount().ToString();
45      txtMissingValuesTotal.Text = logic.GetMissingValueCount().ToString();
46
47      DataGridViewColumn[] columns = new DataGridViewColumn[COLUMNS];
48
49      columnsRowsMatrix = new List<List<string>>();
50
51
52      for (int i = 0; i < logic.GetColumnCount(); ++i) {
53        var column = new DataGridViewTextBoxColumn();
54        column.FillWeight = 1;
55        columns[i] = column;
56
57        List<string> list;
58        if (logic.IsType<double>(i)) {
59          list = GetDoubleColumns(i);
60        } else if (logic.IsType<string>(i)) {
61          list = GetStringColumns(i);
62        } else if (logic.IsType<DateTime>(i)) {
63          list = GetDateTimeColumns(i);
64        } else {
65          list = new List<string>();
66          for (int j = 0; j < COLUMNS; ++j) {
67            list.Add("");
68          }
69        }
70        columnsRowsMatrix.Add(list);
71      }
72
73      dataGridView.Columns.Clear();
74      dataGridView.Columns.AddRange(columns);
75      dataGridView.RowCount = columnsRowsMatrix[0].Count;
76
77    }
78
79    private List<string> GetDoubleColumns(int columnIndex) {
80      var logic = Content.StatisticsLogic;
81      return new List<string> {
82        logic.GetColumnTypeAsString(columnIndex),
83        logic.GetMissingValueCount(columnIndex).ToString(),
84        logic.GetMin<double>(columnIndex).ToString(),
85        logic.GetMax<double>(columnIndex).ToString(),
86        logic.GetMedian(columnIndex).ToString(),
87        logic.GetAverage(columnIndex).ToString(),
88        logic.GetStandardDeviation(columnIndex).ToString(),
89        logic.GetVariance(columnIndex).ToString(),
90        logic.GetMostCommonValue<double>(columnIndex).ToString(),
91        logic.GetDifferentValuesCount<double>(columnIndex).ToString()
92      };
93    }
94
95    private List<string> GetStringColumns(int columnIndex) {
96      return null;
97    }
98    private List<string> GetDateTimeColumns(int columndIndex) {
99      return null;
100    }
101
102    private List<string> GetDoubleColums(int i) {
103      throw new NotImplementedException();
104    }
105
106    private void dataGridView_CellValueNeeded(object sender, DataGridViewCellValueEventArgs e) {
107      if (Content != null && e.RowIndex < columnsRowsMatrix.Count && e.ColumnIndex < Content.StatisticsLogic.GetColumnCount()) {
108
109      }
110    }
111  }
112}
Note: See TracBrowser for help on using the repository browser.