Skip to content

Commit ad1ce6d

Browse files
committed
Removed try catch
Didn't know that c# trick you told
1 parent 9087b96 commit ad1ce6d

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

MaterialDesignThemes.Wpf/PaletteHelper.cs

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -159,23 +159,15 @@ private static bool ReplaceEntry(object entryName, object newValue, ResourceDict
159159

160160
if (parentDictionary.Contains(entryName))
161161
{
162-
if (animate & parentDictionary[entryName] != null & GetPowerState().ACLineStatus == ACLineStatus.Online) //Fade animation is enabled and value is not null.
162+
if (animate & parentDictionary[entryName] != null & GetPowerState().ACLineStatus == ACLineStatus.Online & parentDictionary[entryName] as SolidColorBrush != null) //Fade animation is enabled , type is solidcolorbrush and value is not null.
163163
{
164-
try
164+
ColorAnimation animation = new ColorAnimation()
165165
{
166-
ColorAnimation animation = new ColorAnimation()
167-
{
168-
From = ((SolidColorBrush)parentDictionary[entryName]).Color,//The old color
169-
To = ((SolidColorBrush)newValue).Color, //The new color
170-
Duration = new Duration(new TimeSpan(0,0,0,0,DURATION_MS)) //Set the duration
171-
};
172-
(parentDictionary[entryName] as SolidColorBrush).BeginAnimation(SolidColorBrush.ColorProperty, animation); //Begin the animation
173-
}
174-
catch
175-
{
176-
System.Diagnostics.Debug.WriteLine(@"The argument :" + nameof(newValue) + " is not a brush.");
177-
parentDictionary[entryName] = newValue; //Set the value normally if type is incorrect
178-
}
166+
From = ((SolidColorBrush)parentDictionary[entryName]).Color,//The old color
167+
To = ((SolidColorBrush)newValue).Color, //The new color
168+
Duration = new Duration(new TimeSpan(0,0,0,0,DURATION_MS)) //Set the duration
169+
};
170+
(parentDictionary[entryName] as SolidColorBrush).BeginAnimation(SolidColorBrush.ColorProperty, animation); //Begin the animation
179171
}
180172
else
181173
parentDictionary[entryName] = newValue; //Set value normally

0 commit comments

Comments
 (0)