source: trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/DataGridContent.cs @ 15110

Last change on this file since 15110 was 15110, checked in by pfleck, 2 years ago

#2709: merged branch to trunk

File size: 4.5 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Drawing;
25using System.Linq;
26using HeuristicLab.Common;
27using HeuristicLab.Core;
28using HeuristicLab.Data;
29
30namespace HeuristicLab.DataPreprocessing {
31
32  [Item("Data Grid", "Represents a data grid.")]
33  public class DataGridContent : Item, IStringConvertibleMatrix, IViewShortcut {
34    public static new Image StaticItemImage {
35      get { return HeuristicLab.Common.Resources.VSImageLibrary.Table; }
36    }
37
38    public ITransactionalPreprocessingData PreProcessingData { get; private set; }
39
40    public ManipulationLogic ManipulationLogic { get; private set; }
41    public FilterLogic FilterLogic { get; private set; }
42
43    public int Rows {
44      get { return PreProcessingData.Rows; }
45      set { }
46    }
47
48    public int Columns {
49      get { return PreProcessingData.Columns; }
50      set { }
51    }
52
53    public IEnumerable<string> ColumnNames {
54      get { return PreProcessingData.VariableNames; }
55      set { }
56    }
57
58    public IEnumerable<string> RowNames {
59      get { return Enumerable.Range(1, Rows).Select(n => n.ToString()); }
60      set { throw new NotSupportedException(); }
61    }
62
63    public bool SortableView {
64      get { return true; }
65      set { throw new NotSupportedException(); }
66    }
67
68    public bool ReadOnly {
69      get { return false; }
70    }
71
72    public IDictionary<int, IList<int>> Selection {
73      get { return PreProcessingData.Selection; }
74      set { PreProcessingData.Selection = value; }
75    }
76
77    public DataGridContent(ITransactionalPreprocessingData preProcessingData, ManipulationLogic theManipulationLogic, FilterLogic theFilterLogic) {
78      ManipulationLogic = theManipulationLogic;
79      FilterLogic = theFilterLogic;
80      PreProcessingData = preProcessingData;
81    }
82
83    public DataGridContent(DataGridContent dataGridContent, Cloner cloner)
84      : base(dataGridContent, cloner) {
85
86    }
87    public override IDeepCloneable Clone(Cloner cloner) {
88      return new DataGridContent(this, cloner);
89    }
90
91    public void DeleteRows(IEnumerable<int> rows) {
92      PreProcessingData.DeleteRowsWithIndices(rows);
93    }
94
95    public void DeleteColumn(int column) {
96      PreProcessingData.DeleteColumn(column);
97    }
98
99    public bool Validate(string value, out string errorMessage, int columnIndex) {
100      return PreProcessingData.Validate(value, out errorMessage, columnIndex);
101    }
102
103    public string GetValue(int rowIndex, int columnIndex) {
104      return PreProcessingData.GetCellAsString(columnIndex, rowIndex);
105    }
106
107    public bool SetValue(string value, int rowIndex, int columnIndex) {
108      return PreProcessingData.SetValue(value, columnIndex, rowIndex);
109    }
110
111    public event DataPreprocessingChangedEventHandler Changed {
112      add { PreProcessingData.Changed += value; }
113      remove { PreProcessingData.Changed -= value; }
114    }
115
116    #region unused stuff/not implemented but necessary due to IStringConvertibleMatrix
117#pragma warning disable 0067
118    // Is not used since DataGridContentView overrides dataGridView_CellValidating and uses
119    // DataGridLogic#Validate(string value, out string errorMessage, int columnIndex)
120    public bool Validate(string value, out string errorMessage) {
121      errorMessage = string.Empty;
122      return true;
123    }
124
125    public event EventHandler ColumnsChanged;
126    public event EventHandler RowsChanged;
127    public event EventHandler ColumnNamesChanged;
128    public event EventHandler RowNamesChanged;
129    public event EventHandler SortableViewChanged;
130    public event EventHandler<EventArgs<int, int>> ItemChanged;
131    public event EventHandler Reset;
132#pragma warning restore 0067
133    #endregion
134  }
135}
Note: See TracBrowser for help on using the repository browser.