Changeset 13514
- Timestamp:
- 01/15/16 15:21:04 (9 years ago)
- Location:
- trunk/sources
- Files:
-
- 1 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.cs
r13252 r13514 31 31 namespace HeuristicLab.DataPreprocessing.Views { 32 32 [View("Data Grid Content View")] 33 [Content(typeof( IDataGridContent), true)]33 [Content(typeof(DataGridContent), true)] 34 34 public partial class DataGridContentView : StringConvertibleMatrixView { 35 35 … … 42 42 private Tuple<int, int> currentCell; 43 43 44 public new IDataGridContent Content {45 get { return ( IDataGridContent)base.Content; }44 public new DataGridContent Content { 45 get { return (DataGridContent)base.Content; } 46 46 set { base.Content = value; } 47 47 } … … 145 145 protected override void PasteValuesToDataGridView() { 146 146 string[,] values = SplitClipboardString(Clipboard.GetText()); 147 if (values.Length == 0) return; 147 148 int rowIndex = 0; 148 149 int columnIndex = 0; … … 151 152 columnIndex = dataGridView.CurrentCell.ColumnIndex; 152 153 } 153 if (Content.Rows < values.GetLength(1) + rowIndex) Content.Rows = values.GetLength(1) + rowIndex; 154 if (Content.Columns < values.GetLength(0) + columnIndex) Content.Columns = values.GetLength(0) + columnIndex; 154 155 bool containsHeader = false; 156 var firstRow = Enumerable.Range(0, values.GetLength(0)).Select(col => values[col, 0]).ToList(); 157 if ((Content.Selection.Values.Sum(s => s.Count) == Content.Rows * Content.Columns) 158 || (rowIndex == 0 && columnIndex == 0 && Content.Rows <= values.GetLength(1) && Content.Columns <= values.GetLength(0))) { 159 // All is selected -or- top left selected and everything will be replaced 160 double temp; 161 containsHeader = !firstRow.All(string.IsNullOrEmpty) && firstRow.Any(r => !double.TryParse(r, out temp)); 162 if (containsHeader) 163 rowIndex = columnIndex = 0; 164 } 165 166 int newRows = values.GetLength(1) + rowIndex - (containsHeader ? 1 : 0); 167 int newColumns = values.GetLength(0) + columnIndex; 168 if (Content.Rows < newRows) Content.Rows = newRows; 169 if (Content.Columns < newColumns) Content.Columns = newColumns; 155 170 156 171 ReplaceTransaction(() => { 157 172 Content.PreProcessingData.InTransaction(() => { 158 for (int row = 0; row < values.GetLength(1); row++) {173 for (int row = containsHeader ? 1 : 0; row < values.GetLength(1); row++) { 159 174 for (int col = 0; col < values.GetLength(0); col++) { 160 Content.SetValue(values[col, row], row + rowIndex , col + columnIndex);175 Content.SetValue(values[col, row], row + rowIndex - (containsHeader ? 1 : 0), col + columnIndex); 161 176 } 177 } 178 if (containsHeader) { 179 for (int i = 0; i < firstRow.Count; i++) 180 if (string.IsNullOrWhiteSpace(firstRow[i])) 181 firstRow[i] = string.Format("<{0}>", i); 182 Content.PreProcessingData.RenameColumns(firstRow); 162 183 } 163 184 }); -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/DataGridContent.cs
r13508 r13514 26 26 using HeuristicLab.Common; 27 27 using HeuristicLab.Core; 28 using HeuristicLab.Data; 28 29 29 30 namespace HeuristicLab.DataPreprocessing { 30 31 31 32 [Item("DataGrid", "Represents a data grid.")] 32 public class DataGridContent : Item, I ViewShortcut, IDataGridContent {33 public class DataGridContent : Item, IStringConvertibleMatrix, IViewShortcut { 33 34 34 35 public ITransactionalPreprocessingData PreProcessingData { get; private set; } -
trunk/sources/HeuristicLab.DataPreprocessing/3.4/HeuristicLab.DataPreprocessing-3.4.csproj
r13508 r13514 108 108 <Compile Include="Logic\SearchLogic.cs" /> 109 109 <Compile Include="Logic\StatisticsLogic.cs" /> 110 <Compile Include="Content\IDataGridContent.cs" />111 110 <Compile Include="Data\ITransactionalPreprocessingData.cs" /> 112 111 <Compile Include="Plugin.cs" />
Note: See TracChangeset
for help on using the changeset viewer.