mirror of
https://github.com/ckaczor/wpf-notifyicon.git
synced 2026-02-16 11:08:30 -05:00
Added "NoLeftClickDelay" TaskbarIcon dependency property, to optionally make left clicks work without delay.
This commit is contained in:
@@ -828,6 +828,33 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region NoLeftClickDelay dependency property
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set to true to make left clicks work without delay.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly DependencyProperty NoLeftClickDelayProperty =
|
||||||
|
DependencyProperty.Register("NoLeftClickDelay",
|
||||||
|
typeof(bool),
|
||||||
|
typeof(TaskbarIcon),
|
||||||
|
new FrameworkPropertyMetadata(false));
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A property wrapper for the <see cref="NoLeftClickDelayProperty"/>
|
||||||
|
/// dependency property:<br/>
|
||||||
|
/// Set to true to make left clicks work without delay.
|
||||||
|
/// </summary>
|
||||||
|
[Category(CategoryName)]
|
||||||
|
[Description("Set to true to make left clicks work without delay.")]
|
||||||
|
public bool NoLeftClickDelay
|
||||||
|
{
|
||||||
|
get { return (bool)GetValue(NoLeftClickDelayProperty); }
|
||||||
|
set { SetValue(NoLeftClickDelayProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
//EVENTS
|
//EVENTS
|
||||||
|
|
||||||
#region TrayLeftMouseDown
|
#region TrayLeftMouseDown
|
||||||
|
|||||||
@@ -67,6 +67,14 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly Timer singleClickTimer;
|
private readonly Timer singleClickTimer;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The time we should wait for a double click.
|
||||||
|
/// </summary>
|
||||||
|
private int doubleClickWaitTime
|
||||||
|
{
|
||||||
|
get { return NoLeftClickDelay ? 0 : WinApi.GetDoubleClickTime(); }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A timer that is used to close open balloon tooltips.
|
/// A timer that is used to close open balloon tooltips.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -409,7 +417,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter, LeftClickCommandTarget ?? this);
|
LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter, LeftClickCommandTarget ?? this);
|
||||||
ShowTrayPopup(cursorPosition);
|
ShowTrayPopup(cursorPosition);
|
||||||
};
|
};
|
||||||
singleClickTimer.Change(WinApi.GetDoubleClickTime(), Timeout.Infinite);
|
singleClickTimer.Change(doubleClickWaitTime, Timeout.Infinite);
|
||||||
isLeftClickCommandInvoked = true;
|
isLeftClickCommandInvoked = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -431,7 +439,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter, LeftClickCommandTarget ?? this);
|
LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter, LeftClickCommandTarget ?? this);
|
||||||
ShowContextMenu(cursorPosition);
|
ShowContextMenu(cursorPosition);
|
||||||
};
|
};
|
||||||
singleClickTimer.Change(WinApi.GetDoubleClickTime(), Timeout.Infinite);
|
singleClickTimer.Change(doubleClickWaitTime, Timeout.Infinite);
|
||||||
isLeftClickCommandInvoked = true;
|
isLeftClickCommandInvoked = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -450,7 +458,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
{
|
{
|
||||||
LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter, LeftClickCommandTarget ?? this);
|
LeftClickCommand.ExecuteIfEnabled(LeftClickCommandParameter, LeftClickCommandTarget ?? this);
|
||||||
};
|
};
|
||||||
singleClickTimer.Change(WinApi.GetDoubleClickTime(), Timeout.Infinite);
|
singleClickTimer.Change(doubleClickWaitTime, Timeout.Infinite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user