mirror of
https://github.com/ckaczor/wpf-notifyicon.git
synced 2026-02-16 11:08:30 -05:00
NotifyWPF
--------- CHG Lot of plumbing, some fixes CHG Work on sample project. CHG Popups and ContextMenu now store coordinates - otherwise delayed opending may happen elsewhere. git-svn-id: https://svn.evolvesoftware.ch/repos/evolve.net/WPF/NotifyIcon@55 9f600761-6f11-4665-b6dc-0185e9171623
This commit is contained in:
14
Source/NotifyIconWpf/Interop/Point.cs
Normal file
14
Source/NotifyIconWpf/Interop/Point.cs
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Win API struct providing coordinates for a single point.
|
||||||
|
/// </summary>
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
public struct Point
|
||||||
|
{
|
||||||
|
public int X;
|
||||||
|
public int Y;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -74,7 +74,14 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
|||||||
/// consider the mouse action a double-click.</returns>
|
/// consider the mouse action a double-click.</returns>
|
||||||
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
|
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
|
||||||
public static extern int GetDoubleClickTime();
|
public static extern int GetDoubleClickTime();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the screen coordinates of the current mouse position.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="lpPoint"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[DllImport("USER32.DLL", SetLastError = true)]
|
||||||
|
public static extern bool GetCursorPos(ref Point lpPoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,7 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
|||||||
/// Receives messages from the taskbar icon through
|
/// Receives messages from the taskbar icon through
|
||||||
/// window messages of an underlying helper window.
|
/// window messages of an underlying helper window.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class WindowMessageSink : IDisposable
|
public class WindowMessageSink : IDisposable
|
||||||
{
|
{
|
||||||
|
|
||||||
#region members
|
#region members
|
||||||
@@ -196,10 +196,11 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Processes incoming system messages.
|
/// Processes incoming system messages.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="msg"></param>
|
/// <param name="msg">Callback ID.</param>
|
||||||
/// <param name="wParam"></param>
|
/// <param name="wParam">If the version is <see cref="NotifyIconVersion.Vista"/>
|
||||||
/// <param name="lParam"></param>
|
/// or higher, this parameter can be used to resolve mouse coordinates.
|
||||||
/// <returns></returns>
|
/// Currently not in use.</param>
|
||||||
|
/// <param name="lParam">Provides information about the event.</param>
|
||||||
private void ProcessWindowMessage(uint msg, uint wParam, uint lParam)
|
private void ProcessWindowMessage(uint msg, uint wParam, uint lParam)
|
||||||
{
|
{
|
||||||
if (msg != CallbackMessageId) return;
|
if (msg != CallbackMessageId) return;
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="BalloonIcon.cs" />
|
<Compile Include="BalloonIcon.cs" />
|
||||||
|
<Compile Include="Interop\Point.cs" />
|
||||||
<Compile Include="Interop\TrayLocator.cs" />
|
<Compile Include="Interop\TrayLocator.cs" />
|
||||||
<Compile Include="Interop\WindowClass.cs" />
|
<Compile Include="Interop\WindowClass.cs" />
|
||||||
<Compile Include="PopupActivationMode.cs" />
|
<Compile Include="PopupActivationMode.cs" />
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
@@ -14,8 +15,107 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
partial class TaskbarIcon
|
partial class TaskbarIcon
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Category name that is set on designer properties.
|
||||||
|
/// </summary>
|
||||||
|
public const string CategoryName = "NotifyIcon";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A <see cref="ToolTip"/> control that was created
|
||||||
|
/// in order to display either <see cref="TaskbarIconToolTip"/>
|
||||||
|
/// or <see cref="ToolTipText"/>.
|
||||||
|
/// </summary>
|
||||||
|
internal ToolTip CustomToolTip { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A <see cref="Popup"/> which is either the
|
||||||
|
/// <see cref="TaskbarIconPopup"/> control itself or a
|
||||||
|
/// <see cref="Popup"/> that wraps it.
|
||||||
|
/// </summary>
|
||||||
|
internal Popup CustomPopup { get; private set; }
|
||||||
|
|
||||||
|
|
||||||
//DEPENDENCY PROPERTIES
|
//DEPENDENCY PROPERTIES
|
||||||
|
|
||||||
|
#region Icon property / IconSource dependency property
|
||||||
|
|
||||||
|
private Icon icon;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the icon to be displayed. This is not a
|
||||||
|
/// dependency property - if you want to assign the property
|
||||||
|
/// through XAML, please use the <see cref="IconSource"/>
|
||||||
|
/// dependency property.
|
||||||
|
/// </summary>
|
||||||
|
[Browsable(false)]
|
||||||
|
public Icon Icon
|
||||||
|
{
|
||||||
|
get { return icon; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
icon = value;
|
||||||
|
iconData.IconHandle = value == null ? IntPtr.Zero : icon.Handle;
|
||||||
|
|
||||||
|
Util.WriteIconData(ref iconData, NotifyCommand.Modify, IconDataMembers.Icon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resolves an image source and updates the <see cref="Icon" /> property accordingly.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly DependencyProperty IconSourceProperty =
|
||||||
|
DependencyProperty.Register("IconSource",
|
||||||
|
typeof(ImageSource),
|
||||||
|
typeof(TaskbarIcon),
|
||||||
|
new FrameworkPropertyMetadata(null, IconSourcePropertyChanged));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A property wrapper for the <see cref="IconSourceProperty"/>
|
||||||
|
/// dependency property:<br/>
|
||||||
|
/// Resolves an image source and updates the <see cref="Icon" /> property accordingly.
|
||||||
|
/// </summary>
|
||||||
|
[Category(CategoryName)]
|
||||||
|
[Description("Sets the displayed taskbar icon.")]
|
||||||
|
public ImageSource IconSource
|
||||||
|
{
|
||||||
|
get { return (ImageSource)GetValue(IconSourceProperty); }
|
||||||
|
set { SetValue(IconSourceProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A static callback listener which is being invoked if the
|
||||||
|
/// <see cref="IconSourceProperty"/> dependency property has
|
||||||
|
/// been changed. Invokes the <see cref="OnIconSourcePropertyChanged"/>
|
||||||
|
/// instance method of the changed instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="d">The currently processed owner of the property.</param>
|
||||||
|
/// <param name="e">Provides information about the updated property.</param>
|
||||||
|
private static void IconSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
TaskbarIcon owner = (TaskbarIcon)d;
|
||||||
|
owner.OnIconSourcePropertyChanged(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles changes of the <see cref="IconSourceProperty"/> dependency property. As
|
||||||
|
/// WPF internally uses the dependency property system and bypasses the
|
||||||
|
/// <see cref="IconSource"/> property wrapper, updates of the property's value
|
||||||
|
/// should be handled here.
|
||||||
|
/// </summary
|
||||||
|
/// <param name="e">Provides information about the updated property.</param>
|
||||||
|
private void OnIconSourcePropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
ImageSource newValue = (ImageSource)e.NewValue;
|
||||||
|
|
||||||
|
//resolving the ImageSource at design time probably won't work
|
||||||
|
if (!Util.IsDesignMode) Icon = newValue.ToIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region ToolTipText dependency property
|
#region ToolTipText dependency property
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -35,6 +135,8 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
/// A tooltip text that is being displayed if no custom <see cref="ToolTip"/>
|
/// A tooltip text that is being displayed if no custom <see cref="ToolTip"/>
|
||||||
/// was set or if custom tooltips are not supported.
|
/// was set or if custom tooltips are not supported.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Category(CategoryName)]
|
||||||
|
[Description("Alternative to a fully blown ToolTip, which is only displayed on Vista and above.")]
|
||||||
public string ToolTipText
|
public string ToolTipText
|
||||||
{
|
{
|
||||||
get { return (string) GetValue(ToolTipTextProperty); }
|
get { return (string) GetValue(ToolTipTextProperty); }
|
||||||
@@ -66,128 +168,77 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
/// <param name="e">Provides information about the updated property.</param>
|
/// <param name="e">Provides information about the updated property.</param>
|
||||||
private void OnToolTipTextPropertyChanged(DependencyPropertyChangedEventArgs e)
|
private void OnToolTipTextPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
string newValue = (string) e.NewValue;
|
//only recreate tooltip if we're not using a custom control
|
||||||
|
if (CustomToolTip == null || CustomToolTip.Content is string)
|
||||||
iconData.ToolTipText = newValue ?? String.Empty;
|
{
|
||||||
|
CreateCustomToolTip();
|
||||||
|
}
|
||||||
|
|
||||||
WriteToolTipSettings();
|
WriteToolTipSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ToolTip dependency property override
|
#region TaskbarIconToolTip dependency property
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A static callback listener which is being invoked if the
|
/// A custom UI element that is displayed as a tooltip if the user hovers over the taskbar icon.
|
||||||
/// <see cref="FrameworkElement.ToolTipProperty"/> dependency property has
|
/// Works only with Vista and above. Accordingly, you should make sure that
|
||||||
/// been changed. Invokes the <see cref="OnToolTipPropertyChanged"/>
|
/// the <see cref="ToolTipText"/> property is set as well.
|
||||||
/// instance method of the changed instance.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="d">The currently processed owner of the property.</param>
|
public static readonly DependencyProperty TaskbarIconToolTipProperty =
|
||||||
/// <param name="e">Provides information about the updated property.</param>
|
DependencyProperty.Register("TaskbarIconToolTip",
|
||||||
private static void ToolTipPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
typeof (UIElement),
|
||||||
{
|
|
||||||
TaskbarIcon owner = (TaskbarIcon) d;
|
|
||||||
owner.OnToolTipPropertyChanged(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Handles changes of the <see cref="FrameworkElement.ToolTipProperty"/> dependency property. As
|
|
||||||
/// WPF internally uses the dependency property system and bypasses the
|
|
||||||
/// <see cref="ToolTip"/> property wrapper, updates of the property's value
|
|
||||||
/// should be handled here.
|
|
||||||
/// </summary
|
|
||||||
/// <param name="e">Provides information about the updated property.</param>
|
|
||||||
private void OnToolTipPropertyChanged(DependencyPropertyChangedEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.NewValue != null)
|
|
||||||
{
|
|
||||||
ToolTip tt = e.NewValue as ToolTip;
|
|
||||||
if (tt == null)
|
|
||||||
{
|
|
||||||
tt = new ToolTip();
|
|
||||||
tt.Content = e.NewValue;
|
|
||||||
|
|
||||||
ToolTip = tt;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
WriteToolTipSettings();
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Icon property / IconSource dependency property
|
|
||||||
|
|
||||||
private Icon icon;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets or sets the icon to be displayed. This is not a
|
|
||||||
/// dependency property - if you want to assign the property
|
|
||||||
/// through XAML, please use the <see cref="IconSource"/>
|
|
||||||
/// dependency property.
|
|
||||||
/// </summary>
|
|
||||||
public Icon Icon
|
|
||||||
{
|
|
||||||
get { return icon; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
icon = value;
|
|
||||||
iconData.IconHandle = value == null ? IntPtr.Zero : icon.Handle;
|
|
||||||
|
|
||||||
Util.WriteIconData(ref iconData, NotifyCommand.Modify, IconDataMembers.Icon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Resolves an image source and updates the <see cref="Icon" /> property accordingly.
|
|
||||||
/// </summary>
|
|
||||||
public static readonly DependencyProperty IconSourceProperty =
|
|
||||||
DependencyProperty.Register("IconSource",
|
|
||||||
typeof (ImageSource),
|
|
||||||
typeof (TaskbarIcon),
|
typeof (TaskbarIcon),
|
||||||
new FrameworkPropertyMetadata(null, IconSourcePropertyChanged));
|
new FrameworkPropertyMetadata(null, TaskbarIconToolTipPropertyChanged));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A property wrapper for the <see cref="IconSourceProperty"/>
|
/// A property wrapper for the <see cref="TaskbarIconToolTipProperty"/>
|
||||||
/// dependency property:<br/>
|
/// dependency property:<br/>
|
||||||
/// Resolves an image source and updates the <see cref="Icon" /> property accordingly.
|
/// A custom UI element that is displayed as a tooltip if the user hovers over the taskbar icon.
|
||||||
|
/// Works only with Vista and above. Accordingly, you should make sure that
|
||||||
|
/// the <see cref="ToolTipText"/> property is set as well.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ImageSource IconSource
|
[Category(CategoryName)]
|
||||||
|
[Description("Custom UI element that is displayed as a tooltip. Only on Vista and above")]
|
||||||
|
public UIElement TaskbarIconToolTip
|
||||||
{
|
{
|
||||||
get { return (ImageSource) GetValue(IconSourceProperty); }
|
get { return (UIElement) GetValue(TaskbarIconToolTipProperty); }
|
||||||
set { SetValue(IconSourceProperty, value); }
|
set { SetValue(TaskbarIconToolTipProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A static callback listener which is being invoked if the
|
/// A static callback listener which is being invoked if the
|
||||||
/// <see cref="IconSourceProperty"/> dependency property has
|
/// <see cref="TaskbarIconToolTipProperty"/> dependency property has
|
||||||
/// been changed. Invokes the <see cref="OnIconSourcePropertyChanged"/>
|
/// been changed. Invokes the <see cref="OnTaskbarIconToolTipPropertyChanged"/>
|
||||||
/// instance method of the changed instance.
|
/// instance method of the changed instance.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="d">The currently processed owner of the property.</param>
|
/// <param name="d">The currently processed owner of the property.</param>
|
||||||
/// <param name="e">Provides information about the updated property.</param>
|
/// <param name="e">Provides information about the updated property.</param>
|
||||||
private static void IconSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
private static void TaskbarIconToolTipPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
TaskbarIcon owner = (TaskbarIcon) d;
|
TaskbarIcon owner = (TaskbarIcon) d;
|
||||||
owner.OnIconSourcePropertyChanged(e);
|
owner.OnTaskbarIconToolTipPropertyChanged(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles changes of the <see cref="IconSourceProperty"/> dependency property. As
|
/// Handles changes of the <see cref="TaskbarIconToolTipProperty"/> dependency property. As
|
||||||
/// WPF internally uses the dependency property system and bypasses the
|
/// WPF internally uses the dependency property system and bypasses the
|
||||||
/// <see cref="IconSource"/> property wrapper, updates of the property's value
|
/// <see cref="TaskbarIconToolTip"/> property wrapper, updates of the property's value
|
||||||
/// should be handled here.
|
/// should be handled here.
|
||||||
/// </summary
|
/// </summary
|
||||||
/// <param name="e">Provides information about the updated property.</param>
|
/// <param name="e">Provides information about the updated property.</param>
|
||||||
private void OnIconSourcePropertyChanged(DependencyPropertyChangedEventArgs e)
|
private void OnTaskbarIconToolTipPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
ImageSource newValue = (ImageSource) e.NewValue;
|
//recreate tooltip control
|
||||||
Icon = newValue.ToIcon();
|
CreateCustomToolTip();
|
||||||
|
|
||||||
|
//udpate tooltip settings - needed to make sure a string is set, even
|
||||||
|
//if the ToolTipText property is not set. Otherwise, the event that
|
||||||
|
//triggers tooltip display is never fired.
|
||||||
|
WriteToolTipSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -195,22 +246,24 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
#region TaskbarIconPopup dependency property
|
#region TaskbarIconPopup dependency property
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A custom popup that is displayed when the taskbar icon is clicked.
|
/// A control that is displayed as a popup when the taskbar icon is clicked.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static readonly DependencyProperty TaskbarIconPopupProperty =
|
public static readonly DependencyProperty TaskbarIconPopupProperty =
|
||||||
DependencyProperty.Register("TaskbarIconPopup",
|
DependencyProperty.Register("TaskbarIconPopup",
|
||||||
typeof (Popup),
|
typeof(UIElement),
|
||||||
typeof (TaskbarIcon),
|
typeof (TaskbarIcon),
|
||||||
new FrameworkPropertyMetadata(null, TaskbarIconPopupPropertyChanged));
|
new FrameworkPropertyMetadata(null, TaskbarIconPopupPropertyChanged));
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A property wrapper for the <see cref="TaskbarIconPopupProperty"/>
|
/// A property wrapper for the <see cref="TaskbarIconPopupProperty"/>
|
||||||
/// dependency property:<br/>
|
/// dependency property:<br/>
|
||||||
/// A custom popup that is displayed when the taskbar icon is clicked.
|
/// A control that is displayed as a popup when the taskbar icon is clicked.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Popup TaskbarIconPopup
|
[Category(CategoryName)]
|
||||||
|
[Description("Displayed as a Popup if the user clicks on the taskbar icon.")]
|
||||||
|
public UIElement TaskbarIconPopup
|
||||||
{
|
{
|
||||||
get { return (Popup) GetValue(TaskbarIconPopupProperty); }
|
get { return (UIElement)GetValue(TaskbarIconPopupProperty); }
|
||||||
set { SetValue(TaskbarIconPopupProperty, value); }
|
set { SetValue(TaskbarIconPopupProperty, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -240,10 +293,12 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
private void OnTaskbarIconPopupPropertyChanged(DependencyPropertyChangedEventArgs e)
|
private void OnTaskbarIconPopupPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
//currently not needed
|
//currently not needed
|
||||||
|
CreatePopup();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region MenuActivation dependency property
|
#region MenuActivation dependency property
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -262,6 +317,8 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
/// Defines what mouse events display the context menu.
|
/// Defines what mouse events display the context menu.
|
||||||
/// Defaults to <see cref="PopupActivationMode.RightClick"/>.
|
/// Defaults to <see cref="PopupActivationMode.RightClick"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Category(CategoryName)]
|
||||||
|
[Description("Defines what mouse events display the context menu.")]
|
||||||
public PopupActivationMode MenuActivation
|
public PopupActivationMode MenuActivation
|
||||||
{
|
{
|
||||||
get { return (PopupActivationMode) GetValue(MenuActivationProperty); }
|
get { return (PopupActivationMode) GetValue(MenuActivationProperty); }
|
||||||
@@ -316,6 +373,8 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
/// Defines what mouse events trigger the <see cref="TaskbarIconPopup" />.
|
/// Defines what mouse events trigger the <see cref="TaskbarIconPopup" />.
|
||||||
/// Default is <see cref="PopupActivationMode.LeftClick" />.
|
/// Default is <see cref="PopupActivationMode.LeftClick" />.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Category(CategoryName)]
|
||||||
|
[Description("Defines what mouse events display the TaskbarIconPopup.")]
|
||||||
public PopupActivationMode PopupActivation
|
public PopupActivationMode PopupActivation
|
||||||
{
|
{
|
||||||
get { return (PopupActivationMode) GetValue(PopupActivationProperty); }
|
get { return (PopupActivationMode) GetValue(PopupActivationProperty); }
|
||||||
@@ -352,6 +411,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region Visibility dependency property override
|
#region Visibility dependency property override
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -439,6 +499,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Occurs when the user presses the left mouse button.
|
/// Occurs when the user presses the left mouse button.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[Category(CategoryName)]
|
||||||
public event RoutedEventHandler TaskbarIconLeftMouseDown
|
public event RoutedEventHandler TaskbarIconLeftMouseDown
|
||||||
{
|
{
|
||||||
add { AddHandler(TaskbarIconLeftMouseDownEvent, value); }
|
add { AddHandler(TaskbarIconLeftMouseDownEvent, value); }
|
||||||
@@ -1212,11 +1273,6 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
//register change listener for the ContextMenu property
|
//register change listener for the ContextMenu property
|
||||||
md = new FrameworkPropertyMetadata(new PropertyChangedCallback(ContextMenuPropertyChanged));
|
md = new FrameworkPropertyMetadata(new PropertyChangedCallback(ContextMenuPropertyChanged));
|
||||||
ContextMenuProperty.OverrideMetadata(typeof (TaskbarIcon), md);
|
ContextMenuProperty.OverrideMetadata(typeof (TaskbarIcon), md);
|
||||||
|
|
||||||
//register change listener for the ToolTip property
|
|
||||||
md = new FrameworkPropertyMetadata(new PropertyChangedCallback(ToolTipPropertyChanged));
|
|
||||||
ToolTipProperty.OverrideMetadata(typeof(TaskbarIcon), md);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Controls.Primitives;
|
||||||
using Hardcodet.Wpf.TaskbarNotification.Interop;
|
using Hardcodet.Wpf.TaskbarNotification.Interop;
|
||||||
|
using Point=Hardcodet.Wpf.TaskbarNotification.Interop.Point;
|
||||||
|
|
||||||
|
|
||||||
namespace Hardcodet.Wpf.TaskbarNotification
|
namespace Hardcodet.Wpf.TaskbarNotification
|
||||||
{
|
{
|
||||||
@@ -23,7 +25,94 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
private readonly Timer singleClickTimer;
|
private readonly Timer singleClickTimer;
|
||||||
|
|
||||||
|
|
||||||
#region Update ToolTip Settings
|
#region ToolTip
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Displays a custom tooltip, if available. This method is only
|
||||||
|
/// invoked for Windows Vista and above.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="visible">Whether to show or hide the tooltip.</param>
|
||||||
|
private void OnToolTipChange(bool visible)
|
||||||
|
{
|
||||||
|
//if we don't have a tooltip, there's nothing to do here...
|
||||||
|
if (CustomToolTip == null) return;
|
||||||
|
|
||||||
|
if (visible)
|
||||||
|
{
|
||||||
|
if (ContextMenu != null && ContextMenu.IsOpen ||
|
||||||
|
CustomPopup != null && CustomPopup.IsOpen)
|
||||||
|
{
|
||||||
|
//ignore if we have an open context menu or popup
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var args = RaisePreviewTaskbarIconToolTipOpenEvent();
|
||||||
|
if (args.Handled) return;
|
||||||
|
|
||||||
|
CustomToolTip.IsOpen = true;
|
||||||
|
RaiseTaskbarIconToolTipOpenEvent();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var args = RaisePreviewTaskbarIconToolTipCloseEvent();
|
||||||
|
if (args.Handled) return;
|
||||||
|
|
||||||
|
CustomToolTip.IsOpen = false;
|
||||||
|
RaiseTaskbarIconToolTipCloseEvent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a <see cref="ToolTip"/> control that either
|
||||||
|
/// wraps the currently set <see cref="TaskbarIconToolTip"/>
|
||||||
|
/// control or the <see cref="ToolTipText"/> string.<br/>
|
||||||
|
/// If <see cref="TaskbarIconToolTip"/> itself is already
|
||||||
|
/// a <see cref="ToolTip"/> instance, it will be used directly.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>We use a <see cref="ToolTip"/> rather than
|
||||||
|
/// <see cref="Popup"/> because there was no way to prevent a
|
||||||
|
/// popup from causing cyclic open/close commands if it was
|
||||||
|
/// placed under the mouse. ToolTip internally uses a Popup of
|
||||||
|
/// its own, but takes advance of Popup's internal <see cref="Popup.HitTestable"/>
|
||||||
|
/// property which prevents this issue.</remarks>
|
||||||
|
private void CreateCustomToolTip()
|
||||||
|
{
|
||||||
|
//check if the item itself is a tooltip
|
||||||
|
ToolTip tt = TaskbarIconToolTip as ToolTip;
|
||||||
|
|
||||||
|
if (tt == null && TaskbarIconToolTip != null)
|
||||||
|
{
|
||||||
|
//create an invisible tooltip that hosts the UIElement
|
||||||
|
tt = new ToolTip();
|
||||||
|
tt.Placement = PlacementMode.Mouse;
|
||||||
|
tt.PlacementTarget = this;
|
||||||
|
|
||||||
|
//the tooltip (and implicitly its context) explicitly gets
|
||||||
|
//the DataContext of this instance. If there is no DataContext,
|
||||||
|
//the TaskbarIcon sets itself
|
||||||
|
tt.DataContext = DataContext ?? this;
|
||||||
|
|
||||||
|
//make sure the tooltip is invisible
|
||||||
|
tt.HasDropShadow = false;
|
||||||
|
tt.BorderThickness = new Thickness(0);
|
||||||
|
tt.Background = System.Windows.Media.Brushes.Transparent;
|
||||||
|
|
||||||
|
//setting the
|
||||||
|
tt.StaysOpen = true;
|
||||||
|
|
||||||
|
tt.Content = TaskbarIconToolTip;
|
||||||
|
}
|
||||||
|
else if (tt == null && !String.IsNullOrEmpty(ToolTipText))
|
||||||
|
{
|
||||||
|
//create a simple tooltip for the string
|
||||||
|
tt = new ToolTip();
|
||||||
|
tt.Content = ToolTipText;
|
||||||
|
}
|
||||||
|
|
||||||
|
//store a reference to the used tooltip
|
||||||
|
CustomToolTip = tt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets tooltip settings for the class depending on defined
|
/// Sets tooltip settings for the class depending on defined
|
||||||
@@ -31,32 +120,28 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void WriteToolTipSettings()
|
private void WriteToolTipSettings()
|
||||||
{
|
{
|
||||||
IconDataMembers flags = IconDataMembers.Tip;
|
const IconDataMembers flags = IconDataMembers.Tip;
|
||||||
iconData.ToolTipText = ToolTipText;
|
iconData.ToolTipText = ToolTipText;
|
||||||
|
|
||||||
if (messageSink.Version == NotifyIconVersion.Vista)
|
if (messageSink.Version == NotifyIconVersion.Vista)
|
||||||
{
|
{
|
||||||
if (String.IsNullOrEmpty(ToolTipText) && ToolTip != null)
|
//we need to set a tooltip text to get tooltip events from the
|
||||||
|
//taskbar icon
|
||||||
|
if (String.IsNullOrEmpty(iconData.ToolTipText) && CustomToolTip != null)
|
||||||
{
|
{
|
||||||
//if we have not tooltip text but a custom tooltip, we
|
//if we have not tooltip text but a custom tooltip, we
|
||||||
//need to set a dummy value
|
//need to set a dummy value (we're displaying the ToolTip control, not the string)
|
||||||
iconData.ToolTipText = "ToolTip";
|
iconData.ToolTipText = "ToolTip";
|
||||||
}
|
}
|
||||||
else if (!String.IsNullOrEmpty(ToolTipText) && ToolTip == null)
|
|
||||||
{
|
|
||||||
//if a tooltip text was set but there is no custom tooltip,
|
|
||||||
//we need to fall back to legacy operations
|
|
||||||
flags |= IconDataMembers.UseLegacyToolTips;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//just write the the tooltip
|
//update the tooltip text
|
||||||
Util.WriteIconData(ref iconData, NotifyCommand.Modify, flags);
|
Util.WriteIconData(ref iconData, NotifyCommand.Modify, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Show / Hide Balloon ToolTip
|
#region Show / Hide Balloon Tip
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Displays a balloon tip with the specified title,
|
/// Displays a balloon tip with the specified title,
|
||||||
@@ -64,12 +149,12 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="title">The title to display on the balloon tip.</param>
|
/// <param name="title">The title to display on the balloon tip.</param>
|
||||||
/// <param name="message">The text to display on the balloon tip.</param>
|
/// <param name="message">The text to display on the balloon tip.</param>
|
||||||
/// <param name="icon">Indicates the severity.</param>
|
/// <param name="symbol">A symbol that indicates the severity.</param>
|
||||||
public void ShowBalloonTip(string title, string message, BalloonIcon icon)
|
public void ShowBalloonTip(string title, string message, BalloonIcon symbol)
|
||||||
{
|
{
|
||||||
lock (this)
|
lock (this)
|
||||||
{
|
{
|
||||||
ShowBalloonTip(title, message, icon.GetBalloonFlag(), IntPtr.Zero);
|
ShowBalloonTip(title, message, symbol.GetBalloonFlag(), IntPtr.Zero);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -157,24 +242,78 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Create Popup
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a <see cref="ToolTip"/> control that either
|
||||||
|
/// wraps the currently set <see cref="TaskbarIconToolTip"/>
|
||||||
|
/// control or the <see cref="ToolTipText"/> string.<br/>
|
||||||
|
/// If <see cref="TaskbarIconToolTip"/> itself is already
|
||||||
|
/// a <see cref="ToolTip"/> instance, it will be used directly.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>We use a <see cref="ToolTip"/> rather than
|
||||||
|
/// <see cref="Popup"/> because there was no way to prevent a
|
||||||
|
/// popup from causing cyclic open/close commands if it was
|
||||||
|
/// placed under the mouse. ToolTip internally uses a Popup of
|
||||||
|
/// its own, but takes advance of Popup's internal <see cref="Popup.HitTestable"/>
|
||||||
|
/// property which prevents this issue.</remarks>
|
||||||
|
private void CreatePopup()
|
||||||
|
{
|
||||||
|
//no popup is available
|
||||||
|
if (TaskbarIconPopup == null) return;
|
||||||
|
|
||||||
|
//check if the item itself is a popup
|
||||||
|
Popup popup = TaskbarIconPopup as Popup;
|
||||||
|
|
||||||
|
if (popup == null)
|
||||||
|
{
|
||||||
|
//create an invisible popup that hosts the UIElement
|
||||||
|
popup = new Popup();
|
||||||
|
popup.AllowsTransparency = true;
|
||||||
|
popup.PopupAnimation = PopupAnimation.Fade;
|
||||||
|
|
||||||
|
//the tooltip (and implicitly its context) explicitly gets
|
||||||
|
//the DataContext of this instance. If there is no DataContext,
|
||||||
|
//the TaskbarIcon assigns itself
|
||||||
|
popup.DataContext = DataContext ?? this;
|
||||||
|
|
||||||
|
Popup.CreateRootPopup(popup, TaskbarIconPopup);
|
||||||
|
|
||||||
|
popup.PlacementTarget = this;
|
||||||
|
popup.Placement = PlacementMode.AbsolutePoint;
|
||||||
|
popup.StaysOpen = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//store a reference to the used tooltip
|
||||||
|
CustomPopup = popup;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Show Tray Popup / Context Menu
|
#region Show Tray Popup / Context Menu
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Displays the <see cref="TaskbarIconPopup"/> control if
|
/// Displays the <see cref="TaskbarIconPopup"/> control if
|
||||||
/// it was set.
|
/// it was set.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void ShowTrayPopup()
|
private void ShowTrayPopup(Point cursorPosition)
|
||||||
{
|
{
|
||||||
if (IsDisposed) return;
|
if (IsDisposed) return;
|
||||||
|
|
||||||
|
//raise preview event no matter whether popup is currently set
|
||||||
|
//or not (enables client to set it on demand)
|
||||||
|
var args = RaisePreviewTaskbarIconPopupOpenEvent();
|
||||||
|
if (args.Handled) return;
|
||||||
|
|
||||||
if (TaskbarIconPopup != null)
|
if (TaskbarIconPopup != null)
|
||||||
{
|
{
|
||||||
//raise preview event
|
//use absolute position, but place the popup centered above the icon
|
||||||
var args = RaisePreviewTaskbarIconPopupOpenEvent();
|
CustomPopup.Placement = PlacementMode.AbsolutePoint;
|
||||||
if (args.Handled) return;
|
CustomPopup.HorizontalOffset = cursorPosition.X; //+ TaskbarIconPopup.ActualWidth/2;
|
||||||
|
CustomPopup.VerticalOffset = cursorPosition.Y;
|
||||||
|
|
||||||
//open popup
|
//open popup
|
||||||
TaskbarIconPopup.IsOpen = true;
|
CustomPopup.IsOpen = true;
|
||||||
|
|
||||||
//activate the message window to track deactivation - otherwise, the context menu
|
//activate the message window to track deactivation - otherwise, the context menu
|
||||||
//does not close if the user clicks somewhere else
|
//does not close if the user clicks somewhere else
|
||||||
@@ -190,17 +329,21 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
/// Displays the <see cref="ContextMenu"/> if
|
/// Displays the <see cref="ContextMenu"/> if
|
||||||
/// it was set.
|
/// it was set.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void ShowContextMenu()
|
private void ShowContextMenu(Point cursorPosition)
|
||||||
{
|
{
|
||||||
if (IsDisposed) return;
|
if (IsDisposed) return;
|
||||||
|
|
||||||
|
//raise preview event no matter whether context menu is currently set
|
||||||
|
//or not (enables client to set it on demand)
|
||||||
|
var args = RaisePreviewTaskbarIconContextMenuOpenEvent();
|
||||||
|
if (args.Handled) return;
|
||||||
|
|
||||||
if (ContextMenu != null)
|
if (ContextMenu != null)
|
||||||
{
|
{
|
||||||
//raise preview event
|
//use absolute position
|
||||||
var args = RaisePreviewTaskbarIconContextMenuOpenEvent();
|
ContextMenu.Placement = PlacementMode.AbsolutePoint;
|
||||||
if (args.Handled) return;
|
ContextMenu.HorizontalOffset = cursorPosition.X;
|
||||||
|
ContextMenu.VerticalOffset = cursorPosition.Y;
|
||||||
//CreateActivationWindow();
|
|
||||||
ContextMenu.IsOpen = true;
|
ContextMenu.IsOpen = true;
|
||||||
|
|
||||||
//activate the message window to track deactivation - otherwise, the context menu
|
//activate the message window to track deactivation - otherwise, the context menu
|
||||||
|
|||||||
@@ -1,11 +1,15 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Reflection;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Controls.Primitives;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
using Hardcodet.Wpf.TaskbarNotification.Interop;
|
using Hardcodet.Wpf.TaskbarNotification.Interop;
|
||||||
|
using Point=Hardcodet.Wpf.TaskbarNotification.Interop.Point;
|
||||||
|
|
||||||
|
|
||||||
namespace Hardcodet.Wpf.TaskbarNotification
|
namespace Hardcodet.Wpf.TaskbarNotification
|
||||||
@@ -43,6 +47,8 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#region Construction
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Inits the taskbar icon and registers a message listener
|
/// Inits the taskbar icon and registers a message listener
|
||||||
/// in order to receive events from the taskbar area.
|
/// in order to receive events from the taskbar area.
|
||||||
@@ -79,8 +85,11 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
if (Application.Current != null) Application.Current.Exit += OnExit;
|
if (Application.Current != null) Application.Current.Exit += OnExit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
#region Handle Mouse Events
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Processes mouse events, which are bubbled
|
/// Processes mouse events, which are bubbled
|
||||||
/// through the class' routed events, trigger
|
/// through the class' routed events, trigger
|
||||||
@@ -96,7 +105,8 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
{
|
{
|
||||||
case MouseEvent.MouseMove:
|
case MouseEvent.MouseMove:
|
||||||
RaiseTaskbarIconMouseMoveEvent();
|
RaiseTaskbarIconMouseMoveEvent();
|
||||||
break;
|
//immediately return - there's nothing left to evaluate
|
||||||
|
return;
|
||||||
case MouseEvent.IconRightMouseDown:
|
case MouseEvent.IconRightMouseDown:
|
||||||
RaiseTaskbarIconRightMouseDownEvent();
|
RaiseTaskbarIconRightMouseDownEvent();
|
||||||
break;
|
break;
|
||||||
@@ -130,19 +140,23 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//get mouse coordinates
|
||||||
|
Point cursorPosition = new Point();
|
||||||
|
WinApi.GetCursorPos(ref cursorPosition);
|
||||||
|
|
||||||
//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;
|
delayedTimerAction = () => ShowTrayPopup(cursorPosition);
|
||||||
singleClickTimer.Change(WinApi.GetDoubleClickTime(), Timeout.Infinite);
|
singleClickTimer.Change(WinApi.GetDoubleClickTime(), Timeout.Infinite);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//show popup immediately
|
//show popup immediately
|
||||||
ShowTrayPopup();
|
ShowTrayPopup(cursorPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -153,51 +167,18 @@ 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;
|
delayedTimerAction = () => ShowContextMenu(cursorPosition);
|
||||||
singleClickTimer.Change(WinApi.GetDoubleClickTime(), Timeout.Infinite);
|
singleClickTimer.Change(WinApi.GetDoubleClickTime(), Timeout.Infinite);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//show context menu immediately
|
//show context menu immediately
|
||||||
ShowContextMenu();
|
ShowContextMenu(cursorPosition);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Displays a custom tooltip, if available. This functionality
|
|
||||||
/// is only available for Windows Vista and above.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="visible">Whether to show or hide the tooltip.</param>
|
|
||||||
private void OnToolTipChange(bool visible)
|
|
||||||
{
|
|
||||||
//if we have a custom tooltip, show it now
|
|
||||||
if (ToolTip == null) return;
|
|
||||||
|
|
||||||
|
|
||||||
ToolTip tt = (ToolTip)ToolTip;
|
|
||||||
|
|
||||||
if (visible)
|
|
||||||
{
|
|
||||||
var args = RaisePreviewTaskbarIconToolTipOpenEvent();
|
|
||||||
if (args.Handled) return;
|
|
||||||
|
|
||||||
tt.IsOpen = true;
|
|
||||||
RaiseTaskbarIconToolTipOpenEvent();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var args = RaisePreviewTaskbarIconToolTipCloseEvent();
|
|
||||||
if (args.Handled) return;
|
|
||||||
|
|
||||||
tt.IsOpen = false;
|
|
||||||
RaiseTaskbarIconToolTipCloseEvent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Bubbles events if a balloon ToolTip was displayed
|
/// Bubbles events if a balloon ToolTip was displayed
|
||||||
/// or removed.
|
/// or removed.
|
||||||
@@ -208,7 +189,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
{
|
{
|
||||||
if (visible)
|
if (visible)
|
||||||
{
|
{
|
||||||
RaiseTaskbarIconBalloonTipShownEvent();
|
RaiseTaskbarIconBalloonTipShownEvent();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -216,7 +197,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region SetVersion
|
#region SetVersion
|
||||||
|
|||||||
@@ -214,7 +214,8 @@ namespace Hardcodet.Wpf.TaskbarNotification
|
|||||||
case PopupActivationMode.MiddleClick:
|
case PopupActivationMode.MiddleClick:
|
||||||
return me == MouseEvent.IconMiddleMouseUp;
|
return me == MouseEvent.IconMiddleMouseUp;
|
||||||
case PopupActivationMode.All:
|
case PopupActivationMode.All:
|
||||||
return true;
|
//return true for everything except mouse movements
|
||||||
|
return me != MouseEvent.MouseMove;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException("activationMode");
|
throw new ArgumentOutOfRangeException("activationMode");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,5 +4,11 @@
|
|||||||
StartupUri="Window1.xaml">
|
StartupUri="Window1.xaml">
|
||||||
<Application.Resources>
|
<Application.Resources>
|
||||||
|
|
||||||
|
<ResourceDictionary>
|
||||||
|
<ResourceDictionary.MergedDictionaries>
|
||||||
|
<ResourceDictionary Source="TaskbarIconResources.xaml"/>
|
||||||
|
</ResourceDictionary.MergedDictionaries>
|
||||||
|
</ResourceDictionary>
|
||||||
|
|
||||||
</Application.Resources>
|
</Application.Resources>
|
||||||
</Application>
|
</Application>
|
||||||
|
|||||||
39
Source/Sample Project/Commands/HideMainWindowCommand.cs
Normal file
39
Source/Sample Project/Commands/HideMainWindowCommand.cs
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
|
namespace Sample_Project.Commands
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Hides the main window.
|
||||||
|
/// </summary>
|
||||||
|
public class HideMainWindowCommand : ICommand
|
||||||
|
{
|
||||||
|
public event EventHandler CanExecuteChanged;
|
||||||
|
|
||||||
|
public void Execute(object parameter)
|
||||||
|
{
|
||||||
|
Application.Current.MainWindow.Hide();
|
||||||
|
TaskbarIconCommands.RefreshCommands();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public bool CanExecute(object parameter)
|
||||||
|
{
|
||||||
|
return Application.Current.MainWindow.IsVisible;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raises the <see cref="CanExecuteChanged"/> event.
|
||||||
|
/// </summary>
|
||||||
|
internal void RaiseCanExcecuteChanged()
|
||||||
|
{
|
||||||
|
if (CanExecuteChanged != null) CanExecuteChanged(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
38
Source/Sample Project/Commands/ShowMainWindowCommand.cs
Normal file
38
Source/Sample Project/Commands/ShowMainWindowCommand.cs
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
|
namespace Sample_Project.Commands
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Shows the main window.
|
||||||
|
/// </summary>
|
||||||
|
public class ShowMainWindowCommand : ICommand
|
||||||
|
{
|
||||||
|
public event EventHandler CanExecuteChanged;
|
||||||
|
|
||||||
|
public void Execute(object parameter)
|
||||||
|
{
|
||||||
|
Application.Current.MainWindow.Show();
|
||||||
|
TaskbarIconCommands.RefreshCommands();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public bool CanExecute(object parameter)
|
||||||
|
{
|
||||||
|
return Application.Current.MainWindow.IsVisible == false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raises the <see cref="CanExecuteChanged"/> event.
|
||||||
|
/// </summary>
|
||||||
|
internal void RaiseCanExcecuteChanged()
|
||||||
|
{
|
||||||
|
if (CanExecuteChanged != null) CanExecuteChanged(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
27
Source/Sample Project/Commands/TaskbarIconCommands.cs
Normal file
27
Source/Sample Project/Commands/TaskbarIconCommands.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
|
namespace Sample_Project.Commands
|
||||||
|
{
|
||||||
|
public static class TaskbarIconCommands
|
||||||
|
{
|
||||||
|
public static HideMainWindowCommand HideMain { get; set; }
|
||||||
|
public static ShowMainWindowCommand ShowMain { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
static TaskbarIconCommands()
|
||||||
|
{
|
||||||
|
HideMain = new HideMainWindowCommand();
|
||||||
|
ShowMain =new ShowMainWindowCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RefreshCommands()
|
||||||
|
{
|
||||||
|
HideMain.RaiseCanExcecuteChanged();
|
||||||
|
ShowMain.RaiseCanExcecuteChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
92
Source/Sample Project/FancyPopup.xaml
Normal file
92
Source/Sample Project/FancyPopup.xaml
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
<UserControl
|
||||||
|
x:Class="Sample_Project.FancyPopup"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
Height="215"
|
||||||
|
Width="300" x:Name="me">
|
||||||
|
<Grid>
|
||||||
|
<Border
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
Width="Auto"
|
||||||
|
Height="Auto"
|
||||||
|
Margin="5,5,5,5"
|
||||||
|
CornerRadius="10,10,10,10">
|
||||||
|
<Border.Effect>
|
||||||
|
<DropShadowEffect
|
||||||
|
Color="#FF474747" />
|
||||||
|
</Border.Effect>
|
||||||
|
<Border.Background>
|
||||||
|
<LinearGradientBrush
|
||||||
|
EndPoint="0.5,1"
|
||||||
|
StartPoint="0.5,0">
|
||||||
|
<GradientStop
|
||||||
|
Color="#FF58C2FF"
|
||||||
|
Offset="0" />
|
||||||
|
<GradientStop
|
||||||
|
Color="#FFFFFFFF"
|
||||||
|
Offset="1" />
|
||||||
|
</LinearGradientBrush>
|
||||||
|
</Border.Background>
|
||||||
|
</Border>
|
||||||
|
<Image
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Margin="19,10,0,0"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Width="72"
|
||||||
|
Height="72"
|
||||||
|
Source="Images\preferences.png"
|
||||||
|
Stretch="Fill" />
|
||||||
|
<TextBlock
|
||||||
|
Margin="107,10,20,0"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
Height="32"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
FontSize="16"
|
||||||
|
FontWeight="Bold"
|
||||||
|
Foreground="#FF575757"><Run
|
||||||
|
Text="This is a fancy Popup..."
|
||||||
|
Language="de-ch" /></TextBlock>
|
||||||
|
<Button
|
||||||
|
Click="OnButtonClick"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Width="89"
|
||||||
|
Height="29"
|
||||||
|
Content="Click me"
|
||||||
|
Margin="0,0,20,20"
|
||||||
|
BorderBrush="#FFFFFFFF">
|
||||||
|
<Button.Background>
|
||||||
|
<LinearGradientBrush
|
||||||
|
EndPoint="0,1"
|
||||||
|
StartPoint="0,0">
|
||||||
|
<GradientStop
|
||||||
|
Color="#FFFFFFFF"
|
||||||
|
Offset="1" />
|
||||||
|
<GradientStop
|
||||||
|
Color="#FFFFD197"
|
||||||
|
Offset="0.459" />
|
||||||
|
<GradientStop
|
||||||
|
Color="#FFFFDBAD"
|
||||||
|
Offset="0" />
|
||||||
|
<GradientStop
|
||||||
|
Color="#FFF18E23"
|
||||||
|
Offset="0.508" />
|
||||||
|
<GradientStop
|
||||||
|
Color="#FFF9D4AC"
|
||||||
|
Offset="0.954" />
|
||||||
|
</LinearGradientBrush>
|
||||||
|
</Button.Background>
|
||||||
|
</Button>
|
||||||
|
<TextBlock
|
||||||
|
Margin="19,92,10,49"
|
||||||
|
TextWrapping="Wrap"><Run
|
||||||
|
Text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi sed sem. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla dui nisi, venenatis" /><Run
|
||||||
|
Text="."
|
||||||
|
Language="de-ch" /></TextBlock>
|
||||||
|
<TextBlock Margin="0,52,20,0" VerticalAlignment="Top" Height="30" TextWrapping="Wrap" FontWeight="Bold" FontSize="14" HorizontalAlignment="Right" Foreground="#FF575757"><Run Text="Clicks: " Language="de-ch"/><InlineUIContainer>
|
||||||
|
<TextBlock Width="Auto" Height="Auto" Text="{Binding Path=ClickCount, ElementName=me, Mode=Default}" TextWrapping="Wrap"/>
|
||||||
|
</InlineUIContainer></TextBlock>
|
||||||
|
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
46
Source/Sample Project/FancyPopup.xaml.cs
Normal file
46
Source/Sample Project/FancyPopup.xaml.cs
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace Sample_Project
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for FancyPopup.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class FancyPopup : UserControl
|
||||||
|
{
|
||||||
|
#region ClickCount dependency property
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The number of clicks on the popup button.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly DependencyProperty ClickCountProperty =
|
||||||
|
DependencyProperty.Register("ClickCount",
|
||||||
|
typeof (int),
|
||||||
|
typeof (FancyPopup),
|
||||||
|
new FrameworkPropertyMetadata(0));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A property wrapper for the <see cref="ClickCountProperty"/>
|
||||||
|
/// dependency property:<br/>
|
||||||
|
/// The number of clicks on the popup button.
|
||||||
|
/// </summary>
|
||||||
|
public int ClickCount
|
||||||
|
{
|
||||||
|
get { return (int) GetValue(ClickCountProperty); }
|
||||||
|
set { SetValue(ClickCountProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public FancyPopup()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnButtonClick(object sender, RoutedEventArgs e)
|
||||||
|
{
|
||||||
|
//just increment a counter - will be displayed on screen
|
||||||
|
ClickCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
68
Source/Sample Project/FancyToolTip.xaml
Normal file
68
Source/Sample Project/FancyToolTip.xaml
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<UserControl
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:tb="clr-namespace:Hardcodet.Wpf.TaskbarNotification;assembly=Hardcodet.Wpf.TaskbarNotification"
|
||||||
|
mc:Ignorable="d"
|
||||||
|
x:Class="Sample_Project.FancyToolTip"
|
||||||
|
x:Name="me"
|
||||||
|
Width="285"
|
||||||
|
Height="108">
|
||||||
|
|
||||||
|
<Grid
|
||||||
|
x:Name="LayoutRoot">
|
||||||
|
<Border
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
Width="Auto"
|
||||||
|
Height="Auto"
|
||||||
|
CornerRadius="6,6,6,6"
|
||||||
|
BorderThickness="3,3,3,3"
|
||||||
|
Margin="0,0,5,5">
|
||||||
|
<Border.Effect>
|
||||||
|
<DropShadowEffect
|
||||||
|
Color="#FF7A7A7A" />
|
||||||
|
</Border.Effect>
|
||||||
|
<Border.Background>
|
||||||
|
<LinearGradientBrush
|
||||||
|
EndPoint="0.5,1"
|
||||||
|
StartPoint="0.5,0">
|
||||||
|
<GradientStop
|
||||||
|
Color="#FFFFD283"
|
||||||
|
Offset="0" />
|
||||||
|
<GradientStop
|
||||||
|
Color="#FFFFFFFF"
|
||||||
|
Offset="1" />
|
||||||
|
</LinearGradientBrush>
|
||||||
|
</Border.Background>
|
||||||
|
</Border>
|
||||||
|
<Image
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Margin="10,10,0,26"
|
||||||
|
Width="72"
|
||||||
|
Source="Images\Info.png"
|
||||||
|
Stretch="Fill"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
RenderTransformOrigin="0.792,0.486" />
|
||||||
|
<TextBlock
|
||||||
|
Margin="82,10,20,0"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
Height="32"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
FontSize="16"
|
||||||
|
FontWeight="Bold"
|
||||||
|
Foreground="#FF575757"><Run
|
||||||
|
Text="This is a fancy ToolTip..."
|
||||||
|
Language="de-ch" /></TextBlock>
|
||||||
|
<TextBlock
|
||||||
|
FontSize="12"
|
||||||
|
FontWeight="Normal"
|
||||||
|
Foreground="#FF141414"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
Margin="82,52,20,0"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Text="{Binding ElementName=me, Path=InfoText}"
|
||||||
|
x:Name="txtToolTipDetail" />
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
80
Source/Sample Project/FancyToolTip.xaml.cs
Normal file
80
Source/Sample Project/FancyToolTip.xaml.cs
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using System.Windows;
|
||||||
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Data;
|
||||||
|
using System.Windows.Documents;
|
||||||
|
using System.Windows.Input;
|
||||||
|
using System.Windows.Media;
|
||||||
|
using System.Windows.Media.Imaging;
|
||||||
|
using System.Windows.Navigation;
|
||||||
|
using System.Windows.Shapes;
|
||||||
|
|
||||||
|
namespace Sample_Project
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Interaction logic for FancyToolTip.xaml
|
||||||
|
/// </summary>
|
||||||
|
public partial class FancyToolTip
|
||||||
|
{
|
||||||
|
#region InfoText dependency property
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The tooltip details.
|
||||||
|
/// </summary>
|
||||||
|
public static readonly DependencyProperty InfoTextProperty =
|
||||||
|
DependencyProperty.Register("InfoText",
|
||||||
|
typeof (string),
|
||||||
|
typeof (FancyToolTip),
|
||||||
|
new FrameworkPropertyMetadata("", InfoTextPropertyChanged));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A property wrapper for the <see cref="InfoTextProperty"/>
|
||||||
|
/// dependency property:<br/>
|
||||||
|
/// The tooltip details.
|
||||||
|
/// </summary>
|
||||||
|
public string InfoText
|
||||||
|
{
|
||||||
|
get { return (string) GetValue(InfoTextProperty); }
|
||||||
|
set { SetValue(InfoTextProperty, value); }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A static callback listener which is being invoked if the
|
||||||
|
/// <see cref="InfoTextProperty"/> dependency property has
|
||||||
|
/// been changed. Invokes the <see cref="OnInfoTextPropertyChanged"/>
|
||||||
|
/// instance method of the changed instance.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="d">The currently processed owner of the property.</param>
|
||||||
|
/// <param name="e">Provides information about the updated property.</param>
|
||||||
|
private static void InfoTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
FancyToolTip owner = (FancyToolTip) d;
|
||||||
|
owner.OnInfoTextPropertyChanged(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles changes of the <see cref="InfoTextProperty"/> dependency property. As
|
||||||
|
/// WPF internally uses the dependency property system and bypasses the
|
||||||
|
/// <see cref="InfoText"/> property wrapper, updates of the property's value
|
||||||
|
/// should be handled here.
|
||||||
|
/// </summary
|
||||||
|
/// <param name="e">Provides information about the updated property.</param>
|
||||||
|
private void OnInfoTextPropertyChanged(DependencyPropertyChangedEventArgs e)
|
||||||
|
{
|
||||||
|
// string newValue = (string) e.NewValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public FancyToolTip()
|
||||||
|
{
|
||||||
|
this.InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
Source/Sample Project/Icons/Error.ico
Normal file
BIN
Source/Sample Project/Icons/Error.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
Source/Sample Project/Icons/Inactive.ico
Normal file
BIN
Source/Sample Project/Icons/Inactive.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
BIN
Source/Sample Project/Images/Add.png
Normal file
BIN
Source/Sample Project/Images/Add.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 502 B |
BIN
Source/Sample Project/Images/Info.png
Normal file
BIN
Source/Sample Project/Images/Info.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.9 KiB |
BIN
Source/Sample Project/Images/Remove.png
Normal file
BIN
Source/Sample Project/Images/Remove.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 237 B |
BIN
Source/Sample Project/Images/preferences.png
Normal file
BIN
Source/Sample Project/Images/preferences.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.6 KiB |
@@ -33,6 +33,7 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="PresentationFramework.Aero" />
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core">
|
<Reference Include="System.Core">
|
||||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
@@ -46,29 +47,63 @@
|
|||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="WindowsBase" />
|
<Reference Include="UIAutomationProvider">
|
||||||
<Reference Include="PresentationCore" />
|
<RequiredTargetFramework>3.0</RequiredTargetFramework>
|
||||||
<Reference Include="PresentationFramework" />
|
</Reference>
|
||||||
|
<Reference Include="WindowsBase">
|
||||||
|
<RequiredTargetFramework>3.0</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="PresentationCore">
|
||||||
|
<RequiredTargetFramework>3.0</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="PresentationFramework">
|
||||||
|
<RequiredTargetFramework>3.0</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
|
<Resource Include="Icons\Inactive.ico" />
|
||||||
|
<Resource Include="Icons\Error.ico" />
|
||||||
|
<Resource Include="Images\Info.png" />
|
||||||
|
<Resource Include="Images\preferences.png" />
|
||||||
|
<Page Include="FancyToolTip.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
|
<Page Include="TaskbarIconResources.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
|
<Compile Include="FancyToolTip.xaml.cs">
|
||||||
|
<DependentUpon>FancyToolTip.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ApplicationDefinition Include="App.xaml">
|
<ApplicationDefinition Include="App.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</ApplicationDefinition>
|
</ApplicationDefinition>
|
||||||
|
<Page Include="FancyPopup.xaml">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
</Page>
|
||||||
<Page Include="Window1.xaml">
|
<Page Include="Window1.xaml">
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
</Page>
|
</Page>
|
||||||
<Compile Include="App.xaml.cs">
|
<Compile Include="App.xaml.cs">
|
||||||
<DependentUpon>App.xaml</DependentUpon>
|
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
|
<DependentUpon>App.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Window1.xaml.cs">
|
<Compile Include="Window1.xaml.cs">
|
||||||
<DependentUpon>Window1.xaml</DependentUpon>
|
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
|
<DependentUpon>Window1.xaml</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Commands\TaskbarIconCommands.cs" />
|
||||||
|
<Compile Include="Commands\HideMainWindowCommand.cs" />
|
||||||
|
<Compile Include="Commands\ShowMainWindowCommand.cs" />
|
||||||
|
<Compile Include="FancyPopup.xaml.cs">
|
||||||
|
<DependentUpon>FancyPopup.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
<Compile Include="Properties\AssemblyInfo.cs">
|
<Compile Include="Properties\AssemblyInfo.cs">
|
||||||
<SubType>Code</SubType>
|
<SubType>Code</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -79,8 +114,8 @@
|
|||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Properties\Settings.Designer.cs">
|
<Compile Include="Properties\Settings.Designer.cs">
|
||||||
<AutoGen>True</AutoGen>
|
<AutoGen>True</AutoGen>
|
||||||
<DependentUpon>Settings.settings</DependentUpon>
|
|
||||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||||
|
<DependentUpon>Settings.settings</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
@@ -107,6 +142,10 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Resource Include="Icons\Computers.ico" />
|
<Resource Include="Icons\Computers.ico" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Resource Include="Images\Add.png" />
|
||||||
|
<Resource Include="Images\Remove.png" />
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Folder Include="Samples\" />
|
<Folder Include="Samples\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
142
Source/Sample Project/TaskbarIconResources.xaml
Normal file
142
Source/Sample Project/TaskbarIconResources.xaml
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
<ResourceDictionary
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:Commands="clr-namespace:Sample_Project.Commands"
|
||||||
|
xmlns:tb="clr-namespace:Hardcodet.Wpf.TaskbarNotification;assembly=Hardcodet.Wpf.TaskbarNotification"
|
||||||
|
>
|
||||||
|
<LinearGradientBrush x:Key="MenuBackground" EndPoint="0.5,1" StartPoint="0.5,0">
|
||||||
|
<GradientStop Color="#FFFFD892" Offset="1"/>
|
||||||
|
<GradientStop Color="#FFFFF3DD" Offset="0.259"/>
|
||||||
|
</LinearGradientBrush>
|
||||||
|
|
||||||
|
|
||||||
|
<Style TargetType="{x:Type ContextMenu}">
|
||||||
|
<Setter Property="BorderThickness" Value="1,1,1,1"/>
|
||||||
|
<Setter Property="Template">
|
||||||
|
<Setter.Value>
|
||||||
|
<ControlTemplate TargetType="{x:Type ContextMenu}">
|
||||||
|
<Border Background="{DynamicResource MenuBackground}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
|
||||||
|
<ScrollViewer Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}" Uid="ScrollViewer_9" CanContentScroll="True">
|
||||||
|
<ItemsPresenter Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" KeyboardNavigation.DirectionalNavigation="Cycle"/>
|
||||||
|
</ScrollViewer>
|
||||||
|
</Border>
|
||||||
|
</ControlTemplate>
|
||||||
|
</Setter.Value>
|
||||||
|
</Setter>
|
||||||
|
</Style>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- The taskbar context menu -->
|
||||||
|
<ContextMenu
|
||||||
|
x:Key="tbMenu">
|
||||||
|
<MenuItem
|
||||||
|
Header="Show Main Window"
|
||||||
|
Command="{Binding Source={x:Static Commands:TaskbarIconCommands.ShowMain}}">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<Image
|
||||||
|
Width="16"
|
||||||
|
Height="16"
|
||||||
|
Source="/Images/Add.png" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
|
||||||
|
<Separator />
|
||||||
|
|
||||||
|
<MenuItem
|
||||||
|
Header="Hide Main Window"
|
||||||
|
Command="{Binding Source={x:Static Commands:TaskbarIconCommands.HideMain}}">
|
||||||
|
<MenuItem.Icon>
|
||||||
|
<Image
|
||||||
|
Width="16"
|
||||||
|
Height="16"
|
||||||
|
Source="/Images/Remove.png" />
|
||||||
|
</MenuItem.Icon>
|
||||||
|
</MenuItem>
|
||||||
|
</ContextMenu>
|
||||||
|
|
||||||
|
|
||||||
|
<ToolTip
|
||||||
|
x:Key="tbToolTip"
|
||||||
|
Background="Transparent"
|
||||||
|
BorderThickness="0"
|
||||||
|
HasDropShadow="False"
|
||||||
|
VerticalOffset="-10"
|
||||||
|
>
|
||||||
|
<Grid
|
||||||
|
>
|
||||||
|
<Border
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
Width="Auto"
|
||||||
|
Height="Auto"
|
||||||
|
CornerRadius="6,6,6,6"
|
||||||
|
BorderThickness="3,3,3,3"
|
||||||
|
Margin="0,0,5,5">
|
||||||
|
<Border.Effect>
|
||||||
|
<DropShadowEffect
|
||||||
|
Color="#FF7A7A7A" />
|
||||||
|
</Border.Effect>
|
||||||
|
<Border.Background>
|
||||||
|
<LinearGradientBrush
|
||||||
|
EndPoint="0.5,1"
|
||||||
|
StartPoint="0.5,0">
|
||||||
|
<GradientStop
|
||||||
|
Color="#FFFFD283"
|
||||||
|
Offset="0" />
|
||||||
|
<GradientStop
|
||||||
|
Color="#FFFFFFFF"
|
||||||
|
Offset="1" />
|
||||||
|
</LinearGradientBrush>
|
||||||
|
</Border.Background>
|
||||||
|
</Border>
|
||||||
|
<Image
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Margin="10,10,0,26"
|
||||||
|
Width="72"
|
||||||
|
Source="Images\Info.png"
|
||||||
|
Stretch="Fill"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
RenderTransformOrigin="0.792,0.486" />
|
||||||
|
<TextBlock
|
||||||
|
Margin="82,10,20,0"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
Height="32"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
FontSize="16"
|
||||||
|
FontWeight="Bold"
|
||||||
|
Foreground="#FF575757"><Run
|
||||||
|
Text="This is a fancy ToolTip..."
|
||||||
|
Language="de-ch" /></TextBlock>
|
||||||
|
<TextBlock
|
||||||
|
FontSize="12"
|
||||||
|
FontWeight="Normal"
|
||||||
|
Foreground="#FF141414"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
Margin="82,52,20,0"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type tb:TaskbarIcon}}, Path=ToolTipText}"
|
||||||
|
/>
|
||||||
|
</Grid>
|
||||||
|
</ToolTip>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
As we don't declare the popup with the control, use
|
||||||
|
commands to trigger an action.
|
||||||
|
-->
|
||||||
|
<Popup
|
||||||
|
x:Key="tbPopupSimple"
|
||||||
|
PopupAnimation="Slide"
|
||||||
|
Placement="Mouse"
|
||||||
|
AllowsTransparency="True"
|
||||||
|
StaysOpen="False"
|
||||||
|
>
|
||||||
|
<Border
|
||||||
|
Width="200"
|
||||||
|
Height="200"
|
||||||
|
Background="Red">
|
||||||
|
<Button>Click me</Button>
|
||||||
|
</Border>
|
||||||
|
</Popup>
|
||||||
|
|
||||||
|
|
||||||
|
</ResourceDictionary>
|
||||||
@@ -2,146 +2,437 @@
|
|||||||
x:Class="Sample_Project.Window1"
|
x:Class="Sample_Project.Window1"
|
||||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||||
Title="Window1" Height="480" Width="579">
|
xmlns:sys="clr-namespace:System;assembly=mscorlib"
|
||||||
<Window.Resources>
|
Title="Window1"
|
||||||
<Storyboard x:Key="OnTaskbarIconLeftMouseUp1">
|
Height="808"
|
||||||
<BooleanAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="popup" Storyboard.TargetProperty="(Popup.IsOpen)">
|
Width="769"
|
||||||
<DiscreteBooleanKeyFrame KeyTime="00:00:00" Value="True"/>
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
<DiscreteBooleanKeyFrame KeyTime="00:00:02" Value="False"/>
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
</BooleanAnimationUsingKeyFrames>
|
mc:Ignorable="d"
|
||||||
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
|
xmlns:local="clr-namespace:Sample_Project">
|
||||||
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
|
<Window.Resources>
|
||||||
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="74"/>
|
|
||||||
<SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="26"/>
|
|
||||||
<SplineDoubleKeyFrame KeyTime="00:00:02" Value="0"/>
|
|
||||||
</DoubleAnimationUsingKeyFrames>
|
|
||||||
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
|
|
||||||
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
|
|
||||||
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="106"/>
|
|
||||||
<SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="151"/>
|
|
||||||
<SplineDoubleKeyFrame KeyTime="00:00:02" Value="0"/>
|
|
||||||
</DoubleAnimationUsingKeyFrames>
|
|
||||||
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="popup" Storyboard.TargetProperty="(UIElement.Opacity)">
|
|
||||||
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.1"/>
|
|
||||||
<SplineDoubleKeyFrame KeyTime="00:00:02" Value="1"/>
|
|
||||||
</DoubleAnimationUsingKeyFrames>
|
|
||||||
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.Opacity)">
|
|
||||||
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.47"/>
|
|
||||||
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="1"/>
|
|
||||||
<SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="1"/>
|
|
||||||
<SplineDoubleKeyFrame KeyTime="00:00:02" Value="0.685"/>
|
|
||||||
</DoubleAnimationUsingKeyFrames>
|
|
||||||
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="border" Storyboard.TargetProperty="(UIElement.Opacity)">
|
|
||||||
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
|
|
||||||
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="0.515"/>
|
|
||||||
</DoubleAnimationUsingKeyFrames>
|
|
||||||
</Storyboard>
|
|
||||||
</Window.Resources>
|
|
||||||
<Window.Triggers>
|
|
||||||
<EventTrigger RoutedEvent="tb:TaskbarIcon.TaskbarIconLeftMouseUp" SourceName="tb">
|
|
||||||
<BeginStoryboard Storyboard="{StaticResource OnTaskbarIconLeftMouseUp1}"/>
|
|
||||||
</EventTrigger>
|
|
||||||
</Window.Triggers>
|
|
||||||
<Grid>
|
|
||||||
<Grid.Resources>
|
|
||||||
|
|
||||||
<Border
|
<BooleanToVisibilityConverter
|
||||||
x:Key="yb"
|
x:Key="BooleanToVisibilityConverter" />
|
||||||
Background="Yellow">
|
|
||||||
<Button
|
|
||||||
Width="200"
|
|
||||||
Height="200"
|
|
||||||
Content="CONTENT" />
|
|
||||||
</Border>
|
|
||||||
|
|
||||||
<ToolTip x:Key="borderToolTip">
|
<ObjectDataProvider
|
||||||
<Border
|
MethodName="GetValues"
|
||||||
Background="Red"
|
ObjectType="{x:Type sys:Enum}"
|
||||||
Opacity="0.75">
|
x:Key="ActivationModes">
|
||||||
<TextBlock
|
<ObjectDataProvider.MethodParameters>
|
||||||
Text="hello world" />
|
<x:Type
|
||||||
</Border>
|
TypeName="tb:PopupActivationMode" />
|
||||||
</ToolTip>
|
</ObjectDataProvider.MethodParameters>
|
||||||
</Grid.Resources>
|
</ObjectDataProvider>
|
||||||
<tb:TaskbarIcon
|
|
||||||
x:Name="tb"
|
|
||||||
ToolTip="{StaticResource yb}" Height="23" VerticalAlignment="Top"
|
|
||||||
>
|
|
||||||
|
|
||||||
<tb:TaskbarIcon.TaskbarIconPopup>
|
|
||||||
<Popup StaysOpen="False">
|
<Storyboard
|
||||||
<Border
|
x:Key="OnTaskbarIconLeftMouseUp1">
|
||||||
Width="200"
|
<BooleanAnimationUsingKeyFrames
|
||||||
Height="200"
|
BeginTime="00:00:00"
|
||||||
Background="Orange">
|
Storyboard.TargetName="popup"
|
||||||
<TextBlock
|
Storyboard.TargetProperty="(Popup.IsOpen)">
|
||||||
Text="POPUP!" />
|
<DiscreteBooleanKeyFrame
|
||||||
</Border>
|
KeyTime="00:00:00"
|
||||||
</Popup>
|
Value="True" />
|
||||||
|
<DiscreteBooleanKeyFrame
|
||||||
|
KeyTime="00:00:02"
|
||||||
|
Value="False" />
|
||||||
|
</BooleanAnimationUsingKeyFrames>
|
||||||
|
<DoubleAnimationUsingKeyFrames
|
||||||
|
BeginTime="00:00:00"
|
||||||
|
Storyboard.TargetName="ellipse"
|
||||||
|
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
|
||||||
|
<SplineDoubleKeyFrame
|
||||||
|
KeyTime="00:00:00"
|
||||||
|
Value="0" />
|
||||||
|
<SplineDoubleKeyFrame
|
||||||
|
KeyTime="00:00:01"
|
||||||
|
Value="74" />
|
||||||
|
<SplineDoubleKeyFrame
|
||||||
|
KeyTime="00:00:01.5000000"
|
||||||
|
Value="26" />
|
||||||
|
<SplineDoubleKeyFrame
|
||||||
|
KeyTime="00:00:02"
|
||||||
|
Value="0" />
|
||||||
|
</DoubleAnimationUsingKeyFrames>
|
||||||
|
<DoubleAnimationUsingKeyFrames
|
||||||
|
BeginTime="00:00:00"
|
||||||
|
Storyboard.TargetName="ellipse"
|
||||||
|
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
|
||||||
|
<SplineDoubleKeyFrame
|
||||||
|
KeyTime="00:00:00"
|
||||||
|
Value="0" />
|
||||||
|
<SplineDoubleKeyFrame
|
||||||
|
KeyTime="00:00:01"
|
||||||
|
Value="106" />
|
||||||
|
<SplineDoubleKeyFrame
|
||||||
|
KeyTime="00:00:01.5000000"
|
||||||
|
Value="151" />
|
||||||
|
<SplineDoubleKeyFrame
|
||||||
|
KeyTime="00:00:02"
|
||||||
|
Value="0" />
|
||||||
|
</DoubleAnimationUsingKeyFrames>
|
||||||
|
<DoubleAnimationUsingKeyFrames
|
||||||
|
BeginTime="00:00:00"
|
||||||
|
Storyboard.TargetName="popup"
|
||||||
|
Storyboard.TargetProperty="(UIElement.Opacity)">
|
||||||
|
<SplineDoubleKeyFrame
|
||||||
|
KeyTime="00:00:00"
|
||||||
|
Value="0.1" />
|
||||||
|
<SplineDoubleKeyFrame
|
||||||
|
KeyTime="00:00:02"
|
||||||
|
Value="1" />
|
||||||
|
</DoubleAnimationUsingKeyFrames>
|
||||||
|
<DoubleAnimationUsingKeyFrames
|
||||||
|
BeginTime="00:00:00"
|
||||||
|
Storyboard.TargetName="ellipse"
|
||||||
|
Storyboard.TargetProperty="(UIElement.Opacity)">
|
||||||
|
<SplineDoubleKeyFrame
|
||||||
|
KeyTime="00:00:00"
|
||||||
|
Value="0.47" />
|
||||||
|
<SplineDoubleKeyFrame
|
||||||
|
KeyTime="00:00:01"
|
||||||
|
Value="1" />
|
||||||
|
<SplineDoubleKeyFrame
|
||||||
|
KeyTime="00:00:01.5000000"
|
||||||
|
Value="1" />
|
||||||
|
<SplineDoubleKeyFrame
|
||||||
|
KeyTime="00:00:02"
|
||||||
|
Value="0.685" />
|
||||||
|
</DoubleAnimationUsingKeyFrames>
|
||||||
|
<DoubleAnimationUsingKeyFrames
|
||||||
|
BeginTime="00:00:00"
|
||||||
|
Storyboard.TargetName="border"
|
||||||
|
Storyboard.TargetProperty="(UIElement.Opacity)">
|
||||||
|
<SplineDoubleKeyFrame
|
||||||
|
KeyTime="00:00:00"
|
||||||
|
Value="1" />
|
||||||
|
<SplineDoubleKeyFrame
|
||||||
|
KeyTime="00:00:01"
|
||||||
|
Value="0.515" />
|
||||||
|
</DoubleAnimationUsingKeyFrames>
|
||||||
|
</Storyboard>
|
||||||
|
</Window.Resources>
|
||||||
|
<Window.Triggers>
|
||||||
|
<EventTrigger
|
||||||
|
RoutedEvent="tb:TaskbarIcon.TaskbarIconLeftMouseUp"
|
||||||
|
SourceName="tb">
|
||||||
|
<BeginStoryboard
|
||||||
|
Storyboard="{StaticResource OnTaskbarIconLeftMouseUp1}" />
|
||||||
|
</EventTrigger>
|
||||||
|
</Window.Triggers>
|
||||||
|
<Grid>
|
||||||
|
<tb:TaskbarIcon
|
||||||
|
x:Name="tb"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
IconSource="{Binding Path=SelectedItem.Source, ElementName=iconList, Mode=Default}"
|
||||||
|
ContextMenu="{DynamicResource tbMenu}"
|
||||||
|
ToolTip="hello world"
|
||||||
|
ToolTipText="{Binding Path=Text, ElementName=txtToolTipText, Mode=Default}"
|
||||||
|
Visibility="{Binding Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, ElementName=iconVisibility, Mode=Default}"
|
||||||
|
MenuActivation="{Binding Path=SelectedItem, ElementName=lstMenuTrigger, Mode=Default}"
|
||||||
|
PopupActivation="{Binding Path=SelectedItem, ElementName=lstPopupTrigger, Mode=Default}">
|
||||||
|
|
||||||
|
<tb:TaskbarIcon.TaskbarIconPopup>
|
||||||
|
<local:FancyPopup />
|
||||||
</tb:TaskbarIcon.TaskbarIconPopup>
|
</tb:TaskbarIcon.TaskbarIconPopup>
|
||||||
|
|
||||||
<tb:TaskbarIcon.ContextMenu>
|
|
||||||
<ContextMenu>
|
|
||||||
<MenuItem
|
|
||||||
Header="Open" />
|
|
||||||
<MenuItem
|
|
||||||
Header="Quite" />
|
|
||||||
</ContextMenu>
|
|
||||||
</tb:TaskbarIcon.ContextMenu>
|
|
||||||
|
|
||||||
|
|
||||||
<!-- <tb:TaskbarIcon.ToolTip>-->
|
|
||||||
<!-- <Border Background="Yellow">-->
|
|
||||||
<!-- <TextBlock-->
|
|
||||||
<!-- Text="PopupToolTip" />-->
|
|
||||||
<!-- </Border>-->
|
|
||||||
<!-- </tb:TaskbarIcon.ToolTip>-->
|
|
||||||
</tb:TaskbarIcon>
|
|
||||||
|
|
||||||
|
<tb:TaskbarIcon.TaskbarIconToolTip>
|
||||||
|
<!-- the control will be put into a tooltip with an explicit DataContext -->
|
||||||
|
<local:FancyToolTip
|
||||||
|
Opacity="0.85"
|
||||||
|
InfoText="{Binding Path=ToolTipText}" />
|
||||||
|
</tb:TaskbarIcon.TaskbarIconToolTip>
|
||||||
|
|
||||||
|
</tb:TaskbarIcon>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
x:Name="btn"
|
x:Name="btn"
|
||||||
Click="OnClick"
|
Click="OnClick"
|
||||||
Content="Click me"
|
Content="Click me"
|
||||||
Height="24"
|
Height="24"
|
||||||
Margin="12,33,66,0"
|
Margin="0,70,68,0"
|
||||||
VerticalAlignment="Top" />
|
VerticalAlignment="Top"
|
||||||
|
Width="73"
|
||||||
|
HorizontalAlignment="Right" />
|
||||||
<Button
|
<Button
|
||||||
Height="23"
|
Height="23"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
Margin="0,91,64,0"
|
Margin="0,116,66,0"
|
||||||
Name="button1"
|
x:Name="button1"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
Width="75">Button</Button>
|
Width="75"
|
||||||
<TextBox
|
Content="Button" />
|
||||||
Text="{Binding ElementName=tb, Path=ToolTipText}"
|
<Popup
|
||||||
Height="23"
|
x:Name="popup"
|
||||||
Margin="13,91,0,0"
|
Margin="-231,-276,231,0"
|
||||||
Name="textBox1"
|
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
HorizontalAlignment="Left"
|
Height="549"
|
||||||
Width="120" />
|
d:IsHidden="True"
|
||||||
<Popup x:Name="popup">
|
d:IsLocked="True">
|
||||||
<Grid Width="180" Height="227">
|
<Grid
|
||||||
<Border CornerRadius="10,10,10,10" x:Name="border">
|
Width="180"
|
||||||
<Border.Background>
|
Height="227">
|
||||||
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
|
<Border
|
||||||
<GradientStop Color="#FFF4B569" Offset="0"/>
|
CornerRadius="10,10,10,10"
|
||||||
<GradientStop Color="#FFFFFFFF" Offset="1"/>
|
x:Name="border">
|
||||||
</LinearGradientBrush>
|
<Border.Background>
|
||||||
</Border.Background>
|
<LinearGradientBrush
|
||||||
</Border>
|
EndPoint="0.5,1"
|
||||||
<Ellipse Fill="#FFC13E3E" Stroke="#FF000000" VerticalAlignment="Top" Height="58" Margin="51,19,75,0" x:Name="ellipse" RenderTransformOrigin="0.5,0.5">
|
StartPoint="0.5,0">
|
||||||
<Ellipse.RenderTransform>
|
<GradientStop
|
||||||
<TransformGroup>
|
Color="#FFF4B569"
|
||||||
<ScaleTransform ScaleX="1" ScaleY="1"/>
|
Offset="0" />
|
||||||
<SkewTransform AngleX="0" AngleY="0"/>
|
<GradientStop
|
||||||
<RotateTransform Angle="0"/>
|
Color="#FFFFFFFF"
|
||||||
<TranslateTransform X="0" Y="0"/>
|
Offset="1" />
|
||||||
</TransformGroup>
|
</LinearGradientBrush>
|
||||||
</Ellipse.RenderTransform>
|
</Border.Background>
|
||||||
</Ellipse>
|
</Border>
|
||||||
</Grid>
|
<Ellipse
|
||||||
|
Fill="#FFC13E3E"
|
||||||
|
Stroke="#FF000000"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Height="58"
|
||||||
|
Margin="51,19,75,0"
|
||||||
|
x:Name="ellipse"
|
||||||
|
RenderTransformOrigin="0.5,0.5">
|
||||||
|
<Ellipse.RenderTransform>
|
||||||
|
<TransformGroup>
|
||||||
|
<ScaleTransform
|
||||||
|
ScaleX="1"
|
||||||
|
ScaleY="1" />
|
||||||
|
<SkewTransform
|
||||||
|
AngleX="0"
|
||||||
|
AngleY="0" />
|
||||||
|
<RotateTransform
|
||||||
|
Angle="0" />
|
||||||
|
<TranslateTransform
|
||||||
|
X="0"
|
||||||
|
Y="0" />
|
||||||
|
</TransformGroup>
|
||||||
|
</Ellipse.RenderTransform>
|
||||||
|
</Ellipse>
|
||||||
|
</Grid>
|
||||||
</Popup>
|
</Popup>
|
||||||
|
<CheckBox
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Margin="8,116,0,0"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Width="155.42"
|
||||||
|
Content="Taskbar Icon Visible"
|
||||||
|
x:Name="iconVisibility"
|
||||||
|
IsChecked="True" />
|
||||||
|
<ListBox
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Margin="8,171,0,0"
|
||||||
|
Width="123"
|
||||||
|
IsSynchronizedWithCurrentItem="True"
|
||||||
|
Height="51"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
x:Name="iconList"
|
||||||
|
SelectedIndex="0">
|
||||||
|
<Image
|
||||||
|
Width="16"
|
||||||
|
Margin="0,4,0,0"
|
||||||
|
Height="16"
|
||||||
|
Source="Icons\Inactive.ico" />
|
||||||
|
<Image
|
||||||
|
Width="16"
|
||||||
|
Margin="0,4,0,0"
|
||||||
|
Height="16"
|
||||||
|
Source="Icons\Error.ico" />
|
||||||
|
|
||||||
|
</ListBox>
|
||||||
|
<TextBlock
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Margin="8,149,0,0"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Width="Auto"
|
||||||
|
Height="22"
|
||||||
|
TextWrapping="Wrap"><Run
|
||||||
|
Text="Taskbar Icon:"
|
||||||
|
Language="de-ch" /></TextBlock>
|
||||||
|
<Grid
|
||||||
|
Margin="0,0,10,24"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Height="242"
|
||||||
|
Width="358"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
x:Name="Balloons">
|
||||||
|
<Border
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
BorderBrush="#FF000000"
|
||||||
|
BorderThickness="2,2,2,2" />
|
||||||
|
<TextBox
|
||||||
|
Margin="127,20,15,0"
|
||||||
|
x:Name="txtBalloonTitle"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Height="23" />
|
||||||
|
<TextBox
|
||||||
|
Margin="127,65,15,97"
|
||||||
|
x:Name="txtBalloonText" />
|
||||||
|
<RadioButton
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Margin="14,0,0,54"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Width="111"
|
||||||
|
Height="22"
|
||||||
|
Content="Show as Info"
|
||||||
|
IsChecked="True" />
|
||||||
|
<TextBlock
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Margin="14,20,0,0"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Width="85"
|
||||||
|
Height="23"
|
||||||
|
TextWrapping="Wrap"><Run
|
||||||
|
Text="Balloon Title"
|
||||||
|
Language="de-ch" /></TextBlock>
|
||||||
|
<TextBlock
|
||||||
|
Margin="14,65,0,0"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Height="23"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Width="85"><Run
|
||||||
|
Text="Balloon Text"
|
||||||
|
Language="de-ch" /></TextBlock>
|
||||||
|
<RadioButton
|
||||||
|
Margin="14,0,0,32"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Height="22"
|
||||||
|
Content="Show as Error"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Width="111" />
|
||||||
|
<RadioButton
|
||||||
|
Margin="14,0,0,10"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Height="22"
|
||||||
|
Content="Show Custom Icon"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Width="130" />
|
||||||
|
<Button
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
Margin="0,0,21,12.52"
|
||||||
|
x:Name="showBalloonTip"
|
||||||
|
Width="120"
|
||||||
|
Content="Show Balloon Tip"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Height="23" />
|
||||||
|
</Grid>
|
||||||
|
<Grid
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Margin="12,0,0,24"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Width="307"
|
||||||
|
Height="242"
|
||||||
|
x:Name="Popups">
|
||||||
|
<Border
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
BorderBrush="#FF000000"
|
||||||
|
BorderThickness="2,2,2,2" />
|
||||||
|
<ListBox
|
||||||
|
IsSynchronizedWithCurrentItem="False"
|
||||||
|
x:Name="lstPopupTrigger"
|
||||||
|
ItemsSource="{Binding Mode=OneWay, Source={StaticResource ActivationModes}}"
|
||||||
|
Margin="14,115,97,10"
|
||||||
|
SelectedIndex="0" />
|
||||||
|
<RadioButton
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Margin="14,19,0,0"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Width="Auto"
|
||||||
|
Height="22"
|
||||||
|
Content="Use simple Popup"
|
||||||
|
IsChecked="True" />
|
||||||
|
<RadioButton
|
||||||
|
Margin="14,41,97,0"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Height="22"
|
||||||
|
Content="Use Popup with Storyboard" />
|
||||||
|
<TextBlock
|
||||||
|
Margin="14,83,106,0"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Height="22"><Run
|
||||||
|
Text="Display Popup on:"
|
||||||
|
Language="de-ch" /></TextBlock>
|
||||||
|
</Grid>
|
||||||
|
<Grid
|
||||||
|
Margin="0,323,10,276"
|
||||||
|
Width="358"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
x:Name="ToolTips">
|
||||||
|
<Border
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
BorderBrush="#FF000000"
|
||||||
|
BorderThickness="2,2,2,2" />
|
||||||
|
<RadioButton
|
||||||
|
Margin="14,38,10,42"
|
||||||
|
Content="Use custom ToolTip on MouseOver (Vista and above)" />
|
||||||
|
<RadioButton
|
||||||
|
Margin="14,60,97,0"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Height="22"
|
||||||
|
Content="Use custom ToolTip with Storyboard" />
|
||||||
|
<RadioButton
|
||||||
|
Margin="14,16,10,0"
|
||||||
|
Content="Only use ToolTipText (no custom tooltip)"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Height="22"
|
||||||
|
IsChecked="True" />
|
||||||
|
<TextBox
|
||||||
|
Margin="14,0,21,19"
|
||||||
|
x:Name="txtToolTipText"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Height="23"
|
||||||
|
Text="Click to open tooltip" />
|
||||||
|
<TextBlock
|
||||||
|
Margin="14,0,157,52"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
Height="16"
|
||||||
|
TextWrapping="Wrap"><Run
|
||||||
|
Text="ToolTip Text:"
|
||||||
|
Language="de-ch" /></TextBlock>
|
||||||
|
</Grid>
|
||||||
|
<Grid
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
Margin="12,323,0,276"
|
||||||
|
Width="307"
|
||||||
|
x:Name="ContextMenus">
|
||||||
|
<Border
|
||||||
|
BorderBrush="#FF000000"
|
||||||
|
BorderThickness="2,2,2,2" />
|
||||||
|
<ListBox
|
||||||
|
Margin="10,0,128,10"
|
||||||
|
IsSynchronizedWithCurrentItem="False"
|
||||||
|
x:Name="lstMenuTrigger"
|
||||||
|
ItemsSource="{Binding Mode=OneWay, Source={StaticResource ActivationModes}}"
|
||||||
|
Height="124"
|
||||||
|
VerticalAlignment="Bottom"
|
||||||
|
SelectedIndex="1" />
|
||||||
|
<TextBlock
|
||||||
|
Margin="10,10,110,0"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Height="22"
|
||||||
|
TextWrapping="Wrap"><Run
|
||||||
|
Text="Trigger Context Menu:"
|
||||||
|
Language="de-ch" /></TextBlock>
|
||||||
|
</Grid>
|
||||||
|
<TextBlock
|
||||||
|
Margin="10,10,45,0"
|
||||||
|
VerticalAlignment="Top"
|
||||||
|
Height="Auto"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
FontWeight="Bold"
|
||||||
|
FontSize="14"><Run
|
||||||
|
Text="This window only contains the plumbing. In order to keep things separated, I created a few user controls for the popups and the TaskbarIcon instance."
|
||||||
|
Language="de-ch" /></TextBlock>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@@ -19,13 +20,11 @@ namespace Sample_Project
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class Window1 : Window
|
public partial class Window1 : Window
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public Window1()
|
public Window1()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
//set icon in code - setting the IconSource in XAML
|
|
||||||
//works just fine but breaks the VS designer
|
|
||||||
tb.Icon = Properties.Resources.Computers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClick(object sender, RoutedEventArgs e)
|
private void OnClick(object sender, RoutedEventArgs e)
|
||||||
|
|||||||
Reference in New Issue
Block a user