mirror of
https://github.com/ckaczor/wpf-notifyicon.git
synced 2026-01-14 01:25:45 -05:00
WPF NotifyIcon
-------------- CHG Generally improved sample project - added more bindings, welcome balloon, changed layout. CHG Changed namespace in sample project. Preparing tutorials. git-svn-id: https://svn.evolvesoftware.ch/repos/evolve.net/WPF/NotifyIcon@101 9f600761-6f11-4665-b6dc-0185e9171623
This commit is contained in:
20
Source/Changelog.txt
Normal file
20
Source/Changelog.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
hardcodet.net NotifyIcon for WPF - Changelog
|
||||
Copyright (c) 2009 Philipp Sumi
|
||||
Contact and Information: http://www.hardcodet.net
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
1.0.1
|
||||
*****
|
||||
CHG DataContext is also assigned to ContextMenu, and properly coerced for
|
||||
ToolTips and Popups. Also checks whether target item has a binding
|
||||
on the DataContext (does not just override if DataContext is null).
|
||||
|
||||
|
||||
|
||||
----------------------------------------------------------------------------
|
||||
|
||||
1.0.0
|
||||
*****
|
||||
ADD Initial release.
|
||||
@@ -5,6 +5,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NotifyIconWpf", "NotifyIcon
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample Project", "Sample Project\Sample Project.csproj", "{71C74F29-F1C2-49C5-969F-C25AC4CDFCCC}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C37AE34D-A8C4-4AEC-995C-3C763300934E}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
Changelog.txt = Changelog.txt
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<Application x:Class="Sample_Project.App"
|
||||
<Application x:Class="Samples.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
StartupUri="Window1.xaml">
|
||||
|
||||
@@ -5,7 +5,7 @@ using System.Data;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
|
||||
namespace Sample_Project
|
||||
namespace Samples
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for App.xaml
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Markup;
|
||||
|
||||
namespace Sample_Project.Commands
|
||||
namespace Samples.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// Basic implementation of the <see cref="ICommand"/>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Sample_Project.Commands
|
||||
namespace Samples.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// Hides the main window.
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Sample_Project.Commands
|
||||
namespace Samples.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// Shows the main window.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<UserControl
|
||||
x:Class="Sample_Project.FancyBalloon"
|
||||
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"
|
||||
|
||||
@@ -15,7 +15,7 @@ using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
|
||||
namespace Sample_Project
|
||||
namespace Samples
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for FancyBalloon.xaml
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<UserControl
|
||||
x:Class="Sample_Project.FancyPopup"
|
||||
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"
|
||||
@@ -108,6 +108,8 @@
|
||||
<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>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Sample_Project
|
||||
namespace Samples
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for FancyPopup.xaml
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
mc:Ignorable="d"
|
||||
x:Class="Sample_Project.FancyToolTip"
|
||||
x:Class="Samples.FancyToolTip"
|
||||
x:Name="me"
|
||||
Width="285"
|
||||
Height="136">
|
||||
@@ -109,6 +109,6 @@
|
||||
Foreground="#FF141414"
|
||||
TextWrapping="Wrap"
|
||||
Margin="82,42,20,44.96"
|
||||
x:Name="txtToolTipDetail_Copy" ><Run Text="Data binding is simple: this user control automatically derived the DataContext of the TaskbarIcon." Language="de-ch"/></TextBlock>
|
||||
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>
|
||||
@@ -12,7 +12,7 @@ using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
|
||||
namespace Sample_Project
|
||||
namespace Samples
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for FancyToolTip.xaml
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Sample_Project.Properties {
|
||||
namespace Samples.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Sample_Project.Properties {
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Sample_Project.Properties.Resources", typeof(Resources).Assembly);
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Samples.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
|
||||
@@ -8,23 +8,19 @@
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Sample_Project.Properties
|
||||
{
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
return defaultInstance;
|
||||
}
|
||||
namespace Samples.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<ProjectGuid>{71C74F29-F1C2-49C5-969F-C25AC4CDFCCC}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>Sample_Project</RootNamespace>
|
||||
<RootNamespace>Samples</RootNamespace>
|
||||
<AssemblyName>Sample Project</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
@@ -88,6 +88,18 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Tutorials\01 - Declaration\Window1.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Tutorials\02 - ToolTips\SimpleUserControl.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="WelcomeBalloon.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Window1.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
@@ -124,6 +136,15 @@
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Tutorials\01 - Declaration\Window1.xaml.cs">
|
||||
<DependentUpon>Window1.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Tutorials\02 - ToolTips\SimpleUserControl.xaml.cs">
|
||||
<DependentUpon>SimpleUserControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WelcomeBalloon.xaml.cs">
|
||||
<DependentUpon>WelcomeBalloon.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
@@ -156,9 +177,6 @@
|
||||
<ItemGroup>
|
||||
<Resource Include="Images\Close.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Samples\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<ResourceDictionary
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:Commands="clr-namespace:Sample_Project.Commands"
|
||||
xmlns:tb="clr-namespace:Hardcodet.Wpf.TaskbarNotification;assembly=Hardcodet.Wpf.TaskbarNotification"
|
||||
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"/>
|
||||
@@ -15,20 +15,33 @@
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type ContextMenu}">
|
||||
<Border Background="{DynamicResource MenuBackground}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
|
||||
<ScrollViewer Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}" Uid="ScrollViewer_9" CanContentScroll="True">
|
||||
<ItemsPresenter Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" KeyboardNavigation.DirectionalNavigation="Cycle"/>
|
||||
</ScrollViewer>
|
||||
</Border>
|
||||
<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 taskbar context menu - the first row is a dummy to show of simple data binding -->
|
||||
<ContextMenu
|
||||
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 Main Window"
|
||||
Command="{Commands:ShowMainWindowCommand}">
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<Window
|
||||
x:Class="Samples.Tutorials.SimpleDirectDeclaration"
|
||||
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
|
||||
namespace declaration (see above on line 5) and a single line -->
|
||||
<tb:TaskbarIcon
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="hello world" />
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace Samples.Tutorials
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for SimpleDirectDeclaration.xaml
|
||||
/// </summary>
|
||||
public partial class SimpleDirectDeclaration : Window
|
||||
{
|
||||
public SimpleDirectDeclaration()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<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>
|
||||
@@ -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.Tutorials
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for SimpleUserControl.xaml
|
||||
/// </summary>
|
||||
public partial class SimpleUserControl : UserControl
|
||||
{
|
||||
public SimpleUserControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
93
Source/Sample Project/WelcomeBalloon.xaml
Normal file
93
Source/Sample Project/WelcomeBalloon.xaml
Normal file
@@ -0,0 +1,93 @@
|
||||
<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>
|
||||
27
Source/Sample Project/WelcomeBalloon.xaml.cs
Normal file
27
Source/Sample Project/WelcomeBalloon.xaml.cs
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,20 @@
|
||||
<Window
|
||||
x:Class="Sample_Project.Window1"
|
||||
x:Class="Samples.Window1"
|
||||
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 Sample"
|
||||
Height="833"
|
||||
Width="769"
|
||||
Height="938"
|
||||
Width="880"
|
||||
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:Sample_Project"
|
||||
xmlns:Commands="clr-namespace:Sample_Project.Commands" MinWidth="750" MinHeight="800" ResizeMode="NoResize">
|
||||
xmlns:local="clr-namespace:Samples"
|
||||
xmlns:Commands="clr-namespace:Samples.Commands"
|
||||
MinWidth="750"
|
||||
MinHeight="800"
|
||||
ResizeMode="NoResize">
|
||||
<Window.Resources>
|
||||
|
||||
<BooleanToVisibilityConverter
|
||||
@@ -43,20 +46,21 @@
|
||||
<Window.Triggers>
|
||||
<EventTrigger
|
||||
RoutedEvent="tb:TaskbarIcon.TrayToolTipOpen"
|
||||
SourceName="tb" />
|
||||
SourceName="tb" />
|
||||
</Window.Triggers>
|
||||
|
||||
<Grid>
|
||||
<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 EVEN USE IT IF THERE IS NO WINDOW
|
||||
IT IN A RESOURCE DICTIONARY SO YOU CAN ALSO USE IT IF THERE IS NO WINDOW
|
||||
OPEN.
|
||||
-->
|
||||
|
||||
|
||||
<tb:TaskbarIcon
|
||||
x:Name="tb"
|
||||
VerticalAlignment="Top"
|
||||
@@ -66,8 +70,7 @@
|
||||
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:ShowMainWindowCommand}"
|
||||
>
|
||||
DoubleClickCommand="{Commands:ShowMainWindowCommand}">
|
||||
|
||||
<tb:TaskbarIcon.TrayPopup>
|
||||
<!-- the control will be put into a popup with an explicit DataContext -->
|
||||
@@ -85,57 +88,19 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- EVERYTHING BELOW IS JUST PLUMBING FOR THE SAMPLE -->
|
||||
<!-- ************************************************************************************* -->
|
||||
<!-- ************************************************************************************* -->
|
||||
<!-- EVERYTHING BELOW IS JUST PLUMBING FOR THE SAMPLE -->
|
||||
|
||||
|
||||
<CheckBox
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,38.62,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="155.42"
|
||||
Content="NotifyIcon Visible"
|
||||
x:Name="iconVisibility"
|
||||
IsChecked="True" />
|
||||
<ListBox
|
||||
HorizontalAlignment="Left"
|
||||
Margin="12,86.58,0,0"
|
||||
Width="123"
|
||||
IsSynchronizedWithCurrentItem="True"
|
||||
Height="51"
|
||||
VerticalAlignment="Top"
|
||||
x:Name="iconList"
|
||||
SelectedIndex="0">
|
||||
<Image
|
||||
Width="16"
|
||||
Margin="0,4,0,0"
|
||||
Height="16"
|
||||
Source="Icons\Inactive.ico" />
|
||||
<Image
|
||||
Width="16"
|
||||
Margin="0,4,0,0"
|
||||
Height="16"
|
||||
Source="Icons\Error.ico" />
|
||||
|
||||
</ListBox>
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
Margin="12,64.58,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="Auto"
|
||||
Height="22"
|
||||
TextWrapping="Wrap"><Run
|
||||
Text="Taskbar Icon:"
|
||||
Language="de-ch" /></TextBlock>
|
||||
<Grid
|
||||
Margin="0,544.58,10,0"
|
||||
Margin="486.5,617.58,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="210"
|
||||
Width="358"
|
||||
HorizontalAlignment="Right"
|
||||
x:Name="Balloons">
|
||||
Height="248"
|
||||
x:Name="Balloons"
|
||||
Width="372"
|
||||
HorizontalAlignment="Left">
|
||||
<Border
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
@@ -148,8 +113,13 @@
|
||||
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."/>
|
||||
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"
|
||||
@@ -166,15 +136,16 @@
|
||||
Width="85"
|
||||
Height="23"
|
||||
TextWrapping="Wrap"><Run
|
||||
Text="Balloon Title"
|
||||
Language="de-ch" /></TextBlock>
|
||||
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"
|
||||
Language="de-ch" /></TextBlock>
|
||||
Width="85"
|
||||
Height="23"
|
||||
VerticalAlignment="Bottom"
|
||||
d:LayoutOverrides="VerticalAlignment"><Run
|
||||
Text="Balloon Text" /></TextBlock>
|
||||
<RadioButton
|
||||
Margin="14,0,0,32"
|
||||
VerticalAlignment="Bottom"
|
||||
@@ -201,12 +172,14 @@
|
||||
Height="23"
|
||||
Click="showBalloonTip_Click" />
|
||||
<TextBlock
|
||||
Margin="14,10,17,0"
|
||||
Margin="10,35.96,21,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="33"
|
||||
Height="56.04"
|
||||
TextWrapping="Wrap"><Run
|
||||
Text="Standard balloon tips. You can use custom icons under all OS versions."
|
||||
Language="de-ch" /></TextBlock>
|
||||
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"
|
||||
@@ -216,13 +189,23 @@
|
||||
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,512.58,0,0"
|
||||
Margin="12,582.88,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="307"
|
||||
Height="242"
|
||||
Width="445.5"
|
||||
Height="282.7"
|
||||
x:Name="Popups">
|
||||
<Border
|
||||
HorizontalAlignment="Stretch"
|
||||
@@ -233,34 +216,58 @@
|
||||
IsSynchronizedWithCurrentItem="False"
|
||||
x:Name="lstPopupTrigger"
|
||||
ItemsSource="{Binding Mode=OneWay, Source={StaticResource ActivationModes}}"
|
||||
Margin="14,115,97,10"
|
||||
SelectedIndex="0" />
|
||||
Margin="10,0,190,10"
|
||||
SelectedIndex="0"
|
||||
Height="117"
|
||||
VerticalAlignment="Bottom" />
|
||||
<TextBlock
|
||||
Margin="14,10,10,0"
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Top"
|
||||
Height="105"><Run
|
||||
Text="If the user clicks on the Taskbar Icon, a popup can be opened and displayed. Unlike custom ToolTips, this works under Windows xp as well. In case left-clicks are used, popups are displayed with a delay to ensure the user does not double-click. Trigger is determined by the "
|
||||
Language="de-ch" /><Run
|
||||
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 "
|
||||
Language="de-ch" /><Run
|
||||
Text="property."
|
||||
Language="de-ch" /></TextBlock>
|
||||
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="0,156.38,10,0"
|
||||
Width="358"
|
||||
HorizontalAlignment="Right"
|
||||
x:Name="ToolTips" Height="233" VerticalAlignment="Top" d:LayoutOverrides="VerticalAlignment">
|
||||
Margin="10,317,0,0"
|
||||
x:Name="ToolTips"
|
||||
Height="255.88"
|
||||
VerticalAlignment="Top"
|
||||
d:LayoutOverrides="HorizontalAlignment, VerticalAlignment"
|
||||
Width="447.5"
|
||||
HorizontalAlignment="Left">
|
||||
<Border
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
BorderBrush="#FF000000"
|
||||
BorderThickness="2,2,2,2" />
|
||||
<TextBox
|
||||
Margin="10,0,25,70"
|
||||
Margin="10,0,25,60"
|
||||
x:Name="txtToolTipText"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="23"
|
||||
@@ -268,36 +275,39 @@
|
||||
Foreground="#FFFF0000" />
|
||||
<TextBlock
|
||||
Margin="10,0,25,93"
|
||||
TextWrapping="Wrap" Height="21" VerticalAlignment="Bottom"><Run
|
||||
Text="ToolTipText:"
|
||||
Language="de-ch" /></TextBlock>
|
||||
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,10,10,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="112"
|
||||
Margin="10,29.88,10,114"
|
||||
TextWrapping="Wrap"><Run
|
||||
Text="If the user moves the mouse over the Taskbar Icon, a tooltip can be displayed. Starting from Windows Vista, we have convenient events to display and hide tooltips. If we can, the "
|
||||
Language="de-ch" /><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 "
|
||||
Language="de-ch" /><Run
|
||||
Text="control is being displayed."
|
||||
Language="de-ch" /><LineBreak /><Run
|
||||
Text="If "
|
||||
Language="de-ch" /><Run
|
||||
Text="TrayToolTip " /><Run
|
||||
Text="property." /><LineBreak /><Run
|
||||
Text="" /><Run
|
||||
Text="If " /><Run
|
||||
FontStyle="Italic"
|
||||
FontWeight="Bold"
|
||||
Text="TrayToolTip "
|
||||
Language="de-ch" /><Run
|
||||
Text="is not set or the app runs under an older OS (e.g. xp), the control falls back to the "
|
||||
Language="de-ch" /><Run
|
||||
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 "
|
||||
Language="de-ch" /><Run
|
||||
Text="property."
|
||||
Language="de-ch" /></TextBlock>
|
||||
Text="ToolTipText " /><Run
|
||||
Text="property." /></TextBlock>
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,0,0,10"
|
||||
@@ -312,14 +322,26 @@
|
||||
VerticalAlignment="Bottom"
|
||||
Height="16"
|
||||
TextWrapping="Wrap"><Run
|
||||
Text="Click to fall back to ToolTipText (sets TrayToolTip to null):"
|
||||
Language="de-ch" /></TextBlock>
|
||||
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="12,231.58,0,0"
|
||||
Width="307"
|
||||
x:Name="ContextMenus" Height="271" VerticalAlignment="Top">
|
||||
Margin="488,153.5,0,0"
|
||||
Width="370.5"
|
||||
x:Name="ContextMenus"
|
||||
Height="255.88"
|
||||
VerticalAlignment="Top"
|
||||
d:LayoutOverrides="VerticalAlignment">
|
||||
<Border
|
||||
BorderBrush="#FF000000"
|
||||
BorderThickness="2,2,2,2" />
|
||||
@@ -332,31 +354,37 @@
|
||||
VerticalAlignment="Bottom"
|
||||
SelectedIndex="1" />
|
||||
<TextBlock
|
||||
Margin="10,108,48,0"
|
||||
Margin="10,97,48,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="22"
|
||||
TextWrapping="Wrap"><Run
|
||||
Text="Mouse events that open the context menu:"
|
||||
Language="de-ch" /></TextBlock>
|
||||
Text="Mouse events that open the context menu:" /></TextBlock>
|
||||
<TextBlock
|
||||
Margin="10,10,10,0"
|
||||
Margin="10,30,10,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="78"
|
||||
Height="57"
|
||||
TextWrapping="Wrap"><Run
|
||||
Text="Assign a custon context menu through the "
|
||||
Language="de-ch" /><Run
|
||||
Text="Assign a custon context menu through the " /><Run
|
||||
FontStyle="Italic"
|
||||
FontWeight="Bold"
|
||||
Text="ContextMenu "
|
||||
Language="de-ch" /><Run
|
||||
Text="property of the TaskbarIcon. The "
|
||||
Language="de-ch" /><Run
|
||||
Text="ContextMenu " /><Run
|
||||
Text="property of the " /><Run
|
||||
Text="Notify" /><Run
|
||||
Text="Icon. The " /><Run
|
||||
FontStyle="Italic"
|
||||
FontWeight="Bold"
|
||||
Text="MenuActivation "
|
||||
Language="de-ch" /><Run
|
||||
Text="property determines what mouse events open the context menu."
|
||||
Language="de-ch" /></TextBlock>
|
||||
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"
|
||||
@@ -364,28 +392,163 @@
|
||||
Height="Auto"
|
||||
TextWrapping="Wrap"
|
||||
FontWeight="Bold"
|
||||
FontSize="14" Width="309" HorizontalAlignment="Left"><Run
|
||||
Text="WPF NotifyIcon - RC 1.0"
|
||||
Language="de-ch" /></TextBlock>
|
||||
FontSize="14"
|
||||
Width="309"
|
||||
HorizontalAlignment="Left"><Run
|
||||
Text="WPF NotifyIcon 1.0.1" /></TextBlock>
|
||||
<TextBlock
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,10,10,0"
|
||||
Margin="12,38.62,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="358"
|
||||
Height="146.38"
|
||||
Height="104.88"
|
||||
FontSize="14"
|
||||
FontStyle="Italic"
|
||||
Foreground="#FF303030"
|
||||
TextWrapping="Wrap"><Run Text="This is my first shot at this control and a think a few additions might make sense." Language="de-ch"/><LineBreak/><Run Text="Play around and feel free to commit critical feedback - it's appreciated :)" Language="de-ch"/><LineBreak/><Run Text="" Language="de-ch"/><LineBreak/><Run Foreground="#FF067EBD" Text="Feedback and Updates:" Language="de-ch"/><LineBreak/><Run Foreground="#FF067EBD" Text="http://www.hardcodet.net " Language="de-ch"/><Run FontSize="10" Foreground="#FF067EBD" Text="(watch the spelling" Language="de-ch"/><Run Foreground="#FF067EBD" Text=")" Language="de-ch"/></TextBlock>
|
||||
<TextBlock Margin="12,0,10,10" VerticalAlignment="Bottom" Height="22.42" TextWrapping="Wrap" FontWeight="Bold" Foreground="#FFFFA051"><Run Text="Copyright (c) 2009 Philipp Sumi. This is prerelease software, realeased under the CodeProject Open License (CPOL)" Language="de-ch"/></TextBlock>
|
||||
<Grid HorizontalAlignment="Right" Margin="0,399.38,10,272.42" Width="358" x:Name="CustomBalloons">
|
||||
<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,10,24.377,0" VerticalAlignment="Top" TextWrapping="Wrap" Height="66.68"><Run Text="Custom Balloon Tips are more flexible then standard tips when it comes to styling and they provide attached properties and events that can be used to control behavior. Hover over the tooltip to suspend the fade-out." Language="de-ch"/></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" />
|
||||
TextWrapping="Wrap"
|
||||
HorizontalAlignment="Left"
|
||||
Width="846.5"><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=", have a look at" /><Run
|
||||
Text=" " /><Hyperlink
|
||||
NavigateUri="http://www.hardcodet.net/netdrives/"><Run
|
||||
Text="NetDrives" /></Hyperlink><LineBreak /><Run
|
||||
Text="" /><LineBreak /><Run
|
||||
Foreground="#FF067EBD"
|
||||
Text="Project Page:" /><LineBreak /><Hyperlink
|
||||
NavigateUri="http://www.hardcodet.net/wpf-notifyicon/"><Run
|
||||
Text="http://www.hardcodet.net/wpf-notifyicon/" /></Hyperlink></TextBlock>
|
||||
<TextBlock
|
||||
Margin="12,0,29.5,10"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="22.42"
|
||||
TextWrapping="Wrap"
|
||||
FontWeight="Bold"
|
||||
Foreground="#FFFFA051"><Run Text="The 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>
|
||||
<Grid
|
||||
Margin="486.5,419.38,0,0"
|
||||
x:Name="CustomBalloons"
|
||||
Height="188.2"
|
||||
VerticalAlignment="Top"
|
||||
Width="372"
|
||||
HorizontalAlignment="Left"
|
||||
d:LayoutOverrides="VerticalAlignment">
|
||||
<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,153.5,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="138.38"
|
||||
x:Name="Common"
|
||||
Width="447.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="51"
|
||||
VerticalAlignment="Top">
|
||||
<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>
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
using System.Windows;
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Navigation;
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
|
||||
namespace Sample_Project
|
||||
namespace Samples
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Window1.xaml
|
||||
@@ -16,8 +19,9 @@ namespace Sample_Project
|
||||
|
||||
Loaded += delegate
|
||||
{
|
||||
//show balloon at startup, pointing to the icon
|
||||
showBalloonTip_Click(null, null);
|
||||
//show balloon at startup
|
||||
var balloon = new WelcomeBalloon();
|
||||
tb.ShowCustomBalloon(balloon, PopupAnimation.Slide, 12000);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -71,5 +75,12 @@ namespace Sample_Project
|
||||
{
|
||||
tb.CloseBalloon();
|
||||
}
|
||||
|
||||
|
||||
private void OnNavigationRequest(object sender, RequestNavigateEventArgs e)
|
||||
{
|
||||
Process.Start(e.Uri.ToString());
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user