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>
30 using System.ComponentModel;
32 namespace System.Windows.Forms {
34 public class DataGridViewImageCell : DataGridViewCell {
36 private object defaultNewRowValue;
37 private string description;
38 private DataGridViewImageCellLayout imageLayout;
39 private bool valueIsIcon;
41 public DataGridViewImageCell (bool valueIsIcon) {
42 this.valueIsIcon = valueIsIcon;
43 this.imageLayout = DataGridViewImageCellLayout.NotSet;
46 public DataGridViewImageCell () : this(false) {
49 public override object DefaultNewRowValue {
50 get { return defaultNewRowValue; }
53 public string Description {
54 get { return description; }
55 set { description = value; }
58 public override Type EditType {
62 public override Type FormattedValueType {
63 get { return (valueIsIcon)? typeof(Icon) : typeof(Image); }
66 public DataGridViewImageCellLayout ImageLayout {
67 get { return imageLayout; }
69 if (!Enum.IsDefined(typeof(DataGridViewImageCellLayout), value)) {
70 throw new InvalidEnumArgumentException("Value is invalid image cell layout.");
76 public bool ValueIsIcon {
77 get { return valueIsIcon; }
78 set { valueIsIcon = value; }
81 public override Type ValueType {
83 if (base.ValueType != null) {
84 return base.ValueType;
86 if (OwningColumn != null) {
87 return OwningColumn.ValueType;
96 set { base.ValueType = value; }
99 public override object Clone () {
100 DataGridViewImageCell cell = (DataGridViewImageCell) base.Clone();
101 cell.defaultNewRowValue = this.defaultNewRowValue;
102 cell.description = this.description;
103 cell.valueIsIcon = this.valueIsIcon;
107 public override string ToString () {
108 return GetType().Name;
111 protected override AccessibleObject CreateAccessibilityInstance () {
112 return new DataGridViewImageCellAccessibleObject(this);
115 protected override Rectangle GetContentBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
116 throw new NotImplementedException();
119 protected override Rectangle GetErrorIconBounds (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex) {
120 throw new NotImplementedException();
123 protected override object GetFormattedValue (object value, int rowIndex, ref DataGridViewCellStyle cellStyle, TypeConverter valueTypeConverter, TypeConverter formattedValueTypeConverter, DataGridViewDataErrorContexts context) {
124 throw new NotImplementedException();
127 protected override Size GetPreferredSize (Graphics graphics, DataGridViewCellStyle cellStyle, int rowIndex, Size constraintSize) {
128 throw new NotImplementedException();
131 protected override object GetValue (int rowIndex) {
132 throw new NotImplementedException();
135 protected override void OnMouseEnter (int rowIndex) {
136 throw new NotImplementedException();
139 protected override void OnMouseLeave (int rowIndex) {
140 throw new NotImplementedException();
143 protected override void Paint (Graphics graphics, Rectangle clipBounds, Rectangle cellBounds, int rowIndex, DataGridViewElementStates elementeState, object value, object formattedValue, string errorText, DataGridViewCellStyle cellStyle, DataGridViewAdvancedBorderStyle advancedBorderStyle, DataGridViewPaintParts paintParts) {
144 throw new NotImplementedException();
147 protected class DataGridViewImageCellAccessibleObject : DataGridViewCellAccessibleObject {
149 public DataGridViewImageCellAccessibleObject (DataGridViewCell owner) : base(owner) {
152 public override string DefaultAction {
156 public override string Description {
157 get { return (Owner as DataGridViewImageCell).Description; }
160 public override void DoDefaultAction () {
161 // The DataGridViewImageCell has no default action.
164 public override int GetChildCount () {