@@ -48,8 +48,8 @@ public void ReplacePrimaryColor(Swatch swatch, bool mahapps = false)
48
48
49
49
foreach ( var color in swatch . PrimaryHues )
50
50
{
51
- ReplaceEntry ( color . Name , color . Color ) ;
52
- ReplaceEntry ( color . Name + "Foreground" , color . Foreground ) ;
51
+ ReplaceEntry ( color . Name , color . Color , null , false ) ;
52
+ ReplaceEntry ( color . Name + "Foreground" , color . Foreground , null , false ) ;
53
53
}
54
54
55
55
ReplaceEntry ( "PrimaryHueLightBrush" , new SolidColorBrush ( light . Color ) ) ;
@@ -95,8 +95,8 @@ public void ReplaceAccentColor(Swatch swatch)
95
95
96
96
foreach ( var color in swatch . AccentHues )
97
97
{
98
- ReplaceEntry ( color . Name , color . Color ) ;
99
- ReplaceEntry ( color . Name + "Foreground" , color . Foreground ) ;
98
+ ReplaceEntry ( color . Name , color . Color , null , false ) ;
99
+ ReplaceEntry ( color . Name + "Foreground" , color . Foreground , null , false ) ;
100
100
}
101
101
102
102
ReplaceEntry ( "SecondaryAccentBrush" , new SolidColorBrush ( swatch . AccentExemplarHue . Color ) ) ;
@@ -134,29 +134,17 @@ private static bool ReplaceEntry(object entryName, object newValue, ResourceDict
134
134
{
135
135
if ( animate ) //Fade animation is enabled
136
136
{
137
- System . Windows . Threading . DispatcherTimer dispatcherTimer = new System . Windows . Threading . DispatcherTimer ( ) ;
138
- var brush = new SolidColorBrush ( ) ;
139
137
ColorAnimation animation = new ColorAnimation ( )
140
138
{
141
139
From = ( Color ) parentDictionary [ entryName ] , //The old color
142
140
To = ( Color ) newValue , //The new color
143
141
Duration = new Duration ( new TimeSpan ( 0 , 0 , 0 , 0 , DURATION_MS ) )
144
142
} ;
145
- animation . Completed += ( s , e ) =>
146
- {
147
- dispatcherTimer . Stop ( ) ;
148
- } ;
149
- brush . BeginAnimation ( SolidColorBrush . ColorProperty , animation ) ; //Begin the animation
150
-
151
- dispatcherTimer . Tick += ( sender , e ) => parentDictionary [ entryName ] = brush ;
152
- dispatcherTimer . Interval = new TimeSpan ( 0 , 0 , 0 , 0 , DURATION_MS / 60 ) ; //60 can be replaced with the animation frame rate.
153
- dispatcherTimer . Start ( ) ;
154
-
143
+ parentDictionary [ entryName ] = new SolidColorBrush ( ) ;
144
+ ( parentDictionary [ entryName ] as SolidColorBrush ) . BeginAnimation ( SolidColorBrush . ColorProperty , animation ) ; //Begin the animation
155
145
}
156
146
else
157
- {
158
147
parentDictionary [ entryName ] = newValue ;
159
- }
160
148
return true ;
161
149
}
162
150
foreach ( var dictionary in parentDictionary . MergedDictionaries )
0 commit comments