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" /> <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>

View File

@@ -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;
} }

View File

@@ -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