Skip to content

Commit fe8de2d

Browse files
committed
uwp stuff
2 parents 9626e26 + a27409f commit fe8de2d

File tree

3 files changed

+148
-0
lines changed

3 files changed

+148
-0
lines changed

MainDemo.Uwp/MainPage.xaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
9696
<Grid Background="Transparent">
9797
<Canvas IsHitTestVisible="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
9898
<Ellipse x:Name="ClickEllipse" Fill="{TemplateBinding Feedback}" Opacity="1" Width="10" Height="10"
99+
<<<<<<< HEAD
99100
Canvas.Left="10"
100101
Canvas.Top="10"
101102
RenderTransformOrigin=".5,.5">
@@ -106,6 +107,13 @@
106107
<RotateTransform/>
107108
<TranslateTransform x:Name="TranslateTransform"/>
108109
</TransformGroup>
110+
=======
111+
Canvas.Left="20"
112+
Canvas.Top="10"
113+
RenderTransformOrigin=".5,.5">
114+
<Ellipse.RenderTransform>
115+
<TranslateTransform x:Name="TranslateTransform"/>
116+
>>>>>>> a27409f27850f2f66b86905963924270e29b69a7
109117
</Ellipse.RenderTransform>
110118
</Ellipse>
111119
</Canvas>
@@ -136,12 +144,15 @@
136144
<Button Margin="8 0 0 0" Width="100" Style="{StaticResource MaterialDesignRaisedDarkButton}">DARK</Button>
137145
<Button Margin="8 0 0 0" Width="100" Style="{StaticResource MaterialDesignRaisedAccentButton}">ACCENT</Button>
138146
</StackPanel>
147+
<<<<<<< HEAD
139148
<Button Style="{StaticResource ButtonStyle1}">Normal</Button>
140149
<Border Background="Black">
141150
<uwp:Ripple Padding="26" Style="{StaticResource RippleStyle1}">
142151
<TextBlock Foreground="White">Ballz</TextBlock>
143152
</uwp:Ripple>
144153
</Border>
154+
=======
155+
>>>>>>> a27409f27850f2f66b86905963924270e29b69a7
145156
</StackPanel>
146157
</Grid>
147158
</Page>

MaterialDesignThemes.Uwp/Ripple.cs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
using System.Linq;
55
using System.Runtime.CompilerServices;
66
using System.Runtime.InteropServices.WindowsRuntime;
7+
<<<<<<< HEAD
8+
=======
9+
using Windows.Devices.Input;
10+
>>>>>>> a27409f27850f2f66b86905963924270e29b69a7
711
using Windows.UI.Xaml;
812
using Windows.UI.Xaml.Controls;
913
using Windows.UI.Xaml.Data;
@@ -17,12 +21,28 @@ namespace MaterialDesignThemes.Uwp
1721
[TemplateVisualState(GroupName = "CommonStates", Name = "Pressed")]
1822
public sealed class Ripple : ContentControl, INotifyPropertyChanged
1923
{
24+
<<<<<<< HEAD
2025
private double _pointerPressedY;
2126
private double _pointerPressedX;
27+
=======
28+
private double _rippleSize;
29+
private double _rippleX;
30+
private double _rippleY;
31+
>>>>>>> a27409f27850f2f66b86905963924270e29b69a7
2232

2333
public Ripple()
2434
{
2535
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
2646
}
2747

2848
public static readonly DependencyProperty FeedbackProperty = DependencyProperty.Register(
@@ -43,15 +63,29 @@ protected override void OnApplyTemplate()
4363

4464
protected override void OnPointerPressed(PointerRoutedEventArgs e)
4565
{
66+
<<<<<<< HEAD
4667
var point = e.GetCurrentPoint(this);
4768
PointerPressedX = point.Position.X;
4869
PointerPressedY = point.Position.Y;
4970

5071
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
5184

5285
base.OnPointerPressed(e);
5386
}
5487

88+
<<<<<<< HEAD
5589
protected override void OnPointerReleased(PointerRoutedEventArgs e)
5690
{
5791
VisualStateManager.GoToState(this, "Normal", false);
@@ -66,17 +100,56 @@ private set
66100
{
67101
if (_pointerPressedY == value) return;
68102
_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
69132
OnPropertyChanged();
70133
}
71134
}
72135

136+
<<<<<<< HEAD
73137
public double PointerPressedX
74138
{
75139
get { return _pointerPressedX; }
76140
private set
77141
{
78142
if (_pointerPressedX == value) return;
79143
_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
80153
OnPropertyChanged();
81154
}
82155
}

MaterialDesignThemes.Uwp/Themes/Generic.xaml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<Setter.Value>
3030
<ControlTemplate TargetType="local:Ripple">
3131
<Grid Background="Transparent">
32+
<<<<<<< HEAD
3233
<Canvas IsHitTestVisible="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
3334
<Ellipse x:Name="ClickEllipse" Fill="{TemplateBinding Feedback}" Opacity="1" Width="10" Height="10"
3435
Canvas.Left="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=PointerPressedX}"
@@ -37,6 +38,69 @@
3738
<Ellipse.RenderTransform>
3839
<TransformGroup>
3940
<ScaleTransform />
41+
=======
42+
<VisualStateManager.VisualStateGroups>
43+
<VisualStateGroup x:Name="CommonStates">
44+
<VisualStateGroup.Transitions>
45+
<VisualTransition From="Normal" To="MousePressed">
46+
<Storyboard>
47+
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="ScaleTransform">
48+
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
49+
<EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="1">
50+
<EasingDoubleKeyFrame.EasingFunction>
51+
<SineEase EasingMode="EaseInOut" />
52+
</EasingDoubleKeyFrame.EasingFunction>
53+
</EasingDoubleKeyFrame>
54+
</DoubleAnimationUsingKeyFrames>
55+
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="ScaleY" Storyboard.TargetName="ScaleTransform">
56+
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
57+
<EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="1">
58+
<EasingDoubleKeyFrame.EasingFunction>
59+
<SineEase EasingMode="EaseInOut" />
60+
</EasingDoubleKeyFrame.EasingFunction>
61+
</EasingDoubleKeyFrame>
62+
</DoubleAnimationUsingKeyFrames>
63+
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="ClickEllipse">
64+
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
65+
<EasingDoubleKeyFrame KeyTime="0:0:0.05" Value=".26"/>
66+
<EasingDoubleKeyFrame KeyTime="0:0:0.2" Value=".26"/>
67+
<EasingDoubleKeyFrame KeyTime="0:0:0.4" Value="0"/>
68+
</DoubleAnimationUsingKeyFrames>
69+
</Storyboard>
70+
</VisualTransition>
71+
<VisualTransition From="MousePressed" To="Normal">
72+
<Storyboard>
73+
<DoubleAnimation Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="ScaleTransform" From="1" To="0" Duration="0:0:0" />
74+
<DoubleAnimation Storyboard.TargetProperty="ScaleY" Storyboard.TargetName="ScaleTransform" From="1" To="0" Duration="0:0:0" />
75+
</Storyboard>
76+
</VisualTransition>
77+
</VisualStateGroup.Transitions>
78+
<VisualState x:Name="Normal"/>
79+
<VisualState x:Name="MousePressed">
80+
<Storyboard>
81+
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="ScaleX" Storyboard.TargetName="ScaleTransform">
82+
<DiscreteDoubleKeyFrame KeyTime="0" Value="1" />
83+
</DoubleAnimationUsingKeyFrames>
84+
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="ScaleY" Storyboard.TargetName="ScaleTransform">
85+
<DiscreteDoubleKeyFrame KeyTime="0" Value="1" />
86+
</DoubleAnimationUsingKeyFrames>
87+
88+
</Storyboard>
89+
</VisualState>
90+
</VisualStateGroup>
91+
</VisualStateManager.VisualStateGroups>
92+
<Canvas IsHitTestVisible="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
93+
<Ellipse x:Name="ClickEllipse" Fill="{TemplateBinding Feedback}" Opacity="0"
94+
Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=RippleSize}"
95+
Height="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=RippleSize}"
96+
Canvas.Left="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=RippleX}"
97+
Canvas.Top="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=RippleY}"
98+
RenderTransformOrigin=".5,.5">
99+
<Ellipse.RenderTransform>
100+
<TransformGroup>
101+
<ScaleTransform x:Name="ScaleTransform"
102+
/>
103+
>>>>>>> a27409f27850f2f66b86905963924270e29b69a7
40104
<SkewTransform/>
41105
<RotateTransform/>
42106
<TranslateTransform x:Name="TranslateTransform"/>

0 commit comments

Comments
 (0)