Changeset 10583
- Timestamp:
- 03/12/14 16:28:26 (11 years ago)
- Location:
- branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3
- Files:
-
- 3 edited
- 2 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/CopyOfStringConvertibleMatrixView.Designer.cs
r10571 r10583 20 20 #endregion 21 21 22 namespace HeuristicLab.Data .Views {23 partial class StringConvertibleMatrixView {22 namespace HeuristicLab.DataPreprocessing.Views { 23 partial class CopyOfStringConvertibleMatrixView { 24 24 /// <summary> 25 25 /// Required designer variable. -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/CopyOfStringConvertibleMatrixView.cs
r10571 r10583 28 28 using System.Windows.Forms; 29 29 using HeuristicLab.Common; 30 using HeuristicLab.Data; 31 using HeuristicLab.Data.Views; 30 32 using HeuristicLab.MainForm; 31 33 using HeuristicLab.MainForm.WindowsForms; 32 34 33 namespace HeuristicLab.Data .Views {35 namespace HeuristicLab.DataPreprocessing.Views { 34 36 [View("StringConvertibleMatrix View")] 35 [Content(typeof(IStringConvertibleMatrix), true)] 36 public partial class StringConvertibleMatrixView : AsynchronousContentView { 37 [Content(typeof(IStringConvertibleMatrix), false)] 38 public partial class CopyOfStringConvertibleMatrixView : AsynchronousContentView { 39 40 // Was private before 41 protected virtual void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { 42 if (!dataGridView.ReadOnly) { 43 string errorMessage; 44 if (Content != null && !Content.Validate(e.FormattedValue.ToString(), out errorMessage)) { 45 e.Cancel = true; 46 dataGridView.Rows[e.RowIndex].ErrorText = errorMessage; 47 } 48 } 49 } 50 51 // Was private before 52 protected virtual void dataGridView_CellParsing(object sender, DataGridViewCellParsingEventArgs e) { 53 if (!dataGridView.ReadOnly) { 54 string value = e.Value.ToString(); 55 int rowIndex = virtualRowIndices[e.RowIndex]; 56 e.ParsingApplied = Content.SetValue(value, rowIndex, e.ColumnIndex); 57 if (e.ParsingApplied) e.Value = Content.GetValue(rowIndex, e.ColumnIndex); 58 } 59 } 60 61 // Was private before 62 protected virtual void PasteValuesToDataGridView() { 63 string[,] values = SplitClipboardString(Clipboard.GetText()); 64 int rowIndex = 0; 65 int columnIndex = 0; 66 if (dataGridView.CurrentCell != null) { 67 rowIndex = dataGridView.CurrentCell.RowIndex; 68 columnIndex = dataGridView.CurrentCell.ColumnIndex; 69 } 70 if (Content.Rows < values.GetLength(1) + rowIndex) Content.Rows = values.GetLength(1) + rowIndex; 71 if (Content.Columns < values.GetLength(0) + columnIndex) Content.Columns = values.GetLength(0) + columnIndex; 72 73 for (int row = 0; row < values.GetLength(1); row++) { 74 for (int col = 0; col < values.GetLength(0); col++) { 75 Content.SetValue(values[col, row], row + rowIndex, col + columnIndex); 76 } 77 } 78 ClearSorting(); 79 } 80 81 #region unchanged copied from original - see HeuristicLab.Data.Views.StringConvertibleMatrix 82 37 83 protected int[] virtualRowIndices; 38 84 private List<KeyValuePair<int, SortOrder>> sortedColumnIndices; … … 74 120 } 75 121 76 public StringConvertibleMatrixView() {122 public CopyOfStringConvertibleMatrixView() { 77 123 InitializeComponent(); 78 124 ShowRowsAndColumnsTextBox = true; … … 261 307 262 308 #region DataGridView Events 263 private void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { 264 if (!dataGridView.ReadOnly) { 265 string errorMessage; 266 if (Content != null && !Content.Validate(e.FormattedValue.ToString(), out errorMessage)) { 267 e.Cancel = true; 268 dataGridView.Rows[e.RowIndex].ErrorText = errorMessage; 269 } 270 } 271 } 272 private void dataGridView_CellParsing(object sender, DataGridViewCellParsingEventArgs e) { 273 if (!dataGridView.ReadOnly) { 274 string value = e.Value.ToString(); 275 int rowIndex = virtualRowIndices[e.RowIndex]; 276 e.ParsingApplied = Content.SetValue(value, rowIndex, e.ColumnIndex); 277 if (e.ParsingApplied) e.Value = Content.GetValue(rowIndex, e.ColumnIndex); 278 } 279 } 309 280 310 private void dataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e) { 281 311 dataGridView.Rows[e.RowIndex].ErrorText = string.Empty; … … 364 394 } 365 395 366 private void PasteValuesToDataGridView() {367 string[,] values = SplitClipboardString(Clipboard.GetText());368 int rowIndex = 0;369 int columnIndex = 0;370 if (dataGridView.CurrentCell != null) {371 rowIndex = dataGridView.CurrentCell.RowIndex;372 columnIndex = dataGridView.CurrentCell.ColumnIndex;373 }374 if (Content.Rows < values.GetLength(1) + rowIndex) Content.Rows = values.GetLength(1) + rowIndex;375 if (Content.Columns < values.GetLength(0) + columnIndex) Content.Columns = values.GetLength(0) + columnIndex;376 377 for (int row = 0; row < values.GetLength(1); row++) {378 for (int col = 0; col < values.GetLength(0); col++) {379 Content.SetValue(values[col, row], row + rowIndex, col + columnIndex);380 }381 }382 ClearSorting();383 }384 396 private string[,] SplitClipboardString(string clipboardText) { 385 397 if (clipboardText.EndsWith(Environment.NewLine)) … … 566 578 } 567 579 } 580 #endregion 568 581 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataGridContentView.cs
r10574 r10583 24 24 using System.Linq; 25 25 using System.Windows.Forms; 26 using HeuristicLab.Data.Views;27 26 using HeuristicLab.MainForm; 28 27 using System.Drawing; … … 31 30 [View("Data Grid Content View")] 32 31 [Content(typeof(IDataGridContent), true)] 33 public partial class DataGridContentView : StringConvertibleMatrixView {32 public partial class DataGridContentView : CopyOfStringConvertibleMatrixView { 34 33 35 34 private int lastClickedRow; 36 35 private int lastClickedColumn; 36 37 private bool notOwnEvent = true; 37 38 38 39 public new IDataGridContent Content { … … 75 76 76 77 void Content_Changed(object sender, DataPreprocessingChangedEventArgs e) { 77 dataGridView.Refresh(); 78 if (notOwnEvent) { 79 dataGridView.Refresh(); 80 } 78 81 } 79 82 80 pr ivate void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) {83 protected override void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { 81 84 if (!dataGridView.ReadOnly) { 82 85 string errorMessage; … … 87 90 } 88 91 } 92 93 protected override void dataGridView_CellParsing(object sender, DataGridViewCellParsingEventArgs e) { 94 notOwnEvent = false; 95 base.dataGridView_CellParsing(sender, e); 96 notOwnEvent = true; 97 } 98 99 protected override void PasteValuesToDataGridView() { 100 notOwnEvent = false; 101 base.PasteValuesToDataGridView(); 102 notOwnEvent = true; 103 } 104 89 105 90 106 protected override void SetEnabledStateOfControls() { … … 163 179 private void ReplaceWithAverage_Click(object sender, EventArgs e) { 164 180 Content.PreprocessingDataManipulation.ReplaceIndicesByAverageValue(lastClickedColumn, new List<int>() { lastClickedRow }); 165 OnContentChanged();166 181 } 167 182 168 183 private void ReplaceWithMedian_Click(object sender, EventArgs e) { 169 184 Content.PreprocessingDataManipulation.ReplaceIndicesByMedianValue(lastClickedColumn, new List<int>() { lastClickedRow }); 170 OnContentChanged();171 185 } 172 186 173 187 private void ReplaceWithRandom_Click(object sender, EventArgs e) { 174 188 Content.PreprocessingDataManipulation.ReplaceIndicesByRandomValue(lastClickedColumn, new List<int>() { lastClickedRow }); 175 OnContentChanged();176 189 } 177 190 178 191 private void ReplaceWithMostCommon_Click(object sender, EventArgs e) { 179 192 Content.PreprocessingDataManipulation.ReplaceIndicesByMostCommonValue(lastClickedColumn, new List<int>() { lastClickedRow }); 180 OnContentChanged();181 193 } 182 194 183 195 private void ReplaceWithInterpolation_Click(object sender, EventArgs e) { 184 196 Content.PreprocessingDataManipulation.ReplaceIndicesByLinearInterpolationOfNeighbours(lastClickedColumn, new List<int>() { lastClickedRow }); 185 OnContentChanged();186 197 } 187 198 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/HeuristicLab.DataPreprocessing.Views-3.3.csproj
r10559 r10583 96 96 <DependentUpon>StatisticsView.cs</DependentUpon> 97 97 </Compile> 98 <Compile Include="CopyOfStringConvertibleMatrixView.cs"> 99 <SubType>UserControl</SubType> 100 </Compile> 101 <Compile Include="CopyOfStringConvertibleMatrixView.Designer.cs"> 102 <DependentUpon>CopyOfStringConvertibleMatrixView.cs</DependentUpon> 103 </Compile> 98 104 <Compile Include="TransformationView.cs"> 99 105 <SubType>UserControl</SubType> -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/Plugin.cs.frame
r10542 r10583 30 30 [PluginDependency("HeuristicLab.DataPreprocessing", "3.3")] 31 31 [PluginDependency("HeuristicLab.Data.Views","3.3")] 32 [PluginDependency("HeuristicLab.Data","3.3")] 32 33 [PluginDependency("HeuristicLab.MainForm", "3.3")] 33 34 [PluginDependency("HeuristicLab.MainForm.WindowsForms", "3.3")]
Note: See TracChangeset
for help on using the changeset viewer.