* Test/System.Windows.Forms/DataGridViewCellTest.cs: Added
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / DataGridViewAdvancedBorderStyle.cs
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:
8 // 
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 // 
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.
19 //
20 // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
21 //
22 // Author:
23 //      Pedro Martínez Juliá <pedromj@gmail.com>
24 //
25
26
27 #if NET_2_0
28
29 using System;
30 using System.ComponentModel;
31
32 namespace System.Windows.Forms {
33
34         public sealed class DataGridViewAdvancedBorderStyle : ICloneable {
35
36                 private DataGridViewAdvancedCellBorderStyle bottom;
37                 private DataGridViewAdvancedCellBorderStyle left;
38                 private DataGridViewAdvancedCellBorderStyle right;
39                 private DataGridViewAdvancedCellBorderStyle top;
40
41                 public DataGridViewAdvancedBorderStyle ()
42                 {
43                         All = DataGridViewAdvancedCellBorderStyle.None;
44                 }
45
46                 public DataGridViewAdvancedCellBorderStyle All {
47                         get {
48                                 if (bottom == left && left == right && right == top) {
49                                         return bottom;
50                                 }
51                                 return DataGridViewAdvancedCellBorderStyle.NotSet;
52                         }
53                         set {
54                                 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
55                                         throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
56                                 }
57                                 bottom = left = right = top = value;
58                         }
59                 }
60
61                 public DataGridViewAdvancedCellBorderStyle Bottom {
62                         get { return bottom; }
63                         set {
64                                 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
65                                         throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
66                                 }
67                                 if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
68                                         throw new ArgumentException("Invlid Bottom value.");
69                                 }
70                                 bottom = value;
71                         }
72                 }
73
74                 public DataGridViewAdvancedCellBorderStyle Left {
75                         get { return left; }
76                         set {
77                                 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
78                                         throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
79                                 }
80                                 if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
81                                         throw new ArgumentException("Invlid Left value.");
82                                 }
83                                 /*
84                                 if (Control.RightToLeft == true && (value == DataGridViewAdvancedCellBorderStyle.InsetDouble || value == DataGridViewAdvancedCellBorderStyle.OutsetDouble)) {
85                                         throw new ArgumentException("Invlid Left value.");
86                                 }
87                                 */
88                                 left = value;
89                         }
90                 }
91
92                 public DataGridViewAdvancedCellBorderStyle Right {
93                         get { return right; }
94                         set {
95                                 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
96                                         throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
97                                 }
98                                 if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
99                                         throw new ArgumentException("Invlid Right value.");
100                                 }
101                                 /*
102                                 if (Control.RightToLeft == false && (value == DataGridViewAdvancedCellBorderStyle.InsetDouble || value == DataGridViewAdvancedCellBorderStyle.OutsetDouble)) {
103                                         throw new ArgumentException("Invlid Right value.");
104                                 }
105                                 */
106                                 right = value;
107                         }
108                 }
109
110                 public DataGridViewAdvancedCellBorderStyle Top {
111                         get { return top; }
112                         set {
113                                 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
114                                         throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
115                                 }
116                                 if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
117                                         throw new ArgumentException("Invlid Top value.");
118                                 }
119                                 top = value;
120                         }
121                 }
122
123                 public override bool Equals (object other)
124                 {
125                         if (other is DataGridViewAdvancedBorderStyle) {
126                                 DataGridViewAdvancedBorderStyle otherAux = (DataGridViewAdvancedBorderStyle) other;
127                                 return bottom == otherAux.bottom &&
128                                         left == otherAux.left &&
129                                         right == otherAux.right &&
130                                         top == otherAux.top;
131                         }
132                         return false;
133                 }
134
135                 public override int GetHashCode ()
136                 {
137                         return base.GetHashCode();
138                 }
139
140                 public override string ToString ()
141                 {
142                         return String.Format("DataGridViewAdvancedBorderStyle { All={0}, Left={1}, Right={2}, Top={3}, Bottom={4} }", All, Left, Right, Top, Bottom);
143                 }
144
145                 object ICloneable.Clone ()
146                 {
147                         DataGridViewAdvancedBorderStyle result = new DataGridViewAdvancedBorderStyle();
148                         result.bottom = this.bottom;
149                         result.left = this.left;
150                         result.right = this.right;
151                         result.top = this.top;
152                         return result;
153                 }
154
155         }
156
157 }
158
159 #endif