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 DataGridViewRowPrePaintEventArgs
: HandledEventArgs
{
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
;
43 private DataGridViewPaintParts paintParts
;
45 public DataGridViewRowPrePaintEventArgs (DataGridView dataGridView
, Graphics graphics
, Rectangle clipBounds
, Rectangle rowBounds
, int rowIndex
, DataGridViewElementStates rowState
, string errorText
, DataGridViewCellStyle inheritedRowStyle
, bool isFirstDisplayedRow
, bool isLastVisibleRow
) {
46 this.dataGridView
= dataGridView
;
47 this.graphics
= graphics
;
48 this.clipBounds
= clipBounds
;
49 this.rowBounds
= rowBounds
;
50 this.rowIndex
= rowIndex
;
51 this.rowState
= rowState
;
52 this.errorText
= errorText
;
53 this.inheritedRowStyle
= inheritedRowStyle
;
54 this.isFirstDisplayedRow
= isFirstDisplayedRow
;
55 this.isLastVisibleRow
= isLastVisibleRow
;
58 public Rectangle ClipBounds
{
59 get { return clipBounds; }
60 set { clipBounds = value; }
63 public string ErrorText
{
64 get { return errorText; }
67 public Graphics Graphics
{
68 get { return graphics; }
71 public DataGridViewCellStyle InheritedRowStyle
{
72 get { return inheritedRowStyle; }
75 public bool IsFirstDisplayedRow
{
76 get { return isFirstDisplayedRow; }
79 public bool IsLastVisibleRow
{
80 get { return isLastVisibleRow; }
83 public DataGridViewPaintParts PaintParts
{
84 get { return paintParts; }
85 set { paintParts = value; }
88 public Rectangle RowBounds
{
89 get { return rowBounds; }
93 get { return rowIndex; }
96 public DataGridViewElementStates State
{
97 get { return rowState; }
100 public void DrawFocus (Rectangle bounds
, bool cellsPaintSelectionBackground
) {
101 if (rowIndex
< 0 || rowIndex
>= dataGridView
.Rows
.Count
)
102 throw new InvalidOperationException ("Invalid RowIndex.");
104 DataGridViewRow row
= dataGridView
.GetRowInternal (rowIndex
);
106 row
.PaintCells (graphics
, clipBounds
, bounds
, rowIndex
, rowState
, isFirstDisplayedRow
, isLastVisibleRow
, DataGridViewPaintParts
.Focus
);
109 public void PaintCells (Rectangle clipBounds
, DataGridViewPaintParts paintParts
)
111 if (rowIndex
< 0 || rowIndex
>= dataGridView
.Rows
.Count
)
112 throw new InvalidOperationException ("Invalid RowIndex.");
114 DataGridViewRow row
= dataGridView
.GetRowInternal (rowIndex
);
116 row
.PaintCells (graphics
, clipBounds
, rowBounds
, rowIndex
, rowState
, isFirstDisplayedRow
, isLastVisibleRow
, paintParts
);
119 public void PaintCellsBackground (Rectangle clipBounds
, bool cellsPaintSelectionBackground
)
121 if (cellsPaintSelectionBackground
)
122 PaintCells (clipBounds
, DataGridViewPaintParts
.All
);
124 PaintCells (clipBounds
, DataGridViewPaintParts
.All
& ~DataGridViewPaintParts
.SelectionBackground
);
127 public void PaintCellsContent (Rectangle clipBounds
)
129 PaintCells (clipBounds
, DataGridViewPaintParts
.ContentBackground
| DataGridViewPaintParts
.ContentForeground
);
132 public void PaintHeader (bool paintSelectionBackground
)
134 if (paintSelectionBackground
)
135 PaintHeader (DataGridViewPaintParts
.All
);
137 PaintHeader (DataGridViewPaintParts
.All
& ~DataGridViewPaintParts
.SelectionBackground
);
140 public void PaintHeader (DataGridViewPaintParts paintParts
)
142 if (rowIndex
< 0 || rowIndex
>= dataGridView
.Rows
.Count
)
143 throw new InvalidOperationException ("Invalid RowIndex.");
145 DataGridViewRow row
= dataGridView
.GetRowInternal (rowIndex
);
147 row
.PaintHeader (graphics
, clipBounds
, rowBounds
, rowIndex
, rowState
, isFirstDisplayedRow
, isLastVisibleRow
, paintParts
);