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 sealed class DataGridViewAdvancedBorderStyle : ICloneable {
36 private DataGridViewAdvancedCellBorderStyle bottom;
37 private DataGridViewAdvancedCellBorderStyle left;
38 private DataGridViewAdvancedCellBorderStyle right;
39 private DataGridViewAdvancedCellBorderStyle top;
41 public DataGridViewAdvancedBorderStyle ()
43 All = DataGridViewAdvancedCellBorderStyle.None;
46 public DataGridViewAdvancedCellBorderStyle All {
48 if (bottom == left && left == right && right == top) {
51 return DataGridViewAdvancedCellBorderStyle.NotSet;
54 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
55 throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
57 bottom = left = right = top = value;
61 public DataGridViewAdvancedCellBorderStyle Bottom {
62 get { return bottom; }
64 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
65 throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
67 if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
68 throw new ArgumentException("Invlid Bottom value.");
74 public DataGridViewAdvancedCellBorderStyle Left {
77 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
78 throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
80 if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
81 throw new ArgumentException("Invlid Left value.");
84 if (Control.RightToLeft == true && (value == DataGridViewAdvancedCellBorderStyle.InsetDouble || value == DataGridViewAdvancedCellBorderStyle.OutsetDouble)) {
85 throw new ArgumentException("Invlid Left value.");
92 public DataGridViewAdvancedCellBorderStyle Right {
95 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
96 throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
98 if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
99 throw new ArgumentException("Invlid Right value.");
102 if (Control.RightToLeft == false && (value == DataGridViewAdvancedCellBorderStyle.InsetDouble || value == DataGridViewAdvancedCellBorderStyle.OutsetDouble)) {
103 throw new ArgumentException("Invlid Right value.");
110 public DataGridViewAdvancedCellBorderStyle Top {
113 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
114 throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
116 if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
117 throw new ArgumentException("Invlid Top value.");
123 public override bool Equals (object other)
125 if (other is DataGridViewAdvancedBorderStyle) {
126 DataGridViewAdvancedBorderStyle otherAux = (DataGridViewAdvancedBorderStyle) other;
127 return bottom == otherAux.bottom &&
128 left == otherAux.left &&
129 right == otherAux.right &&
135 public override int GetHashCode ()
137 return base.GetHashCode();
140 public override string ToString ()
142 return String.Format("DataGridViewAdvancedBorderStyle { All={0}, Left={1}, Right={2}, Top={3}, Bottom={4} }", All, Left, Right, Top, Bottom);
145 object ICloneable.Clone ()
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;