add ShowBalloonTip

This commit is contained in:
Liu Zhenpeng committed 2019-09-10 16:19:11 +08:00
1 parent 5a1bed83a2
commit bf46f20704
2 files changed
+58 -1

No files matched your search

@@ -165,7 +165,39 @@ namespace HandyControl.Controls
public static readonly DependencyProperty IsBlinkProperty = DependencyProperty.Register(
"IsBlink", typeof(bool), typeof(NotifyIcon), new PropertyMetadata(ValueBoxes.FalseBox, OnIsBlinkChanged));
private static void OnIsBlinkChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
public void ShowBalloonTip(string tipTitle, string tipText, ToolTipIcon tipIcon)
{
if (DesignerHelper.IsInDesignMode) return;
var data = new NOTIFYICONDATA
{
hWnd = _messageWindowHandle,
uID = _id,
uFlags = NativeMethods.NIF_INFO,
dwInfoFlags = NativeMethods.NIF_TIP,
szInfoTitle = tipTitle ?? string.Empty,
szInfo = tipText ?? string.Empty,
};
switch (tipIcon)
{
case ToolTipIcon.Info:
data.dwInfoFlags = NativeMethods.NIIF_INFO;
break;
case ToolTipIcon.Warning:
data.dwInfoFlags = NativeMethods.NIIF_WARNING;
break;
case ToolTipIcon.Error:
data.dwInfoFlags = NativeMethods.NIIF_ERROR;
break;
case ToolTipIcon.None:
data.dwInfoFlags = NativeMethods.NIIF_NONE;
break;
}
UnsafeNativeMethods.Shell_NotifyIcon(NativeMethods.NIM_MODIFY, data);
}
private static void OnIsBlinkChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var ctl = (NotifyIcon)d;
if (ctl.Visibility != Visibility.Visible) return;
@@ -0,0 +1,25 @@
namespace HandyControl.Data
{
public enum ToolTipIcon
{
/// <summary>
/// No Icon.
/// </summary>
None = 0,
/// <summary>
/// A Information Icon.
/// </summary>
Info = 1,
/// <summary>
/// A Warning Icon.
/// </summary>
Warning = 2,
/// <summary>
/// A Error Icon.
/// </summary>
Error = 3
}
}