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>
28 using System.ComponentModel;
30 namespace System.Windows.Forms {
32 public sealed class DataGridViewAdvancedBorderStyle : ICloneable {
34 private DataGridViewAdvancedCellBorderStyle bottom;
35 private DataGridViewAdvancedCellBorderStyle left;
36 private DataGridViewAdvancedCellBorderStyle right;
37 private DataGridViewAdvancedCellBorderStyle top;
39 public DataGridViewAdvancedBorderStyle ()
41 All = DataGridViewAdvancedCellBorderStyle.None;
44 public DataGridViewAdvancedCellBorderStyle All {
46 if (bottom == left && left == right && right == top) {
49 return DataGridViewAdvancedCellBorderStyle.NotSet;
52 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
53 throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
55 bottom = left = right = top = value;
59 public DataGridViewAdvancedCellBorderStyle Bottom {
60 get { return bottom; }
62 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
63 throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
65 if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
66 throw new ArgumentException("Invlid Bottom value.");
72 public DataGridViewAdvancedCellBorderStyle Left {
75 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
76 throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
78 if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
79 throw new ArgumentException("Invlid Left value.");
82 if (Control.RightToLeft == true && (value == DataGridViewAdvancedCellBorderStyle.InsetDouble || value == DataGridViewAdvancedCellBorderStyle.OutsetDouble)) {
83 throw new ArgumentException("Invlid Left value.");
90 public DataGridViewAdvancedCellBorderStyle Right {
93 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
94 throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
96 if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
97 throw new ArgumentException("Invlid Right value.");
100 if (Control.RightToLeft == false && (value == DataGridViewAdvancedCellBorderStyle.InsetDouble || value == DataGridViewAdvancedCellBorderStyle.OutsetDouble)) {
101 throw new ArgumentException("Invlid Right value.");
108 public DataGridViewAdvancedCellBorderStyle Top {
111 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
112 throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
114 if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
115 throw new ArgumentException("Invlid Top value.");
121 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 &&
133 public override int GetHashCode ()
135 return base.GetHashCode();
138 public override string ToString ()
140 return String.Format("DataGridViewAdvancedBorderStyle { All={0}, Left={1}, Right={2}, Top={3}, Bottom={4} }", All, Left, Right, Top, Bottom);
143 object ICloneable.Clone ()
145 DataGridViewAdvancedBorderStyle result = new DataGridViewAdvancedBorderStyle();
146 result.bottom = this.bottom;
147 result.left = this.left;
148 result.right = this.right;
149 result.top = this.top;