mirror of
https://github.com/ckaczor/wpf-notifyicon.git
synced 2026-02-16 18:49:54 -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" />
|
<Compartment Name="Properties" Collapsed="true" />
|
||||||
</Compartments>
|
</Compartments>
|
||||||
<TypeIdentifier>
|
<TypeIdentifier>
|
||||||
<HashCode>N6qdVIeUdLmQtSUbiJhEGdYRjvJYXlhbEVBBKuPRO5s=</HashCode>
|
<HashCode>N6qdVIeUdLmQtSUbiJhEGdYRjvJYXlhbEVBDKuPRO5s=</HashCode>
|
||||||
<FileName>TaskbarIcon.cs</FileName>
|
<FileName>TaskbarIcon.cs</FileName>
|
||||||
</TypeIdentifier>
|
</TypeIdentifier>
|
||||||
<Lollipop Position="0.2" />
|
<Lollipop Position="0.2" />
|
||||||
</Class>
|
</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" />
|
<Font Name="Segoe UI" Size="9" />
|
||||||
</ClassDiagram>
|
</ClassDiagram>
|
||||||
@@ -782,9 +782,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected RoutedEventArgs RaiseTrayLeftMouseDownEvent()
|
protected RoutedEventArgs RaiseTrayLeftMouseDownEvent()
|
||||||
{
|
{
|
||||||
//first raise event, then command
|
|
||||||
RoutedEventArgs args = RaiseTrayLeftMouseDownEvent(this);
|
RoutedEventArgs args = RaiseTrayLeftMouseDownEvent(this);
|
||||||
LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter);
|
|
||||||
return args;
|
return args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -369,14 +369,21 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
Point cursorPosition = new Point();
|
Point cursorPosition = new Point();
|
||||||
WinApi.GetCursorPos(ref cursorPosition);
|
WinApi.GetCursorPos(ref cursorPosition);
|
||||||
|
|
||||||
|
bool isLeftClickCommandInvoked = false;
|
||||||
|
|
||||||
//show popup, if requested
|
//show popup, if requested
|
||||||
if (me.IsMatch(PopupActivation))
|
if (me.IsMatch(PopupActivation))
|
||||||
{
|
{
|
||||||
if (me == MouseEvent.IconLeftMouseUp)
|
if (me == MouseEvent.IconLeftMouseUp)
|
||||||
{
|
{
|
||||||
//show popup once we are sure it's not a double click
|
//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);
|
singleClickTimer.Change(WinApi.GetDoubleClickTime(), Timeout.Infinite);
|
||||||
|
isLeftClickCommandInvoked = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -392,8 +399,13 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
if (me == MouseEvent.IconLeftMouseUp)
|
if (me == MouseEvent.IconLeftMouseUp)
|
||||||
{
|
{
|
||||||
//show context menu once we are sure it's not a double click
|
//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);
|
singleClickTimer.Change(WinApi.GetDoubleClickTime(), Timeout.Infinite);
|
||||||
|
isLeftClickCommandInvoked = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -401,6 +413,15 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
ShowContextMenu(cursorPosition);
|
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
|
#endregion
|
||||||
|
|||||||
Reference in New Issue
Block a user