mirror of
https://github.com/ckaczor/wpf-notifyicon.git
synced 2026-02-06 17:26:47 -05:00
WPF NotifyIcon
--------------
FIX If a popup is opened, its window handle is now being set as the foreground.
This fixes an issue with certain controls being disabled on popups.
(thanks Andrew Smith for pointing me in the right direction!).
FIX Changed dispatcher access in order to work in WinForms scenarios, too.
ADD Added WinForms sample.
git-svn-id: https://svn.evolvesoftware.ch/repos/evolve.net/WPF/NotifyIcon@118 9f600761-6f11-4665-b6dc-0185e9171623
This commit is contained in:
@@ -22,7 +22,6 @@
|
||||
// THIS COPYRIGHT NOTICE MAY NOT BE REMOVED FROM THIS FILE
|
||||
|
||||
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
@@ -30,6 +29,7 @@ using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Resources;
|
||||
using System.Windows.Threading;
|
||||
using Hardcodet.Wpf.TaskbarNotification.Interop;
|
||||
|
||||
namespace Hardcodet.Wpf.TaskbarNotification
|
||||
@@ -41,7 +41,6 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
||||
{
|
||||
public static readonly object SyncRoot = new object();
|
||||
|
||||
|
||||
#region IsDesignMode
|
||||
|
||||
private static readonly bool isDesignMode;
|
||||
@@ -56,19 +55,18 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region construction
|
||||
|
||||
static Util()
|
||||
{
|
||||
isDesignMode =
|
||||
(bool)DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty, typeof(FrameworkElement))
|
||||
.Metadata.DefaultValue;
|
||||
(bool)
|
||||
DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty, typeof (FrameworkElement))
|
||||
.Metadata.DefaultValue;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region CreateHelperWindow
|
||||
|
||||
/// <summary>
|
||||
@@ -80,19 +78,18 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
||||
public static Window CreateHelperWindow()
|
||||
{
|
||||
return new Window
|
||||
{
|
||||
Width = 0,
|
||||
Height = 0,
|
||||
ShowInTaskbar = false,
|
||||
WindowStyle = WindowStyle.None,
|
||||
AllowsTransparency = true,
|
||||
Opacity = 0
|
||||
};
|
||||
{
|
||||
Width = 0,
|
||||
Height = 0,
|
||||
ShowInTaskbar = false,
|
||||
WindowStyle = WindowStyle.None,
|
||||
AllowsTransparency = true,
|
||||
Opacity = 0
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region WriteIconData
|
||||
|
||||
/// <summary>
|
||||
@@ -133,7 +130,6 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region GetBalloonFlag
|
||||
|
||||
/// <summary>
|
||||
@@ -159,7 +155,6 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region ImageSource to Icon
|
||||
|
||||
/// <summary>
|
||||
@@ -188,7 +183,6 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region evaluate listings
|
||||
|
||||
/// <summary>
|
||||
@@ -219,7 +213,6 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region match MouseEvent to PopupActivation
|
||||
|
||||
/// <summary>
|
||||
@@ -252,7 +245,6 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region execute command
|
||||
|
||||
/// <summary>
|
||||
@@ -281,6 +273,22 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Returns a dispatcher for multi-threaded scenarios
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
internal static Dispatcher GetDispatcher(this DispatcherObject source)
|
||||
{
|
||||
//use the application's dispatcher by default
|
||||
if (Application.Current != null) return Application.Current.Dispatcher;
|
||||
|
||||
//fallback for WinForms environments
|
||||
if (source.Dispatcher != null) return source.Dispatcher;
|
||||
|
||||
//ultimatively use the thread's dispatcher
|
||||
return Dispatcher.CurrentDispatcher;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Checks whether the <see cref="FrameworkElement.DataContextProperty"/>
|
||||
@@ -296,6 +304,5 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
||||
if (element == null) throw new ArgumentNullException("element");
|
||||
return element.GetBindingExpression(FrameworkElement.DataContextProperty) != null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user