* roottypes.cs: Rename from tree.cs.
[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                         All = DataGridViewAdvancedCellBorderStyle.None;
43                 }
44
45                 public DataGridViewAdvancedCellBorderStyle All {
46                         get {
47                                 if (bottom == left && left == right && right == top) {
48                                         return bottom;
49                                 }
50                                 return DataGridViewAdvancedCellBorderStyle.NotSet;
51                         }
52                         set {
53                                 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
54                                         throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
55                                 }
56                                 bottom = left = right = top = value;
57                         }
58                 }
59
60                 public DataGridViewAdvancedCellBorderStyle Bottom {
61                         get { return bottom; }
62                         set {
63                                 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
64                                         throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
65                                 }
66                                 if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
67                                         throw new ArgumentException("Invlid Bottom value.");
68                                 }
69                                 bottom = value;
70                         }
71                 }
72
73                 public DataGridViewAdvancedCellBorderStyle Left {
74                         get { return left; }
75                         set {
76                                 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
77                                         throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
78                                 }
79                                 if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
80                                         throw new ArgumentException("Invlid Left value.");
81                                 }
82                                 /*
83                                 if (Control.RightToLeft == true && (value == DataGridViewAdvancedCellBorderStyle.InsetDouble || value == DataGridViewAdvancedCellBorderStyle.OutsetDouble)) {
84                                         throw new ArgumentException("Invlid Left value.");
85                                 }
86                                 */
87                                 left = value;
88                         }
89                 }
90
91                 public DataGridViewAdvancedCellBorderStyle Right {
92                         get { return right; }
93                         set {
94                                 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
95                                         throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
96                                 }
97                                 if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
98                                         throw new ArgumentException("Invlid Right value.");
99                                 }
100                                 /*
101                                 if (Control.RightToLeft == false && (value == DataGridViewAdvancedCellBorderStyle.InsetDouble || value == DataGridViewAdvancedCellBorderStyle.OutsetDouble)) {
102                                         throw new ArgumentException("Invlid Right value.");
103                                 }
104                                 */
105                                 right = value;
106                         }
107                 }
108
109                 public DataGridViewAdvancedCellBorderStyle Top {
110                         get { return top; }
111                         set {
112                                 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
113                                         throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
114                                 }
115                                 if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
116                                         throw new ArgumentException("Invlid Top value.");
117                                 }
118                                 top = value;
119                         }
120                 }
121
122                 public override bool Equals (object other) {
123                         if (other is DataGridViewAdvancedBorderStyle) {
124                                 DataGridViewAdvancedBorderStyle otherAux = (DataGridViewAdvancedBorderStyle) other;
125                                 return bottom == otherAux.bottom &&
126                                         left == otherAux.left &&
127                                         right == otherAux.right &&
128                                         top == otherAux.top;
129                         }
130                         return false;
131                 }
132
133                 public override int GetHashCode () {
134                         return base.GetHashCode();
135                 }
136
137                 public override string ToString () {
138                         return String.Format("DataGridViewAdvancedBorderStyle { All={0}, Left={1}, Right={2}, Top={3}, Bottom={4} }", All, Left, Right, Top, Bottom);
139                 }
140
141                 public object Clone () {
142                         DataGridViewAdvancedBorderStyle result = new DataGridViewAdvancedBorderStyle();
143                         result.bottom = this.bottom;
144                         result.left = this.left;
145                         result.right = this.right;
146                         result.top = this.top;
147                         return result;
148                 }
149
150         }
151
152 }
153
154 #endif