WPF NotifyIcon

--------------
CHG   LeftClickCommand now only uses the single click timer in order to delay
      command executation until it's sure that the user does not double-click.

git-svn-id: https://svn.evolvesoftware.ch/repos/evolve.net/WPF/NotifyIcon@102 9f600761-6f11-4665-b6dc-0185e9171623
This commit is contained in:
Philipp Sumi
2009-05-13 13:26:00 +00:00
parent f349d3d339
commit b91a186b2b
3 changed files with 31 additions and 5 deletions

View File

@@ -8,10 +8,17 @@
<Compartment Name="Properties" Collapsed="true" />
</Compartments>
<TypeIdentifier>
<HashCode>N6qdVIeUdLmQtSUbiJhEGdYRjvJYXlhbEVBBKuPRO5s=</HashCode>
<HashCode>N6qdVIeUdLmQtSUbiJhEGdYRjvJYXlhbEVBDKuPRO5s=</HashCode>
<FileName>TaskbarIcon.cs</FileName>
</TypeIdentifier>
<Lollipop Position="0.2" />
</Class>
<Enum Name="Hardcodet.Wpf.TaskbarNotification.PopupActivationMode">
<Position X="5.25" Y="0.5" Width="2" />
<TypeIdentifier>
<HashCode>ABAEAAAAAAAAAAABAAAAAAAAAAAAAAAAAIAKAIAAAAA=</HashCode>
<FileName>PopupActivationMode.cs</FileName>
</TypeIdentifier>
</Enum>
<Font Name="Segoe UI" Size="9" />
</ClassDiagram>

View File

@@ -782,9 +782,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
/// </summary>
protected RoutedEventArgs RaiseTrayLeftMouseDownEvent()
{
//first raise event, then command
RoutedEventArgs args = RaiseTrayLeftMouseDownEvent(this);
LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter);
return args;
}

View File

@@ -369,14 +369,21 @@ namespace Hardcodet.Wpf.TaskbarNotification
Point cursorPosition = new Point();
WinApi.GetCursorPos(ref cursorPosition);
bool isLeftClickCommandInvoked = false;
//show popup, if requested
if (me.IsMatch(PopupActivation))
{
if (me == MouseEvent.IconLeftMouseUp)
{
//show popup once we are sure it's not a double click
delayedTimerAction = () => ShowTrayPopup(cursorPosition);
delayedTimerAction = () =>
{
LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter);
ShowTrayPopup(cursorPosition);
};
singleClickTimer.Change(WinApi.GetDoubleClickTime(), Timeout.Infinite);
isLeftClickCommandInvoked = true;
}
else
{
@@ -392,8 +399,13 @@ namespace Hardcodet.Wpf.TaskbarNotification
if (me == MouseEvent.IconLeftMouseUp)
{
//show context menu once we are sure it's not a double click
delayedTimerAction = () => ShowContextMenu(cursorPosition);
delayedTimerAction = () =>
{
LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter);
ShowContextMenu(cursorPosition);
};
singleClickTimer.Change(WinApi.GetDoubleClickTime(), Timeout.Infinite);
isLeftClickCommandInvoked = true;
}
else
{
@@ -401,6 +413,15 @@ namespace Hardcodet.Wpf.TaskbarNotification
ShowContextMenu(cursorPosition);
}
}
//make sure the left click command is invoked on mouse clicks
if (me == MouseEvent.IconLeftMouseUp && !isLeftClickCommandInvoked)
{
//show context menu once we are sure it's not a double click
delayedTimerAction = () => LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter);
singleClickTimer.Change(WinApi.GetDoubleClickTime(), Timeout.Infinite);
}
}
#endregion