comparison Chronosv2/source/Presentation/Windows/Controls/DragOrResizeStatus.cs @ 10:443821e55f06

Initial cleaned up add from Codeplex files
author stevenh7776 stevenhollidge@hotmail.com
date Tue, 21 Feb 2012 17:25:44 +0700
parents
children
comparison
equal deleted inserted replaced
9:904a9faadf8b 10:443821e55f06
1 using System;
2
3 namespace Chronos.Presentation.Windows.Controls
4 {
5 /// <summary>
6 /// Structure for the possible drag and/or resize statuses
7 /// </summary>
8 [Serializable]
9 public struct DragOrResizeStatus
10 {
11 #region · Consts ·
12
13 const byte _TopLeft = 9;
14 const byte _TopCenter = 10;
15 const byte _TopRight = 12;
16 const byte _MiddleLeft = 17;
17 const byte _Drag = 18;
18 const byte _MiddleRight = 20;
19 const byte _BottomLeft = 33;
20 const byte _BottomCenter = 34;
21 const byte _BottomRight = 36;
22 const byte _Left = 1;
23 const byte _HMiddle = 2;
24 const byte _Right = 4;
25 const byte _Top = 8;
26 const byte _VCenter = 16;
27 const byte _Bottom = 32;
28
29 #endregion
30
31 #region · Static Members ·
32
33 /// <summary>
34 /// No resize or drag status
35 /// </summary>
36 public static readonly DragOrResizeStatus None = new DragOrResizeStatus { value = 0 };
37 /// <summary>
38 /// Identifies the top/left resize status
39 /// </summary>
40 public static readonly DragOrResizeStatus TopLeft = new DragOrResizeStatus { value = _TopLeft };
41 /// <summary>
42 /// Identifies the top/center resize status
43 /// </summary>
44 public static readonly DragOrResizeStatus TopCenter = new DragOrResizeStatus { value = _TopCenter };
45 /// <summary>
46 /// /// Identifies the top/right resize status
47 /// </summary>
48 public static readonly DragOrResizeStatus TopRight = new DragOrResizeStatus { value = _TopRight };
49 /// <summary>
50 /// /// Identifies the middle/left resize status
51 /// </summary>
52 public static readonly DragOrResizeStatus MiddleLeft = new DragOrResizeStatus { value = _MiddleLeft };
53 /// <summary>
54 /// Identifies the dragging status
55 /// </summary>
56 public static readonly DragOrResizeStatus Drag = new DragOrResizeStatus { value = _Drag };
57 /// <summary>
58 /// Identifies the middle/right resize status
59 /// </summary>
60 public static readonly DragOrResizeStatus MiddleRight = new DragOrResizeStatus { value = _MiddleRight };
61 /// <summary>
62 /// /// Identifies the bottom/left resize status
63 /// </summary>
64 public static readonly DragOrResizeStatus BottomLeft = new DragOrResizeStatus { value = _BottomLeft };
65 /// <summary>
66 /// Identifies the bottom/center resize status
67 /// </summary>
68 public static readonly DragOrResizeStatus BottomCenter = new DragOrResizeStatus { value = _BottomCenter };
69 /// <summary>
70 /// Identifies the bottom/right resize status
71 /// </summary>
72 public static readonly DragOrResizeStatus BottomRight = new DragOrResizeStatus { value = _BottomRight };
73
74 #endregion
75
76 #region · Operators ·
77
78 /// <summary>
79 /// Implements the operator ==.
80 /// </summary>
81 /// <param name="x">The x.</param>
82 /// <param name="y">The y.</param>
83 /// <returns>The result of the operator.</returns>
84 public static bool operator ==(DragOrResizeStatus x, DragOrResizeStatus y)
85 {
86 return x.Equals(y);
87 }
88
89 /// <summary>
90 /// Implements the operator !=.
91 /// </summary>
92 /// <param name="x">The x.</param>
93 /// <param name="y">The y.</param>
94 /// <returns>The result of the operator.</returns>
95 public static bool operator !=(DragOrResizeStatus x, DragOrResizeStatus y)
96 {
97 return !x.Equals(y);
98 }
99
100 #endregion
101
102 #region · Fields ·
103
104 private byte value;
105
106 #endregion
107
108 #region · Properties ·
109
110 /// <summary>
111 /// Gets a value the resize status is on left.
112 /// </summary>
113 public bool IsOnLeft
114 {
115 get { return (this.value & _Left) == _Left; }
116 }
117
118 /// <summary>
119 /// Gets a value the resize status is on horizontal middle.
120 /// </summary>
121 public bool IsOnHMiddle
122 {
123 get { return (this.value & _HMiddle) == _HMiddle; }
124 }
125
126 /// <summary>
127 /// Gets a value the resize status is on right.
128 /// </summary>
129 public bool IsOnRight
130 {
131 get { return (this.value & _Right) == _Right; }
132 }
133
134 /// <summary>
135 /// Gets a value the resize status is on top.
136 /// </summary>
137 public bool IsOnTop
138 {
139 get { return (this.value & _Top) == _Top; }
140 }
141
142 /// <summary>
143 /// Gets a value the resize status is on vertical center.
144 /// </summary>
145 public bool IsOnVCenter
146 {
147 get { return (this.value & _VCenter) == _VCenter; }
148 }
149
150 /// <summary>
151 /// Gets a value the resize status is on bottom.
152 /// </summary>
153 public bool IsOnBottom
154 {
155 get { return (this.value & _Bottom) == _Bottom; }
156 }
157
158 /// <summary>
159 /// Gets a value the resize status is on top/left or bottom/right.
160 /// </summary>
161 public bool IsOnTopLeftOrBottomRight
162 {
163 get { return this.value == _TopLeft || this.value == _BottomRight; }
164 }
165
166 /// <summary>
167 /// Gets a value the resize status is on top/right or bottom/center.
168 /// </summary>
169 public bool IsOnTopRightOrBottomLeft
170 {
171 get { return this.value == _TopRight || this.value == _BottomLeft; }
172 }
173
174 /// <summary>
175 /// Gets a value the resize status is on top/center or bottom/center.
176 /// </summary>
177 public bool IsOnTopCenterOrBottomCenter
178 {
179 get { return this.value == _TopCenter || this.value == _BottomCenter; }
180 }
181
182 /// <summary>
183 /// Gets a value the resize status is on middle/left or middle/right.
184 /// </summary>
185 public bool IsOnMiddleLeftOrMiddleRight
186 {
187 get { return this.value == _MiddleLeft || this.value == _MiddleRight; }
188 }
189
190 /// <summary>
191 /// Gets a value the status is dragging
192 /// </summary>
193 public bool IsDragging
194 {
195 get { return this.value == _Drag; }
196 }
197
198 #endregion
199
200 #region · Methods ·
201
202 /// <summary>
203 /// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
204 /// </summary>
205 /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
206 /// <returns>
207 /// <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
208 /// </returns>
209 public override bool Equals(object obj)
210 {
211 if (obj == null || this.GetType() != obj.GetType())
212 {
213 return false;
214 }
215
216 return ((DragOrResizeStatus)obj).value == this.value;
217 }
218
219 /// <summary>
220 /// Returns a hash code for this instance.
221 /// </summary>
222 /// <returns>
223 /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
224 /// </returns>
225 public override int GetHashCode()
226 {
227 return this.value.GetHashCode();
228 }
229
230 #endregion
231 }
232 }