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>
29 using System.ComponentModel;
32 namespace System.Windows.Forms {
34 public class DataGridViewCellPaintingEventArgs : HandledEventArgs {
36 private DataGridView dataGridView;
37 private Graphics graphics;
38 private Rectangle clipBounds;
39 private Rectangle cellBounds;
41 private int columnIndex;
42 private DataGridViewElementStates cellState;
43 private object cellValue;
44 private object formattedValue;
45 private string errorText;
46 private DataGridViewCellStyle cellStyle;
47 private DataGridViewAdvancedBorderStyle advancedBorderStyle;
48 private DataGridViewPaintParts paintParts;
50 public DataGridViewCellPaintingEventArgs (DataGridView dataGridView, Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, int columnIndex, DataGridViewElementStates cellState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
51 this.dataGridView = dataGridView;
52 this.graphics = graphics;
53 this.clipBounds = clipBounds;
54 this.cellBounds = cellBounds;
55 this.rowIndex = rowIndex;
56 this.columnIndex = columnIndex;
57 this.cellState = cellState;
58 this.cellValue = value;
59 this.formattedValue = formattedValue;
60 this.errorText = errorText;
61 this.cellStyle = cellStyle;
62 this.advancedBorderStyle = advancedBorderStyle;
63 this.paintParts = paintParts;
66 public DataGridViewAdvancedBorderStyle AdvancedBorderStyle {
67 get { return advancedBorderStyle; }
70 public Rectangle CellBounds {
71 get { return cellBounds; }
74 public DataGridViewCellStyle CellStyle {
75 get { return cellStyle; }
78 public Rectangle ClipBounds {
79 get { return clipBounds; }
82 public int ColumnIndex {
83 get { return columnIndex; }
86 public string ErrorText {
87 get { return errorText; }
90 public object FormattedValue {
91 get { return formattedValue; }
94 public Graphics Graphics {
95 get { return graphics; }
98 public DataGridViewPaintParts PaintParts {
99 get { return paintParts; }
102 public int RowIndex {
103 get { return rowIndex; }
106 public DataGridViewElementStates State {
107 get { return cellState; }
110 public object Value {
111 get { return cellValue; }
114 public void Paint (Rectangle clipBounds, DataGridViewPaintParts paintParts) {
115 if (rowIndex < -1 || rowIndex >= dataGridView.Rows.Count) {
116 throw new InvalidOperationException("Invalid \"RowIndex.\"");
118 if (columnIndex < -1 || columnIndex >= dataGridView.Columns.Count) {
119 throw new InvalidOperationException("Invalid \"ColumnIndex.\"");
121 throw new NotImplementedException();
124 public void PaintBackground (Rectangle clipBounds, bool cellsPaintSelectionBackground) {
125 if (rowIndex < -1 || rowIndex >= dataGridView.Rows.Count) {
126 throw new InvalidOperationException("Invalid \"RowIndex.\"");
128 if (columnIndex < -1 || columnIndex >= dataGridView.Columns.Count) {
129 throw new InvalidOperationException("Invalid \"ColumnIndex.\"");
131 DataGridViewCell cell = dataGridView.Rows[rowIndex].Cells[columnIndex];
133 if (cellsPaintSelectionBackground) {
134 color = cell.InheritedStyle.SelectionBackColor;
137 color = cell.InheritedStyle.BackColor;
139 ///////// NOT CHECKED //////////////
140 graphics.FillRectangle(new SolidBrush(color), clipBounds);
143 public void PaintContent (Rectangle clipBounds) {
144 if (rowIndex < -1 || rowIndex >= dataGridView.Rows.Count) {
145 throw new InvalidOperationException("Invalid \"RowIndex.\"");
147 if (columnIndex < -1 || columnIndex >= dataGridView.Columns.Count) {
148 throw new InvalidOperationException("Invalid \"ColumnIndex.\"");
150 throw new NotImplementedException();