Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10574


Ignore:
Timestamp:
03/12/14 14:24:39 (10 years ago)
Author:
mleitner
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataGridContentView.cs

    r10571 r10574  
    2626using HeuristicLab.Data.Views;
    2727using HeuristicLab.MainForm;
     28using System.Drawing;
    2829
    2930namespace HeuristicLab.DataPreprocessing.Views {
     
    4041    }
    4142
     43    private IList<int> _highlightedRowIndices;
     44    public IList<int> highlightedRowIndices
     45    {
     46        get { return _highlightedRowIndices; }
     47        set
     48        {
     49            _highlightedRowIndices = value;
     50            Refresh();
     51        }
     52    }
     53
    4254    public DataGridContentView() {
    4355      InitializeComponent();
    4456      dataGridView.CellMouseClick += dataGridView_CellMouseClick;
     57      dataGridView.CellPainting      += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(dataGridView_CellPainting);
    4558      contextMenuCell.Items.Add(ShowHideColumns);
    4659    }
     
    100113    }
    101114
     115    protected void dataGridView_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
     116    {
     117        if (Content == null) return;
     118        if (e.RowIndex < 0) return;
     119        if (e.ColumnIndex < 0) return;
     120        if (e.State.HasFlag(DataGridViewElementStates.Selected)) return;
     121        if (!e.PaintParts.HasFlag(DataGridViewPaintParts.Background)) return;
     122
     123        int rowIndex = virtualRowIndices[e.RowIndex];
     124
     125        Color backColor = e.CellStyle.BackColor;
     126
     127        if (highlightedRowIndices != null && highlightedRowIndices.Contains(rowIndex))
     128        {
     129            backColor = Color.Pink;
     130        }
     131
     132        using (Brush backColorBrush = new SolidBrush(backColor))
     133        {
     134            Rectangle bounds = new Rectangle(e.CellBounds.X, e.CellBounds.Y, e.CellBounds.Width, e.CellBounds.Height);
     135            e.Graphics.FillRectangle(backColorBrush, bounds);
     136        }
     137
     138        using (Brush gridBrush = new SolidBrush(Color.LightGray))
     139        {
     140            Pen gridLinePen = new Pen(gridBrush);
     141            e.Graphics.DrawLine(gridLinePen, e.CellBounds.Left,
     142                   e.CellBounds.Bottom - 1, e.CellBounds.Right - 1,
     143                   e.CellBounds.Bottom - 1);
     144            e.Graphics.DrawLine(gridLinePen, e.CellBounds.Right - 1,
     145                e.CellBounds.Top, e.CellBounds.Right - 1,
     146                e.CellBounds.Bottom);
     147        }
     148       
     149        e.PaintContent(e.CellBounds);
     150        e.Handled = true;
     151    }
     152
    102153    protected override int[] Sort(IEnumerable<KeyValuePair<int, SortOrder>> sortedColumns) {
    103154      btnApplySort.Enabled = sortedColumns.Any();
Note: See TracChangeset for help on using the changeset viewer.