mirror of
https://github.com/ckaczor/wpf-notifyicon.git
synced 2026-01-14 01:25:45 -05:00
CHG Moved files to new root folder.
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
<UserControl x:Class="Samples.FancyBalloon"
|
||||
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"
|
||||
x:Name="me"
|
||||
Height="120"
|
||||
Width="240">
|
||||
<UserControl.Resources>
|
||||
<Storyboard x:Key="FadeIn">
|
||||
<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.95" />
|
||||
<SplineDoubleKeyFrame KeyTime="00:00:03"
|
||||
Value="0.95" />
|
||||
<!-- <SplineDoubleKeyFrame KeyTime="00:00:05" Value="0"/>-->
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
<Storyboard x:Key="HighlightCloseButton">
|
||||
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
|
||||
Storyboard.TargetName="imgClose"
|
||||
Storyboard.TargetProperty="(UIElement.Opacity)">
|
||||
<SplineDoubleKeyFrame KeyTime="00:00:00"
|
||||
Value="0.4" />
|
||||
<SplineDoubleKeyFrame KeyTime="00:00:00.3000000"
|
||||
Value="1" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
<Storyboard x:Key="FadeCloseButton">
|
||||
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
|
||||
Storyboard.TargetName="imgClose"
|
||||
Storyboard.TargetProperty="(UIElement.Opacity)">
|
||||
<SplineDoubleKeyFrame KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame KeyTime="00:00:00.3000000"
|
||||
Value="0.4" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
<Storyboard x:Key="FadeBack">
|
||||
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
|
||||
Storyboard.TargetName="grid"
|
||||
Storyboard.TargetProperty="(UIElement.Opacity)">
|
||||
<SplineDoubleKeyFrame KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame KeyTime="00:00:00.3000000"
|
||||
Value="1" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
<Storyboard x:Key="FadeOut"
|
||||
Completed="OnFadeOutCompleted">
|
||||
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
|
||||
Storyboard.TargetName="grid"
|
||||
Storyboard.TargetProperty="(UIElement.Opacity)">
|
||||
<SplineDoubleKeyFrame KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame KeyTime="00:00:00.3000000"
|
||||
Value="0.2" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</UserControl.Resources>
|
||||
<UserControl.Triggers>
|
||||
<EventTrigger RoutedEvent="tb:TaskbarIcon.BalloonShowing">
|
||||
<BeginStoryboard Storyboard="{StaticResource FadeIn}"
|
||||
x:Name="FadeIn_BeginStoryboard" />
|
||||
</EventTrigger>
|
||||
<EventTrigger RoutedEvent="Mouse.MouseEnter"
|
||||
SourceName="imgClose">
|
||||
<BeginStoryboard Storyboard="{StaticResource HighlightCloseButton}"
|
||||
x:Name="HighlightCloseButton_BeginStoryboard" />
|
||||
</EventTrigger>
|
||||
<EventTrigger RoutedEvent="Mouse.MouseLeave"
|
||||
SourceName="imgClose">
|
||||
<BeginStoryboard Storyboard="{StaticResource FadeCloseButton}"
|
||||
x:Name="FadeCloseButton_BeginStoryboard" />
|
||||
</EventTrigger>
|
||||
<EventTrigger RoutedEvent="Mouse.MouseEnter">
|
||||
<StopStoryboard BeginStoryboardName="FadeIn_BeginStoryboard" />
|
||||
<BeginStoryboard x:Name="FadeBack_BeginStoryboard1"
|
||||
Storyboard="{StaticResource FadeBack}" />
|
||||
</EventTrigger>
|
||||
<EventTrigger RoutedEvent="tb:TaskbarIcon.BalloonClosing">
|
||||
<BeginStoryboard Storyboard="{StaticResource FadeOut}"
|
||||
x:Name="FadeOut_BeginStoryboard" />
|
||||
</EventTrigger>
|
||||
</UserControl.Triggers>
|
||||
<Grid x:Name="grid"
|
||||
MouseEnter="grid_MouseEnter">
|
||||
<Border HorizontalAlignment="Stretch"
|
||||
Margin="5,5,5,5"
|
||||
BorderThickness="1,1,1,1"
|
||||
BorderBrush="#FF997137">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect Color="#FF747474" />
|
||||
</Border.Effect>
|
||||
<Border.Background>
|
||||
<LinearGradientBrush EndPoint="0.5,1"
|
||||
StartPoint="0.5,0">
|
||||
<GradientStop Color="#FF4B4B4B"
|
||||
Offset="0" />
|
||||
<GradientStop Color="#FF8F8F8F"
|
||||
Offset="1" />
|
||||
</LinearGradientBrush>
|
||||
</Border.Background>
|
||||
</Border>
|
||||
<Image HorizontalAlignment="Left"
|
||||
Margin="0,10,0,0"
|
||||
Width="72"
|
||||
Source="/Images/Info.png"
|
||||
Stretch="Fill"
|
||||
Height="72"
|
||||
VerticalAlignment="Top" />
|
||||
<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>
|
||||
<Path Fill="#FFFFFFFF"
|
||||
Stretch="Fill"
|
||||
Margin="72,38.2,34,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="1"
|
||||
Data="M26,107 L220.04123,107"
|
||||
SnapsToDevicePixels="True">
|
||||
<Path.Stroke>
|
||||
<LinearGradientBrush EndPoint="0.973,0.5"
|
||||
StartPoint="0.005,0.5">
|
||||
<GradientStop Color="#00ECAD25"
|
||||
Offset="1" />
|
||||
<GradientStop Color="#87ECAD25"
|
||||
Offset="0" />
|
||||
</LinearGradientBrush>
|
||||
</Path.Stroke>
|
||||
</Path>
|
||||
<TextBlock Margin="72,10,10,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="23.2"
|
||||
Text="{Binding Path=BalloonText, ElementName=me, Mode=Default}"
|
||||
TextWrapping="Wrap"
|
||||
Foreground="#FFECAD25"
|
||||
FontWeight="Bold" />
|
||||
<Image HorizontalAlignment="Right"
|
||||
Margin="0,10,10,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="16"
|
||||
Height="16"
|
||||
Source="/Images/Close.png"
|
||||
Stretch="Fill"
|
||||
Opacity="0.4"
|
||||
ToolTip="Close Balloon"
|
||||
x:Name="imgClose"
|
||||
MouseDown="imgClose_MouseDown" />
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,107 @@
|
||||
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.Animation;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
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
|
||||
/// </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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
<UserControl
|
||||
x:Class="Samples.FancyPopup"
|
||||
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="215"
|
||||
Width="300" x:Name="me">
|
||||
<UserControl.Resources>
|
||||
<Storyboard x:Key="RotateIcon">
|
||||
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="image" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
|
||||
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
|
||||
<SplineDoubleKeyFrame KeySpline="0,0.284,0.39,1" KeyTime="00:00:01.4000000" Value="360"/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</UserControl.Resources>
|
||||
<UserControl.Triggers>
|
||||
<EventTrigger RoutedEvent="tb:TaskbarIcon.PopupOpened">
|
||||
<BeginStoryboard Storyboard="{StaticResource RotateIcon}" x:Name="RotateIcon_BeginStoryboard"/>
|
||||
</EventTrigger>
|
||||
</UserControl.Triggers>
|
||||
<Grid>
|
||||
<Border
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Width="Auto"
|
||||
Height="Auto"
|
||||
Margin="5,5,5,5"
|
||||
CornerRadius="10,10,10,10">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect
|
||||
Color="#FF474747" />
|
||||
</Border.Effect>
|
||||
<Border.Background>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0.5,1"
|
||||
StartPoint="0.5,0">
|
||||
<GradientStop
|
||||
Color="#FF58C2FF"
|
||||
Offset="0" />
|
||||
<GradientStop
|
||||
Color="#FFFFFFFF"
|
||||
Offset="1" />
|
||||
</LinearGradientBrush>
|
||||
</Border.Background>
|
||||
</Border>
|
||||
<Image
|
||||
HorizontalAlignment="Left"
|
||||
Margin="19,10,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="72"
|
||||
Height="72"
|
||||
Source="/Images/Preferences.png"
|
||||
Stretch="Fill" x:Name="image" RenderTransformOrigin="0.5,0.5" >
|
||||
<Image.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform ScaleX="1" ScaleY="1"/>
|
||||
<SkewTransform AngleX="0" AngleY="0"/>
|
||||
<RotateTransform Angle="0"/>
|
||||
<TranslateTransform X="0" Y="0"/>
|
||||
</TransformGroup>
|
||||
</Image.RenderTransform>
|
||||
</Image>
|
||||
<TextBlock
|
||||
Margin="107,10,20,0"
|
||||
TextWrapping="Wrap"
|
||||
Height="Auto"
|
||||
VerticalAlignment="Top"
|
||||
FontSize="16"
|
||||
FontWeight="Bold"
|
||||
Foreground="#FF575757" HorizontalAlignment="Right"><Run
|
||||
Text="This is a fancy Popup..."
|
||||
Language="de-ch" /></TextBlock>
|
||||
<Button
|
||||
Click="OnButtonClick"
|
||||
ToolTip="{Binding Path=ToolTipText}"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Width="89"
|
||||
Height="29"
|
||||
Content="Click me"
|
||||
Margin="0,0,20,20"
|
||||
BorderBrush="#FFFFFFFF">
|
||||
<Button.Background>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0,1"
|
||||
StartPoint="0,0">
|
||||
<GradientStop
|
||||
Color="#FFFFFFFF"
|
||||
Offset="1" />
|
||||
<GradientStop
|
||||
Color="#FFFFD197"
|
||||
Offset="0.459" />
|
||||
<GradientStop
|
||||
Color="#FFFFDBAD"
|
||||
Offset="0" />
|
||||
<GradientStop
|
||||
Color="#FFF18E23"
|
||||
Offset="0.508" />
|
||||
<GradientStop
|
||||
Color="#FFF9D4AC"
|
||||
Offset="0.954" />
|
||||
</LinearGradientBrush>
|
||||
</Button.Background>
|
||||
</Button>
|
||||
<TextBlock
|
||||
Margin="19,92,10,49"
|
||||
TextWrapping="Wrap"><Run Text="This user control makes use of the " Language="de-ch"/><Run FontStyle="Italic" FontWeight="Bold" Text="PopupOpened " Language="de-ch"/><Run Text="attached routed event . Whenever the popup is opened, this attached event fires and triggers the rotation animation." Language="de-ch"/></TextBlock>
|
||||
<TextBlock Margin="0,52,20,0" VerticalAlignment="Top" Height="Auto" TextWrapping="Wrap" FontWeight="Bold" FontSize="14" HorizontalAlignment="Right" Foreground="#FF575757"><Run Text="Clicks: " Language="de-ch"/><InlineUIContainer>
|
||||
<TextBlock Width="Auto" Height="Auto" Text="{Binding Path=ClickCount, ElementName=me, Mode=Default}" TextWrapping="Wrap"/>
|
||||
</InlineUIContainer></TextBlock>
|
||||
<Image
|
||||
Source="{Binding Path=IconSource}" Width="16" HorizontalAlignment="Left" Margin="19,0,0,23" Height="16" VerticalAlignment="Bottom" />
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,46 @@
|
||||
using System.Windows;
|
||||
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.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ClickCountProperty =
|
||||
DependencyProperty.Register("ClickCount",
|
||||
typeof (int),
|
||||
typeof (FancyPopup),
|
||||
new FrameworkPropertyMetadata(0));
|
||||
|
||||
/// <summary>
|
||||
/// A property wrapper for the <see cref="ClickCountProperty"/>
|
||||
/// dependency property:<br/>
|
||||
/// The number of clicks on the popup button.
|
||||
/// </summary>
|
||||
public int ClickCount
|
||||
{
|
||||
get { return (int) GetValue(ClickCountProperty); }
|
||||
set { SetValue(ClickCountProperty, value); }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public FancyPopup()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OnButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//just increment a counter - will be displayed on screen
|
||||
ClickCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,114 @@
|
||||
<UserControl
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
mc:Ignorable="d"
|
||||
x:Class="Samples.FancyToolTip"
|
||||
x:Name="me"
|
||||
Width="285"
|
||||
Height="136">
|
||||
<UserControl.Resources>
|
||||
<Storyboard x:Key="FadeIn">
|
||||
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="border" Storyboard.TargetProperty="(UIElement.Opacity)">
|
||||
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
|
||||
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="1" KeySpline="0,0,0.46,0.969"/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="image" Storyboard.TargetProperty="(UIElement.Opacity)">
|
||||
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.6"/>
|
||||
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="1"/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
<Storyboard x:Key="FadeOut">
|
||||
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="border" Storyboard.TargetProperty="(UIElement.Opacity)">
|
||||
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
|
||||
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="0.25"/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="image" Storyboard.TargetProperty="(UIElement.Opacity)">
|
||||
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
|
||||
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="0.6"/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</UserControl.Resources>
|
||||
<UserControl.Triggers>
|
||||
<EventTrigger RoutedEvent="tb:TaskbarIcon.ToolTipOpened">
|
||||
<BeginStoryboard Storyboard="{StaticResource FadeIn}" x:Name="FadeIn_BeginStoryboard"/>
|
||||
</EventTrigger>
|
||||
<EventTrigger RoutedEvent="tb:TaskbarIcon.ToolTipClose">
|
||||
<BeginStoryboard Storyboard="{StaticResource FadeOut}" x:Name="FadeOut_BeginStoryboard"/>
|
||||
</EventTrigger>
|
||||
</UserControl.Triggers>
|
||||
|
||||
<Grid
|
||||
x:Name="LayoutRoot" Height="Auto">
|
||||
<Border
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Width="Auto"
|
||||
Height="Auto"
|
||||
CornerRadius="6,6,6,6"
|
||||
BorderThickness="3,3,3,3"
|
||||
Margin="0,0,5,5" x:Name="border">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect
|
||||
Color="#FF7A7A7A" />
|
||||
</Border.Effect>
|
||||
<Border.Background>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0.5,1"
|
||||
StartPoint="0.5,0">
|
||||
<GradientStop
|
||||
Color="#FFFFD283"
|
||||
Offset="0" />
|
||||
<GradientStop
|
||||
Color="#FFFFFFFF"
|
||||
Offset="1" />
|
||||
</LinearGradientBrush>
|
||||
</Border.Background>
|
||||
</Border>
|
||||
<Image
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,10,0,26"
|
||||
Width="72"
|
||||
Source="/Images/Info.png"
|
||||
Stretch="Fill"
|
||||
VerticalAlignment="Top"
|
||||
RenderTransformOrigin="0.792,0.486" x:Name="image" Height="72" >
|
||||
<Image.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform ScaleX="1" ScaleY="1"/>
|
||||
<SkewTransform AngleX="0" AngleY="0"/>
|
||||
<RotateTransform Angle="0"/>
|
||||
<TranslateTransform X="0" Y="0"/>
|
||||
</TransformGroup>
|
||||
</Image.RenderTransform>
|
||||
</Image>
|
||||
<TextBlock
|
||||
Margin="82,10,20,0"
|
||||
TextWrapping="Wrap"
|
||||
Height="32"
|
||||
VerticalAlignment="Top"
|
||||
FontSize="16"
|
||||
FontWeight="Bold"
|
||||
Foreground="#FF575757"><Run
|
||||
Text="This is a fancy ToolTip..."
|
||||
Language="de-ch" /></TextBlock>
|
||||
<TextBlock
|
||||
FontSize="12"
|
||||
FontWeight="Bold"
|
||||
Foreground="#FF141414"
|
||||
TextWrapping="Wrap"
|
||||
Margin="10,0,20,19"
|
||||
VerticalAlignment="Bottom"
|
||||
Text="{Binding ElementName=me, Path=InfoText}"
|
||||
x:Name="txtToolTipDetail" d:LayoutOverrides="Height" />
|
||||
<TextBlock
|
||||
FontSize="12"
|
||||
FontWeight="Normal"
|
||||
Foreground="#FF141414"
|
||||
TextWrapping="Wrap"
|
||||
Margin="82,42,20,44.96"
|
||||
x:Name="txtToolTipDetail_Copy" ><Run Text="Data binding is simple: The NotifyIcon sets the DataContext unless it's not already in use." Language="de-ch"/></TextBlock>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
|
||||
namespace Samples
|
||||
{
|
||||
/// <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>
|
||||
/// 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
|
||||
|
||||
public FancyToolTip()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Commands="clr-namespace:Samples.Commands"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar">
|
||||
<LinearGradientBrush x:Key="MenuBackground"
|
||||
EndPoint="0.5,1"
|
||||
StartPoint="0.5,0">
|
||||
<GradientStop Color="#FFFFD892"
|
||||
Offset="1" />
|
||||
<GradientStop Color="#FFFFF3DD"
|
||||
Offset="0.259" />
|
||||
</LinearGradientBrush>
|
||||
|
||||
|
||||
<Style TargetType="{x:Type ContextMenu}">
|
||||
<Setter Property="BorderThickness"
|
||||
Value="1,1,1,1" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ContextMenu}">
|
||||
<Grid>
|
||||
<Border Background="{DynamicResource MenuBackground}"
|
||||
BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}">
|
||||
<ScrollViewer
|
||||
Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}"
|
||||
Uid="ScrollViewer_9"
|
||||
CanContentScroll="True">
|
||||
<ItemsPresenter Margin="{TemplateBinding Padding}"
|
||||
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
|
||||
KeyboardNavigation.DirectionalNavigation="Cycle" />
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
|
||||
<!-- The taskbar context menu - the first row is a dummy to show off simple data binding -->
|
||||
<!--
|
||||
The "shared" directive is needed if we reopen the sample window a few times - WPF will otherwise
|
||||
reuse the same context menu (which is a resource) again (which will have its DataContext set to the old TaskbarIcon)
|
||||
-->
|
||||
<ContextMenu x:Shared="false"
|
||||
x:Key="tbMenu">
|
||||
<MenuItem IsEnabled="False"
|
||||
Header="{Binding Path=ToolTipText}">
|
||||
<MenuItem.Icon>
|
||||
<Image Width="16"
|
||||
Height="16"
|
||||
Source="{Binding Path=IconSource}" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
|
||||
<MenuItem Header="Show Showcase Window"
|
||||
Command="{Commands:ShowSampleWindowCommand}"
|
||||
CommandParameter="{Binding}">
|
||||
<MenuItem.Icon>
|
||||
<Image Width="16"
|
||||
Height="16"
|
||||
Source="/Images/Add.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
|
||||
<Separator />
|
||||
|
||||
<MenuItem Header="Hide Showcase Window"
|
||||
Command="{Commands:HideSampleWindowCommand}"
|
||||
CommandParameter="{Binding}">
|
||||
<MenuItem.Icon>
|
||||
<Image Width="16"
|
||||
Height="16"
|
||||
Source="/Images/Remove.png" />
|
||||
</MenuItem.Icon>
|
||||
</MenuItem>
|
||||
</ContextMenu>
|
||||
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -0,0 +1,640 @@
|
||||
<Window
|
||||
x:Class="Samples.ShowcaseWindow"
|
||||
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:sys="clr-namespace:System;assembly=mscorlib"
|
||||
Title="WPF NotifyIcon"
|
||||
Height="874"
|
||||
Width="936.387"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
xmlns:local="clr-namespace:Samples"
|
||||
xmlns:Commands="clr-namespace:Samples.Commands"
|
||||
MinWidth="750"
|
||||
MinHeight="800"
|
||||
ResizeMode="NoResize">
|
||||
<Window.Resources>
|
||||
|
||||
<BooleanToVisibilityConverter
|
||||
x:Key="BooleanToVisibilityConverter" />
|
||||
|
||||
<ObjectDataProvider
|
||||
MethodName="GetValues"
|
||||
ObjectType="{x:Type sys:Enum}"
|
||||
x:Key="ActivationModes">
|
||||
<ObjectDataProvider.MethodParameters>
|
||||
<x:Type
|
||||
TypeName="tb:PopupActivationMode" />
|
||||
</ObjectDataProvider.MethodParameters>
|
||||
</ObjectDataProvider>
|
||||
|
||||
</Window.Resources>
|
||||
<Window.Background>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0.771,0.907"
|
||||
StartPoint="0.229,0.093">
|
||||
<GradientStop
|
||||
Color="#FFFFFFFF"
|
||||
Offset="1" />
|
||||
<GradientStop
|
||||
Color="#FFDAE9FF" />
|
||||
</LinearGradientBrush>
|
||||
</Window.Background>
|
||||
<Window.Triggers>
|
||||
<EventTrigger
|
||||
RoutedEvent="tb:TaskbarIcon.TrayToolTipOpen"
|
||||
SourceName="tb" />
|
||||
</Window.Triggers>
|
||||
|
||||
<Grid
|
||||
Hyperlink.RequestNavigate="OnNavigationRequest">
|
||||
|
||||
|
||||
<!--
|
||||
THE TASKBARICON ELEMENT WAS DECLARED INLINE IN ORDER TO USE DATABINDING
|
||||
FOR ITS PROPERTIES. IN A REAL-LIFE APP, YOU'D PROBABLY RATHER DECLARE
|
||||
IT IN A RESOURCE DICTIONARY SO YOU CAN ALSO USE IT IF THERE IS NO WINDOW
|
||||
OPEN.
|
||||
-->
|
||||
|
||||
<tb:TaskbarIcon
|
||||
x:Name="tb"
|
||||
VerticalAlignment="Top"
|
||||
IconSource="{Binding Path=SelectedItem.Source, ElementName=iconList, Mode=Default}"
|
||||
ContextMenu="{StaticResource tbMenu}"
|
||||
ToolTipText="{Binding Path=Text, ElementName=txtToolTipText, Mode=Default}"
|
||||
Visibility="{Binding Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, ElementName=iconVisibility, Mode=Default}"
|
||||
MenuActivation="{Binding Path=SelectedItem, ElementName=lstMenuTrigger, Mode=Default}"
|
||||
PopupActivation="{Binding Path=SelectedItem, ElementName=lstPopupTrigger, Mode=Default}"
|
||||
DoubleClickCommand="{Commands:ShowSampleWindowCommand}"
|
||||
DoubleClickCommandParameter="{Binding RelativeSource={RelativeSource Self}}">
|
||||
|
||||
<tb:TaskbarIcon.TrayPopup>
|
||||
<!-- the control will be put into a popup with an explicit DataContext -->
|
||||
<local:FancyPopup />
|
||||
</tb:TaskbarIcon.TrayPopup>
|
||||
|
||||
<tb:TaskbarIcon.TrayToolTip>
|
||||
<!-- the control will be put into a tooltip with an explicit DataContext -->
|
||||
<local:FancyToolTip
|
||||
Opacity="0.85"
|
||||
InfoText="{Binding Path=ToolTipText}" />
|
||||
</tb:TaskbarIcon.TrayToolTip>
|
||||
|
||||
</tb:TaskbarIcon>
|
||||
|
||||
|
||||
<!-- ************************************************************************************* -->
|
||||
<!-- ************************************************************************************* -->
|
||||
<!-- EVERYTHING BELOW IS JUST PLUMBING FOR THE SAMPLE -->
|
||||
|
||||
|
||||
<Grid
|
||||
Margin="509.567,578.58,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="248"
|
||||
x:Name="Balloons"
|
||||
Width="405.32"
|
||||
HorizontalAlignment="Left">
|
||||
<Border
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
BorderBrush="Black"
|
||||
BorderThickness="2,2,2,2" />
|
||||
<TextBox
|
||||
Margin="125,0,17,133"
|
||||
x:Name="txtBalloonTitle"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="23">
|
||||
WPF NotifyIcon
|
||||
</TextBox>
|
||||
<TextBox
|
||||
Margin="125,0,17,76"
|
||||
x:Name="txtBalloonText"
|
||||
AcceptsReturn="True"
|
||||
Height="47"
|
||||
VerticalAlignment="Bottom"
|
||||
d:LayoutOverrides="VerticalAlignment"
|
||||
TextWrapping="Wrap"
|
||||
Text="You should see a LED icon in your system tray. This is your NotifyIcon." />
|
||||
<RadioButton
|
||||
HorizontalAlignment="Left"
|
||||
Margin="14,0,0,54"
|
||||
VerticalAlignment="Bottom"
|
||||
Width="111"
|
||||
Height="22"
|
||||
Content="Show as Info"
|
||||
IsChecked="True"
|
||||
x:Name="rbInfo" />
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
Margin="14,0,0,133"
|
||||
VerticalAlignment="Bottom"
|
||||
Width="85"
|
||||
Height="23"
|
||||
TextWrapping="Wrap">
|
||||
<Run
|
||||
Text="Balloon Title" />
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
Margin="14,0,0,100"
|
||||
TextWrapping="Wrap"
|
||||
HorizontalAlignment="Left"
|
||||
Width="85"
|
||||
Height="23"
|
||||
VerticalAlignment="Bottom"
|
||||
d:LayoutOverrides="VerticalAlignment">
|
||||
<Run
|
||||
Text="Balloon Text" />
|
||||
</TextBlock>
|
||||
<RadioButton
|
||||
Margin="14,0,0,32"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="22"
|
||||
Content="Show as Error"
|
||||
HorizontalAlignment="Left"
|
||||
Width="111"
|
||||
x:Name="rbError" />
|
||||
<RadioButton
|
||||
Margin="14,0,0,10"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="22"
|
||||
Content="Show Custom Icon"
|
||||
HorizontalAlignment="Left"
|
||||
Width="130"
|
||||
x:Name="rbCustomIcon" />
|
||||
<Button
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,17,43"
|
||||
x:Name="showBalloonTip"
|
||||
Width="120"
|
||||
Content="Show Balloon Tip"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="23"
|
||||
Click="showBalloonTip_Click" />
|
||||
<TextBlock
|
||||
Margin="10,35.96,21,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="56.04"
|
||||
TextWrapping="Wrap">
|
||||
<Run
|
||||
Text="Displays default balloon tips as supported by the OS. " />
|
||||
<Run
|
||||
Text="You can use custom icons under all OS versions" />
|
||||
<Run
|
||||
Text=" (not supported by WinForms NotifyIcon)." />
|
||||
<Run
|
||||
Text="." />
|
||||
</TextBlock>
|
||||
<Button
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,17,12.52"
|
||||
x:Name="hideBalloonTip"
|
||||
Width="120"
|
||||
Content="Hide Balloon Tip"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="23"
|
||||
Click="hideBalloonTip_Click" />
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,10,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="Auto"
|
||||
Height="Auto"
|
||||
FontWeight="Bold"
|
||||
TextDecorations="Underline"
|
||||
TextWrapping="Wrap">
|
||||
<Run
|
||||
Text="Standard (OS) Balloon Tips" />
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
<Grid
|
||||
HorizontalAlignment="Left"
|
||||
Margin="12,543.88,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="469.5"
|
||||
Height="282.7"
|
||||
x:Name="Popups">
|
||||
<Border
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
BorderBrush="#FF000000"
|
||||
BorderThickness="2,2,2,2" />
|
||||
<ListBox
|
||||
IsSynchronizedWithCurrentItem="False"
|
||||
x:Name="lstPopupTrigger"
|
||||
ItemsSource="{Binding Mode=OneWay, Source={StaticResource ActivationModes}}"
|
||||
Margin="10,0,190,10"
|
||||
SelectedIndex="0"
|
||||
Height="117"
|
||||
VerticalAlignment="Bottom" />
|
||||
<TextBlock
|
||||
Margin="10,31.7,14,137"
|
||||
TextWrapping="Wrap">
|
||||
<Run
|
||||
Text="If the user clicks on the " />
|
||||
<Run
|
||||
Text="Notify" />
|
||||
<Run
|
||||
Text="Icon, a " />
|
||||
<Run
|
||||
Text="P" />
|
||||
<Run
|
||||
Text="opup can be opened and displayed" />
|
||||
<Run
|
||||
Text=" that allows the user to quickly interact with the application" />
|
||||
<Run
|
||||
Text=". " />
|
||||
<Run
|
||||
Text="Unlike custom ToolTips, this works under all OS versions" />
|
||||
<Run
|
||||
Text=". " />
|
||||
<Run
|
||||
Text="Which mouse button(s) opens the Popup is " />
|
||||
<Run
|
||||
Text="determined by the " />
|
||||
<Run
|
||||
FontStyle="Italic"
|
||||
FontWeight="Bold"
|
||||
Text="PopupActivation " />
|
||||
<Run
|
||||
Text="property." />
|
||||
<Run
|
||||
Text=" If both Popup and ContextMenu are configured for the same mouse buttons, ContextMenu takes precedence." />
|
||||
<LineBreak />
|
||||
<Run
|
||||
Text="(Note: " />
|
||||
<Run
|
||||
Text="In case left-clicks are used, popups are displayed with a delay to ensure the user does not double-click." />
|
||||
<Run
|
||||
Text=")" />
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,10,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="Auto"
|
||||
Height="Auto"
|
||||
FontWeight="Bold"
|
||||
TextDecorations="Underline"
|
||||
TextWrapping="Wrap">
|
||||
<Run
|
||||
Text="Popup Controls" />
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
<Grid
|
||||
Margin="10,278,0,0"
|
||||
x:Name="ToolTips"
|
||||
Height="255.88"
|
||||
VerticalAlignment="Top"
|
||||
Width="471.5"
|
||||
HorizontalAlignment="Left">
|
||||
<Border
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
BorderBrush="#FF000000"
|
||||
BorderThickness="2,2,2,2" />
|
||||
<TextBox
|
||||
Margin="10,0,25,60"
|
||||
x:Name="txtToolTipText"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="23"
|
||||
Text="THIS IS A SAMPLE TEXT...."
|
||||
Foreground="#FFFF0000" />
|
||||
<TextBlock
|
||||
Margin="10,0,25,93"
|
||||
TextWrapping="Wrap"
|
||||
Height="21"
|
||||
VerticalAlignment="Bottom">
|
||||
<Run
|
||||
Text="ToolTipText" />
|
||||
<Run
|
||||
Text=" (assigned to property and also used by several bindings)" />
|
||||
<Run
|
||||
Text=":" />
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
Margin="10,29.88,10,114"
|
||||
TextWrapping="Wrap">
|
||||
<Run
|
||||
Text="If the user moves the mouse over the " />
|
||||
<Run
|
||||
Text="Notify" />
|
||||
<Run
|
||||
Text="Icon, " />
|
||||
<Run
|
||||
Text="a ToolTip " />
|
||||
<Run
|
||||
Text="can be displayed. Starting from Windows Vista, we have convenient events to display and hide tooltips." />
|
||||
<Run
|
||||
Text=" You can assign arbitrary UIElements (e.g. User Controls) to the " />
|
||||
<Run
|
||||
FontStyle="Italic"
|
||||
FontWeight="Bold"
|
||||
Text="TrayToolTip " />
|
||||
<Run
|
||||
Text="property." />
|
||||
<LineBreak />
|
||||
<Run
|
||||
Text="" />
|
||||
<Run
|
||||
Text="If " />
|
||||
<Run
|
||||
FontStyle="Italic"
|
||||
FontWeight="Bold"
|
||||
Text="TrayToolTip " />
|
||||
<Run
|
||||
Text="is not set or the app runs under an older OS (e.g. " />
|
||||
<Run
|
||||
Text="Windows " />
|
||||
<Run
|
||||
Text="xp), the " />
|
||||
<Run
|
||||
Text="NotifyIcon " />
|
||||
<Run
|
||||
Text="falls back to the " />
|
||||
<Run
|
||||
FontStyle="Italic"
|
||||
FontWeight="Bold"
|
||||
Text="ToolTipText " />
|
||||
<Run
|
||||
Text="property." />
|
||||
</TextBlock>
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,0,0,10"
|
||||
VerticalAlignment="Bottom"
|
||||
Width="147"
|
||||
Height="24"
|
||||
Content="Remove Custom ToolTip"
|
||||
Name="removeToolTip"
|
||||
Click="removeToolTip_Click" />
|
||||
<TextBlock
|
||||
Margin="10,0,25,44"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="16"
|
||||
TextWrapping="Wrap">
|
||||
<Run
|
||||
Text="Click to fall back to ToolTipText (sets TrayToolTip to null):" />
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,10,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="Auto"
|
||||
Height="Auto"
|
||||
FontWeight="Bold"
|
||||
TextDecorations="Underline"
|
||||
TextWrapping="Wrap">
|
||||
<Run
|
||||
Text="ToolTips and ToolTipText" />
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
<Grid
|
||||
HorizontalAlignment="Left"
|
||||
Margin="509.567,114.5,0,0"
|
||||
Width="405.32"
|
||||
x:Name="ContextMenus"
|
||||
Height="255.88"
|
||||
VerticalAlignment="Top">
|
||||
<Border
|
||||
BorderBrush="#FF000000"
|
||||
BorderThickness="2,2,2,2" />
|
||||
<ListBox
|
||||
Margin="10,0,95,10"
|
||||
IsSynchronizedWithCurrentItem="False"
|
||||
x:Name="lstMenuTrigger"
|
||||
ItemsSource="{Binding Mode=OneWay, Source={StaticResource ActivationModes}}"
|
||||
Height="124"
|
||||
VerticalAlignment="Bottom"
|
||||
SelectedIndex="1" />
|
||||
<TextBlock
|
||||
Margin="10,97,48,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="22"
|
||||
TextWrapping="Wrap">
|
||||
<Run
|
||||
Text="Mouse events that open the context menu:" />
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
Margin="10,30,10,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="57"
|
||||
TextWrapping="Wrap">
|
||||
<Run
|
||||
Text="Assign a custon context menu through the " />
|
||||
<Run
|
||||
FontStyle="Italic"
|
||||
FontWeight="Bold"
|
||||
Text="ContextMenu " />
|
||||
<Run
|
||||
Text="property of the " />
|
||||
<Run
|
||||
Text="Notify" />
|
||||
<Run
|
||||
Text="Icon. The " />
|
||||
<Run
|
||||
FontStyle="Italic"
|
||||
FontWeight="Bold"
|
||||
Text="MenuActivation " />
|
||||
<Run
|
||||
Text="property determines what mouse events open the context menu." />
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
Margin="10,10,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="Auto"
|
||||
TextWrapping="Wrap"
|
||||
Width="Auto"
|
||||
HorizontalAlignment="Left"
|
||||
FontWeight="Bold"
|
||||
TextDecorations="Underline">
|
||||
<Run
|
||||
Text="Context Menu" />
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
<TextBlock
|
||||
Margin="10,10,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="Auto"
|
||||
TextWrapping="Wrap"
|
||||
FontWeight="Bold"
|
||||
FontSize="16"
|
||||
HorizontalAlignment="Left">
|
||||
<Run
|
||||
Text="WPF NotifyIcon" />
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
Margin="12,57.62,15.5,0"
|
||||
VerticalAlignment="Top"
|
||||
FontSize="14"
|
||||
FontStyle="Italic"
|
||||
Foreground="#FF303030"
|
||||
TextWrapping="Wrap"
|
||||
HorizontalAlignment="Stretch">
|
||||
<Run
|
||||
Text="This " />
|
||||
<Run
|
||||
Text="is a showcase of the different features of the WPF NotifyIcon. Have a look at the used controls and styles in order to see how binding can be supported. For a real-life " />
|
||||
<Run
|
||||
Text="example" />
|
||||
<Run
|
||||
Text=", " />
|
||||
<Run
|
||||
Language="de-ch"
|
||||
Text="check out " />
|
||||
<Hyperlink
|
||||
NavigateUri="http://www.hardcodet.net/netdrives/">
|
||||
<Run
|
||||
Text="NetDrives" />
|
||||
</Hyperlink>
|
||||
</TextBlock>
|
||||
<Grid
|
||||
Margin="509.567,380.38,0,0"
|
||||
x:Name="CustomBalloons"
|
||||
Height="188.2"
|
||||
VerticalAlignment="Top"
|
||||
Width="405.32"
|
||||
HorizontalAlignment="Left">
|
||||
<Border
|
||||
HorizontalAlignment="Stretch"
|
||||
Width="Auto"
|
||||
BorderThickness="2,2,2,2"
|
||||
BorderBrush="#FF000000" />
|
||||
<Button
|
||||
Content="Show"
|
||||
x:Name="showCustomBalloon"
|
||||
Click="showCustomBalloon_Click"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,91.377,10"
|
||||
Width="71.623"
|
||||
Height="23"
|
||||
VerticalAlignment="Bottom" />
|
||||
<TextBox
|
||||
VerticalAlignment="Bottom"
|
||||
Height="23"
|
||||
Text="WPF Balloon"
|
||||
TextWrapping="Wrap"
|
||||
Margin="10,0,173,10"
|
||||
x:Name="customBalloonTitle" />
|
||||
<TextBlock
|
||||
Margin="10,35,24.377,0"
|
||||
VerticalAlignment="Top"
|
||||
TextWrapping="Wrap"
|
||||
Height="119.68">
|
||||
<Run
|
||||
Text="Custom " />
|
||||
<Run
|
||||
Text="Balloons are much " />
|
||||
<Run
|
||||
Text="ore flexible then standard balloons " />
|
||||
<Run
|
||||
Text="tips " />
|
||||
<Run
|
||||
Text="when it comes to styling." />
|
||||
<Run
|
||||
Text=" You can display arbitrary UI Elements (e.g. User Controls) as custom balloons." />
|
||||
<LineBreak />
|
||||
<Run
|
||||
Text="Apart from the richer UI, custom balloons also provide a" />
|
||||
<Run
|
||||
Text="ttached properties and events that can be used to control behavior." />
|
||||
<Run
|
||||
Text=" Custom balloons also work if the NotifyIcon is not visible." />
|
||||
<LineBreak />
|
||||
<Run
|
||||
Text="(Hint: Hover over the " />
|
||||
<Run
|
||||
Text="balloon " />
|
||||
<Run
|
||||
Text="to suspend the fade-out.)" />
|
||||
</TextBlock>
|
||||
<Button
|
||||
Content="Close"
|
||||
x:Name="hideCustomBalloon"
|
||||
Click="hideCustomBalloon_Click"
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,0,9.754,10.52"
|
||||
Width="71.623"
|
||||
Height="23"
|
||||
VerticalAlignment="Bottom" />
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,10,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="Auto"
|
||||
Height="Auto"
|
||||
FontWeight="Bold"
|
||||
TextDecorations="Underline"
|
||||
TextWrapping="Wrap">
|
||||
<Run
|
||||
Text="Custom Balloons" />
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
<Grid
|
||||
Margin="10,114.5,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="147.351"
|
||||
x:Name="Common"
|
||||
Width="471.5"
|
||||
HorizontalAlignment="Left">
|
||||
<Border
|
||||
BorderThickness="2,2,2,2"
|
||||
BorderBrush="#FF000000"
|
||||
d:IsLocked="True" />
|
||||
<CheckBox
|
||||
Margin="10,35.96,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Content="NotifyIcon Visible"
|
||||
x:Name="iconVisibility"
|
||||
IsChecked="True"
|
||||
HorizontalAlignment="Left"
|
||||
Width="155.42"
|
||||
d:LayoutOverrides="Height" />
|
||||
<ListBox
|
||||
Margin="10,77.38,0,0"
|
||||
IsSynchronizedWithCurrentItem="True"
|
||||
x:Name="iconList"
|
||||
SelectedIndex="0"
|
||||
Width="123"
|
||||
HorizontalAlignment="Left"
|
||||
Height="59.971"
|
||||
VerticalAlignment="Top" ScrollViewer.VerticalScrollBarVisibility="Auto">
|
||||
<Image
|
||||
Width="16"
|
||||
Margin="0,4,0,0"
|
||||
Height="16"
|
||||
Source="/Icons/Inactive.ico" />
|
||||
<Image
|
||||
Width="16"
|
||||
Margin="0,4,0,0"
|
||||
Height="16"
|
||||
Source="/Icons/Error.ico" />
|
||||
|
||||
</ListBox>
|
||||
<TextBlock
|
||||
Margin="10,55.38,0,61"
|
||||
Width="Auto"
|
||||
TextWrapping="Wrap"
|
||||
d:LayoutOverrides="Width"
|
||||
HorizontalAlignment="Left">
|
||||
<Run
|
||||
Text="Select an image to switch icons:" />
|
||||
</TextBlock>
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,10,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="Auto"
|
||||
Height="Auto"
|
||||
FontWeight="Bold"
|
||||
TextDecorations="Underline"
|
||||
TextWrapping="Wrap">
|
||||
<Run
|
||||
Text="Icon / Visibility" />
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,92 @@
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Navigation;
|
||||
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.
|
||||
/// </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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +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">
|
||||
|
||||
<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>
|
||||
@@ -0,0 +1,27 @@
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Samples
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for WelcomeBalloon.xaml
|
||||
/// </summary>
|
||||
public partial class WelcomeBalloon : UserControl
|
||||
{
|
||||
public WelcomeBalloon()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user