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 () {
42 All = DataGridViewAdvancedCellBorderStyle.None;
45 public DataGridViewAdvancedCellBorderStyle All {
47 if (bottom == left && left == right && right == top) {
50 return DataGridViewAdvancedCellBorderStyle.NotSet;
53 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
54 throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
56 bottom = left = right = top = value;
60 public DataGridViewAdvancedCellBorderStyle Bottom {
61 get { return bottom; }
63 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
64 throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
66 if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
67 throw new ArgumentException("Invlid Bottom value.");
73 public DataGridViewAdvancedCellBorderStyle Left {
76 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
77 throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
79 if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
80 throw new ArgumentException("Invlid Left value.");
83 if (Control.RightToLeft == true && (value == DataGridViewAdvancedCellBorderStyle.InsetDouble || value == DataGridViewAdvancedCellBorderStyle.OutsetDouble)) {
84 throw new ArgumentException("Invlid Left value.");
91 public DataGridViewAdvancedCellBorderStyle Right {
94 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
95 throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
97 if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
98 throw new ArgumentException("Invlid Right value.");
101 if (Control.RightToLeft == false && (value == DataGridViewAdvancedCellBorderStyle.InsetDouble || value == DataGridViewAdvancedCellBorderStyle.OutsetDouble)) {
102 throw new ArgumentException("Invlid Right value.");
109 public DataGridViewAdvancedCellBorderStyle Top {
112 if (!Enum.IsDefined(typeof(DataGridViewAdvancedCellBorderStyle), value)) {
113 throw new InvalidEnumArgumentException("Value is not valid DataGridViewAdvancedCellBorderStyle.");
115 if (value == DataGridViewAdvancedCellBorderStyle.NotSet) {
116 throw new ArgumentException("Invlid Top value.");
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 &&
133 public override int GetHashCode () {
134 return base.GetHashCode();
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);
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;