mirror of
https://github.com/ckaczor/wpf-notifyicon.git
synced 2026-01-16 01:35:38 -05:00
Code modernising (#8)
* Applied some code conventions, used more current language features which should improve readability and making it easier to re-factor / modify. Also fixed some typos in documentation. * Changes based on PR conversation for the SystemInfo * Some modifications due to conversations on the PR, especially I removed the FlagsAttribute on the BalloonFlags. * Removed Silverlight targeting in code.
This commit is contained in:
@@ -18,13 +18,13 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
||||
/// <param name="args">RoutedEventArgs to use when raising the event</param>
|
||||
internal static void RaiseEvent(DependencyObject target, RoutedEventArgs args)
|
||||
{
|
||||
if (target is UIElement)
|
||||
if (target is UIElement uiElement)
|
||||
{
|
||||
(target as UIElement).RaiseEvent(args);
|
||||
uiElement.RaiseEvent(args);
|
||||
}
|
||||
else if (target is ContentElement)
|
||||
else if (target is ContentElement contentElement)
|
||||
{
|
||||
(target as ContentElement).RaiseEvent(args);
|
||||
contentElement.RaiseEvent(args);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,18 +37,13 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
||||
/// <param name="handler">Event handler to be added</param>
|
||||
internal static void AddHandler(DependencyObject element, RoutedEvent routedEvent, Delegate handler)
|
||||
{
|
||||
UIElement uie = element as UIElement;
|
||||
if (uie != null)
|
||||
if (element is UIElement uie)
|
||||
{
|
||||
uie.AddHandler(routedEvent, handler);
|
||||
}
|
||||
else
|
||||
else if (element is ContentElement ce)
|
||||
{
|
||||
ContentElement ce = element as ContentElement;
|
||||
if (ce != null)
|
||||
{
|
||||
ce.AddHandler(routedEvent, handler);
|
||||
}
|
||||
ce.AddHandler(routedEvent, handler);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,18 +56,13 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
||||
/// <param name="handler">Event handler to be removed</param>
|
||||
internal static void RemoveHandler(DependencyObject element, RoutedEvent routedEvent, Delegate handler)
|
||||
{
|
||||
UIElement uie = element as UIElement;
|
||||
if (uie != null)
|
||||
if (element is UIElement uie)
|
||||
{
|
||||
uie.RemoveHandler(routedEvent, handler);
|
||||
}
|
||||
else
|
||||
else if (element is ContentElement ce)
|
||||
{
|
||||
ContentElement ce = element as ContentElement;
|
||||
if (ce != null)
|
||||
{
|
||||
ce.RemoveHandler(routedEvent, handler);
|
||||
}
|
||||
ce.RemoveHandler(routedEvent, handler);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user