18
18
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
19
// THE SOFTWARE.
20
20
21
+ using System ;
22
+ using System . Runtime . InteropServices ;
23
+
21
24
namespace SharpDX . Toolkit . Input
22
25
{
23
26
/// <summary>
24
27
/// Represents a platform-independent information about a pointer event.
25
28
/// </summary>
26
- public struct PointerPoint
29
+ [ StructLayout ( LayoutKind . Sequential ) ]
30
+ public struct PointerPoint : IEquatable < PointerPoint >
27
31
{
28
32
/// <summary>
29
33
/// The type of event that represents current pointer point
@@ -154,5 +158,80 @@ public struct PointerPoint
154
158
/// Indicates the kind of pointer state change.
155
159
/// </summary>
156
160
public PointerUpdateKind PointerUpdateKind { get ; internal set ; }
161
+
162
+ /// <summary>
163
+ /// Indicates whether the current object is equal to another object of the same type.
164
+ /// </summary>
165
+ /// <param name="other">An object to compare with this object.</param>
166
+ /// <returns>true if the current object is equal to the <paramref name="other" /> parameter; otherwise, false.</returns>
167
+ public bool Equals ( PointerPoint other )
168
+ {
169
+ return EventType == other . EventType && DeviceType == other . DeviceType && PointerId == other . PointerId && Position . Equals ( other . Position ) && Timestamp == other . Timestamp && KeyModifiers == other . KeyModifiers && ContactRect . Equals ( other . ContactRect ) && IsBarrelButtonPresset . Equals ( other . IsBarrelButtonPresset ) && IsCanceled . Equals ( other . IsCanceled ) && IsEraser . Equals ( other . IsEraser ) && IsHorizontalMouseWheel . Equals ( other . IsHorizontalMouseWheel ) && IsInRange . Equals ( other . IsInRange ) && IsInverted . Equals ( other . IsInverted ) && IsLeftButtonPressed . Equals ( other . IsLeftButtonPressed ) && IsMiddleButtonPressed . Equals ( other . IsMiddleButtonPressed ) && IsRightButtonPressed . Equals ( other . IsRightButtonPressed ) && IsXButton1Pressed . Equals ( other . IsXButton1Pressed ) && IsXButton2Pressed . Equals ( other . IsXButton2Pressed ) && IsPrimary . Equals ( other . IsPrimary ) && MouseWheelDelta == other . MouseWheelDelta && Orientation . Equals ( other . Orientation ) && TouchConfidence . Equals ( other . TouchConfidence ) && Twist . Equals ( other . Twist ) && XTilt . Equals ( other . XTilt ) && YTilt . Equals ( other . YTilt ) && PointerUpdateKind == other . PointerUpdateKind ;
170
+ }
171
+
172
+ public override bool Equals ( object obj )
173
+ {
174
+ if ( ReferenceEquals ( null , obj ) )
175
+ {
176
+ return false ;
177
+ }
178
+ return obj is PointerPoint && Equals ( ( PointerPoint ) obj ) ;
179
+ }
180
+
181
+ public override int GetHashCode ( )
182
+ {
183
+ unchecked
184
+ {
185
+ int hashCode = ( int ) EventType ;
186
+ hashCode = ( hashCode * 397 ) ^ ( int ) DeviceType ;
187
+ hashCode = ( hashCode * 397 ) ^ ( int ) PointerId ;
188
+ hashCode = ( hashCode * 397 ) ^ Position . GetHashCode ( ) ;
189
+ hashCode = ( hashCode * 397 ) ^ Timestamp . GetHashCode ( ) ;
190
+ hashCode = ( hashCode * 397 ) ^ ( int ) KeyModifiers ;
191
+ hashCode = ( hashCode * 397 ) ^ ContactRect . GetHashCode ( ) ;
192
+ hashCode = ( hashCode * 397 ) ^ IsBarrelButtonPresset . GetHashCode ( ) ;
193
+ hashCode = ( hashCode * 397 ) ^ IsCanceled . GetHashCode ( ) ;
194
+ hashCode = ( hashCode * 397 ) ^ IsEraser . GetHashCode ( ) ;
195
+ hashCode = ( hashCode * 397 ) ^ IsHorizontalMouseWheel . GetHashCode ( ) ;
196
+ hashCode = ( hashCode * 397 ) ^ IsInRange . GetHashCode ( ) ;
197
+ hashCode = ( hashCode * 397 ) ^ IsInverted . GetHashCode ( ) ;
198
+ hashCode = ( hashCode * 397 ) ^ IsLeftButtonPressed . GetHashCode ( ) ;
199
+ hashCode = ( hashCode * 397 ) ^ IsMiddleButtonPressed . GetHashCode ( ) ;
200
+ hashCode = ( hashCode * 397 ) ^ IsRightButtonPressed . GetHashCode ( ) ;
201
+ hashCode = ( hashCode * 397 ) ^ IsXButton1Pressed . GetHashCode ( ) ;
202
+ hashCode = ( hashCode * 397 ) ^ IsXButton2Pressed . GetHashCode ( ) ;
203
+ hashCode = ( hashCode * 397 ) ^ IsPrimary . GetHashCode ( ) ;
204
+ hashCode = ( hashCode * 397 ) ^ MouseWheelDelta ;
205
+ hashCode = ( hashCode * 397 ) ^ Orientation . GetHashCode ( ) ;
206
+ hashCode = ( hashCode * 397 ) ^ TouchConfidence . GetHashCode ( ) ;
207
+ hashCode = ( hashCode * 397 ) ^ Twist . GetHashCode ( ) ;
208
+ hashCode = ( hashCode * 397 ) ^ XTilt . GetHashCode ( ) ;
209
+ hashCode = ( hashCode * 397 ) ^ YTilt . GetHashCode ( ) ;
210
+ hashCode = ( hashCode * 397 ) ^ ( int ) PointerUpdateKind ;
211
+ return hashCode ;
212
+ }
213
+ }
214
+
215
+ /// <summary>
216
+ /// Implements the ==.
217
+ /// </summary>
218
+ /// <param name="left">The left.</param>
219
+ /// <param name="right">The right.</param>
220
+ /// <returns>The result of the operator.</returns>
221
+ public static bool operator == ( PointerPoint left , PointerPoint right )
222
+ {
223
+ return left . Equals ( right ) ;
224
+ }
225
+
226
+ /// <summary>
227
+ /// Implements the !=.
228
+ /// </summary>
229
+ /// <param name="left">The left.</param>
230
+ /// <param name="right">The right.</param>
231
+ /// <returns>The result of the operator.</returns>
232
+ public static bool operator != ( PointerPoint left , PointerPoint right )
233
+ {
234
+ return ! left . Equals ( right ) ;
235
+ }
157
236
}
158
237
}
0 commit comments