@@ -8,6 +8,12 @@ public sealed partial class FlipSide : Control
88 private const string PART_Side1Content = "Side1Content" ;
99 private const string PART_Side2Content = "Side2Content" ;
1010 private const string PART_LayoutRoot = "LayoutRoot" ;
11+
12+ public bool IsFlipped
13+ {
14+ get { return ( bool ) GetValue ( IsFlippedProperty ) ; }
15+ set { SetValue ( IsFlippedProperty , value ) ; }
16+ }
1117 public static readonly DependencyProperty IsFlippedProperty =
1218 DependencyProperty . Register ( nameof ( IsFlipped ) , typeof ( bool ) , typeof ( FlipSide ) , new PropertyMetadata ( false , ( s , a ) =>
1319 {
@@ -20,12 +26,27 @@ public sealed partial class FlipSide : Control
2026 }
2127 } ) ) ;
2228
29+ public object Side1
30+ {
31+ get { return ( object ) GetValue ( Side1Property ) ; }
32+ set { SetValue ( Side1Property , value ) ; }
33+ }
2334 public static readonly DependencyProperty Side1Property =
2435 DependencyProperty . Register ( nameof ( Side1 ) , typeof ( object ) , typeof ( FlipSide ) , new PropertyMetadata ( null ) ) ;
2536
37+ public object Side2
38+ {
39+ get { return ( object ) GetValue ( Side2Property ) ; }
40+ set { SetValue ( Side2Property , value ) ; }
41+ }
2642 public static readonly DependencyProperty Side2Property =
2743 DependencyProperty . Register ( nameof ( Side2 ) , typeof ( object ) , typeof ( FlipSide ) , new PropertyMetadata ( null ) ) ;
2844
45+ public Vector2 Axis
46+ {
47+ get { return ( Vector2 ) GetValue ( AxisProperty ) ; }
48+ set { SetValue ( AxisProperty , value ) ; }
49+ }
2950 public static readonly DependencyProperty AxisProperty =
3051 DependencyProperty . Register ( nameof ( Axis ) , typeof ( Vector2 ) , typeof ( FlipSide ) , new PropertyMetadata ( new Vector2 ( 0 , 1 ) , ( d , e ) =>
3152 {
@@ -37,7 +58,11 @@ public sealed partial class FlipSide : Control
3758 }
3859 } ) ) ;
3960
40-
61+ public FlipOrientationMode FlipOrientation
62+ {
63+ get { return ( FlipOrientationMode ) GetValue ( FlipOrientationProperty ) ; }
64+ set { SetValue ( FlipOrientationProperty , value ) ; }
65+ }
4166 public static readonly DependencyProperty FlipOrientationProperty =
4267 DependencyProperty . Register ( nameof ( FlipOrientation ) , typeof ( FlipOrientationMode ) , typeof ( FlipSide ) , new PropertyMetadata ( FlipOrientationMode . Horizontal , ( d , e ) =>
4368 {
@@ -56,32 +81,31 @@ public sealed partial class FlipSide : Control
5681 }
5782 } ) ) ;
5883
59- public bool IsFlipped
84+ public float AnimationDampingRatio
6085 {
61- get { return ( bool ) GetValue ( IsFlippedProperty ) ; }
62- set { SetValue ( IsFlippedProperty , value ) ; }
86+ get { return ( float ) GetValue ( AnimationDampingRatioProperty ) ; }
87+ set { SetValue ( AnimationDampingRatioProperty , value ) ; }
6388 }
6489
65- public object Side1
66- {
67- get { return ( object ) GetValue ( Side1Property ) ; }
68- set { SetValue ( Side1Property , value ) ; }
69- }
90+ public static readonly DependencyProperty AnimationDampingRatioProperty =
91+ DependencyProperty . Register ( nameof ( AnimationDampingRatio ) , typeof ( float ) , typeof ( FlipSide ) , new PropertyMetadata ( 0.5f , OnAnimationChanged ) ) ;
7092
71- public object Side2
93+ public TimeSpan AnimationDuration
7294 {
73- get { return ( object ) GetValue ( Side2Property ) ; }
74- set { SetValue ( Side2Property , value ) ; }
95+ get { return ( TimeSpan ) GetValue ( AnimationDurationProperty ) ; }
96+ set { SetValue ( AnimationDurationProperty , value ) ; }
7597 }
76- public Vector2 Axis
77- {
78- get { return ( Vector2 ) GetValue ( AxisProperty ) ; }
79- set { SetValue ( AxisProperty , value ) ; }
80- }
81- public FlipOrientationMode FlipOrientation
98+
99+ public static readonly DependencyProperty AnimationDurationProperty =
100+ DependencyProperty . Register ( nameof ( AnimationDuration ) , typeof ( TimeSpan ) , typeof ( FlipSide ) , new PropertyMetadata ( TimeSpan . FromMilliseconds ( 200 ) , OnAnimationChanged ) ) ;
101+
102+ private static void OnAnimationChanged ( DependencyObject d , DependencyPropertyChangedEventArgs e )
82103 {
83- get { return ( FlipOrientationMode ) GetValue ( FlipOrientationProperty ) ; }
84- set { SetValue ( FlipOrientationProperty , value ) ; }
104+ var ctl = ( FlipSide ) d ;
105+ if ( ctl != null )
106+ {
107+ ctl . InitComposition ( ) ;
108+ }
85109 }
86110
87111 private Grid LayoutRoot ;
@@ -132,13 +156,13 @@ private void InitComposition()
132156 OnIsFlippedChanged ( ) ;
133157
134158 springAnimation1 = compositor . CreateSpringScalarAnimation ( ) ;
135- springAnimation1 . DampingRatio = 0.5f ;
136- springAnimation1 . Period = TimeSpan . FromMilliseconds ( 200 ) ;
159+ springAnimation1 . DampingRatio = AnimationDampingRatio ;
160+ springAnimation1 . Period = AnimationDuration ;
137161 springAnimation1 . FinalValue = 180f ;
138162
139163 springAnimation2 = compositor . CreateSpringScalarAnimation ( ) ;
140- springAnimation2 . DampingRatio = 0.5f ;
141- springAnimation2 . Period = TimeSpan . FromMilliseconds ( 200 ) ;
164+ springAnimation2 . DampingRatio = AnimationDampingRatio ;
165+ springAnimation2 . Period = AnimationDuration ;
142166 springAnimation2 . FinalValue = 180f ;
143167
144168 UpdateAxis ( Side1Content , Axis ) ;
0 commit comments