mirror of
https://github.com/ckaczor/wpf-notifyicon.git
synced 2026-01-21 01:35:39 -05:00
CHG Reformatting code (NTFY-20).
git-svn-id: https://svn.evolvesoftware.ch/repos/evolve.net/WPF/NotifyIcon@192 9f600761-6f11-4665-b6dc-0185e9171623
This commit is contained in:
@@ -8,11 +8,10 @@ using Hardcodet.Wpf.TaskbarNotification;
|
||||
|
||||
namespace Samples
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -8,151 +8,150 @@ using Hardcodet.Wpf.TaskbarNotification;
|
||||
|
||||
namespace Samples.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// Basic implementation of the <see cref="ICommand"/>
|
||||
/// interface, which is also accessible as a markup
|
||||
/// extension.
|
||||
/// </summary>
|
||||
public abstract class CommandBase<T> : MarkupExtension, ICommand
|
||||
where T : class, ICommand, new()
|
||||
{
|
||||
/// <summary>
|
||||
/// A singleton instance.
|
||||
/// Basic implementation of the <see cref="ICommand"/>
|
||||
/// interface, which is also accessible as a markup
|
||||
/// extension.
|
||||
/// </summary>
|
||||
private static T command;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a shared command instance.
|
||||
/// </summary>
|
||||
public override object ProvideValue(IServiceProvider serviceProvider)
|
||||
public abstract class CommandBase<T> : MarkupExtension, ICommand
|
||||
where T : class, ICommand, new()
|
||||
{
|
||||
if (command == null) command = new T();
|
||||
return command;
|
||||
/// <summary>
|
||||
/// A singleton instance.
|
||||
/// </summary>
|
||||
private static T command;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a shared command instance.
|
||||
/// </summary>
|
||||
public override object ProvideValue(IServiceProvider serviceProvider)
|
||||
{
|
||||
if (command == null) command = new T();
|
||||
return command;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires when changes occur that affect whether
|
||||
/// or not the command should execute.
|
||||
/// </summary>
|
||||
public event EventHandler CanExecuteChanged
|
||||
{
|
||||
add { CommandManager.RequerySuggested += value; }
|
||||
remove { CommandManager.RequerySuggested -= value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the method to be called when the command is invoked.
|
||||
/// </summary>
|
||||
/// <param name="parameter">Data used by the command.
|
||||
/// If the command does not require data to be passed,
|
||||
/// this object can be set to null.
|
||||
/// </param>
|
||||
public abstract void Execute(object parameter);
|
||||
|
||||
/// <summary>
|
||||
/// Defines the method that determines whether the command
|
||||
/// can execute in its current state.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// This default implementation always returns true.
|
||||
/// </returns>
|
||||
/// <param name="parameter">Data used by the command.
|
||||
/// If the command does not require data to be passed,
|
||||
/// this object can be set to null.
|
||||
/// </param>
|
||||
public virtual bool CanExecute(object parameter)
|
||||
{
|
||||
return IsDesignMode ? false : true;
|
||||
}
|
||||
|
||||
|
||||
public static bool IsDesignMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool)
|
||||
DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty,
|
||||
typeof (FrameworkElement))
|
||||
.Metadata.DefaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the window that owns the TaskbarIcon class.
|
||||
/// </summary>
|
||||
/// <param name="commandParameter"></param>
|
||||
/// <returns></returns>
|
||||
protected Window GetTaskbarWindow(object commandParameter)
|
||||
{
|
||||
if (IsDesignMode) return null;
|
||||
|
||||
//get the showcase window off the taskbaricon
|
||||
var tb = commandParameter as TaskbarIcon;
|
||||
return tb == null ? null : TryFindParent<Window>(tb);
|
||||
}
|
||||
|
||||
#region TryFindParent helper
|
||||
|
||||
/// <summary>
|
||||
/// Finds a parent of a given item on the visual tree.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the queried item.</typeparam>
|
||||
/// <param name="child">A direct or indirect child of the
|
||||
/// queried item.</param>
|
||||
/// <returns>The first parent item that matches the submitted
|
||||
/// type parameter. If not matching item can be found, a null
|
||||
/// reference is being returned.</returns>
|
||||
public static T TryFindParent<T>(DependencyObject child)
|
||||
where T : DependencyObject
|
||||
{
|
||||
//get parent item
|
||||
DependencyObject parentObject = GetParentObject(child);
|
||||
|
||||
//we've reached the end of the tree
|
||||
if (parentObject == null) return null;
|
||||
|
||||
//check if the parent matches the type we're looking for
|
||||
T parent = parentObject as T;
|
||||
if (parent != null)
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
else
|
||||
{
|
||||
//use recursion to proceed with next level
|
||||
return TryFindParent<T>(parentObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is an alternative to WPF's
|
||||
/// <see cref="VisualTreeHelper.GetParent"/> method, which also
|
||||
/// supports content elements. Keep in mind that for content element,
|
||||
/// this method falls back to the logical tree of the element!
|
||||
/// </summary>
|
||||
/// <param name="child">The item to be processed.</param>
|
||||
/// <returns>The submitted item's parent, if available. Otherwise
|
||||
/// null.</returns>
|
||||
public static DependencyObject GetParentObject(DependencyObject child)
|
||||
{
|
||||
if (child == null) return null;
|
||||
ContentElement contentElement = child as ContentElement;
|
||||
|
||||
if (contentElement != null)
|
||||
{
|
||||
DependencyObject parent = ContentOperations.GetParent(contentElement);
|
||||
if (parent != null) return parent;
|
||||
|
||||
FrameworkContentElement fce = contentElement as FrameworkContentElement;
|
||||
return fce != null ? fce.Parent : null;
|
||||
}
|
||||
|
||||
//if it's not a ContentElement, rely on VisualTreeHelper
|
||||
return VisualTreeHelper.GetParent(child);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires when changes occur that affect whether
|
||||
/// or not the command should execute.
|
||||
/// </summary>
|
||||
public event EventHandler CanExecuteChanged
|
||||
{
|
||||
add { CommandManager.RequerySuggested += value; }
|
||||
remove { CommandManager.RequerySuggested -= value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Defines the method to be called when the command is invoked.
|
||||
/// </summary>
|
||||
/// <param name="parameter">Data used by the command.
|
||||
/// If the command does not require data to be passed,
|
||||
/// this object can be set to null.
|
||||
/// </param>
|
||||
public abstract void Execute(object parameter);
|
||||
|
||||
/// <summary>
|
||||
/// Defines the method that determines whether the command
|
||||
/// can execute in its current state.
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// This default implementation always returns true.
|
||||
/// </returns>
|
||||
/// <param name="parameter">Data used by the command.
|
||||
/// If the command does not require data to be passed,
|
||||
/// this object can be set to null.
|
||||
/// </param>
|
||||
public virtual bool CanExecute(object parameter)
|
||||
{
|
||||
return IsDesignMode ? false : true;
|
||||
}
|
||||
|
||||
|
||||
public static bool IsDesignMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool)
|
||||
DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty, typeof(FrameworkElement))
|
||||
.Metadata.DefaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the window that owns the TaskbarIcon class.
|
||||
/// </summary>
|
||||
/// <param name="commandParameter"></param>
|
||||
/// <returns></returns>
|
||||
protected Window GetTaskbarWindow(object commandParameter)
|
||||
{
|
||||
if (IsDesignMode) return null;
|
||||
|
||||
//get the showcase window off the taskbaricon
|
||||
var tb = commandParameter as TaskbarIcon;
|
||||
return tb == null ? null : TryFindParent<Window>(tb);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region TryFindParent helper
|
||||
|
||||
/// <summary>
|
||||
/// Finds a parent of a given item on the visual tree.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of the queried item.</typeparam>
|
||||
/// <param name="child">A direct or indirect child of the
|
||||
/// queried item.</param>
|
||||
/// <returns>The first parent item that matches the submitted
|
||||
/// type parameter. If not matching item can be found, a null
|
||||
/// reference is being returned.</returns>
|
||||
public static T TryFindParent<T>(DependencyObject child)
|
||||
where T : DependencyObject
|
||||
{
|
||||
//get parent item
|
||||
DependencyObject parentObject = GetParentObject(child);
|
||||
|
||||
//we've reached the end of the tree
|
||||
if (parentObject == null) return null;
|
||||
|
||||
//check if the parent matches the type we're looking for
|
||||
T parent = parentObject as T;
|
||||
if (parent != null)
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
else
|
||||
{
|
||||
//use recursion to proceed with next level
|
||||
return TryFindParent<T>(parentObject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This method is an alternative to WPF's
|
||||
/// <see cref="VisualTreeHelper.GetParent"/> method, which also
|
||||
/// supports content elements. Keep in mind that for content element,
|
||||
/// this method falls back to the logical tree of the element!
|
||||
/// </summary>
|
||||
/// <param name="child">The item to be processed.</param>
|
||||
/// <returns>The submitted item's parent, if available. Otherwise
|
||||
/// null.</returns>
|
||||
public static DependencyObject GetParentObject(DependencyObject child)
|
||||
{
|
||||
if (child == null) return null;
|
||||
ContentElement contentElement = child as ContentElement;
|
||||
|
||||
if (contentElement != null)
|
||||
{
|
||||
DependencyObject parent = ContentOperations.GetParent(contentElement);
|
||||
if (parent != null) return parent;
|
||||
|
||||
FrameworkContentElement fce = contentElement as FrameworkContentElement;
|
||||
return fce != null ? fce.Parent : null;
|
||||
}
|
||||
|
||||
//if it's not a ContentElement, rely on VisualTreeHelper
|
||||
return VisualTreeHelper.GetParent(child);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,25 +3,22 @@ using System.Windows.Input;
|
||||
|
||||
namespace Samples.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// Hides the main window.
|
||||
/// </summary>
|
||||
public class HideSampleWindowCommand : CommandBase<HideSampleWindowCommand>
|
||||
{
|
||||
|
||||
public override void Execute(object parameter)
|
||||
/// <summary>
|
||||
/// Hides the main window.
|
||||
/// </summary>
|
||||
public class HideSampleWindowCommand : CommandBase<HideSampleWindowCommand>
|
||||
{
|
||||
GetTaskbarWindow(parameter).Hide();
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
public override void Execute(object parameter)
|
||||
{
|
||||
GetTaskbarWindow(parameter).Hide();
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
|
||||
|
||||
public override bool CanExecute(object parameter)
|
||||
{
|
||||
Window win = GetTaskbarWindow(parameter);
|
||||
return win != null && win.IsVisible;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override bool CanExecute(object parameter)
|
||||
{
|
||||
Window win = GetTaskbarWindow(parameter);
|
||||
return win != null && win.IsVisible;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,22 +3,22 @@ using System.Windows.Input;
|
||||
|
||||
namespace Samples.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// Shows the main window.
|
||||
/// </summary>
|
||||
public class ShowSampleWindowCommand : CommandBase<ShowSampleWindowCommand>
|
||||
{
|
||||
public override void Execute(object parameter)
|
||||
/// <summary>
|
||||
/// Shows the main window.
|
||||
/// </summary>
|
||||
public class ShowSampleWindowCommand : CommandBase<ShowSampleWindowCommand>
|
||||
{
|
||||
GetTaskbarWindow(parameter).Show();
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
public override void Execute(object parameter)
|
||||
{
|
||||
GetTaskbarWindow(parameter).Show();
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
|
||||
|
||||
public override bool CanExecute(object parameter)
|
||||
{
|
||||
Window win = GetTaskbarWindow(parameter);
|
||||
return win != null && !win.IsVisible;
|
||||
public override bool CanExecute(object parameter)
|
||||
{
|
||||
Window win = GetTaskbarWindow(parameter);
|
||||
return win != null && !win.IsVisible;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,210 +1,227 @@
|
||||
<Window
|
||||
x:Class="Samples.Main"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="NotifyIcon Samples"
|
||||
Height="563"
|
||||
Width="703"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
<Grid
|
||||
Hyperlink.RequestNavigate="OnNavigationRequest">
|
||||
<Grid.Background>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0.673,0.95"
|
||||
StartPoint="0.274,0.137">
|
||||
<GradientStop
|
||||
Color="#FFFFFFFF"
|
||||
Offset="0" />
|
||||
<GradientStop
|
||||
Color="#FFB4C6D8"
|
||||
Offset="0.982" />
|
||||
</LinearGradientBrush>
|
||||
</Grid.Background>
|
||||
x:Class="Samples.Main"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="NotifyIcon Samples"
|
||||
Height="563"
|
||||
Width="703"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
<Grid
|
||||
Hyperlink.RequestNavigate="OnNavigationRequest">
|
||||
<Grid.Background>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0.673,0.95"
|
||||
StartPoint="0.274,0.137">
|
||||
<GradientStop
|
||||
Color="#FFFFFFFF"
|
||||
Offset="0" />
|
||||
<GradientStop
|
||||
Color="#FFB4C6D8"
|
||||
Offset="0.982" />
|
||||
</LinearGradientBrush>
|
||||
</Grid.Background>
|
||||
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,10,0,0"
|
||||
VerticalAlignment="Top"
|
||||
FontSize="14"
|
||||
FontStyle="Italic"
|
||||
FontWeight="Bold"
|
||||
TextWrapping="Wrap"><Run
|
||||
Text="WPF NotifyIcon 1.0.4 - Samples" /></TextBlock>
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,133,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="164"
|
||||
Height="27"
|
||||
Content="NotifyIcon Declaration"
|
||||
x:Name="btnDeclaration"
|
||||
Click="btnDeclaration_Click" />
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,50,0,0"
|
||||
VerticalAlignment="Top"
|
||||
FontWeight="Bold"
|
||||
TextWrapping="Wrap"><Run
|
||||
Text="Tutorials:" /></TextBlock>
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,75.96,0,0"
|
||||
VerticalAlignment="Top"
|
||||
TextWrapping="Wrap"
|
||||
Width="224.31"
|
||||
Height="47.04"
|
||||
d:LayoutOverrides="HorizontalAlignment"><Run
|
||||
Text="Tutorials follow the contents of the CodeProject article. Check the "Tutorials" folder for the source code." /></TextBlock>
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,170,0,0"
|
||||
Width="164"
|
||||
Content="ToolTips - Inline Declaration"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
x:Name="btnInlineToolTip"
|
||||
Click="btnInlineToolTip_Click" />
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,244,0,0"
|
||||
Width="164"
|
||||
Content="Popups"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
x:Name="btnPopups"
|
||||
Click="btnPopups_Click" />
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,281,0,0"
|
||||
Width="164"
|
||||
Content="Context Menus"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
x:Name="btnContextMenus"
|
||||
Click="btnContextMenus_Click" />
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,318,0,0"
|
||||
Width="164"
|
||||
Content="Balloon Tips"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
x:Name="btnBalloons"
|
||||
Click="btnBalloons_Click" />
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,355,0,0"
|
||||
Width="164"
|
||||
Content="Commands"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
x:Name="btnCommands"
|
||||
Click="btnCommands_Click" />
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,207,0,0"
|
||||
Width="164"
|
||||
Content="ToolTip User Control"
|
||||
Height="27"
|
||||
VerticalAlignment="Top"
|
||||
x:Name="btnToolTipControl"
|
||||
Click="btnToolTipControl_Click" />
|
||||
<TextBlock
|
||||
Margin="0,50,328.76,0"
|
||||
VerticalAlignment="Top"
|
||||
FontWeight="Bold"
|
||||
TextWrapping="Wrap"
|
||||
HorizontalAlignment="Right"
|
||||
d:LayoutOverrides="HorizontalAlignment, Width"><Run
|
||||
Text="Showcase Sample:" /></TextBlock>
|
||||
<TextBlock
|
||||
Margin="255.31,75.96,145.38,0"
|
||||
VerticalAlignment="Top"
|
||||
TextWrapping="Wrap"
|
||||
Height="47.04"><Run
|
||||
Text="An interactive sample that shows off most features on a single NotifyIcon." /></TextBlock>
|
||||
<Button
|
||||
Margin="255.31,133,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
Content="Open Sample Window"
|
||||
x:Name="btnMainSample"
|
||||
Click="btnMainSample_Click"
|
||||
Width="164"
|
||||
HorizontalAlignment="Left" />
|
||||
<Path
|
||||
Fill="#FFFFFFFF"
|
||||
Stretch="Fill"
|
||||
Stroke="#FF60758A"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="244.31,50,0,66"
|
||||
Width="1"
|
||||
Data="M269,57 L269,390.18163" Opacity="0.325" />
|
||||
<TextBlock
|
||||
Margin="255.31,191,10,0"
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Top">
|
||||
<Run Text="The latest news related to the component can be found on the project page:"/>
|
||||
<LineBreak/>
|
||||
<Hyperlink NavigateUri="http://www.hardcodet.net/wpf-notifyicon">
|
||||
<Run Text="http://www.hardcodet.net/wpf-notifyicon"/>
|
||||
</Hyperlink>
|
||||
<LineBreak/>
|
||||
<LineBreak/>
|
||||
<Run Text="Critical feedback is appreciated - please post bug reports, requests, questions etc. to the CodeProject forum"/>
|
||||
<Run Language="de-ch" Text=":"/>
|
||||
<LineBreak/>
|
||||
<Hyperlink NavigateUri="http://www.codeproject.com/KB/WPF/wpf_notifyicon.aspx">
|
||||
<Run Text="http://www.codeproject.com/KB/WPF/wpf_notifyicon.aspx"/>
|
||||
</Hyperlink>
|
||||
<LineBreak/>
|
||||
<LineBreak/>
|
||||
<LineBreak/>
|
||||
<TextBlock>
|
||||
<Run Text="Love it or hate it? Please let me know and "/>
|
||||
<Hyperlink NavigateUri="http://www.codeproject.com/KB/WPF/wpf_notifyicon.aspx">
|
||||
<Run FontWeight="Bold" Text="rate the project"/>
|
||||
</Hyperlink>
|
||||
<Run Text=" - thanks!" />
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,10,0,0"
|
||||
VerticalAlignment="Top"
|
||||
FontSize="14"
|
||||
FontStyle="Italic"
|
||||
FontWeight="Bold"
|
||||
TextWrapping="Wrap">
|
||||
<Run
|
||||
Text="WPF NotifyIcon 1.0.4 - Samples" />
|
||||
</TextBlock>
|
||||
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
Margin="10,0,10,10"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="22.42"
|
||||
TextWrapping="Wrap"
|
||||
FontWeight="Bold"><Run
|
||||
Text="WPF NotifyIcon is free software, released under the" /><Run
|
||||
Text=" " /><Hyperlink
|
||||
NavigateUri="http://www.codeproject.com/info/cpol10.aspx"><Run
|
||||
Text="CodeProject Open License" /></Hyperlink></TextBlock>
|
||||
<Path
|
||||
Fill="#FFFFFFFF"
|
||||
Stretch="Fill"
|
||||
Stroke="#FF60758A"
|
||||
Margin="11,0,17.926,41"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="1"
|
||||
Data="M11,517 L561.07363,517" Opacity="0.33" />
|
||||
<Button
|
||||
Margin="11,429,0,0"
|
||||
Content="Events"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
x:Name="btnEvents"
|
||||
Click="btnEvents_Click" Width="164" HorizontalAlignment="Left" />
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,392,0,0"
|
||||
Width="164"
|
||||
Content="Data Binding"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
x:Name="btnDataBinding"
|
||||
Click="btnDataBinding_Click" />
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,133,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="164"
|
||||
Height="27"
|
||||
Content="NotifyIcon Declaration"
|
||||
x:Name="btnDeclaration"
|
||||
Click="btnDeclaration_Click" />
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,50,0,0"
|
||||
VerticalAlignment="Top"
|
||||
FontWeight="Bold"
|
||||
TextWrapping="Wrap">
|
||||
<Run
|
||||
Text="Tutorials:" />
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,75.96,0,0"
|
||||
VerticalAlignment="Top"
|
||||
TextWrapping="Wrap"
|
||||
Width="224.31"
|
||||
Height="47.04"
|
||||
d:LayoutOverrides="HorizontalAlignment">
|
||||
<Run
|
||||
Text="Tutorials follow the contents of the CodeProject article. Check the "Tutorials" folder for the source code." />
|
||||
</TextBlock>
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,170,0,0"
|
||||
Width="164"
|
||||
Content="ToolTips - Inline Declaration"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
x:Name="btnInlineToolTip"
|
||||
Click="btnInlineToolTip_Click" />
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,244,0,0"
|
||||
Width="164"
|
||||
Content="Popups"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
x:Name="btnPopups"
|
||||
Click="btnPopups_Click" />
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,281,0,0"
|
||||
Width="164"
|
||||
Content="Context Menus"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
x:Name="btnContextMenus"
|
||||
Click="btnContextMenus_Click" />
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,318,0,0"
|
||||
Width="164"
|
||||
Content="Balloon Tips"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
x:Name="btnBalloons"
|
||||
Click="btnBalloons_Click" />
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,355,0,0"
|
||||
Width="164"
|
||||
Content="Commands"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
x:Name="btnCommands"
|
||||
Click="btnCommands_Click" />
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,207,0,0"
|
||||
Width="164"
|
||||
Content="ToolTip User Control"
|
||||
Height="27"
|
||||
VerticalAlignment="Top"
|
||||
x:Name="btnToolTipControl"
|
||||
Click="btnToolTipControl_Click" />
|
||||
<TextBlock
|
||||
Margin="0,50,328.76,0"
|
||||
VerticalAlignment="Top"
|
||||
FontWeight="Bold"
|
||||
TextWrapping="Wrap"
|
||||
HorizontalAlignment="Right"
|
||||
d:LayoutOverrides="HorizontalAlignment, Width">
|
||||
<Run
|
||||
Text="Showcase Sample:" />
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
Margin="255.31,75.96,145.38,0"
|
||||
VerticalAlignment="Top"
|
||||
TextWrapping="Wrap"
|
||||
Height="47.04">
|
||||
<Run
|
||||
Text="An interactive sample that shows off most features on a single NotifyIcon." />
|
||||
</TextBlock>
|
||||
<Button
|
||||
Margin="255.31,133,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
Content="Open Sample Window"
|
||||
x:Name="btnMainSample"
|
||||
Click="btnMainSample_Click"
|
||||
Width="164"
|
||||
HorizontalAlignment="Left" />
|
||||
<Path
|
||||
Fill="#FFFFFFFF"
|
||||
Stretch="Fill"
|
||||
Stroke="#FF60758A"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="244.31,50,0,66"
|
||||
Width="1"
|
||||
Data="M269,57 L269,390.18163" Opacity="0.325" />
|
||||
<TextBlock
|
||||
Margin="255.31,191,10,0"
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Top">
|
||||
<Run Text="The latest news related to the component can be found on the project page:" />
|
||||
<LineBreak />
|
||||
<Hyperlink NavigateUri="http://www.hardcodet.net/wpf-notifyicon">
|
||||
<Run Text="http://www.hardcodet.net/wpf-notifyicon" />
|
||||
</Hyperlink>
|
||||
<LineBreak />
|
||||
<LineBreak />
|
||||
<Run
|
||||
Text="Critical feedback is appreciated - please post bug reports, requests, questions etc. to the CodeProject forum" />
|
||||
<Run Language="de-ch" Text=":" />
|
||||
<LineBreak />
|
||||
<Hyperlink NavigateUri="http://www.codeproject.com/KB/WPF/wpf_notifyicon.aspx">
|
||||
<Run Text="http://www.codeproject.com/KB/WPF/wpf_notifyicon.aspx" />
|
||||
</Hyperlink>
|
||||
<LineBreak />
|
||||
<LineBreak />
|
||||
<LineBreak />
|
||||
<TextBlock>
|
||||
<Run Text="Love it or hate it? Please let me know and " />
|
||||
<Hyperlink NavigateUri="http://www.codeproject.com/KB/WPF/wpf_notifyicon.aspx">
|
||||
<Run FontWeight="Bold" Text="rate the project" />
|
||||
</Hyperlink>
|
||||
<Run Text=" - thanks!" />
|
||||
</TextBlock>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
Margin="10,0,10,10"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="22.42"
|
||||
TextWrapping="Wrap"
|
||||
FontWeight="Bold">
|
||||
<Run
|
||||
Text="WPF NotifyIcon is free software, released under the" />
|
||||
<Run
|
||||
Text=" " />
|
||||
<Hyperlink
|
||||
NavigateUri="http://www.codeproject.com/info/cpol10.aspx">
|
||||
<Run
|
||||
Text="CodeProject Open License" />
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
<Path
|
||||
Fill="#FFFFFFFF"
|
||||
Stretch="Fill"
|
||||
Stroke="#FF60758A"
|
||||
Margin="11,0,17.926,41"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="1"
|
||||
Data="M11,517 L561.07363,517" Opacity="0.33" />
|
||||
<Button
|
||||
Margin="11,429,0,0"
|
||||
Content="Events"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
x:Name="btnEvents"
|
||||
Click="btnEvents_Click" Width="164" HorizontalAlignment="Left" />
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,392,0,0"
|
||||
Width="164"
|
||||
Content="Data Binding"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
x:Name="btnDataBinding"
|
||||
Click="btnDataBinding_Click" />
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -11,90 +11,90 @@ using Samples.Tutorials.ToolTips;
|
||||
|
||||
namespace Samples
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Main.xaml
|
||||
/// </summary>
|
||||
public partial class Main : Window
|
||||
{
|
||||
public Main()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sets <see cref="Window.WindowStartupLocation"/> and
|
||||
/// <see cref="Window.Owner"/> properties of a dialog that
|
||||
/// is about to be displayed.
|
||||
/// Interaction logic for Main.xaml
|
||||
/// </summary>
|
||||
/// <param name="window">The processed window.</param>
|
||||
private void ShowDialog(Window window)
|
||||
public partial class Main : Window
|
||||
{
|
||||
window.Owner = this;
|
||||
window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
||||
window.ShowDialog();
|
||||
public Main()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sets <see cref="Window.WindowStartupLocation"/> and
|
||||
/// <see cref="Window.Owner"/> properties of a dialog that
|
||||
/// is about to be displayed.
|
||||
/// </summary>
|
||||
/// <param name="window">The processed window.</param>
|
||||
private void ShowDialog(Window window)
|
||||
{
|
||||
window.Owner = this;
|
||||
window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
||||
window.ShowDialog();
|
||||
}
|
||||
|
||||
private void btnDeclaration_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new SimpleWindowWithNotifyIcon());
|
||||
}
|
||||
|
||||
|
||||
private void btnInlineToolTip_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new InlineToolTipWindow());
|
||||
}
|
||||
|
||||
private void btnToolTipControl_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new UserControlToolTipWindow());
|
||||
}
|
||||
|
||||
private void btnPopups_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new InlinePopupWindow());
|
||||
}
|
||||
|
||||
private void btnContextMenus_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new InlineContextMenuWindow());
|
||||
}
|
||||
|
||||
private void btnBalloons_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new BalloonSampleWindow());
|
||||
}
|
||||
|
||||
private void btnCommands_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new CommandWindow());
|
||||
}
|
||||
|
||||
private void btnEvents_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new EventVisualizerWindow());
|
||||
}
|
||||
|
||||
private void btnDataBinding_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new DataBoundToolTipWindow());
|
||||
}
|
||||
|
||||
private void btnMainSample_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var sampleWindow = new ShowcaseWindow();
|
||||
|
||||
sampleWindow.Owner = this;
|
||||
sampleWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
sampleWindow.ShowDialog();
|
||||
}
|
||||
|
||||
|
||||
private void OnNavigationRequest(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
|
||||
{
|
||||
Process.Start(e.Uri.ToString());
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void btnDeclaration_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new SimpleWindowWithNotifyIcon());
|
||||
}
|
||||
|
||||
|
||||
private void btnInlineToolTip_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new InlineToolTipWindow());
|
||||
}
|
||||
|
||||
private void btnToolTipControl_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new UserControlToolTipWindow());
|
||||
}
|
||||
|
||||
private void btnPopups_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new InlinePopupWindow());
|
||||
}
|
||||
|
||||
private void btnContextMenus_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new InlineContextMenuWindow());
|
||||
}
|
||||
|
||||
private void btnBalloons_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new BalloonSampleWindow());
|
||||
}
|
||||
|
||||
private void btnCommands_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new CommandWindow());
|
||||
}
|
||||
|
||||
private void btnEvents_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new EventVisualizerWindow());
|
||||
}
|
||||
|
||||
private void btnDataBinding_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new DataBoundToolTipWindow());
|
||||
}
|
||||
|
||||
private void btnMainSample_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var sampleWindow = new ShowcaseWindow();
|
||||
|
||||
sampleWindow.Owner = this;
|
||||
sampleWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
sampleWindow.ShowDialog();
|
||||
}
|
||||
|
||||
|
||||
private void OnNavigationRequest(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
|
||||
{
|
||||
Process.Start(e.Uri.ToString());
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ using System.Windows;
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
|
||||
[assembly: AssemblyTitle("Sample Project")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
@@ -19,6 +20,7 @@ using System.Windows;
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
//In order to begin building localizable applications, set
|
||||
@@ -33,12 +35,12 @@ using System.Windows;
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
//(used if a resource is not found in the page,
|
||||
// or application resource dictionaries)
|
||||
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
//(used if a resource is not found in the page,
|
||||
// app, or any theme specific resource dictionaries)
|
||||
)]
|
||||
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
@@ -51,5 +53,6 @@ using System.Windows;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -1,4 +1,5 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
|
||||
@@ -115,9 +115,13 @@
|
||||
<TextBlock Margin="72,49.2,10,0"
|
||||
VerticalAlignment="Top"
|
||||
Foreground="#FFECAD25"
|
||||
TextWrapping="Wrap"><Run Text="This is a user control. The animation uses the attached "/><Run FontStyle="Italic"
|
||||
FontWeight="Bold"
|
||||
Text="BalloonShowing "/><Run Text="event."/></TextBlock>
|
||||
TextWrapping="Wrap">
|
||||
<Run Text="This is a user control. The animation uses the attached " />
|
||||
<Run FontStyle="Italic"
|
||||
FontWeight="Bold"
|
||||
Text="BalloonShowing " />
|
||||
<Run Text="event." />
|
||||
</TextBlock>
|
||||
<Path Fill="#FFFFFFFF"
|
||||
Stretch="Fill"
|
||||
Margin="72,38.2,34,0"
|
||||
@@ -155,4 +159,4 @@
|
||||
MouseDown="imgClose_MouseDown" />
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
</UserControl>
|
||||
@@ -17,92 +17,91 @@ using Hardcodet.Wpf.TaskbarNotification;
|
||||
|
||||
namespace Samples
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for FancyBalloon.xaml
|
||||
/// </summary>
|
||||
public partial class FancyBalloon : UserControl
|
||||
{
|
||||
private bool isClosing = false;
|
||||
|
||||
#region BalloonText dependency property
|
||||
|
||||
/// <summary>
|
||||
/// Description
|
||||
/// Interaction logic for FancyBalloon.xaml
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty BalloonTextProperty =
|
||||
DependencyProperty.Register("BalloonText",
|
||||
typeof (string),
|
||||
typeof (FancyBalloon),
|
||||
new FrameworkPropertyMetadata(""));
|
||||
|
||||
/// <summary>
|
||||
/// A property wrapper for the <see cref="BalloonTextProperty"/>
|
||||
/// dependency property:<br/>
|
||||
/// Description
|
||||
/// </summary>
|
||||
public string BalloonText
|
||||
public partial class FancyBalloon : UserControl
|
||||
{
|
||||
get { return (string) GetValue(BalloonTextProperty); }
|
||||
set { SetValue(BalloonTextProperty, value); }
|
||||
private bool isClosing = false;
|
||||
|
||||
#region BalloonText dependency property
|
||||
|
||||
/// <summary>
|
||||
/// Description
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty BalloonTextProperty =
|
||||
DependencyProperty.Register("BalloonText",
|
||||
typeof (string),
|
||||
typeof (FancyBalloon),
|
||||
new FrameworkPropertyMetadata(""));
|
||||
|
||||
/// <summary>
|
||||
/// A property wrapper for the <see cref="BalloonTextProperty"/>
|
||||
/// dependency property:<br/>
|
||||
/// Description
|
||||
/// </summary>
|
||||
public string BalloonText
|
||||
{
|
||||
get { return (string) GetValue(BalloonTextProperty); }
|
||||
set { SetValue(BalloonTextProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public FancyBalloon()
|
||||
{
|
||||
InitializeComponent();
|
||||
TaskbarIcon.AddBalloonClosingHandler(this, OnBalloonClosing);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// By subscribing to the <see cref="TaskbarIcon.BalloonClosingEvent"/>
|
||||
/// and setting the "Handled" property to true, we suppress the popup
|
||||
/// from being closed in order to display the custom fade-out animation.
|
||||
/// </summary>
|
||||
private void OnBalloonClosing(object sender, RoutedEventArgs e)
|
||||
{
|
||||
e.Handled = true; //suppresses the popup from being closed immediately
|
||||
isClosing = true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the <see cref="TaskbarIcon"/> that displayed
|
||||
/// the balloon and requests a close action.
|
||||
/// </summary>
|
||||
private void imgClose_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
//the tray icon assigned this attached property to simplify access
|
||||
TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);
|
||||
taskbarIcon.CloseBalloon();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If the users hovers over the balloon, we don't close it.
|
||||
/// </summary>
|
||||
private void grid_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
//if we're already running the fade-out animation, do not interrupt anymore
|
||||
//(makes things too complicated for the sample)
|
||||
if (isClosing) return;
|
||||
|
||||
//the tray icon assigned this attached property to simplify access
|
||||
TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);
|
||||
taskbarIcon.ResetBalloonCloseTimer();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Closes the popup once the fade-out animation completed.
|
||||
/// The animation was triggered in XAML through the attached
|
||||
/// BalloonClosing event.
|
||||
/// </summary>
|
||||
private void OnFadeOutCompleted(object sender, EventArgs e)
|
||||
{
|
||||
Popup pp = (Popup) Parent;
|
||||
pp.IsOpen = false;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
public FancyBalloon()
|
||||
{
|
||||
InitializeComponent();
|
||||
TaskbarIcon.AddBalloonClosingHandler(this, OnBalloonClosing);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// By subscribing to the <see cref="TaskbarIcon.BalloonClosingEvent"/>
|
||||
/// and setting the "Handled" property to true, we suppress the popup
|
||||
/// from being closed in order to display the custom fade-out animation.
|
||||
/// </summary>
|
||||
private void OnBalloonClosing(object sender, RoutedEventArgs e)
|
||||
{
|
||||
e.Handled = true; //suppresses the popup from being closed immediately
|
||||
isClosing = true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Resolves the <see cref="TaskbarIcon"/> that displayed
|
||||
/// the balloon and requests a close action.
|
||||
/// </summary>
|
||||
private void imgClose_MouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
//the tray icon assigned this attached property to simplify access
|
||||
TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);
|
||||
taskbarIcon.CloseBalloon();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// If the users hovers over the balloon, we don't close it.
|
||||
/// </summary>
|
||||
private void grid_MouseEnter(object sender, MouseEventArgs e)
|
||||
{
|
||||
//if we're already running the fade-out animation, do not interrupt anymore
|
||||
//(makes things too complicated for the sample)
|
||||
if (isClosing) return;
|
||||
|
||||
//the tray icon assigned this attached property to simplify access
|
||||
TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);
|
||||
taskbarIcon.ResetBalloonCloseTimer();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Closes the popup once the fade-out animation completed.
|
||||
/// The animation was triggered in XAML through the attached
|
||||
/// BalloonClosing event.
|
||||
/// </summary>
|
||||
private void OnFadeOutCompleted(object sender, EventArgs e)
|
||||
{
|
||||
Popup pp = (Popup)Parent;
|
||||
pp.IsOpen = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,44 +3,44 @@ using System.Windows.Controls;
|
||||
|
||||
namespace Samples
|
||||
{
|
||||
/// <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.
|
||||
/// Interaction logic for FancyPopup.xaml
|
||||
/// </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
|
||||
public partial class FancyPopup : UserControl
|
||||
{
|
||||
get { return (int) GetValue(ClickCountProperty); }
|
||||
set { SetValue(ClickCountProperty, value); }
|
||||
}
|
||||
#region ClickCount dependency property
|
||||
|
||||
#endregion
|
||||
/// <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));
|
||||
|
||||
public FancyPopup()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
/// <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); }
|
||||
}
|
||||
|
||||
private void OnButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//just increment a counter - will be displayed on screen
|
||||
ClickCount++;
|
||||
#endregion
|
||||
|
||||
public FancyPopup()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OnButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//just increment a counter - will be displayed on screen
|
||||
ClickCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,41 +14,38 @@ using Hardcodet.Wpf.TaskbarNotification;
|
||||
|
||||
namespace Samples
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for FancyToolTip.xaml
|
||||
/// </summary>
|
||||
public partial class FancyToolTip
|
||||
{
|
||||
#region InfoText dependency property
|
||||
/// <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(""));
|
||||
/// <summary>
|
||||
/// The tooltip details.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty InfoTextProperty =
|
||||
DependencyProperty.Register("InfoText",
|
||||
typeof (string),
|
||||
typeof (FancyToolTip),
|
||||
new FrameworkPropertyMetadata(""));
|
||||
|
||||
/// <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 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); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
public FancyToolTip()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
}
|
||||
public FancyToolTip()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,9 +22,10 @@
|
||||
<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">
|
||||
<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" />
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,88 +6,87 @@ using Hardcodet.Wpf.TaskbarNotification;
|
||||
|
||||
namespace Samples
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ShowcaseWindow.xaml
|
||||
/// </summary>
|
||||
public partial class ShowcaseWindow : Window
|
||||
{
|
||||
public ShowcaseWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
Loaded += delegate
|
||||
{
|
||||
//show balloon at startup
|
||||
var balloon = new WelcomeBalloon();
|
||||
tb.ShowCustomBalloon(balloon, PopupAnimation.Slide, 12000);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Displays a balloon tip.
|
||||
/// Interaction logic for ShowcaseWindow.xaml
|
||||
/// </summary>
|
||||
private void showBalloonTip_Click(object sender, RoutedEventArgs e)
|
||||
public partial class ShowcaseWindow : Window
|
||||
{
|
||||
string title = txtBalloonTitle.Text;
|
||||
string message = txtBalloonText.Text;
|
||||
public ShowcaseWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (rbCustomIcon.IsChecked == true)
|
||||
{
|
||||
//just display the icon on the tray
|
||||
var icon = tb.Icon;
|
||||
tb.ShowBalloonTip(title, message, icon);
|
||||
}
|
||||
else
|
||||
{
|
||||
BalloonIcon bi = rbInfo.IsChecked == true ? BalloonIcon.Info : BalloonIcon.Error;
|
||||
tb.ShowBalloonTip(title, message, bi);
|
||||
}
|
||||
|
||||
Loaded += delegate
|
||||
{
|
||||
//show balloon at startup
|
||||
var balloon = new WelcomeBalloon();
|
||||
tb.ShowCustomBalloon(balloon, PopupAnimation.Slide, 12000);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Displays a balloon tip.
|
||||
/// </summary>
|
||||
private void showBalloonTip_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string title = txtBalloonTitle.Text;
|
||||
string message = txtBalloonText.Text;
|
||||
|
||||
if (rbCustomIcon.IsChecked == true)
|
||||
{
|
||||
//just display the icon on the tray
|
||||
var icon = tb.Icon;
|
||||
tb.ShowBalloonTip(title, message, icon);
|
||||
}
|
||||
else
|
||||
{
|
||||
BalloonIcon bi = rbInfo.IsChecked == true ? BalloonIcon.Info : BalloonIcon.Error;
|
||||
tb.ShowBalloonTip(title, message, bi);
|
||||
}
|
||||
}
|
||||
|
||||
private void hideBalloonTip_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
tb.HideBalloonTip();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Resets the tooltip.
|
||||
/// </summary>
|
||||
private void removeToolTip_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
tb.TrayToolTip = null;
|
||||
}
|
||||
|
||||
|
||||
private void showCustomBalloon_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FancyBalloon balloon = new FancyBalloon();
|
||||
balloon.BalloonText = customBalloonTitle.Text;
|
||||
//show and close after 2.5 seconds
|
||||
tb.ShowCustomBalloon(balloon, PopupAnimation.Slide, 5000);
|
||||
}
|
||||
|
||||
private void hideCustomBalloon_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
tb.CloseBalloon();
|
||||
}
|
||||
|
||||
|
||||
private void OnNavigationRequest(object sender, RequestNavigateEventArgs e)
|
||||
{
|
||||
Process.Start(e.Uri.ToString());
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
tb.Dispose();
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void hideBalloonTip_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
tb.HideBalloonTip();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Resets the tooltip.
|
||||
/// </summary>
|
||||
private void removeToolTip_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
tb.TrayToolTip = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void showCustomBalloon_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FancyBalloon balloon = new FancyBalloon();
|
||||
balloon.BalloonText = customBalloonTitle.Text;
|
||||
//show and close after 2.5 seconds
|
||||
tb.ShowCustomBalloon(balloon, PopupAnimation.Slide, 5000);
|
||||
}
|
||||
|
||||
private void hideCustomBalloon_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
tb.CloseBalloon();
|
||||
}
|
||||
|
||||
|
||||
private void OnNavigationRequest(object sender, RequestNavigateEventArgs e)
|
||||
{
|
||||
Process.Start(e.Uri.ToString());
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
tb.Dispose();
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,93 +1,105 @@
|
||||
<UserControl
|
||||
x:Class="Samples.WelcomeBalloon"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="130"
|
||||
Width="283"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
x:Name="me">
|
||||
<UserControl.Resources>
|
||||
<Storyboard
|
||||
x:Key="FadeInAndOut">
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00"
|
||||
Storyboard.TargetName="grid"
|
||||
Storyboard.TargetProperty="(UIElement.Opacity)">
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00"
|
||||
Value="0" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:01"
|
||||
Value="0.895" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:10"
|
||||
Value="0.895" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:11.6000000"
|
||||
Value="0" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</UserControl.Resources>
|
||||
<UserControl.Triggers>
|
||||
<EventTrigger
|
||||
RoutedEvent="tb:TaskbarIcon.BalloonShowing">
|
||||
<BeginStoryboard
|
||||
Storyboard="{StaticResource FadeInAndOut}"
|
||||
x:Name="FadeInAndOut_BeginStoryboard" />
|
||||
</EventTrigger>
|
||||
</UserControl.Triggers>
|
||||
<Grid
|
||||
x:Name="grid">
|
||||
x:Class="Samples.WelcomeBalloon"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="130"
|
||||
Width="283"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
x:Name="me">
|
||||
<UserControl.Resources>
|
||||
<Storyboard
|
||||
x:Key="FadeInAndOut">
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00"
|
||||
Storyboard.TargetName="grid"
|
||||
Storyboard.TargetProperty="(UIElement.Opacity)">
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00"
|
||||
Value="0" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:01"
|
||||
Value="0.895" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:10"
|
||||
Value="0.895" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:11.6000000"
|
||||
Value="0" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</UserControl.Resources>
|
||||
<UserControl.Triggers>
|
||||
<EventTrigger
|
||||
RoutedEvent="tb:TaskbarIcon.BalloonShowing">
|
||||
<BeginStoryboard
|
||||
Storyboard="{StaticResource FadeInAndOut}"
|
||||
x:Name="FadeInAndOut_BeginStoryboard" />
|
||||
</EventTrigger>
|
||||
</UserControl.Triggers>
|
||||
<Grid
|
||||
x:Name="grid">
|
||||
|
||||
<Border
|
||||
x:Name="border"
|
||||
CornerRadius="10,10,10,10"
|
||||
Margin="0,0,5,5">
|
||||
<Border.Background>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0.5,1"
|
||||
StartPoint="0.5,0">
|
||||
<GradientStop
|
||||
Color="#FFEEEEEE"
|
||||
Offset="1" />
|
||||
<GradientStop
|
||||
Color="#FFFB6B42"
|
||||
Offset="0" />
|
||||
</LinearGradientBrush>
|
||||
</Border.Background>
|
||||
<Border.Effect>
|
||||
<DropShadowEffect />
|
||||
</Border.Effect>
|
||||
</Border>
|
||||
<TextBlock
|
||||
Margin="10,10,15,0"
|
||||
VerticalAlignment="Top"
|
||||
FontSize="14"
|
||||
FontWeight="Bold"
|
||||
TextWrapping="Wrap"
|
||||
HorizontalAlignment="Center"><Run
|
||||
Text="WPF NotifyIcon - Sample Application"
|
||||
Language="de-ch" /></TextBlock>
|
||||
<TextBlock
|
||||
Margin="10,38.62,10,0"
|
||||
VerticalAlignment="Top"
|
||||
TextWrapping="Wrap"
|
||||
HorizontalAlignment="Left"><Run
|
||||
Text="You should see this icon in your system tray:" /><Run
|
||||
Text=" " /><InlineUIContainer>
|
||||
<Image
|
||||
Source="{Binding Path=IconSource}"
|
||||
Width="16"
|
||||
Height="16" />
|
||||
</InlineUIContainer><LineBreak /><Run
|
||||
Text="This is your NotifyIcon." /><LineBreak /><Run
|
||||
Text="" /><LineBreak /><Run
|
||||
FontSize="10"
|
||||
FontStyle="Italic"
|
||||
Text="You can change the displayed icon by selecting another image in the sample window." /></TextBlock>
|
||||
<Border
|
||||
x:Name="border"
|
||||
CornerRadius="10,10,10,10"
|
||||
Margin="0,0,5,5">
|
||||
<Border.Background>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0.5,1"
|
||||
StartPoint="0.5,0">
|
||||
<GradientStop
|
||||
Color="#FFEEEEEE"
|
||||
Offset="1" />
|
||||
<GradientStop
|
||||
Color="#FFFB6B42"
|
||||
Offset="0" />
|
||||
</LinearGradientBrush>
|
||||
</Border.Background>
|
||||
<Border.Effect>
|
||||
<DropShadowEffect />
|
||||
</Border.Effect>
|
||||
</Border>
|
||||
<TextBlock
|
||||
Margin="10,10,15,0"
|
||||
VerticalAlignment="Top"
|
||||
FontSize="14"
|
||||
FontWeight="Bold"
|
||||
TextWrapping="Wrap"
|
||||
HorizontalAlignment="Center">
|
||||
<Run
|
||||
Text="WPF NotifyIcon - Sample Application"
|
||||
Language="de-ch" />
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
Margin="10,38.62,10,0"
|
||||
VerticalAlignment="Top"
|
||||
TextWrapping="Wrap"
|
||||
HorizontalAlignment="Left">
|
||||
<Run
|
||||
Text="You should see this icon in your system tray:" />
|
||||
<Run
|
||||
Text=" " />
|
||||
<InlineUIContainer>
|
||||
<Image
|
||||
Source="{Binding Path=IconSource}"
|
||||
Width="16"
|
||||
Height="16" />
|
||||
</InlineUIContainer>
|
||||
<LineBreak />
|
||||
<Run
|
||||
Text="This is your NotifyIcon." />
|
||||
<LineBreak />
|
||||
<Run
|
||||
Text="" />
|
||||
<LineBreak />
|
||||
<Run
|
||||
FontSize="10"
|
||||
FontStyle="Italic"
|
||||
Text="You can change the displayed icon by selecting another image in the sample window." />
|
||||
</TextBlock>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -14,14 +14,14 @@ using System.Windows.Shapes;
|
||||
|
||||
namespace Samples
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for WelcomeBalloon.xaml
|
||||
/// </summary>
|
||||
public partial class WelcomeBalloon : UserControl
|
||||
{
|
||||
public WelcomeBalloon()
|
||||
/// <summary>
|
||||
/// Interaction logic for WelcomeBalloon.xaml
|
||||
/// </summary>
|
||||
public partial class WelcomeBalloon : UserControl
|
||||
{
|
||||
InitializeComponent();
|
||||
public WelcomeBalloon()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,19 +1,21 @@
|
||||
<Window
|
||||
x:Class="Samples.Tutorials.SimpleWindowWithNotifyIcon"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<Grid>
|
||||
x:Class="Samples.Tutorials.SimpleWindowWithNotifyIcon"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<Grid>
|
||||
|
||||
<!-- in order to declare a NotifyIcon, all you need is the
|
||||
<!-- in order to declare a NotifyIcon, all you need is the
|
||||
namespace declaration (see above on line 5) and a single line -->
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="hello world" />
|
||||
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap"><Run Text="You should see an icon in the tray." Language="de-ch"/></TextBlock>
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="hello world" />
|
||||
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap">
|
||||
<Run Text="You should see an icon in the tray." Language="de-ch" />
|
||||
</TextBlock>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -2,22 +2,22 @@
|
||||
|
||||
namespace Samples.Tutorials
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for SimpleWindowWithNotifyIcon.xaml
|
||||
/// </summary>
|
||||
public partial class SimpleWindowWithNotifyIcon : Window
|
||||
{
|
||||
public SimpleWindowWithNotifyIcon()
|
||||
/// <summary>
|
||||
/// Interaction logic for SimpleWindowWithNotifyIcon.xaml
|
||||
/// </summary>
|
||||
public partial class SimpleWindowWithNotifyIcon : Window
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public SimpleWindowWithNotifyIcon()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
MyNotifyIcon.Dispose();
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
MyNotifyIcon.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,40 +1,41 @@
|
||||
<Window
|
||||
x:Class="Samples.Tutorials.ToolTips.InlineToolTipWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<Grid>
|
||||
x:Class="Samples.Tutorials.ToolTips.InlineToolTipWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<Grid>
|
||||
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="hello world">
|
||||
|
||||
<!--
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="hello world">
|
||||
|
||||
<!--
|
||||
We can use arbitrary UI elements as ToolTips.
|
||||
Let's use a semi-transparent border.
|
||||
-->
|
||||
<tb:TaskbarIcon.TrayToolTip>
|
||||
<Border
|
||||
Background="White"
|
||||
BorderBrush="Orange"
|
||||
BorderThickness="2"
|
||||
CornerRadius="4"
|
||||
Opacity="0.8"
|
||||
Width="160"
|
||||
Height="40">
|
||||
<TextBlock
|
||||
Text="hello world"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
</Border>
|
||||
</tb:TaskbarIcon.TrayToolTip>
|
||||
|
||||
</tb:TaskbarIcon>
|
||||
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap"><Run Text="Move mouse over NotifyIcon to show ToolTip" Language="de-ch"/></TextBlock>
|
||||
<tb:TaskbarIcon.TrayToolTip>
|
||||
<Border
|
||||
Background="White"
|
||||
BorderBrush="Orange"
|
||||
BorderThickness="2"
|
||||
CornerRadius="4"
|
||||
Opacity="0.8"
|
||||
Width="160"
|
||||
Height="40">
|
||||
<TextBlock
|
||||
Text="hello world"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Border>
|
||||
</tb:TaskbarIcon.TrayToolTip>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
</tb:TaskbarIcon>
|
||||
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap">
|
||||
<Run Text="Move mouse over NotifyIcon to show ToolTip" Language="de-ch" />
|
||||
</TextBlock>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -13,22 +13,22 @@ using System.Windows.Shapes;
|
||||
|
||||
namespace Samples.Tutorials.ToolTips
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Window1.xaml
|
||||
/// </summary>
|
||||
public partial class InlineToolTipWindow : Window
|
||||
{
|
||||
public InlineToolTipWindow()
|
||||
/// <summary>
|
||||
/// Interaction logic for Window1.xaml
|
||||
/// </summary>
|
||||
public partial class InlineToolTipWindow : Window
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public InlineToolTipWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
MyNotifyIcon.Dispose();
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
MyNotifyIcon.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,22 +1,21 @@
|
||||
<UserControl
|
||||
x:Class="Samples.Tutorials.ToolTips.SimpleUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
>
|
||||
x:Class="Samples.Tutorials.ToolTips.SimpleUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
|
||||
<!-- a simple user control which displays a fixed text within a border -->
|
||||
<Border
|
||||
Background="White"
|
||||
BorderBrush="Orange"
|
||||
BorderThickness="2"
|
||||
CornerRadius="4"
|
||||
Opacity="0.8"
|
||||
Width="160"
|
||||
Height="40">
|
||||
<TextBlock
|
||||
Text="hello world"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Border>
|
||||
|
||||
</UserControl>
|
||||
<!-- a simple user control which displays a fixed text within a border -->
|
||||
<Border
|
||||
Background="White"
|
||||
BorderBrush="Orange"
|
||||
BorderThickness="2"
|
||||
CornerRadius="4"
|
||||
Opacity="0.8"
|
||||
Width="160"
|
||||
Height="40">
|
||||
<TextBlock
|
||||
Text="hello world"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Border>
|
||||
|
||||
</UserControl>
|
||||
@@ -14,14 +14,14 @@ using System.Windows.Shapes;
|
||||
|
||||
namespace Samples.Tutorials.ToolTips
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for SimpleUserControl.xaml
|
||||
/// </summary>
|
||||
public partial class SimpleUserControl : UserControl
|
||||
{
|
||||
public SimpleUserControl()
|
||||
/// <summary>
|
||||
/// Interaction logic for SimpleUserControl.xaml
|
||||
/// </summary>
|
||||
public partial class SimpleUserControl : UserControl
|
||||
{
|
||||
InitializeComponent();
|
||||
public SimpleUserControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,25 +1,27 @@
|
||||
<Window
|
||||
x:Class="Samples.Tutorials.ToolTips.UserControlToolTipWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
xmlns:local="clr-namespace:Samples.Tutorials.ToolTips"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<Grid>
|
||||
x:Class="Samples.Tutorials.ToolTips.UserControlToolTipWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
xmlns:local="clr-namespace:Samples.Tutorials.ToolTips"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<Grid>
|
||||
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="hello world">
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="hello world">
|
||||
|
||||
<!-- assign user control as ToolTip -->
|
||||
<tb:TaskbarIcon.TrayToolTip>
|
||||
<local:SimpleUserControl />
|
||||
</tb:TaskbarIcon.TrayToolTip>
|
||||
<!-- assign user control as ToolTip -->
|
||||
<tb:TaskbarIcon.TrayToolTip>
|
||||
<local:SimpleUserControl />
|
||||
</tb:TaskbarIcon.TrayToolTip>
|
||||
|
||||
</tb:TaskbarIcon>
|
||||
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap"><Run Text="Move mouse over NotifyIcon to show ToolTip" Language="de-ch"/></TextBlock>
|
||||
</tb:TaskbarIcon>
|
||||
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap">
|
||||
<Run Text="Move mouse over NotifyIcon to show ToolTip" Language="de-ch" />
|
||||
</TextBlock>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -13,22 +13,22 @@ using System.Windows.Shapes;
|
||||
|
||||
namespace Samples.Tutorials.ToolTips
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for UserControlToolTipWindow.xaml
|
||||
/// </summary>
|
||||
public partial class UserControlToolTipWindow : Window
|
||||
{
|
||||
public UserControlToolTipWindow()
|
||||
/// <summary>
|
||||
/// Interaction logic for UserControlToolTipWindow.xaml
|
||||
/// </summary>
|
||||
public partial class UserControlToolTipWindow : Window
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public UserControlToolTipWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
MyNotifyIcon.Dispose();
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
MyNotifyIcon.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +1,58 @@
|
||||
<Window
|
||||
x:Class="Samples.Tutorials.Popups.InlinePopupWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<Grid>
|
||||
x:Class="Samples.Tutorials.Popups.InlinePopupWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<Grid>
|
||||
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="hello world">
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="hello world">
|
||||
|
||||
<!--
|
||||
<!--
|
||||
We can use arbitrary UI elements as Popups.
|
||||
Popups stay open if the user moves away from the tray area
|
||||
-->
|
||||
<tb:TaskbarIcon.TrayPopup>
|
||||
<Border
|
||||
Background="White"
|
||||
BorderBrush="Orange"
|
||||
BorderThickness="2"
|
||||
CornerRadius="4"
|
||||
Width="160">
|
||||
<StackPanel>
|
||||
<TextBox
|
||||
x:Name="popupText"
|
||||
Margin="5,10,5,10"
|
||||
Width="200"
|
||||
Height="24"
|
||||
Text="Enter Text..." />
|
||||
<Button
|
||||
Content="Click Me!"
|
||||
Margin="5,0,5,10"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</tb:TaskbarIcon.TrayPopup>
|
||||
<tb:TaskbarIcon.TrayPopup>
|
||||
<Border
|
||||
Background="White"
|
||||
BorderBrush="Orange"
|
||||
BorderThickness="2"
|
||||
CornerRadius="4"
|
||||
Width="160">
|
||||
<StackPanel>
|
||||
<TextBox
|
||||
x:Name="popupText"
|
||||
Margin="5,10,5,10"
|
||||
Width="200"
|
||||
Height="24"
|
||||
Text="Enter Text..." />
|
||||
<Button
|
||||
Content="Click Me!"
|
||||
Margin="5,0,5,10"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</Border>
|
||||
</tb:TaskbarIcon.TrayPopup>
|
||||
|
||||
</tb:TaskbarIcon>
|
||||
<TextBlock
|
||||
Margin="26,26,24,0"
|
||||
VerticalAlignment="Top"
|
||||
FontWeight="Bold"
|
||||
Text="Left-Click NotifyIcon to open popup." />
|
||||
|
||||
<TextBlock
|
||||
Text="Text on Popup: "
|
||||
Margin="26,66,24,0"
|
||||
VerticalAlignment="Top">
|
||||
<TextBlock Foreground="Red"
|
||||
Text="{Binding ElementName=popupText, Path=Text}" />
|
||||
</TextBlock>
|
||||
</tb:TaskbarIcon>
|
||||
<TextBlock
|
||||
Margin="26,26,24,0"
|
||||
VerticalAlignment="Top"
|
||||
FontWeight="Bold"
|
||||
Text="Left-Click NotifyIcon to open popup." />
|
||||
|
||||
</Grid>
|
||||
<TextBlock
|
||||
Text="Text on Popup: "
|
||||
Margin="26,66,24,0"
|
||||
VerticalAlignment="Top">
|
||||
<TextBlock Foreground="Red"
|
||||
Text="{Binding ElementName=popupText, Path=Text}" />
|
||||
</TextBlock>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -13,22 +13,22 @@ using System.Windows.Shapes;
|
||||
|
||||
namespace Samples.Tutorials.Popups
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for InlinePopupWindow.xaml
|
||||
/// </summary>
|
||||
public partial class InlinePopupWindow : Window
|
||||
{
|
||||
public InlinePopupWindow()
|
||||
/// <summary>
|
||||
/// Interaction logic for InlinePopupWindow.xaml
|
||||
/// </summary>
|
||||
public partial class InlinePopupWindow : Window
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public InlinePopupWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
MyNotifyIcon.Dispose();
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
MyNotifyIcon.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,8 +46,10 @@
|
||||
<TextBlock Margin="26,26,24,0"
|
||||
VerticalAlignment="Top"
|
||||
FontWeight="Bold"
|
||||
TextWrapping="Wrap"><Run Language="de-ch"
|
||||
Text="Right-click on NotifyIcon to open Context Menu" /></TextBlock>
|
||||
TextWrapping="Wrap">
|
||||
<Run Language="de-ch"
|
||||
Text="Right-click on NotifyIcon to open Context Menu" />
|
||||
</TextBlock>
|
||||
<TextBlock HorizontalAlignment="Left"
|
||||
Margin="26,83,0,0"
|
||||
TextWrapping="Wrap"
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace Samples.Tutorials.ContextMenus
|
||||
private void MyNotifyIcon_PreviewTrayContextMenuOpen(object sender, System.Windows.RoutedEventArgs e)
|
||||
{
|
||||
//marking the event as handled suppresses the context menu
|
||||
e.Handled = (bool)SuppressContextMenu.IsChecked;
|
||||
e.Handled = (bool) SuppressContextMenu.IsChecked;
|
||||
|
||||
PreviewOpenEventCounter.Text = (int.Parse(PreviewOpenEventCounter.Text) + 1).ToString();
|
||||
}
|
||||
|
||||
@@ -1,54 +1,51 @@
|
||||
<Window
|
||||
x:Class="Samples.Tutorials.Balloons.BalloonSampleWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<Grid>
|
||||
x:Class="Samples.Tutorials.Balloons.BalloonSampleWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<Grid>
|
||||
|
||||
<!-- the ToolTipText property is bound to the TextBox below -->
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="Balloon Sample Icon" />
|
||||
<Button
|
||||
x:Name="btnShowStandardBalloon"
|
||||
Click="btnShowStandardBalloon_Click"
|
||||
Margin="26,74,29,0"
|
||||
Content="Show Standard Balloon" Height="29" VerticalAlignment="Top"
|
||||
/>
|
||||
<Button
|
||||
x:Name="btnShowCustomBalloon"
|
||||
Click="btnShowCustomBalloon_Click"
|
||||
Margin="26,0,29,49"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="27"
|
||||
Content="Show Custom Balloon"
|
||||
/>
|
||||
<TextBlock
|
||||
Margin="26,26,24,0"
|
||||
VerticalAlignment="Top"
|
||||
FontWeight="Bold"
|
||||
TextWrapping="Wrap"><Run
|
||||
Language="de-ch"
|
||||
Text="Clicking on buttons shows balloon tips" /></TextBlock>
|
||||
<Button
|
||||
x:Name="btnHideStandardBalloon"
|
||||
Click="btnHideStandardBalloon_Click"
|
||||
Margin="26,113,29,122"
|
||||
Content="Hide Standard Balloon"
|
||||
/>
|
||||
<Button
|
||||
x:Name="btnCloseCustomBalloon"
|
||||
Click="btnCloseCustomBalloon_Click"
|
||||
Margin="26,0,29,12"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="27"
|
||||
Content="Close Custom Balloon"
|
||||
/>
|
||||
<!-- the ToolTipText property is bound to the TextBox below -->
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="Balloon Sample Icon" />
|
||||
<Button
|
||||
x:Name="btnShowStandardBalloon"
|
||||
Click="btnShowStandardBalloon_Click"
|
||||
Margin="26,74,29,0"
|
||||
Content="Show Standard Balloon" Height="29" VerticalAlignment="Top" />
|
||||
<Button
|
||||
x:Name="btnShowCustomBalloon"
|
||||
Click="btnShowCustomBalloon_Click"
|
||||
Margin="26,0,29,49"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="27"
|
||||
Content="Show Custom Balloon" />
|
||||
<TextBlock
|
||||
Margin="26,26,24,0"
|
||||
VerticalAlignment="Top"
|
||||
FontWeight="Bold"
|
||||
TextWrapping="Wrap">
|
||||
<Run
|
||||
Language="de-ch"
|
||||
Text="Clicking on buttons shows balloon tips" />
|
||||
</TextBlock>
|
||||
<Button
|
||||
x:Name="btnHideStandardBalloon"
|
||||
Click="btnHideStandardBalloon_Click"
|
||||
Margin="26,113,29,122"
|
||||
Content="Hide Standard Balloon" />
|
||||
<Button
|
||||
x:Name="btnCloseCustomBalloon"
|
||||
Click="btnCloseCustomBalloon_Click"
|
||||
Margin="26,0,29,12"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="27"
|
||||
Content="Close Custom Balloon" />
|
||||
|
||||
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -15,53 +15,51 @@ using Hardcodet.Wpf.TaskbarNotification;
|
||||
|
||||
namespace Samples.Tutorials.Balloons
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for BalloonSampleWindow.xaml
|
||||
/// </summary>
|
||||
public partial class BalloonSampleWindow : Window
|
||||
{
|
||||
public BalloonSampleWindow()
|
||||
/// <summary>
|
||||
/// Interaction logic for BalloonSampleWindow.xaml
|
||||
/// </summary>
|
||||
public partial class BalloonSampleWindow : Window
|
||||
{
|
||||
InitializeComponent();
|
||||
public BalloonSampleWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
MyNotifyIcon.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
}
|
||||
|
||||
|
||||
private void btnShowCustomBalloon_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FancyBalloon balloon = new FancyBalloon();
|
||||
balloon.BalloonText = "Custom Balloon";
|
||||
|
||||
//show balloon and close it after 4 seconds
|
||||
MyNotifyIcon.ShowCustomBalloon(balloon, PopupAnimation.Slide, 4000);
|
||||
}
|
||||
|
||||
private void btnHideStandardBalloon_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MyNotifyIcon.HideBalloonTip();
|
||||
}
|
||||
|
||||
|
||||
private void btnShowStandardBalloon_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string title = "WPF NotifyIcon";
|
||||
string text = "This is a standard balloon";
|
||||
|
||||
MyNotifyIcon.ShowBalloonTip(title, text, MyNotifyIcon.Icon);
|
||||
}
|
||||
|
||||
private void btnCloseCustomBalloon_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MyNotifyIcon.CloseBalloon();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
MyNotifyIcon.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
}
|
||||
|
||||
|
||||
private void btnShowCustomBalloon_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FancyBalloon balloon = new FancyBalloon();
|
||||
balloon.BalloonText = "Custom Balloon";
|
||||
|
||||
//show balloon and close it after 4 seconds
|
||||
MyNotifyIcon.ShowCustomBalloon(balloon, PopupAnimation.Slide, 4000);
|
||||
}
|
||||
|
||||
private void btnHideStandardBalloon_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MyNotifyIcon.HideBalloonTip();
|
||||
}
|
||||
|
||||
|
||||
private void btnShowStandardBalloon_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string title = "WPF NotifyIcon";
|
||||
string text = "This is a standard balloon";
|
||||
|
||||
MyNotifyIcon.ShowBalloonTip(title, text, MyNotifyIcon.Icon);
|
||||
}
|
||||
|
||||
private void btnCloseCustomBalloon_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MyNotifyIcon.CloseBalloon();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,58 +1,64 @@
|
||||
<Window
|
||||
x:Class="Samples.Tutorials.Commands.CommandWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
xmlns:local="clr-namespace:Samples.Tutorials.Commands"
|
||||
Height="300"
|
||||
Width="300"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
x:Class="Samples.Tutorials.Commands.CommandWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
xmlns:local="clr-namespace:Samples.Tutorials.Commands"
|
||||
Height="300"
|
||||
Width="300"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
<Grid>
|
||||
|
||||
<!-- declare the command as a local resource -->
|
||||
<Grid.Resources>
|
||||
<local:ShowMessageCommand
|
||||
x:Key="MessageCommand" />
|
||||
</Grid.Resources>
|
||||
<!-- declare the command as a local resource -->
|
||||
<Grid.Resources>
|
||||
<local:ShowMessageCommand
|
||||
x:Key="MessageCommand" />
|
||||
</Grid.Resources>
|
||||
|
||||
<!-- declare the NotifyIcon and configure commands with parameters -->
|
||||
<tb:TaskbarIcon
|
||||
x:Name="CustomCommandNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
LeftClickCommand="{StaticResource MessageCommand}"
|
||||
LeftClickCommandParameter="Left mouse button was clicked"
|
||||
DoubleClickCommand="{StaticResource MessageCommand}"
|
||||
DoubleClickCommandParameter="Double click on NotifyIcon" />
|
||||
<!-- declare the NotifyIcon and configure commands with parameters -->
|
||||
<tb:TaskbarIcon
|
||||
x:Name="CustomCommandNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
LeftClickCommand="{StaticResource MessageCommand}"
|
||||
LeftClickCommandParameter="Left mouse button was clicked"
|
||||
DoubleClickCommand="{StaticResource MessageCommand}"
|
||||
DoubleClickCommandParameter="Double click on NotifyIcon" />
|
||||
|
||||
<!-- declare the NotifyIcon and configure commands with targets -->
|
||||
<tb:TaskbarIcon
|
||||
x:Name="RoutedCommandNotifyIcon"
|
||||
IconSource="/Icons/Inactive.ico"
|
||||
LeftClickCommand="ApplicationCommands.Cut"
|
||||
LeftClickCommandTarget="{Binding ElementName=txtInput}"
|
||||
DoubleClickCommand="ApplicationCommands.Paste"
|
||||
DoubleClickCommandTarget="{Binding ElementName=txtInput}" />
|
||||
|
||||
<!-- declare the NotifyIcon and configure commands with targets -->
|
||||
<tb:TaskbarIcon
|
||||
x:Name="RoutedCommandNotifyIcon"
|
||||
IconSource="/Icons/Inactive.ico"
|
||||
LeftClickCommand="ApplicationCommands.Cut"
|
||||
LeftClickCommandTarget="{Binding ElementName=txtInput}"
|
||||
DoubleClickCommand="ApplicationCommands.Paste"
|
||||
DoubleClickCommandTarget="{Binding ElementName=txtInput}" />
|
||||
|
||||
<TextBlock
|
||||
Margin="26,26,24,0"
|
||||
VerticalAlignment="Top"
|
||||
FontWeight="Bold"
|
||||
TextWrapping="Wrap"><Run
|
||||
Language="de-ch"
|
||||
Text="Left / Double clicks on red NotifyIcon executes simple custom commands." /></TextBlock>
|
||||
<TextBlock
|
||||
Margin="26,112,24,80"
|
||||
FontWeight="Bold"
|
||||
TextWrapping="Wrap"><Run Language="de-ch" Text="Left / Double clicks on grey NotifyIcon executes routed commands."/><LineBreak/><Run Language="de-ch" Text="Single click: Cuts selected text"/><LineBreak/><Run Language="de-ch" Text="Double click: Paste text from clipboard"/></TextBlock>
|
||||
<TextBox
|
||||
Margin="26,0,24,48"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="22"
|
||||
Text="hello world"
|
||||
TextWrapping="Wrap"
|
||||
x:Name="txtInput" />
|
||||
</Grid>
|
||||
|
||||
<TextBlock
|
||||
Margin="26,26,24,0"
|
||||
VerticalAlignment="Top"
|
||||
FontWeight="Bold"
|
||||
TextWrapping="Wrap">
|
||||
<Run
|
||||
Language="de-ch"
|
||||
Text="Left / Double clicks on red NotifyIcon executes simple custom commands." />
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
Margin="26,112,24,80"
|
||||
FontWeight="Bold"
|
||||
TextWrapping="Wrap">
|
||||
<Run Language="de-ch" Text="Left / Double clicks on grey NotifyIcon executes routed commands." />
|
||||
<LineBreak /><Run Language="de-ch" Text="Single click: Cuts selected text" /><LineBreak />
|
||||
<Run Language="de-ch" Text="Double click: Paste text from clipboard" />
|
||||
</TextBlock>
|
||||
<TextBox
|
||||
Margin="26,0,24,48"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="22"
|
||||
Text="hello world"
|
||||
TextWrapping="Wrap"
|
||||
x:Name="txtInput" />
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -13,24 +13,24 @@ using System.Windows.Shapes;
|
||||
|
||||
namespace Samples.Tutorials.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for CommandWindow.xaml
|
||||
/// </summary>
|
||||
public partial class CommandWindow : Window
|
||||
{
|
||||
public CommandWindow()
|
||||
/// <summary>
|
||||
/// Interaction logic for CommandWindow.xaml
|
||||
/// </summary>
|
||||
public partial class CommandWindow : Window
|
||||
{
|
||||
InitializeComponent();
|
||||
public CommandWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
CustomCommandNotifyIcon.Dispose();
|
||||
RoutedCommandNotifyIcon.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
CustomCommandNotifyIcon.Dispose();
|
||||
RoutedCommandNotifyIcon.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,22 +4,22 @@ using System.Windows.Input;
|
||||
|
||||
namespace Samples.Tutorials.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// A simple command that displays the command parameter as
|
||||
/// a dialog message.
|
||||
/// </summary>
|
||||
public class ShowMessageCommand : ICommand
|
||||
{
|
||||
public void Execute(object parameter)
|
||||
/// <summary>
|
||||
/// A simple command that displays the command parameter as
|
||||
/// a dialog message.
|
||||
/// </summary>
|
||||
public class ShowMessageCommand : ICommand
|
||||
{
|
||||
MessageBox.Show(parameter.ToString());
|
||||
}
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
MessageBox.Show(parameter.ToString());
|
||||
}
|
||||
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public event EventHandler CanExecuteChanged;
|
||||
}
|
||||
}
|
||||
public event EventHandler CanExecuteChanged;
|
||||
}
|
||||
}
|
||||
@@ -1,259 +1,265 @@
|
||||
<Window
|
||||
x:Class="Samples.Tutorials.Events.EventVisualizerWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<Window.Resources>
|
||||
<Storyboard
|
||||
x:Key="ShowMovement"
|
||||
AutoReverse="True">
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00"
|
||||
Storyboard.TargetName="MoveIndicator"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00.1000000"
|
||||
Value="1.2" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00"
|
||||
Storyboard.TargetName="MoveIndicator"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00.1000000"
|
||||
Value="1.2" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
<Storyboard
|
||||
x:Key="ShowMouseUp"
|
||||
AutoReverse="True">
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00"
|
||||
Storyboard.TargetName="LeftMouseIndicator"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00.1000000"
|
||||
Value="1.35" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00"
|
||||
Storyboard.TargetName="LeftMouseIndicator"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00.1000000"
|
||||
Value="1.35" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
<Storyboard
|
||||
x:Key="ShowToolTipOpened"
|
||||
AutoReverse="True">
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00"
|
||||
Storyboard.TargetName="ToolTipIndicator"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00.2000000"
|
||||
Value="1.4" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00"
|
||||
Storyboard.TargetName="ToolTipIndicator"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00.2000000"
|
||||
Value="1.4" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</Window.Resources>
|
||||
<Window.Triggers>
|
||||
<EventTrigger
|
||||
RoutedEvent="tb:TaskbarIcon.TrayMouseMove"
|
||||
SourceName="notifyIcon">
|
||||
<BeginStoryboard
|
||||
Storyboard="{StaticResource ShowMovement}" />
|
||||
</EventTrigger>
|
||||
<EventTrigger
|
||||
RoutedEvent="tb:TaskbarIcon.TrayLeftMouseUp"
|
||||
SourceName="notifyIcon">
|
||||
<BeginStoryboard
|
||||
Storyboard="{StaticResource ShowMouseUp}"
|
||||
x:Name="ShowMouseUp_BeginStoryboard" />
|
||||
</EventTrigger>
|
||||
<EventTrigger
|
||||
RoutedEvent="tb:TaskbarIcon.TrayToolTipOpen"
|
||||
SourceName="notifyIcon">
|
||||
<BeginStoryboard
|
||||
Storyboard="{StaticResource ShowToolTipOpened}"
|
||||
x:Name="ShowToolTipOpened_BeginStoryboard" />
|
||||
</EventTrigger>
|
||||
</Window.Triggers>
|
||||
<Grid>
|
||||
x:Class="Samples.Tutorials.Events.EventVisualizerWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<Window.Resources>
|
||||
<Storyboard
|
||||
x:Key="ShowMovement"
|
||||
AutoReverse="True">
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00"
|
||||
Storyboard.TargetName="MoveIndicator"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00.1000000"
|
||||
Value="1.2" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00"
|
||||
Storyboard.TargetName="MoveIndicator"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00.1000000"
|
||||
Value="1.2" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
<Storyboard
|
||||
x:Key="ShowMouseUp"
|
||||
AutoReverse="True">
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00"
|
||||
Storyboard.TargetName="LeftMouseIndicator"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00.1000000"
|
||||
Value="1.35" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00"
|
||||
Storyboard.TargetName="LeftMouseIndicator"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00.1000000"
|
||||
Value="1.35" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
<Storyboard
|
||||
x:Key="ShowToolTipOpened"
|
||||
AutoReverse="True">
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00"
|
||||
Storyboard.TargetName="ToolTipIndicator"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00.2000000"
|
||||
Value="1.4" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00"
|
||||
Storyboard.TargetName="ToolTipIndicator"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00.2000000"
|
||||
Value="1.4" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</Window.Resources>
|
||||
<Window.Triggers>
|
||||
<EventTrigger
|
||||
RoutedEvent="tb:TaskbarIcon.TrayMouseMove"
|
||||
SourceName="notifyIcon">
|
||||
<BeginStoryboard
|
||||
Storyboard="{StaticResource ShowMovement}" />
|
||||
</EventTrigger>
|
||||
<EventTrigger
|
||||
RoutedEvent="tb:TaskbarIcon.TrayLeftMouseUp"
|
||||
SourceName="notifyIcon">
|
||||
<BeginStoryboard
|
||||
Storyboard="{StaticResource ShowMouseUp}"
|
||||
x:Name="ShowMouseUp_BeginStoryboard" />
|
||||
</EventTrigger>
|
||||
<EventTrigger
|
||||
RoutedEvent="tb:TaskbarIcon.TrayToolTipOpen"
|
||||
SourceName="notifyIcon">
|
||||
<BeginStoryboard
|
||||
Storyboard="{StaticResource ShowToolTipOpened}"
|
||||
x:Name="ShowToolTipOpened_BeginStoryboard" />
|
||||
</EventTrigger>
|
||||
</Window.Triggers>
|
||||
<Grid>
|
||||
|
||||
<!-- the NotifyIcon does not need to be configured here - animations were set up in Blend -->
|
||||
<tb:TaskbarIcon
|
||||
x:Name="notifyIcon"
|
||||
ToolTipText="hello world"
|
||||
IconSource="/Icons/Error.ico" />
|
||||
<!-- the NotifyIcon does not need to be configured here - animations were set up in Blend -->
|
||||
<tb:TaskbarIcon
|
||||
x:Name="notifyIcon"
|
||||
ToolTipText="hello world"
|
||||
IconSource="/Icons/Error.ico" />
|
||||
|
||||
|
||||
<Ellipse
|
||||
HorizontalAlignment="Left"
|
||||
Margin="24,62,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="19"
|
||||
Height="19"
|
||||
Stroke="#FF549D2D"
|
||||
x:Name="MoveIndicator"
|
||||
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.Fill>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0.528,0.694"
|
||||
StartPoint="-0.056,-0.118">
|
||||
<GradientStop
|
||||
Color="#FFFFFFFF"
|
||||
Offset="0" />
|
||||
<GradientStop
|
||||
Color="#FF65A135"
|
||||
Offset="1" />
|
||||
</LinearGradientBrush>
|
||||
</Ellipse.Fill>
|
||||
</Ellipse>
|
||||
<Ellipse
|
||||
Stroke="#FF549D2D"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="24,106,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="19"
|
||||
Height="19"
|
||||
x:Name="LeftMouseIndicator"
|
||||
RenderTransformOrigin="0.5,0.5">
|
||||
<Ellipse.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform />
|
||||
<SkewTransform
|
||||
AngleX="0"
|
||||
AngleY="0" />
|
||||
<RotateTransform
|
||||
Angle="0" />
|
||||
<TranslateTransform
|
||||
X="0"
|
||||
Y="0" />
|
||||
</TransformGroup>
|
||||
</Ellipse.RenderTransform>
|
||||
<Ellipse.Fill>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0.528,0.694"
|
||||
StartPoint="-0.056,-0.118">
|
||||
<GradientStop
|
||||
Color="#FFFFFFFF"
|
||||
Offset="0" />
|
||||
<GradientStop
|
||||
Color="#FF65A135"
|
||||
Offset="1" />
|
||||
</LinearGradientBrush>
|
||||
</Ellipse.Fill>
|
||||
</Ellipse>
|
||||
<Ellipse
|
||||
Stroke="#FF549D2D"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="24,0,0,94"
|
||||
Width="19"
|
||||
x:Name="ToolTipIndicator"
|
||||
RenderTransformOrigin="0.5,0.5"
|
||||
Height="19"
|
||||
VerticalAlignment="Bottom">
|
||||
<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.Fill>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0.528,0.694"
|
||||
StartPoint="-0.056,-0.118">
|
||||
<GradientStop
|
||||
Color="#FFFFFFFF"
|
||||
Offset="0" />
|
||||
<GradientStop
|
||||
Color="#FF65A135"
|
||||
Offset="1" />
|
||||
</LinearGradientBrush>
|
||||
</Ellipse.Fill>
|
||||
</Ellipse>
|
||||
<TextBlock
|
||||
Margin="63,62,91,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="19"
|
||||
TextWrapping="Wrap">
|
||||
<Run
|
||||
Language="de-ch"
|
||||
Text="TrayMouseMove Event" />
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
Margin="63,106,91,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="19"
|
||||
TextWrapping="Wrap">
|
||||
<Run
|
||||
Language="de-ch"
|
||||
Text="TrayLeftMouseUp Event" />
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
Margin="63,0,91,94"
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="19">
|
||||
<Run
|
||||
Language="de-ch"
|
||||
Text="TrayToolTipOpen Event" />
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
Margin="10,10,10,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="31"
|
||||
TextWrapping="Wrap"
|
||||
FontWeight="Bold">
|
||||
<Run Language="de-ch" Text="The green ellipses are animated based on routed events of the NotifyIcon" />
|
||||
</TextBlock>
|
||||
|
||||
|
||||
<Ellipse
|
||||
HorizontalAlignment="Left"
|
||||
Margin="24,62,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="19"
|
||||
Height="19"
|
||||
Stroke="#FF549D2D"
|
||||
x:Name="MoveIndicator"
|
||||
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.Fill>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0.528,0.694"
|
||||
StartPoint="-0.056,-0.118">
|
||||
<GradientStop
|
||||
Color="#FFFFFFFF"
|
||||
Offset="0" />
|
||||
<GradientStop
|
||||
Color="#FF65A135"
|
||||
Offset="1" />
|
||||
</LinearGradientBrush>
|
||||
</Ellipse.Fill>
|
||||
</Ellipse>
|
||||
<Ellipse
|
||||
Stroke="#FF549D2D"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="24,106,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="19"
|
||||
Height="19"
|
||||
x:Name="LeftMouseIndicator"
|
||||
RenderTransformOrigin="0.5,0.5">
|
||||
<Ellipse.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform />
|
||||
<SkewTransform
|
||||
AngleX="0"
|
||||
AngleY="0" />
|
||||
<RotateTransform
|
||||
Angle="0" />
|
||||
<TranslateTransform
|
||||
X="0"
|
||||
Y="0" />
|
||||
</TransformGroup>
|
||||
</Ellipse.RenderTransform>
|
||||
<Ellipse.Fill>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0.528,0.694"
|
||||
StartPoint="-0.056,-0.118">
|
||||
<GradientStop
|
||||
Color="#FFFFFFFF"
|
||||
Offset="0" />
|
||||
<GradientStop
|
||||
Color="#FF65A135"
|
||||
Offset="1" />
|
||||
</LinearGradientBrush>
|
||||
</Ellipse.Fill>
|
||||
</Ellipse>
|
||||
<Ellipse
|
||||
Stroke="#FF549D2D"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="24,0,0,94"
|
||||
Width="19"
|
||||
x:Name="ToolTipIndicator"
|
||||
RenderTransformOrigin="0.5,0.5"
|
||||
Height="19"
|
||||
VerticalAlignment="Bottom">
|
||||
<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.Fill>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0.528,0.694"
|
||||
StartPoint="-0.056,-0.118">
|
||||
<GradientStop
|
||||
Color="#FFFFFFFF"
|
||||
Offset="0" />
|
||||
<GradientStop
|
||||
Color="#FF65A135"
|
||||
Offset="1" />
|
||||
</LinearGradientBrush>
|
||||
</Ellipse.Fill>
|
||||
</Ellipse>
|
||||
<TextBlock
|
||||
Margin="63,62,91,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="19"
|
||||
TextWrapping="Wrap"><Run
|
||||
Language="de-ch"
|
||||
Text="TrayMouseMove Event" /></TextBlock>
|
||||
<TextBlock
|
||||
Margin="63,106,91,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="19"
|
||||
TextWrapping="Wrap"><Run
|
||||
Language="de-ch"
|
||||
Text="TrayLeftMouseUp Event" /></TextBlock>
|
||||
<TextBlock
|
||||
Margin="63,0,91,94"
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="19"><Run
|
||||
Language="de-ch"
|
||||
Text="TrayToolTipOpen Event" /></TextBlock>
|
||||
<TextBlock
|
||||
Margin="10,10,10,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="31"
|
||||
TextWrapping="Wrap"
|
||||
FontWeight="Bold"><Run Language="de-ch" Text="The green ellipses are animated based on routed events of the NotifyIcon"/></TextBlock>
|
||||
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -2,23 +2,23 @@
|
||||
|
||||
namespace Samples.Tutorials.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for EventVisualizerWindow.xaml
|
||||
/// </summary>
|
||||
public partial class EventVisualizerWindow : Window
|
||||
{
|
||||
public EventVisualizerWindow()
|
||||
/// <summary>
|
||||
/// Interaction logic for EventVisualizerWindow.xaml
|
||||
/// </summary>
|
||||
public partial class EventVisualizerWindow : Window
|
||||
{
|
||||
InitializeComponent();
|
||||
public EventVisualizerWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
notifyIcon.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
notifyIcon.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,97 +1,101 @@
|
||||
<Window
|
||||
x:Class="Samples.Tutorials.DataBinding.DataBoundToolTipWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="300"
|
||||
Width="500">
|
||||
<Grid>
|
||||
x:Class="Samples.Tutorials.DataBinding.DataBoundToolTipWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="300"
|
||||
Width="500">
|
||||
<Grid>
|
||||
|
||||
<!-- the ToolTipText property is bound to the TextBox below -->
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon1"
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="{Binding ElementName=txtToolTip, Path=Text}">
|
||||
<!-- the ToolTipText property is bound to the TextBox below -->
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon1"
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="{Binding ElementName=txtToolTip, Path=Text}">
|
||||
|
||||
<!--
|
||||
<!--
|
||||
The TextBlock bound to the ToolTipText property of the NotifyIcon
|
||||
The binding is implicit (using DataContext)
|
||||
-->
|
||||
<tb:TaskbarIcon.TrayToolTip>
|
||||
<Border
|
||||
Background="White"
|
||||
BorderBrush="Orange"
|
||||
BorderThickness="2"
|
||||
CornerRadius="4"
|
||||
Opacity="0.8"
|
||||
Width="160"
|
||||
Height="40">
|
||||
<TextBlock
|
||||
Text="{Binding Path=ToolTipText}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Border>
|
||||
</tb:TaskbarIcon.TrayToolTip>
|
||||
<tb:TaskbarIcon.TrayToolTip>
|
||||
<Border
|
||||
Background="White"
|
||||
BorderBrush="Orange"
|
||||
BorderThickness="2"
|
||||
CornerRadius="4"
|
||||
Opacity="0.8"
|
||||
Width="160"
|
||||
Height="40">
|
||||
<TextBlock
|
||||
Text="{Binding Path=ToolTipText}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Border>
|
||||
</tb:TaskbarIcon.TrayToolTip>
|
||||
|
||||
</tb:TaskbarIcon>
|
||||
</tb:TaskbarIcon>
|
||||
|
||||
|
||||
<!-- This NotifyIcon has its DataContext set (just the string "WPF FTW") - implicit binding is no longer possible -->
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon2"
|
||||
DataContext="WPF FTW "
|
||||
IconSource="/Icons/Inactive.ico"
|
||||
ToolTipText="{Binding ElementName=txtToolTip, Path=Text}">
|
||||
<!-- This NotifyIcon has its DataContext set (just the string "WPF FTW") - implicit binding is no longer possible -->
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon2"
|
||||
DataContext="WPF FTW "
|
||||
IconSource="/Icons/Inactive.ico"
|
||||
ToolTipText="{Binding ElementName=txtToolTip, Path=Text}">
|
||||
|
||||
<tb:TaskbarIcon.TrayToolTip>
|
||||
|
||||
<!--
|
||||
<tb:TaskbarIcon.TrayToolTip>
|
||||
|
||||
<!--
|
||||
Important: The attached property is assigned to the border, but derived by all controls.
|
||||
The NotifyIcon does not touch the underlying controls.
|
||||
-->
|
||||
<Border
|
||||
Background="White"
|
||||
BorderBrush="Orange"
|
||||
BorderThickness="2"
|
||||
CornerRadius="4"
|
||||
Opacity="0.8"
|
||||
Width="160"
|
||||
Height="40">
|
||||
<!-- Implicitly access the DataContext (which is a string this time)-->
|
||||
<TextBlock Text="{Binding}">
|
||||
<!-- Explicitly access the NotifyIcon, as it is an attached property -->
|
||||
<TextBlock
|
||||
Text="{Binding RelativeSource={RelativeSource Self},
|
||||
<Border
|
||||
Background="White"
|
||||
BorderBrush="Orange"
|
||||
BorderThickness="2"
|
||||
CornerRadius="4"
|
||||
Opacity="0.8"
|
||||
Width="160"
|
||||
Height="40">
|
||||
<!-- Implicitly access the DataContext (which is a string this time)-->
|
||||
<TextBlock Text="{Binding}">
|
||||
<!-- Explicitly access the NotifyIcon, as it is an attached property -->
|
||||
<TextBlock
|
||||
Text="{Binding RelativeSource={RelativeSource Self},
|
||||
Path=(tb:TaskbarIcon.ParentTaskbarIcon).ToolTipText}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</TextBlock>
|
||||
</Border>
|
||||
</tb:TaskbarIcon.TrayToolTip>
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</TextBlock>
|
||||
</Border>
|
||||
</tb:TaskbarIcon.TrayToolTip>
|
||||
|
||||
</tb:TaskbarIcon>
|
||||
|
||||
|
||||
</tb:TaskbarIcon>
|
||||
|
||||
|
||||
<TextBlock
|
||||
Margin="26,26,24,0"
|
||||
VerticalAlignment="Top"
|
||||
TextWrapping="Wrap"
|
||||
FontWeight="Bold">
|
||||
<Run Text="This sample shows data bound ToolTips in two flavors" /><LineBreak /><Run Text="" />
|
||||
<LineBreak /><Run Text="- implicit binding via DataContext" /><LineBreak />
|
||||
<Run Text="- explicit binding via ParentTaskbarIcon (attached property)" /><LineBreak /><Run Text="" />
|
||||
<LineBreak /><Run Text="Move over NotifyIcons (grey / red) to show data bound ToolTip" />
|
||||
</TextBlock>
|
||||
<TextBox
|
||||
Margin="26,0,24,10"
|
||||
Text="hello world"
|
||||
TextWrapping="Wrap"
|
||||
x:Name="txtToolTip" Height="25" VerticalAlignment="Bottom" />
|
||||
<TextBlock
|
||||
Margin="26,0,125,45"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="26"
|
||||
TextWrapping="Wrap">
|
||||
<Run
|
||||
|
||||
<TextBlock
|
||||
Margin="26,26,24,0"
|
||||
VerticalAlignment="Top"
|
||||
TextWrapping="Wrap"
|
||||
FontWeight="Bold"><Run Text="This sample shows data bound ToolTips in two flavors"/><LineBreak/><Run Text=""/><LineBreak/><Run Text="- implicit binding via DataContext"/><LineBreak/><Run Text="- explicit binding via ParentTaskbarIcon (attached property)"/><LineBreak/><Run Text=""/><LineBreak/><Run Text="Move over NotifyIcons (grey / red) to show data bound ToolTip"/></TextBlock>
|
||||
<TextBox
|
||||
Margin="26,0,24,10"
|
||||
Text="hello world"
|
||||
TextWrapping="Wrap"
|
||||
x:Name="txtToolTip" Height="25" VerticalAlignment="Bottom" />
|
||||
<TextBlock
|
||||
Margin="26,0,125,45"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="26"
|
||||
TextWrapping="Wrap"><Run
|
||||
|
||||
Text="ToolTipText:" /></TextBlock>
|
||||
Text="ToolTipText:" />
|
||||
</TextBlock>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -2,24 +2,24 @@
|
||||
|
||||
namespace Samples.Tutorials.DataBinding
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for DataBoundToolTipWindow.xaml
|
||||
/// </summary>
|
||||
public partial class DataBoundToolTipWindow : Window
|
||||
{
|
||||
public DataBoundToolTipWindow()
|
||||
/// <summary>
|
||||
/// Interaction logic for DataBoundToolTipWindow.xaml
|
||||
/// </summary>
|
||||
public partial class DataBoundToolTipWindow : Window
|
||||
{
|
||||
InitializeComponent();
|
||||
public DataBoundToolTipWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
MyNotifyIcon1.Dispose();
|
||||
MyNotifyIcon2.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
MyNotifyIcon1.Dispose();
|
||||
MyNotifyIcon2.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user