diff --git a/Source/Changelog.txt b/Source/Changelog.txt
index 95b7bf7..75ade54 100644
--- a/Source/Changelog.txt
+++ b/Source/Changelog.txt
@@ -3,6 +3,16 @@ Copyright (c) 2009 Philipp Sumi
Contact and Information: http://www.hardcodet.net
+----------------------------------------------------------------------------
+
+1.0.3 (2009.07.02)
+*****
+FIX Commands did not work with RoutedCommands which require an explicit target.
+ADD Added command target properties for both left and double click commands.
+ Allows to explicitly define another control as the target of a routed
+ command.
+
+
----------------------------------------------------------------------------
1.0.2 (2009.05.18)
diff --git a/Source/NotifyIconWpf/Properties/AssemblyInfo.cs b/Source/NotifyIconWpf/Properties/AssemblyInfo.cs
index c6bb619..6cb610e 100644
--- a/Source/NotifyIconWpf/Properties/AssemblyInfo.cs
+++ b/Source/NotifyIconWpf/Properties/AssemblyInfo.cs
@@ -53,5 +53,5 @@ using System.Windows.Markup;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.2.0")]
-[assembly: AssemblyFileVersion("1.0.2.0")]
+[assembly: AssemblyVersion("1.0.3.0")]
+[assembly: AssemblyFileVersion("1.0.3.0")]
diff --git a/Source/NotifyIconWpf/TaskbarIcon.Declarations.cs b/Source/NotifyIconWpf/TaskbarIcon.Declarations.cs
index 32d2996..a5f4128 100644
--- a/Source/NotifyIconWpf/TaskbarIcon.Declarations.cs
+++ b/Source/NotifyIconWpf/TaskbarIcon.Declarations.cs
@@ -712,6 +712,32 @@ namespace Hardcodet.Wpf.TaskbarNotification
#endregion
+ #region DoubleClickCommandTarget dependency property
+
+ ///
+ /// The target of the command that is fired if the notify icon is double clicked.
+ ///
+ public static readonly DependencyProperty DoubleClickCommandTargetProperty =
+ DependencyProperty.Register("DoubleClickCommandTarget",
+ typeof (IInputElement),
+ typeof (TaskbarIcon),
+ new FrameworkPropertyMetadata(null));
+
+ ///
+ /// A property wrapper for the
+ /// dependency property:
+ /// The target of the command that is fired if the notify icon is double clicked.
+ ///
+ public IInputElement DoubleClickCommandTarget
+ {
+ get { return (IInputElement) GetValue(DoubleClickCommandTargetProperty); }
+ set { SetValue(DoubleClickCommandTargetProperty, value); }
+ }
+
+ #endregion
+
+
+
#region LeftClickCommand dependency property
///
@@ -762,6 +788,31 @@ namespace Hardcodet.Wpf.TaskbarNotification
#endregion
+ #region LeftClickCommandTarget dependency property
+
+ ///
+ /// The target of the command that is fired if the notify icon is clicked.
+ ///
+ public static readonly DependencyProperty LeftClickCommandTargetProperty =
+ DependencyProperty.Register("LeftClickCommandTarget",
+ typeof (IInputElement),
+ typeof (TaskbarIcon),
+ new FrameworkPropertyMetadata(null));
+
+ ///
+ /// A property wrapper for the
+ /// dependency property:
+ /// The target of the command that is fired if the notify icon is clicked.
+ ///
+ public IInputElement LeftClickCommandTarget
+ {
+ get { return (IInputElement) GetValue(LeftClickCommandTargetProperty); }
+ set { SetValue(LeftClickCommandTargetProperty, value); }
+ }
+
+ #endregion
+
+
//EVENTS
@@ -1038,7 +1089,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
protected RoutedEventArgs RaiseTrayMouseDoubleClickEvent()
{
RoutedEventArgs args = RaiseTrayMouseDoubleClickEvent(this);
- DoubleClickCommand.ExecuteIfEnabled(DoubleClickCommandParameter);
+ DoubleClickCommand.ExecuteIfEnabled(DoubleClickCommandParameter, DoubleClickCommandTarget ?? this);
return args;
}
diff --git a/Source/NotifyIconWpf/TaskbarIcon.cs b/Source/NotifyIconWpf/TaskbarIcon.cs
index 875663f..b04a336 100644
--- a/Source/NotifyIconWpf/TaskbarIcon.cs
+++ b/Source/NotifyIconWpf/TaskbarIcon.cs
@@ -380,7 +380,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
//show popup once we are sure it's not a double click
delayedTimerAction = () =>
{
- LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter);
+ LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter, LeftClickCommandTarget ?? this);
ShowTrayPopup(cursorPosition);
};
singleClickTimer.Change(WinApi.GetDoubleClickTime(), Timeout.Infinite);
@@ -402,7 +402,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
//show context menu once we are sure it's not a double click
delayedTimerAction = () =>
{
- LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter);
+ LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter, LeftClickCommandTarget ?? this);
ShowContextMenu(cursorPosition);
};
singleClickTimer.Change(WinApi.GetDoubleClickTime(), Timeout.Infinite);
@@ -419,7 +419,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
if (me == MouseEvent.IconLeftMouseUp && !isLeftClickCommandInvoked)
{
//show context menu once we are sure it's not a double click
- delayedTimerAction = () => LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter);
+ delayedTimerAction = () => LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter, LeftClickCommandTarget ?? this);
singleClickTimer.Change(WinApi.GetDoubleClickTime(), Timeout.Infinite);
}
diff --git a/Source/NotifyIconWpf/Util.cs b/Source/NotifyIconWpf/Util.cs
index c7ef9f6..771287d 100644
--- a/Source/NotifyIconWpf/Util.cs
+++ b/Source/NotifyIconWpf/Util.cs
@@ -27,7 +27,6 @@ using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows;
-using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Resources;
@@ -263,10 +262,18 @@ namespace Hardcodet.Wpf.TaskbarNotification
/// The command to be executed, or a null reference.
/// An optional parameter that is associated with
/// the command.
- public static void ExecuteIfEnabled(this ICommand command, object commandParameter)
+ /// The target element on which to raise the command.
+ public static void ExecuteIfEnabled(this ICommand command, object commandParameter, IInputElement target)
{
if (command == null) return;
- if (command.CanExecute(commandParameter))
+
+ RoutedCommand rc = command as RoutedCommand;
+ if (rc != null)
+ {
+ //routed commands work on a target
+ if (rc.CanExecute(commandParameter, target)) rc.Execute(commandParameter, target);
+ }
+ else if (command.CanExecute(commandParameter))
{
command.Execute(commandParameter);
}
diff --git a/Source/Sample Project/Tutorials/06 - Commands/CommandWindow.xaml b/Source/Sample Project/Tutorials/06 - Commands/CommandWindow.xaml
index 8a9a606..24bef08 100644
--- a/Source/Sample Project/Tutorials/06 - Commands/CommandWindow.xaml
+++ b/Source/Sample Project/Tutorials/06 - Commands/CommandWindow.xaml
@@ -5,9 +5,12 @@
xmlns:tb="http://www.hardcodet.net/taskbar"
xmlns:local="clr-namespace:Samples.Tutorials.Commands"
Height="300"
- Width="300">
+ Width="300"
+ xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
+ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ mc:Ignorable="d">
-
+
-
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Source/Sample Project/Tutorials/06 - Commands/CommandWindow.xaml.cs b/Source/Sample Project/Tutorials/06 - Commands/CommandWindow.xaml.cs
index abe9b6f..8ad80a6 100644
--- a/Source/Sample Project/Tutorials/06 - Commands/CommandWindow.xaml.cs
+++ b/Source/Sample Project/Tutorials/06 - Commands/CommandWindow.xaml.cs
@@ -23,10 +23,12 @@ namespace Samples.Tutorials.Commands
InitializeComponent();
}
+
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
- MyNotifyIcon.Dispose();
+ CustomCommandNotifyIcon.Dispose();
+ RoutedCommandNotifyIcon.Dispose();
base.OnClosing(e);
}