2 // Moonlight List (moonlight-list@lists.ximian.com)
4 // Copyright 2007 Novell, Inc.
6 // Permission is hereby granted, free of charge, to any person obtaining
7 // a copy of this software and associated documentation files (the
8 // "Software"), to deal in the Software without restriction, including
9 // without limitation the rights to use, copy, modify, merge, publish,
10 // distribute, sublicense, and/or sell copies of the Software, and to
11 // permit persons to whom the Software is furnished to do so, subject to
12 // the following conditions:
14 // The above copyright notice and this permission notice shall be
15 // included in all copies or substantial portions of the Software.
17 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 using System
.Threading
;
29 using System
.Windows
.Media
;
30 using System
.Windows
.Input
;
31 using System
.Runtime
.InteropServices
;
34 namespace System
.Windows
.Input
36 public struct StylusPoint
: INativeDependencyObjectWrapper
38 // FIXME: we shouldn't implement INativeDependencyObjectWrapper and have toggle ref behaviour,
39 // since a struct can't have a destructor, we'll always end up leaking the native object.
40 // The right thing to do is probably to just have a managed struct with no native representation.
41 internal StylusPoint (IntPtr raw
)
46 public StylusPoint (double x
, double y
) : this (NativeMethods
.stylus_point_new ())
52 public float PressureFactor
{
53 get { return (float) ((INativeDependencyObjectWrapper)this).GetValue (PressureFactorProperty); }
54 set { ((INativeDependencyObjectWrapper)this).SetValue (PressureFactorProperty, value); }
58 get { return (double) ((INativeDependencyObjectWrapper)this).GetValue (XProperty); }
59 set { ((INativeDependencyObjectWrapper)this).SetValue (XProperty, value); }
63 get { return (double) ((INativeDependencyObjectWrapper)this).GetValue (YProperty); }
64 set { ((INativeDependencyObjectWrapper)this).SetValue (YProperty, value); }
67 private static readonly DependencyProperty PressureFactorProperty
=
68 DependencyProperty
.Lookup (Kind
.STYLUSPOINT
, "PressureFactor", typeof (float));
70 private static readonly DependencyProperty XProperty
=
71 DependencyProperty
.Lookup (Kind
.STYLUSPOINT
, "X", typeof (double));
73 private static readonly DependencyProperty YProperty
=
74 DependencyProperty
.Lookup (Kind
.STYLUSPOINT
, "Y", typeof (double));
76 #region "INativeDependencyObjectWrapper interface"
79 internal IntPtr NativeHandle
{
80 get { return _native; }
82 if (_native
!= IntPtr
.Zero
) {
83 throw new InvalidOperationException ("Application.native is already set");
88 NativeDependencyObjectHelper
.AddNativeMapping (value, this);
92 IntPtr INativeEventObjectWrapper
.NativeHandle
{
93 get { return NativeHandle; }
94 set { NativeHandle = value; }
97 object INativeDependencyObjectWrapper
.GetValue (DependencyProperty dp
)
99 return NativeDependencyObjectHelper
.GetValue (this, dp
);
102 void INativeDependencyObjectWrapper
.SetValue (DependencyProperty dp
, object value)
104 NativeDependencyObjectHelper
.SetValue (this, dp
, value);
107 object INativeDependencyObjectWrapper
.GetAnimationBaseValue (DependencyProperty dp
)
109 return NativeDependencyObjectHelper
.GetAnimationBaseValue (this, dp
);
112 object INativeDependencyObjectWrapper
.ReadLocalValue (DependencyProperty dp
)
114 return NativeDependencyObjectHelper
.ReadLocalValue (this, dp
);
117 void INativeDependencyObjectWrapper
.ClearValue (DependencyProperty dp
)
119 NativeDependencyObjectHelper
.ClearValue (this, dp
);
122 Kind INativeEventObjectWrapper
.GetKind ()
124 return Kind
.STYLUSPOINT
;
127 bool INativeDependencyObjectWrapper
.CheckAccess ()
129 return Thread
.CurrentThread
== DependencyObject
.moonlight_thread
;