Changeset 11098
- Timestamp:
- 07/06/14 20:15:28 (10 years ago)
- Location:
- branches/DataPreprocessing
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.cs
r11070 r11098 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing;25 24 using System.Linq; 26 25 using System.Windows.Forms; … … 35 34 public partial class DataGridContentView : StringConvertibleMatrixView { 36 35 37 private bool notOwnEvent = true;38 36 private bool isSearching = false; 39 37 private bool updateOnMouseUp = false; … … 49 47 } 50 48 51 private IList<int> _highlightedRowIndices;52 public IList<int> HighlightedRowIndices {53 get { return _highlightedRowIndices; }54 set {55 _highlightedRowIndices = value;56 Refresh();57 }58 }59 60 49 private IDictionary<int, IList<int>> _highlightedCellsBackground; 61 50 public IDictionary<int, IList<int>> HightlightedCellsBackground { … … 70 59 InitializeComponent(); 71 60 dataGridView.CellMouseClick += dataGridView_CellMouseClick; 72 dataGridView.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(dataGridView_CellPainting);73 61 dataGridView.KeyDown += dataGridView_KeyDown; 74 62 dataGridView.MouseUp += dataGridView_MouseUp; 75 63 dataGridView.ColumnHeaderMouseClick += dataGridView_ColumnHeaderMouseClick; 76 64 contextMenuCell.Items.Add(ShowHideColumns); 77 _highlightedRowIndices = new List<int>();78 65 _highlightedCellsBackground = new Dictionary<int, IList<int>>(); 79 66 currentCell = null; … … 123 110 124 111 private void Content_Changed(object sender, DataPreprocessingChangedEventArgs e) { 125 if (notOwnEvent) { 126 OnContentChanged(); 127 } 112 OnContentChanged(); 128 113 searchIterator = null; 129 114 } … … 131 116 protected override void dataGridView_SelectionChanged(object sender, EventArgs e) { 132 117 base.dataGridView_SelectionChanged(sender, e); 133 if (Content != null )118 if (Content != null && dataGridView.RowCount != 0 && dataGridView.ColumnCount != 0) 134 119 Content.Selection = GetSelectedCells(); 135 120 } 136 121 122 //couldn't use base.dataGridView_CellValidating as the values have to be validated per column individually 137 123 protected override void dataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e) { 138 if ( !dataGridView.ReadOnly) {139 string errorMessage;140 if (Content != null) {141 if (dataGridView.IsCurrentCellInEditMode && Content.FilterLogic.IsFiltered) { 142 errorMessage = "A filter is active, you cannot modify data. Press ESC to exit edit mode.";143 } else{144 Content.Validate(e.FormattedValue.ToString(), out errorMessage, e.ColumnIndex);145 }146 147 if (!String.IsNullOrEmpty(errorMessage)) {148 e.Cancel = true;149 dataGridView.Rows[e.RowIndex].ErrorText = errorMessage; 150 }151 }152 }153 }154 155 protected override void dataGridView_CellParsing(object sender, DataGridViewCellParsingEventArgs e) {156 triggersOwnEvent(() => base.dataGridView_CellParsing(sender, e));157 } 158 159 protected override void PasteValuesToDataGridView() {160 triggersOwnEvent(() => base.PasteValuesToDataGridView());161 dataGridView.Refresh();162 }124 if (dataGridView.ReadOnly) return; 125 if (Content == null) return; 126 if (Content.Rows == 0 || Content.Columns == 0) return; 127 128 string errorMessage; 129 if (Content != null) { 130 if (dataGridView.IsCurrentCellInEditMode && Content.FilterLogic.IsFiltered) { 131 errorMessage = "A filter is active, you cannot modify data. Press ESC to exit edit mode."; 132 } else { 133 Content.Validate(e.FormattedValue.ToString(), out errorMessage, e.ColumnIndex); 134 } 135 136 if (!String.IsNullOrEmpty(errorMessage)) { 137 e.Cancel = true; 138 dataGridView.Rows[e.RowIndex].ErrorText = errorMessage; 139 } 140 141 } 142 } 143 144 145 //protected override void PasteValuesToDataGridView() { 146 // base.PasteValuesToDataGridView(); 147 // dataGridView.Refresh(); 148 //} 163 149 164 150 protected override void SetEnabledStateOfControls() { … … 191 177 192 178 private void btnApplySort_Click(object sender, System.EventArgs e) { 193 triggersOwnEvent(() => { 194 Content.ManipulationLogic.ReOrderToIndices(virtualRowIndices); 195 OnContentChanged(); 196 }); 197 } 198 199 private void triggersOwnEvent(Action action) { 200 notOwnEvent = false; 201 action(); 202 notOwnEvent = true; 179 Content.ManipulationLogic.ReOrderToIndices(virtualRowIndices); 180 OnContentChanged(); 203 181 } 204 182 … … 494 472 } 495 473 496 protected void dataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) {497 if (Content == null) return;498 if (e.RowIndex < 0) return;499 if (e.ColumnIndex < 0) return;500 if (e.State.HasFlag(DataGridViewElementStates.Selected)) return;501 if (!e.PaintParts.HasFlag(DataGridViewPaintParts.Background)) return;502 if (HighlightedRowIndices == null) return;503 504 int rowIndex = virtualRowIndices[e.RowIndex];505 506 Color backColor = e.CellStyle.BackColor;507 508 if (HightlightedCellsBackground.ContainsKey(e.ColumnIndex) && HightlightedCellsBackground[e.ColumnIndex].Contains(e.RowIndex)) {509 backColor = Color.LightGray;510 }511 512 using (Brush backColorBrush = new SolidBrush(backColor)) {513 Rectangle bounds = new Rectangle(e.CellBounds.X, e.CellBounds.Y, e.CellBounds.Width, e.CellBounds.Height);514 e.Graphics.FillRectangle(backColorBrush, bounds);515 }516 517 using (Brush gridBrush = new SolidBrush(Color.LightGray)) {518 Pen gridLinePen = new Pen(gridBrush);519 e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left,520 e.CellBounds.Bottom - 1, e.CellBounds.Right - 1,521 e.CellBounds.Bottom - 1);522 e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1,523 e.CellBounds.Top, e.CellBounds.Right - 1,524 e.CellBounds.Bottom);525 }526 e.PaintContent(e.CellBounds);527 e.Handled = true;528 }529 530 474 private void dataGridView_KeyDown(object sender, KeyEventArgs e) { 531 475 var selectedRows = dataGridView.SelectedRows; … … 535 479 rows.Add(selectedRows[i].Index); 536 480 } 537 triggersOwnEvent(() => { 538 Content.DeleteRow(rows); 539 OnContentChanged(); 540 }); 481 Content.DeleteRow(rows); 541 482 } else if (e.Control && e.KeyCode == Keys.F) { 542 483 CreateFindAndReplaceDialog(); -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/HistogramView.cs
r10992 r11098 40 40 base.OnContentChanged(); 41 41 if (Content != null) { 42 43 42 classifierComboBox.Items.Clear(); 44 43 classifierComboBox.Items.Add("None"); … … 47 46 classifierComboBox.Items.Add(var); 48 47 } 49 50 48 51 49 if (classifierComboBox.SelectedItem == null && Content.ClassifierVariableIndex < classifierComboBox.Items.Count) { -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/PreprocessingChartView.cs
r11039 r11098 263 263 264 264 protected void GenerateChart() { 265 266 265 ClearTableLayout(); 267 266 if (Content.AllInOneMode) { -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/TransactionalPreprocessingData.cs
r11068 r11098 212 212 213 213 public override void DeleteRowsWithIndices(IEnumerable<int> rows) { 214 foreach (int rowIndex in rows) { 215 DeleteRow(rowIndex); 216 } 214 SaveSnapshot(DataPreprocessingChangedEventType.AddRow, -1, -1); 215 foreach (int rowIndex in rows.OrderByDescending(x => x)) { 216 foreach (IList column in variableValues) { 217 column.RemoveAt(rowIndex); 218 } 219 } 220 if (!IsInTransaction) 221 OnChanged(DataPreprocessingChangedEventType.DeleteRow, -1, -1); 217 222 } 218 223 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/ProblemDataCreator.cs
r11068 r11098 42 42 43 43 public IDataAnalysisProblemData CreateProblemData() { 44 if (context.Data.Rows == 0 || context.Data.Columns == 0) return null; 45 44 46 var oldProblemData = context.ProblemData; 45 46 47 IDataAnalysisProblemData problemData; 47 48 -
branches/DataPreprocessing/HeuristicLab.MainForm.WindowsForms/3.3/HeuristicLab.MainForm.WindowsForms-3.3.csproj
r9915 r11098 159 159 <None Include="Plugin.cs.frame" /> 160 160 <Compile Include="Controls\ControlExtensions.cs" /> 161 <Compile Include="MainForms\DockForm.cs"> 162 <SubType>Form</SubType> 163 </Compile> 161 <Compile Include="MainForms\DockForm.cs" /> 164 162 <Compile Include="MainForms\DockForm.Designer.cs"> 165 163 <DependentUpon>DockForm.cs</DependentUpon> -
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Symbolic.Regression.Views/3.4/SymbolicRegressionSolutionView.cs
r11070 r11098 22 22 using System; 23 23 using System.ComponentModel; 24 using System.Linq; 24 25 using System.Windows.Forms; 25 26 using HeuristicLab.MainForm; … … 44 45 btnSimplify.Enabled = Content != null && !Locked; 45 46 exportButton.Enabled = Content != null && !Locked; 46 transformModelButton.Visible = false;47 transformModelButton.Visible = Content != null && Content.ProblemData.Transformations.Any(); 47 48 transformModelButton.Enabled = Content != null && !Locked; 48 49 } -
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views/3.4/FeatureCorrelation/AbstractFeatureCorrelationView.cs
r9456 r11098 57 57 partitionComboBox.DataSource = Partitions; 58 58 partitionComboBox.SelectedItem = TRAININGSAMPLES; 59 progressPanel.Visible = false; 59 60 } 60 61 … … 78 79 CalculateCorrelation(); 79 80 } else { 81 progressPanel.Visible = false; 80 82 dataView.Maximum = 0; 81 83 dataView.Minimum = 0;
Note: See TracChangeset
for help on using the changeset viewer.