4
4
using System . Linq ;
5
5
using System . Runtime . CompilerServices ;
6
6
using System . Runtime . InteropServices . WindowsRuntime ;
7
+ < << << << HEAD
8
+ == = == ==
9
+ using Windows. Devices . Input ;
10
+ >>> > >>> a27409f27850f2f66b86905963924270e29b69a7
7
11
using Windows. UI . Xaml ;
8
12
using Windows . UI . Xaml . Controls ;
9
13
using Windows . UI . Xaml . Data ;
@@ -17,12 +21,28 @@ namespace MaterialDesignThemes.Uwp
17
21
[ TemplateVisualState ( GroupName = "CommonStates" , Name = "Pressed" ) ]
18
22
public sealed class Ripple : ContentControl , INotifyPropertyChanged
19
23
{
24
+ < << << << HEAD
20
25
private double _pointerPressedY;
21
26
private double _pointerPressedX ;
27
+ = == == ==
28
+ private double _rippleSize ;
29
+ private double _rippleX ;
30
+ private double _rippleY ;
31
+ > >>> >>> a27409f27850f2f66b86905963924270e29b69a7
22
32
23
33
public Ripple( )
24
34
{
25
35
DefaultStyleKey = typeof ( Ripple ) ;
36
+ < << << << HEAD
37
+ == = == ==
38
+ SizeChanged += OnSizeChanged ;
39
+ }
40
+
41
+ private void OnSizeChanged ( object sender , SizeChangedEventArgs sizeChangedEventArgs )
42
+ {
43
+ RippleSize = Math . Max ( sizeChangedEventArgs . NewSize . Width , sizeChangedEventArgs . NewSize . Height ) * RippleSizeMultiplier ;
44
+ Clip = new RectangleGeometry ( ) { Rect = new Windows . Foundation . Rect ( 0 , 0 , sizeChangedEventArgs . NewSize . Width , sizeChangedEventArgs . NewSize . Height ) } ;
45
+ > >>> >>> a27409f27850f2f66b86905963924270e29b69a7
26
46
}
27
47
28
48
public static readonly DependencyProperty FeedbackProperty = DependencyProperty . Register (
@@ -43,15 +63,29 @@ protected override void OnApplyTemplate()
43
63
44
64
protected override void OnPointerPressed ( PointerRoutedEventArgs e )
45
65
{
66
+ < << << << HEAD
46
67
var point = e . GetCurrentPoint ( this ) ;
47
68
PointerPressedX = point . Position . X ;
48
69
PointerPressedY = point . Position . Y ;
49
70
50
71
VisualStateManager . GoToState ( this , "Pressed" , false ) ;
72
+ = == == ==
73
+ if ( e . Pointer . PointerDeviceType == PointerDeviceType . Mouse )
74
+ {
75
+ var point = e . GetCurrentPoint ( this ) ;
76
+
77
+ RippleX = point . Position . X - RippleSize / 2 ;
78
+ RippleY = point . Position . Y - RippleSize / 2 ;
79
+
80
+ VisualStateManager . GoToState ( this , "Normal" , true ) ;
81
+ VisualStateManager . GoToState ( this , "MousePressed" , true ) ;
82
+ }
83
+ > >>> >>> a27409f27850f2f66b86905963924270e29b69a7
51
84
52
85
base . OnPointerPressed( e ) ;
53
86
}
54
87
88
+ < << << << HEAD
55
89
protected override void OnPointerReleased ( PointerRoutedEventArgs e )
56
90
{
57
91
VisualStateManager . GoToState ( this , "Normal" , false ) ;
@@ -66,17 +100,56 @@ private set
66
100
{
67
101
if ( _pointerPressedY == value ) return ;
68
102
_pointerPressedY = value ;
103
+ = == == ==
104
+ public static readonly DependencyProperty RippleSizeMultiplierProperty = DependencyProperty . Register (
105
+ "RippleSizeMultiplier" , typeof ( double ) , typeof ( Ripple ) , new PropertyMetadata ( 1.75 ) ) ;
106
+
107
+ public double RippleSizeMultiplier
108
+ {
109
+ get { return ( double ) GetValue ( RippleSizeMultiplierProperty ) ; }
110
+ set { SetValue ( RippleSizeMultiplierProperty , value ) ; }
111
+ }
112
+
113
+ public double RippleSize
114
+ {
115
+ get { return _rippleSize ; }
116
+ private set
117
+ {
118
+ if ( _rippleSize == value ) return ;
119
+ _rippleSize = value ;
120
+ OnPropertyChanged ( ) ;
121
+ }
122
+ }
123
+
124
+ public double RippleY
125
+ {
126
+ get { return _rippleY ; }
127
+ private set
128
+ {
129
+ if ( _rippleY == value ) return ;
130
+ _rippleY = value ;
131
+ > >>> >>> a27409f27850f2f66b86905963924270e29b69a7
69
132
OnPropertyChanged ( ) ;
70
133
}
71
134
}
72
135
136
+ < << << << HEAD
73
137
public double PointerPressedX
74
138
{
75
139
get { return _pointerPressedX ; }
76
140
private set
77
141
{
78
142
if ( _pointerPressedX == value ) return ;
79
143
_pointerPressedX = value ;
144
+ = == == ==
145
+ public double RippleX
146
+ {
147
+ get { return _rippleX ; }
148
+ private set
149
+ {
150
+ if ( _rippleX == value ) return ;
151
+ _rippleX = value ;
152
+ > >>> >>> a27409f27850f2f66b86905963924270e29b69a7
80
153
OnPropertyChanged ( ) ;
81
154
}
82
155
}
0 commit comments