Changeset 10585
- Timestamp:
- 03/12/14 16:45:58 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataGridContentView.cs
r10583 r10585 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing; 24 25 using System.Linq; 25 26 using System.Windows.Forms; 26 27 using HeuristicLab.MainForm; 27 using System.Drawing;28 28 29 29 namespace HeuristicLab.DataPreprocessing.Views { … … 43 43 44 44 private IList<int> _highlightedRowIndices; 45 public IList<int> highlightedRowIndices 46 { 47 get { return _highlightedRowIndices; } 48 set 49 { 50 _highlightedRowIndices = value; 51 Refresh(); 52 } 45 public IList<int> highlightedRowIndices { 46 get { return _highlightedRowIndices; } 47 set { 48 _highlightedRowIndices = value; 49 Refresh(); 50 } 53 51 } 54 52 … … 56 54 InitializeComponent(); 57 55 dataGridView.CellMouseClick += dataGridView_CellMouseClick; 58 dataGridView.CellPainting 56 dataGridView.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(dataGridView_CellPainting); 59 57 contextMenuCell.Items.Add(ShowHideColumns); 60 58 } … … 92 90 93 91 protected override void dataGridView_CellParsing(object sender, DataGridViewCellParsingEventArgs e) { 94 notOwnEvent = false; 95 base.dataGridView_CellParsing(sender, e); 96 notOwnEvent = true; 92 triggersOwnEvent(() => base.dataGridView_CellParsing(sender, e)); 97 93 } 98 94 99 95 protected override void PasteValuesToDataGridView() { 100 notOwnEvent = false; 101 base.PasteValuesToDataGridView(); 102 notOwnEvent = true; 96 triggersOwnEvent(() => base.PasteValuesToDataGridView()); 103 97 } 104 105 98 106 99 protected override void SetEnabledStateOfControls() { … … 111 104 112 105 private void btnApplySort_Click(object sender, System.EventArgs e) { 113 Content.PreprocessingDataManipulation.ReOrderToIndices(virtualRowIndices); 114 OnContentChanged(); 106 triggersOwnEvent(() => { 107 Content.PreprocessingDataManipulation.ReOrderToIndices(virtualRowIndices); 108 OnContentChanged(); 109 }); 115 110 } 111 112 private void triggersOwnEvent(Action action) { 113 notOwnEvent = false; 114 action(); 115 notOwnEvent = true; 116 } 117 116 118 117 119 private void dataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { … … 129 131 } 130 132 131 protected void dataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) 132 { 133 if (Content == null) return; 134 if (e.RowIndex < 0) return; 135 if (e.ColumnIndex < 0) return; 136 if (e.State.HasFlag(DataGridViewElementStates.Selected)) return; 137 if (!e.PaintParts.HasFlag(DataGridViewPaintParts.Background)) return; 133 protected void dataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e) { 134 if (Content == null) return; 135 if (e.RowIndex < 0) return; 136 if (e.ColumnIndex < 0) return; 137 if (e.State.HasFlag(DataGridViewElementStates.Selected)) return; 138 if (!e.PaintParts.HasFlag(DataGridViewPaintParts.Background)) return; 138 139 139 140 int rowIndex = virtualRowIndices[e.RowIndex]; 140 141 141 142 Color backColor = e.CellStyle.BackColor; 142 143 143 if (highlightedRowIndices != null && highlightedRowIndices.Contains(rowIndex)) 144 { 145 backColor = Color.Pink; 146 } 144 if (highlightedRowIndices != null && highlightedRowIndices.Contains(rowIndex)) { 145 backColor = Color.Pink; 146 } 147 147 148 using (Brush backColorBrush = new SolidBrush(backColor)) 149 { 150 Rectangle bounds = new Rectangle(e.CellBounds.X, e.CellBounds.Y, e.CellBounds.Width, e.CellBounds.Height); 151 e.Graphics.FillRectangle(backColorBrush, bounds); 152 } 148 using (Brush backColorBrush = new SolidBrush(backColor)) { 149 Rectangle bounds = new Rectangle(e.CellBounds.X, e.CellBounds.Y, e.CellBounds.Width, e.CellBounds.Height); 150 e.Graphics.FillRectangle(backColorBrush, bounds); 151 } 153 152 154 using (Brush gridBrush = new SolidBrush(Color.LightGray)) 155 { 156 Pen gridLinePen = new Pen(gridBrush); 157 e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left, 158 e.CellBounds.Bottom - 1, e.CellBounds.Right - 1, 159 e.CellBounds.Bottom - 1); 160 e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1, 161 e.CellBounds.Top, e.CellBounds.Right - 1, 162 e.CellBounds.Bottom); 163 } 164 165 e.PaintContent(e.CellBounds); 166 e.Handled = true; 153 using (Brush gridBrush = new SolidBrush(Color.LightGray)) { 154 Pen gridLinePen = new Pen(gridBrush); 155 e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left, 156 e.CellBounds.Bottom - 1, e.CellBounds.Right - 1, 157 e.CellBounds.Bottom - 1); 158 e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1, 159 e.CellBounds.Top, e.CellBounds.Right - 1, 160 e.CellBounds.Bottom); 161 } 162 163 e.PaintContent(e.CellBounds); 164 e.Handled = true; 167 165 } 168 166
Note: See TracChangeset
for help on using the changeset viewer.