WPF NotifyIcon

--------------
FIX   Removed debug output in WindowMessageSink.
CHG   Major rework on sample project.

git-svn-id: https://svn.evolvesoftware.ch/repos/evolve.net/WPF/NotifyIcon@104 9f600761-6f11-4665-b6dc-0185e9171623
This commit is contained in:
Philipp Sumi
2009-05-15 09:51:55 +00:00
parent af046cf7bf
commit 97ef369a02
47 changed files with 1405 additions and 107 deletions

View File

@@ -0,0 +1,10 @@
<ResourceDictionary 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">
<!-- Globally declared notify icon (ResourceDictionary is not in use, example only) -->
<tb:TaskbarIcon x:Key="MyNotifyIcon"
IconSource="/Icons/Error.ico"
ToolTipText="hello world" />
</ResourceDictionary>

View File

@@ -1,5 +1,5 @@
<Window
x:Class="Samples.Tutorials.SimpleDirectDeclaration"
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"
@@ -10,8 +10,10 @@
<!-- 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>
</Grid>
</Window>

View File

@@ -0,0 +1,23 @@
using System.Windows;
namespace Samples.Tutorials
{
/// <summary>
/// Interaction logic for SimpleWindowWithNotifyIcon.xaml
/// </summary>
public partial class SimpleWindowWithNotifyIcon : Window
{
public SimpleWindowWithNotifyIcon()
{
InitializeComponent();
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
MyNotifyIcon.Dispose();
base.OnClosing(e);
}
}
}

View File

@@ -1,15 +0,0 @@
using System.Windows;
namespace Samples.Tutorials
{
/// <summary>
/// Interaction logic for SimpleDirectDeclaration.xaml
/// </summary>
public partial class SimpleDirectDeclaration : Window
{
public SimpleDirectDeclaration()
{
InitializeComponent();
}
}
}

View File

@@ -0,0 +1,40 @@
<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>
<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>
</Grid>
</Window>

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Samples.Tutorials.ToolTips
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class InlineToolTipWindow : Window
{
public InlineToolTipWindow()
{
InitializeComponent();
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
MyNotifyIcon.Dispose();
base.OnClosing(e);
}
}
}

View File

@@ -1,8 +1,22 @@
<UserControl x:Class="Samples.Tutorials.SimpleUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="300" Width="300">
<Grid>
</Grid>
<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"
>
<!-- 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>

View File

@@ -12,7 +12,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Samples.Tutorials
namespace Samples.Tutorials.ToolTips
{
/// <summary>
/// Interaction logic for SimpleUserControl.xaml

View File

@@ -0,0 +1,25 @@
<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>
<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>
</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>

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Samples.Tutorials.ToolTips
{
/// <summary>
/// Interaction logic for UserControlToolTipWindow.xaml
/// </summary>
public partial class UserControlToolTipWindow : Window
{
public UserControlToolTipWindow()
{
InitializeComponent();
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
MyNotifyIcon.Dispose();
base.OnClosing(e);
}
}
}

View File

@@ -0,0 +1,39 @@
<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>
<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"
Height="40">
<Button
Content="Click Me!"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
</tb:TaskbarIcon.TrayPopup>
</tb:TaskbarIcon>
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap"><Run Language="de-ch" Text="Left-Click NotifyIcon to open popup."/></TextBlock>
</Grid>
</Window>

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Samples.Tutorials.Popups
{
/// <summary>
/// Interaction logic for InlinePopupWindow.xaml
/// </summary>
public partial class InlinePopupWindow : Window
{
public InlinePopupWindow()
{
InitializeComponent();
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
MyNotifyIcon.Dispose();
base.OnClosing(e);
}
}
}

View File

@@ -0,0 +1,27 @@
<Window
x:Class="Samples.Tutorials.ContextMenus.InlineContextMenuWindow"
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">
<!-- Set a simple context menu -->
<tb:TaskbarIcon.ContextMenu>
<ContextMenu>
<MenuItem Header="First Menu Item" />
<MenuItem Header="Second Menu Item" />
</ContextMenu>
</tb:TaskbarIcon.ContextMenu>
</tb:TaskbarIcon>
<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>
</Grid>
</Window>

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Samples.Tutorials.ContextMenus
{
/// <summary>
/// Interaction logic for InlineContextMenuWindow.xaml
/// </summary>
public partial class InlineContextMenuWindow : Window
{
public InlineContextMenuWindow()
{
InitializeComponent();
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
MyNotifyIcon.Dispose();
base.OnClosing(e);
}
}
}

View File

@@ -0,0 +1,54 @@
<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>
<!-- 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>

View File

@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Hardcodet.Wpf.TaskbarNotification;
namespace Samples.Tutorials.Balloons
{
/// <summary>
/// Interaction logic for BalloonSampleWindow.xaml
/// </summary>
public partial class BalloonSampleWindow : Window
{
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();
}
}
}

View File

@@ -0,0 +1,30 @@
<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">
<Grid>
<!-- 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="MyNotifyIcon"
IconSource="/Icons/Error.ico"
LeftClickCommand="{StaticResource MessageCommand}"
LeftClickCommandParameter="Left mouse button was clicked"
DoubleClickCommand="{StaticResource MessageCommand}"
DoubleClickCommandParameter="Double click on NotifyIcon" />
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap"><Run Language="de-ch" Text="Left / Double clicks on NotifyIcon executes commands."/></TextBlock>
</Grid>
</Window>

View File

@@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Samples.Tutorials.Commands
{
/// <summary>
/// Interaction logic for CommandWindow.xaml
/// </summary>
public partial class CommandWindow : Window
{
public CommandWindow()
{
InitializeComponent();
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
MyNotifyIcon.Dispose();
base.OnClosing(e);
}
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Windows;
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)
{
MessageBox.Show(parameter.ToString());
}
public bool CanExecute(object parameter)
{
return true;
}
public event EventHandler CanExecuteChanged;
}
}

View File

@@ -0,0 +1,261 @@
<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>
<!-- 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 elipses are animated based on routed events of the NotifyIcon" /></TextBlock>
</Grid>
</Window>

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Samples.Tutorials.Events
{
/// <summary>
/// Interaction logic for EventVisualizerWindow.xaml
/// </summary>
public partial class EventVisualizerWindow : Window
{
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);
}
}
}

View File

@@ -0,0 +1,89 @@
<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="300">
<Grid>
<!-- the ToolTipText property is bound to the TextBox below -->
<tb:TaskbarIcon
x:Name="MyNotifyIcon"
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>
<!-- the ToolTipText property is bound to the TextBox below -->
<tb:TaskbarIcon
IconSource="/Icons/Inactive.ico"
ToolTipText="{Binding ElementName=txtToolTip, Path=Text}">
<!--
The TextBlock bound to the ToolTipText property of the NotifyIcon
The binding is explicit (via attached ParentTaskbarIcon property)
-->
<tb:TaskbarIcon.TrayToolTip>
<Border
Background="White"
BorderBrush="Orange"
BorderThickness="2"
CornerRadius="4"
Opacity="0.8"
Width="160"
Height="40">
<TextBlock
Text="{Binding (tb:TaskbarIcon.ParentTaskbarIcon), Path=ToolTipText}"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
</tb:TaskbarIcon.TrayToolTip>
</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
Text="ToolTipText:" /></TextBlock>
</Grid>
</Window>

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace Samples.Tutorials.DataBinding
{
/// <summary>
/// Interaction logic for DataBoundToolTipWindow.xaml
/// </summary>
public partial class DataBoundToolTipWindow : Window
{
public DataBoundToolTipWindow()
{
InitializeComponent();
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
MyNotifyIcon.Dispose();
base.OnClosing(e);
}
}
}