mirror of
https://github.com/ckaczor/wpf-notifyicon.git
synced 2026-02-16 11:08:30 -05:00
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:
@@ -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>
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user