1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
23 // Pedro MartÃnez Juliá <pedromj@gmail.com>
26 using System.ComponentModel;
29 namespace System.Windows.Forms {
31 public class DataGridViewRowPostPaintEventArgs : EventArgs {
33 private DataGridView dataGridView;
34 private Graphics graphics;
35 private Rectangle clipBounds;
36 private Rectangle rowBounds;
38 private DataGridViewElementStates rowState;
39 private string errorText;
40 private DataGridViewCellStyle inheritedRowStyle;
41 private bool isFirstDisplayedRow;
42 private bool isLastVisibleRow;
44 public DataGridViewRowPostPaintEventArgs (DataGridView dataGridView, Graphics graphics, Rectangle clipBounds, Rectangle rowBounds, int rowIndex, DataGridViewElementStates rowState, string errorText, DataGridViewCellStyle inheritedRowStyle, bool isFirstDisplayedRow, bool isLastVisibleRow) {
45 this.dataGridView = dataGridView;
46 this.graphics = graphics;
47 this.clipBounds = clipBounds;
48 this.rowBounds = rowBounds;
49 this.rowIndex = rowIndex;
50 this.rowState = rowState;
51 this.errorText = errorText;
52 this.inheritedRowStyle = inheritedRowStyle;
53 this.isFirstDisplayedRow = isFirstDisplayedRow;
54 this.isLastVisibleRow = isLastVisibleRow;
57 public Rectangle ClipBounds {
58 get { return clipBounds; }
59 set { clipBounds = value; }
62 public string ErrorText {
63 get { return errorText; }
66 public Graphics Graphics {
67 get { return graphics; }
70 public DataGridViewCellStyle InheritedRowStyle {
71 get { return inheritedRowStyle; }
74 public bool IsFirstDisplayedRow {
75 get { return isFirstDisplayedRow; }
78 public bool IsLastVisibleRow {
79 get { return isLastVisibleRow; }
82 public Rectangle RowBounds {
83 get { return rowBounds; }
87 get { return rowIndex; }
90 public DataGridViewElementStates State {
91 get { return rowState; }
94 public void DrawFocus (Rectangle bounds, bool cellsPaintSelectionBackground)
96 if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count)
97 throw new InvalidOperationException ("Invalid RowIndex.");
99 DataGridViewRow row = dataGridView.GetRowInternal (rowIndex);
101 row.PaintCells (graphics, clipBounds, bounds, rowIndex, rowState, isFirstDisplayedRow, isLastVisibleRow, DataGridViewPaintParts.Focus);
104 public void PaintCells (Rectangle clipBounds, DataGridViewPaintParts paintParts)
106 if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count)
107 throw new InvalidOperationException ("Invalid RowIndex.");
109 DataGridViewRow row = dataGridView.GetRowInternal (rowIndex);
111 row.PaintCells (graphics, clipBounds, rowBounds, rowIndex, rowState, isFirstDisplayedRow, isLastVisibleRow, paintParts);
114 public void PaintCellsBackground (Rectangle clipBounds, bool cellsPaintSelectionBackground)
116 if (cellsPaintSelectionBackground)
117 PaintCells (clipBounds, DataGridViewPaintParts.All);
119 PaintCells (clipBounds, DataGridViewPaintParts.All & ~DataGridViewPaintParts.SelectionBackground);
122 public void PaintCellsContent (Rectangle clipBounds)
124 PaintCells (clipBounds, DataGridViewPaintParts.ContentBackground | DataGridViewPaintParts.ContentForeground);
127 public void PaintHeader (bool paintSelectionBackground)
129 if (paintSelectionBackground)
130 PaintHeader (DataGridViewPaintParts.All);
132 PaintHeader (DataGridViewPaintParts.All & ~DataGridViewPaintParts.SelectionBackground);
135 public void PaintHeader (DataGridViewPaintParts paintParts)
137 if (rowIndex < 0 || rowIndex >= dataGridView.Rows.Count)
138 throw new InvalidOperationException ("Invalid RowIndex.");
140 DataGridViewRow row = dataGridView.GetRowInternal (rowIndex);
142 row.PaintHeader (graphics, clipBounds, rowBounds, rowIndex, rowState, isFirstDisplayedRow, isLastVisibleRow, paintParts);