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; }
54 public string Description
{
55 get { return description; }
56 set { description = value; }
59 public override Type EditType
{
63 public override Type FormattedValueType
{
64 get { return (valueIsIcon)? typeof(Icon) : typeof(Image); }
67 [DefaultValue (DataGridViewImageCellLayout
.NotSet
)]
68 public DataGridViewImageCellLayout ImageLayout
{
69 get { return imageLayout; }
71 if (!Enum
.IsDefined(typeof(DataGridViewImageCellLayout
), value)) {
72 throw new InvalidEnumArgumentException("Value is invalid image cell layout.");
78 [DefaultValue (false)]
79 public bool ValueIsIcon
{
80 get { return valueIsIcon; }
81 set { valueIsIcon = value; }
84 public override Type ValueType
{
86 if (base.ValueType
!= null) {
87 return base.ValueType
;
89 if (OwningColumn
!= null) {
90 return OwningColumn
.ValueType
;
99 set { base.ValueType = value; }
102 public override object Clone () {
103 DataGridViewImageCell cell
= (DataGridViewImageCell
) base.Clone();
104 cell
.defaultNewRowValue
= this.defaultNewRowValue
;
105 cell
.description
= this.description
;
106 cell
.valueIsIcon
= this.valueIsIcon
;
110 public override string ToString () {
111 return GetType().Name
;
114 protected override AccessibleObject
CreateAccessibilityInstance () {
115 return new DataGridViewImageCellAccessibleObject(this);
118 protected override Rectangle
GetContentBounds (Graphics graphics
, DataGridViewCellStyle cellStyle
, int rowIndex
) {
119 throw new NotImplementedException();
122 protected override Rectangle
GetErrorIconBounds (Graphics graphics
, DataGridViewCellStyle cellStyle
, int rowIndex
) {
123 throw new NotImplementedException();
126 protected override object GetFormattedValue (object value, int rowIndex
, ref DataGridViewCellStyle cellStyle
, TypeConverter valueTypeConverter
, TypeConverter formattedValueTypeConverter
, DataGridViewDataErrorContexts context
) {
127 throw new NotImplementedException();
130 protected override Size
GetPreferredSize (Graphics graphics
, DataGridViewCellStyle cellStyle
, int rowIndex
, Size constraintSize
) {
131 throw new NotImplementedException();
134 protected override object GetValue (int rowIndex
) {
135 throw new NotImplementedException();
138 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
) {
139 throw new NotImplementedException();
142 protected class DataGridViewImageCellAccessibleObject
: DataGridViewCellAccessibleObject
{
144 public DataGridViewImageCellAccessibleObject (DataGridViewCell owner
) : base(owner
) {
147 public override string DefaultAction
{
151 public override string Description
{
152 get { return (Owner as DataGridViewImageCell).Description; }
155 public override void DoDefaultAction () {
156 // The DataGridViewImageCell has no default action.
159 public override int GetChildCount () {