mirror of
https://github.com/ckaczor/wpf-notifyicon.git
synced 2026-01-16 01:35:38 -05:00
WPF NotifyIcon
-------------- FIX Removed debug output in WindowMessageSink. CHG Major rework on sample project. git-svn-id: https://svn.evolvesoftware.ch/repos/evolve.net/WPF/NotifyIcon@104 9f600761-6f11-4665-b6dc-0185e9171623
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
<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">
|
||||
StartupUri="Main.xaml">
|
||||
<Application.Resources>
|
||||
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="TaskbarIconResources.xaml"/>
|
||||
<ResourceDictionary Source="Showcase/NotifyIconResources.xaml"/>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
|
||||
namespace Samples
|
||||
{
|
||||
@@ -12,5 +13,6 @@ namespace Samples
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Markup;
|
||||
|
||||
@@ -58,7 +60,18 @@ namespace Samples.Commands
|
||||
/// </param>
|
||||
public virtual bool CanExecute(object parameter)
|
||||
{
|
||||
return true;
|
||||
return IsDesignMode ? false : true;
|
||||
}
|
||||
|
||||
|
||||
public static bool IsDesignMode
|
||||
{
|
||||
get
|
||||
{
|
||||
return (bool)
|
||||
DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty, typeof(FrameworkElement))
|
||||
.Metadata.DefaultValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Samples.Commands
|
||||
|
||||
public override bool CanExecute(object parameter)
|
||||
{
|
||||
return Application.Current.MainWindow.IsVisible;
|
||||
return !IsDesignMode && Application.Current.MainWindow.IsVisible;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Samples.Commands
|
||||
|
||||
public override bool CanExecute(object parameter)
|
||||
{
|
||||
return Application.Current.MainWindow.IsVisible == false;
|
||||
return !IsDesignMode && Application.Current.MainWindow.IsVisible == false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
BIN
Source/Sample Project/Images/Preferences.png
Normal file
BIN
Source/Sample Project/Images/Preferences.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.6 KiB |
191
Source/Sample Project/Main.xaml
Normal file
191
Source/Sample Project/Main.xaml
Normal file
@@ -0,0 +1,191 @@
|
||||
<Window
|
||||
x:Class="Samples.Main"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Title="Main"
|
||||
Height="595"
|
||||
Width="596"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d">
|
||||
<Grid
|
||||
Hyperlink.RequestNavigate="OnNavigationRequest">
|
||||
<Grid.Background>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0.673,0.95"
|
||||
StartPoint="0.274,0.137">
|
||||
<GradientStop
|
||||
Color="#FFFFFFFF"
|
||||
Offset="0" />
|
||||
<GradientStop
|
||||
Color="#FFB4C6D8"
|
||||
Offset="0.982" />
|
||||
</LinearGradientBrush>
|
||||
</Grid.Background>
|
||||
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,10,0,0"
|
||||
VerticalAlignment="Top"
|
||||
FontSize="14"
|
||||
FontStyle="Italic"
|
||||
FontWeight="Bold"
|
||||
TextWrapping="Wrap"><Run
|
||||
Text="WPF NotifyIcon 1.0.1 - Samples"
|
||||
/></TextBlock>
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,133,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="164"
|
||||
Height="27"
|
||||
Content="NotifyIcon Declaration"
|
||||
x:Name="btnDeclaration"
|
||||
Click="btnDeclaration_Click" />
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,50,0,0"
|
||||
VerticalAlignment="Top"
|
||||
FontWeight="Bold"
|
||||
TextWrapping="Wrap"><Run
|
||||
Text="Tutorials:"
|
||||
/></TextBlock>
|
||||
<TextBlock
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,75.96,0,0"
|
||||
VerticalAlignment="Top"
|
||||
TextWrapping="Wrap"
|
||||
Width="224.31"
|
||||
Height="47.04"
|
||||
d:LayoutOverrides="HorizontalAlignment"><Run
|
||||
Text="Tutorials follow the contents of the CodeProject article. Check the "Tutorials" folder for the source code."
|
||||
/></TextBlock>
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,170,0,0"
|
||||
Width="164"
|
||||
Content="ToolTips - Inline Declaration"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
x:Name="btnInlineToolTip"
|
||||
Click="btnInlineToolTip_Click" />
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,249,0,0"
|
||||
Width="164"
|
||||
Content="Popups"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
x:Name="btnPopups"
|
||||
Click="btnPopups_Click" />
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,286,0,0"
|
||||
Width="164"
|
||||
Content="Context Menus"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
x:Name="btnContextMenus"
|
||||
Click="btnContextMenus_Click" />
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,323,0,0"
|
||||
Width="164"
|
||||
Content="Balloon Tips"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
x:Name="btnBalloons"
|
||||
Click="btnBalloons_Click" />
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,360,0,0"
|
||||
Width="164"
|
||||
Content="Commands"
|
||||
VerticalAlignment="Top"
|
||||
Height="27"
|
||||
x:Name="btnCommands"
|
||||
Click="btnCommands_Click" />
|
||||
<Button
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,207,0,0"
|
||||
Width="164"
|
||||
Content="ToolTip User Control"
|
||||
Height="27"
|
||||
VerticalAlignment="Top"
|
||||
x:Name="btnToolTipControl"
|
||||
Click="btnToolTipControl_Click" />
|
||||
<TextBlock
|
||||
Margin="0,50,166.627,0"
|
||||
VerticalAlignment="Top"
|
||||
FontWeight="Bold"
|
||||
TextWrapping="Wrap"
|
||||
HorizontalAlignment="Right"
|
||||
d:LayoutOverrides="HorizontalAlignment, Width"><Run
|
||||
Text="Showcase Sample:"
|
||||
/></TextBlock>
|
||||
<TextBlock
|
||||
Margin="0,75.96,90.247,0"
|
||||
VerticalAlignment="Top"
|
||||
TextWrapping="Wrap"
|
||||
Height="47.04"
|
||||
HorizontalAlignment="Right"
|
||||
Width="179.31"><Run
|
||||
Text="An interactive sample that shows off most features on a single NotifyIcon."
|
||||
/></TextBlock>
|
||||
<Button
|
||||
HorizontalAlignment="Right"
|
||||
Margin="0,133,105.557,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="164"
|
||||
Height="27"
|
||||
Content="Open Sample Window"
|
||||
x:Name="btnMainSample"
|
||||
Click="btnMainSample_Click" />
|
||||
<Path
|
||||
Fill="#FFFFFFFF"
|
||||
Stretch="Fill"
|
||||
Stroke="#FF60758A"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="269,57,0,172"
|
||||
Width="1"
|
||||
Data="M269,57 L269,390.18163" />
|
||||
<TextBlock
|
||||
Margin="10,413,20,0"
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Top"
|
||||
Height="102.76"><Run
|
||||
Text="You will always find the latest news related to the component on the project page:"
|
||||
/><LineBreak />
|
||||
<Hyperlink
|
||||
NavigateUri="http://www.hardcodet.net/wpf-notifyicon">http://www.hardcodet.net/wpf-notifyicon</Hyperlink>
|
||||
<LineBreak /><Run
|
||||
Text=""
|
||||
/><LineBreak /><Run
|
||||
Text="Critical feedback is appreciated - please post bug reports, requests, questions etc. to the CodeProject forum @"
|
||||
/>
|
||||
<Hyperlink
|
||||
NavigateUri="http://www.codeproject.com/wpf-notifyicon">http://www.codeproject.com/wpf-notifyicon</Hyperlink>
|
||||
<LineBreak /><Run
|
||||
Text="And if you love it or hate it, please let me know and leave your rating - thanks!"
|
||||
/></TextBlock>
|
||||
<TextBlock
|
||||
Margin="10,0,10,10"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="22.42"
|
||||
TextWrapping="Wrap"
|
||||
FontWeight="Bold"><Run
|
||||
Text="WPF NotifyIcon is free software, released under the" /><Run
|
||||
Text=" " /><Hyperlink
|
||||
NavigateUri="http://www.codeproject.com/info/cpol10.aspx"><Run
|
||||
Text="CodeProject Open License" /></Hyperlink></TextBlock>
|
||||
<Path
|
||||
Fill="#FFFFFFFF"
|
||||
Stretch="Fill"
|
||||
Stroke="#FF60758A"
|
||||
Margin="11,0,17.926,41"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="1"
|
||||
Data="M11,517 L561.07363,517" />
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
105
Source/Sample Project/Main.xaml.cs
Normal file
105
Source/Sample Project/Main.xaml.cs
Normal file
@@ -0,0 +1,105 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
using Samples.Tutorials;
|
||||
using Samples.Tutorials.Balloons;
|
||||
using Samples.Tutorials.Commands;
|
||||
using Samples.Tutorials.ContextMenus;
|
||||
using Samples.Tutorials.Popups;
|
||||
using Samples.Tutorials.ToolTips;
|
||||
|
||||
namespace Samples
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Main.xaml
|
||||
/// </summary>
|
||||
public partial class Main : Window
|
||||
{
|
||||
public Main()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Sets <see cref="Window.WindowStartupLocation"/> and
|
||||
/// <see cref="Window.Owner"/> properties of a dialog that
|
||||
/// is about to be displayed.
|
||||
/// </summary>
|
||||
/// <param name="window">The processed window.</param>
|
||||
private void ShowDialog(Window window)
|
||||
{
|
||||
window.Owner = this;
|
||||
window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
||||
window.ShowDialog();
|
||||
}
|
||||
|
||||
private void btnDeclaration_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new SimpleWindowWithNotifyIcon());
|
||||
}
|
||||
|
||||
|
||||
private void btnInlineToolTip_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new InlineToolTipWindow());
|
||||
}
|
||||
|
||||
private void btnToolTipControl_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new UserControlToolTipWindow());
|
||||
}
|
||||
|
||||
private void btnPopups_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new InlinePopupWindow());
|
||||
}
|
||||
|
||||
private void btnContextMenus_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new InlineContextMenuWindow());
|
||||
}
|
||||
|
||||
private void btnBalloons_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new BalloonSampleWindow());
|
||||
}
|
||||
|
||||
private void btnCommands_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
ShowDialog(new CommandWindow());
|
||||
}
|
||||
|
||||
private void btnMainSample_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var sampleWindow = new ShowcaseWindow();
|
||||
|
||||
sampleWindow.Owner = this;
|
||||
sampleWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
sampleWindow.ShowDialog();
|
||||
}
|
||||
|
||||
|
||||
private void OnNavigationRequest(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
|
||||
{
|
||||
Process.Start(e.Uri.ToString());
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -62,16 +62,16 @@
|
||||
<Resource Include="Icons\Inactive.ico" />
|
||||
<Resource Include="Icons\Error.ico" />
|
||||
<Resource Include="Images\Info.png" />
|
||||
<Resource Include="Images\preferences.png" />
|
||||
<Page Include="FancyToolTip.xaml">
|
||||
<Resource Include="Images\Preferences.png" />
|
||||
<Page Include="Showcase\FancyToolTip.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="TaskbarIconResources.xaml">
|
||||
<Page Include="Showcase\NotifyIconResources.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Compile Include="FancyToolTip.xaml.cs">
|
||||
<Compile Include="Showcase\FancyToolTip.xaml.cs">
|
||||
<DependentUpon>FancyToolTip.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
@@ -80,15 +80,27 @@
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="FancyBalloon.xaml">
|
||||
<Page Include="Showcase\FancyBalloon.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="FancyPopup.xaml">
|
||||
<Page Include="Showcase\FancyPopup.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Tutorials\01 - Declaration\Window1.xaml">
|
||||
<Page Include="Main.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Tutorials\02 - ToolTips\UserControlToolTipWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Tutorials\01 - Declaration\NotifyIconResourceDictionary.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Tutorials\01 - Declaration\SimpleWindowWithNotifyIcon.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
@@ -96,11 +108,39 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="WelcomeBalloon.xaml">
|
||||
<Page Include="Tutorials\02 - ToolTips\InlineToolTipWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Window1.xaml">
|
||||
<Page Include="Tutorials\03 - Popups\InlinePopupWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Tutorials\04 - ContextMenus\InlineContextMenuWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Tutorials\06 - Commands\CommandWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Tutorials\07 - Events\EventVisualizerWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Tutorials\05 - Balloons\BalloonSampleWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Tutorials\08 - DataBinding\DataBoundToolTipWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Showcase\WelcomeBalloon.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Showcase\ShowcaseWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
@@ -108,21 +148,24 @@
|
||||
<SubType>Code</SubType>
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Window1.xaml.cs">
|
||||
<Compile Include="Showcase\ShowcaseWindow.xaml.cs">
|
||||
<SubType>Code</SubType>
|
||||
<DependentUpon>Window1.xaml</DependentUpon>
|
||||
<DependentUpon>ShowcaseWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Commands\CommandBase.cs" />
|
||||
<Compile Include="Commands\HideMainWindowCommand.cs" />
|
||||
<Compile Include="Commands\ShowMainWindowCommand.cs" />
|
||||
<Compile Include="FancyBalloon.xaml.cs">
|
||||
<Compile Include="Showcase\FancyBalloon.xaml.cs">
|
||||
<DependentUpon>FancyBalloon.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="FancyPopup.xaml.cs">
|
||||
<Compile Include="Showcase\FancyPopup.xaml.cs">
|
||||
<DependentUpon>FancyPopup.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Main.xaml.cs">
|
||||
<DependentUpon>Main.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
@@ -136,13 +179,38 @@
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Tutorials\01 - Declaration\Window1.xaml.cs">
|
||||
<DependentUpon>Window1.xaml</DependentUpon>
|
||||
<Compile Include="Tutorials\01 - Declaration\SimpleWindowWithNotifyIcon.xaml.cs">
|
||||
<DependentUpon>SimpleWindowWithNotifyIcon.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Tutorials\02 - ToolTips\SimpleUserControl.xaml.cs">
|
||||
<DependentUpon>SimpleUserControl.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="WelcomeBalloon.xaml.cs">
|
||||
<Compile Include="Tutorials\02 - ToolTips\InlineToolTipWindow.xaml.cs">
|
||||
<DependentUpon>InlineToolTipWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Tutorials\02 - ToolTips\UserControlToolTipWindow.xaml.cs">
|
||||
<DependentUpon>UserControlToolTipWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Tutorials\03 - Popups\InlinePopupWindow.xaml.cs">
|
||||
<DependentUpon>InlinePopupWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Tutorials\04 - ContextMenus\InlineContextMenuWindow.xaml.cs">
|
||||
<DependentUpon>InlineContextMenuWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Tutorials\06 - Commands\CommandWindow.xaml.cs">
|
||||
<DependentUpon>CommandWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Tutorials\06 - Commands\ShowMessageCommand.cs" />
|
||||
<Compile Include="Tutorials\07 - Events\EventVisualizerWindow.xaml.cs">
|
||||
<DependentUpon>EventVisualizerWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Tutorials\05 - Balloons\BalloonSampleWindow.xaml.cs">
|
||||
<DependentUpon>BalloonSampleWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Tutorials\08 - DataBinding\DataBoundToolTipWindow.xaml.cs">
|
||||
<DependentUpon>DataBoundToolTipWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Showcase\WelcomeBalloon.xaml.cs">
|
||||
<DependentUpon>WelcomeBalloon.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
|
||||
@@ -84,7 +84,7 @@
|
||||
HorizontalAlignment="Left"
|
||||
Margin="0,10,0,0"
|
||||
Width="72"
|
||||
Source="Images\Info.png"
|
||||
Source="/Images/Info.png"
|
||||
Stretch="Fill" Height="72" VerticalAlignment="Top" />
|
||||
<TextBlock
|
||||
Margin="72,49.2,10,0"
|
||||
@@ -112,7 +112,7 @@
|
||||
</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"/>
|
||||
<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>
|
||||
@@ -49,7 +49,7 @@
|
||||
VerticalAlignment="Top"
|
||||
Width="72"
|
||||
Height="72"
|
||||
Source="Images\preferences.png"
|
||||
Source="/Images/Preferences.png"
|
||||
Stretch="Fill" x:Name="image" RenderTransformOrigin="0.5,0.5" >
|
||||
<Image.RenderTransform>
|
||||
<TransformGroup>
|
||||
@@ -71,7 +71,7 @@
|
||||
HorizontalAlignment="Left"
|
||||
Margin="10,10,0,26"
|
||||
Width="72"
|
||||
Source="Images\Info.png"
|
||||
Source="/Images/Info.png"
|
||||
Stretch="Fill"
|
||||
VerticalAlignment="Top"
|
||||
RenderTransformOrigin="0.792,0.486" x:Name="image" Height="72" >
|
||||
@@ -1,11 +1,11 @@
|
||||
<Window
|
||||
x:Class="Samples.Window1"
|
||||
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 Sample"
|
||||
Height="938"
|
||||
Height="874"
|
||||
Width="880"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
@@ -91,11 +91,11 @@
|
||||
|
||||
<!-- ************************************************************************************* -->
|
||||
<!-- ************************************************************************************* -->
|
||||
<!-- EVERYTHING BELOW IS JUST PLUMBING FOR THE SAMPLE -->
|
||||
|
||||
|
||||
<!-- EVERYTHING BELOW IS JUST PLUMBING FOR THE SAMPLE -->
|
||||
|
||||
|
||||
<Grid
|
||||
Margin="486.5,617.58,0,0"
|
||||
Margin="486.5,578.58,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="248"
|
||||
x:Name="Balloons"
|
||||
@@ -202,7 +202,7 @@
|
||||
</Grid>
|
||||
<Grid
|
||||
HorizontalAlignment="Left"
|
||||
Margin="12,582.88,0,0"
|
||||
Margin="12,543.88,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="445.5"
|
||||
Height="282.7"
|
||||
@@ -254,7 +254,7 @@
|
||||
Text="Popup Controls" /></TextBlock>
|
||||
</Grid>
|
||||
<Grid
|
||||
Margin="10,317,0,0"
|
||||
Margin="10,278,0,0"
|
||||
x:Name="ToolTips"
|
||||
Height="255.88"
|
||||
VerticalAlignment="Top"
|
||||
@@ -336,7 +336,7 @@
|
||||
</Grid>
|
||||
<Grid
|
||||
HorizontalAlignment="Left"
|
||||
Margin="488,153.5,0,0"
|
||||
Margin="488,114.5,0,0"
|
||||
Width="370.5"
|
||||
x:Name="ContextMenus"
|
||||
Height="255.88"
|
||||
@@ -392,41 +392,27 @@
|
||||
Height="Auto"
|
||||
TextWrapping="Wrap"
|
||||
FontWeight="Bold"
|
||||
FontSize="14"
|
||||
Width="309"
|
||||
FontSize="16"
|
||||
HorizontalAlignment="Left"><Run
|
||||
Text="WPF NotifyIcon 1.0.1" /></TextBlock>
|
||||
<TextBlock
|
||||
Margin="12,38.62,0,0"
|
||||
Margin="12,57.62,15.5,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="104.88"
|
||||
FontSize="14"
|
||||
FontStyle="Italic"
|
||||
Foreground="#FF303030"
|
||||
TextWrapping="Wrap"
|
||||
HorizontalAlignment="Left"
|
||||
Width="846.5"><Run
|
||||
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=", have a look at" /><Run
|
||||
Text=" " /><Hyperlink
|
||||
Text=", " /><Run
|
||||
Language="de-ch"
|
||||
Text="check out " /><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>
|
||||
Text="NetDrives" /></Hyperlink></TextBlock>
|
||||
<Grid
|
||||
Margin="486.5,419.38,0,0"
|
||||
Margin="486.5,380.38,0,0"
|
||||
x:Name="CustomBalloons"
|
||||
Height="188.2"
|
||||
VerticalAlignment="Top"
|
||||
@@ -492,7 +478,7 @@
|
||||
Text="Custom Balloons" /></TextBlock>
|
||||
</Grid>
|
||||
<Grid
|
||||
Margin="10,153.5,0,0"
|
||||
Margin="10,114.5,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="138.38"
|
||||
x:Name="Common"
|
||||
@@ -524,12 +510,12 @@
|
||||
Width="16"
|
||||
Margin="0,4,0,0"
|
||||
Height="16"
|
||||
Source="Icons\Inactive.ico" />
|
||||
Source="/Icons/Inactive.ico" />
|
||||
<Image
|
||||
Width="16"
|
||||
Margin="0,4,0,0"
|
||||
Height="16"
|
||||
Source="Icons\Error.ico" />
|
||||
Source="/Icons/Error.ico" />
|
||||
|
||||
</ListBox>
|
||||
<TextBlock
|
||||
@@ -1,18 +1,17 @@
|
||||
using System.Diagnostics;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Navigation;
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
|
||||
namespace Samples
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Window1.xaml
|
||||
/// Interaction logic for ShowcaseWindow.xaml
|
||||
/// </summary>
|
||||
public partial class Window1 : Window
|
||||
public partial class ShowcaseWindow : Window
|
||||
{
|
||||
public Window1()
|
||||
public ShowcaseWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
@@ -82,5 +81,13 @@ namespace Samples
|
||||
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,10 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar">
|
||||
|
||||
<!-- Globally declared notify icon (ResourceDictionary is not in use, example only) -->
|
||||
<tb:TaskbarIcon x:Key="MyNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="hello world" />
|
||||
|
||||
</ResourceDictionary>
|
||||
@@ -1,5 +1,5 @@
|
||||
<Window
|
||||
x:Class="Samples.Tutorials.SimpleDirectDeclaration"
|
||||
x:Class="Samples.Tutorials.SimpleWindowWithNotifyIcon"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
@@ -10,8 +10,10 @@
|
||||
<!-- in order to declare a NotifyIcon, all you need is the
|
||||
namespace declaration (see above on line 5) and a single line -->
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="hello world" />
|
||||
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap"><Run Text="You should see an icon in the tray." Language="de-ch"/></TextBlock>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace Samples.Tutorials
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for SimpleWindowWithNotifyIcon.xaml
|
||||
/// </summary>
|
||||
public partial class SimpleWindowWithNotifyIcon : Window
|
||||
{
|
||||
public SimpleWindowWithNotifyIcon()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
MyNotifyIcon.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace Samples.Tutorials
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for SimpleDirectDeclaration.xaml
|
||||
/// </summary>
|
||||
public partial class SimpleDirectDeclaration : Window
|
||||
{
|
||||
public SimpleDirectDeclaration()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<Window
|
||||
x:Class="Samples.Tutorials.ToolTips.InlineToolTipWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<Grid>
|
||||
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="hello world">
|
||||
|
||||
<!--
|
||||
We can use arbitrary UI elements as ToolTips.
|
||||
Let's use a semi-transparent border.
|
||||
-->
|
||||
<tb:TaskbarIcon.TrayToolTip>
|
||||
<Border
|
||||
Background="White"
|
||||
BorderBrush="Orange"
|
||||
BorderThickness="2"
|
||||
CornerRadius="4"
|
||||
Opacity="0.8"
|
||||
Width="160"
|
||||
Height="40">
|
||||
<TextBlock
|
||||
Text="hello world"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
/>
|
||||
</Border>
|
||||
</tb:TaskbarIcon.TrayToolTip>
|
||||
|
||||
</tb:TaskbarIcon>
|
||||
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap"><Run Text="Move mouse over NotifyIcon to show ToolTip" Language="de-ch"/></TextBlock>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Samples.Tutorials.ToolTips
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for Window1.xaml
|
||||
/// </summary>
|
||||
public partial class InlineToolTipWindow : Window
|
||||
{
|
||||
public InlineToolTipWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
MyNotifyIcon.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,22 @@
|
||||
<UserControl x:Class="Samples.Tutorials.SimpleUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Height="300" Width="300">
|
||||
<Grid>
|
||||
|
||||
</Grid>
|
||||
<UserControl
|
||||
x:Class="Samples.Tutorials.ToolTips.SimpleUserControl"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
>
|
||||
|
||||
<!-- a simple user control which displays a fixed text within a border -->
|
||||
<Border
|
||||
Background="White"
|
||||
BorderBrush="Orange"
|
||||
BorderThickness="2"
|
||||
CornerRadius="4"
|
||||
Opacity="0.8"
|
||||
Width="160"
|
||||
Height="40">
|
||||
<TextBlock
|
||||
Text="hello world"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Border>
|
||||
|
||||
</UserControl>
|
||||
|
||||
@@ -12,7 +12,7 @@ using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Samples.Tutorials
|
||||
namespace Samples.Tutorials.ToolTips
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for SimpleUserControl.xaml
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<Window
|
||||
x:Class="Samples.Tutorials.ToolTips.UserControlToolTipWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
xmlns:local="clr-namespace:Samples.Tutorials.ToolTips"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<Grid>
|
||||
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="hello world">
|
||||
|
||||
<!-- assign user control as ToolTip -->
|
||||
<tb:TaskbarIcon.TrayToolTip>
|
||||
<local:SimpleUserControl />
|
||||
</tb:TaskbarIcon.TrayToolTip>
|
||||
|
||||
</tb:TaskbarIcon>
|
||||
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap"><Run Text="Move mouse over NotifyIcon to show ToolTip" Language="de-ch"/></TextBlock>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Samples.Tutorials.ToolTips
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for UserControlToolTipWindow.xaml
|
||||
/// </summary>
|
||||
public partial class UserControlToolTipWindow : Window
|
||||
{
|
||||
public UserControlToolTipWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
MyNotifyIcon.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<Window
|
||||
x:Class="Samples.Tutorials.Popups.InlinePopupWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<Grid>
|
||||
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="hello world"
|
||||
>
|
||||
|
||||
<!--
|
||||
We can use arbitrary UI elements as Popups.
|
||||
Popups stay open if the user moves away from the tray area
|
||||
-->
|
||||
<tb:TaskbarIcon.TrayPopup>
|
||||
<Border
|
||||
Background="White"
|
||||
BorderBrush="Orange"
|
||||
BorderThickness="2"
|
||||
CornerRadius="4"
|
||||
Width="160"
|
||||
Height="40">
|
||||
<Button
|
||||
Content="Click Me!"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Border>
|
||||
</tb:TaskbarIcon.TrayPopup>
|
||||
|
||||
</tb:TaskbarIcon>
|
||||
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap"><Run Language="de-ch" Text="Left-Click NotifyIcon to open popup."/></TextBlock>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Samples.Tutorials.Popups
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for InlinePopupWindow.xaml
|
||||
/// </summary>
|
||||
public partial class InlinePopupWindow : Window
|
||||
{
|
||||
public InlinePopupWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
MyNotifyIcon.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<Window
|
||||
x:Class="Samples.Tutorials.ContextMenus.InlineContextMenuWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<Grid>
|
||||
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="hello world">
|
||||
|
||||
<!-- Set a simple context menu -->
|
||||
<tb:TaskbarIcon.ContextMenu>
|
||||
<ContextMenu>
|
||||
<MenuItem Header="First Menu Item" />
|
||||
<MenuItem Header="Second Menu Item" />
|
||||
</ContextMenu>
|
||||
</tb:TaskbarIcon.ContextMenu>
|
||||
|
||||
</tb:TaskbarIcon>
|
||||
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap"><Run Language="de-ch" Text="Right-click on NotifyIcon to open Context Menu"/></TextBlock>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Samples.Tutorials.ContextMenus
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for InlineContextMenuWindow.xaml
|
||||
/// </summary>
|
||||
public partial class InlineContextMenuWindow : Window
|
||||
{
|
||||
public InlineContextMenuWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
MyNotifyIcon.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<Window
|
||||
x:Class="Samples.Tutorials.Balloons.BalloonSampleWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<Grid>
|
||||
|
||||
<!-- the ToolTipText property is bound to the TextBox below -->
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="Balloon Sample Icon" />
|
||||
<Button
|
||||
x:Name="btnShowStandardBalloon"
|
||||
Click="btnShowStandardBalloon_Click"
|
||||
Margin="26,74,29,0"
|
||||
Content="Show Standard Balloon" Height="29" VerticalAlignment="Top"
|
||||
/>
|
||||
<Button
|
||||
x:Name="btnShowCustomBalloon"
|
||||
Click="btnShowCustomBalloon_Click"
|
||||
Margin="26,0,29,49"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="27"
|
||||
Content="Show Custom Balloon"
|
||||
/>
|
||||
<TextBlock
|
||||
Margin="26,26,24,0"
|
||||
VerticalAlignment="Top"
|
||||
FontWeight="Bold"
|
||||
TextWrapping="Wrap"><Run
|
||||
Language="de-ch"
|
||||
Text="Clicking on buttons shows balloon tips" /></TextBlock>
|
||||
<Button
|
||||
x:Name="btnHideStandardBalloon"
|
||||
Click="btnHideStandardBalloon_Click"
|
||||
Margin="26,113,29,122"
|
||||
Content="Hide Standard Balloon"
|
||||
/>
|
||||
<Button
|
||||
x:Name="btnCloseCustomBalloon"
|
||||
Click="btnCloseCustomBalloon_Click"
|
||||
Margin="26,0,29,12"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="27"
|
||||
Content="Close Custom Balloon"
|
||||
/>
|
||||
|
||||
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using Hardcodet.Wpf.TaskbarNotification;
|
||||
|
||||
namespace Samples.Tutorials.Balloons
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for BalloonSampleWindow.xaml
|
||||
/// </summary>
|
||||
public partial class BalloonSampleWindow : Window
|
||||
{
|
||||
public BalloonSampleWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
MyNotifyIcon.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
}
|
||||
|
||||
|
||||
private void btnShowCustomBalloon_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
FancyBalloon balloon = new FancyBalloon();
|
||||
balloon.BalloonText = "Custom Balloon";
|
||||
|
||||
//show balloon and close it after 4 seconds
|
||||
MyNotifyIcon.ShowCustomBalloon(balloon, PopupAnimation.Slide, 4000);
|
||||
}
|
||||
|
||||
private void btnHideStandardBalloon_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MyNotifyIcon.HideBalloonTip();
|
||||
}
|
||||
|
||||
|
||||
private void btnShowStandardBalloon_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string title = "WPF NotifyIcon";
|
||||
string text = "This is a standard balloon";
|
||||
|
||||
MyNotifyIcon.ShowBalloonTip(title, text, MyNotifyIcon.Icon);
|
||||
}
|
||||
|
||||
private void btnCloseCustomBalloon_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
MyNotifyIcon.CloseBalloon();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<Window
|
||||
x:Class="Samples.Tutorials.Commands.CommandWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
xmlns:local="clr-namespace:Samples.Tutorials.Commands"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<Grid>
|
||||
|
||||
<!-- declare the command as a local resource -->
|
||||
<Grid.Resources>
|
||||
<local:ShowMessageCommand
|
||||
x:Key="MessageCommand" />
|
||||
</Grid.Resources>
|
||||
|
||||
<!-- declare the NotifyIcon and configure commands with parameters -->
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
|
||||
LeftClickCommand="{StaticResource MessageCommand}"
|
||||
LeftClickCommandParameter="Left mouse button was clicked"
|
||||
|
||||
DoubleClickCommand="{StaticResource MessageCommand}"
|
||||
DoubleClickCommandParameter="Double click on NotifyIcon" />
|
||||
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap"><Run Language="de-ch" Text="Left / Double clicks on NotifyIcon executes commands."/></TextBlock>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Samples.Tutorials.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for CommandWindow.xaml
|
||||
/// </summary>
|
||||
public partial class CommandWindow : Window
|
||||
{
|
||||
public CommandWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
MyNotifyIcon.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Samples.Tutorials.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// A simple command that displays the command parameter as
|
||||
/// a dialog message.
|
||||
/// </summary>
|
||||
public class ShowMessageCommand : ICommand
|
||||
{
|
||||
public void Execute(object parameter)
|
||||
{
|
||||
MessageBox.Show(parameter.ToString());
|
||||
}
|
||||
|
||||
public bool CanExecute(object parameter)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public event EventHandler CanExecuteChanged;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,261 @@
|
||||
<Window
|
||||
x:Class="Samples.Tutorials.Events.EventVisualizerWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<Window.Resources>
|
||||
<Storyboard
|
||||
x:Key="ShowMovement"
|
||||
AutoReverse="True">
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00"
|
||||
Storyboard.TargetName="MoveIndicator"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00.1000000"
|
||||
Value="1.2" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00"
|
||||
Storyboard.TargetName="MoveIndicator"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00.1000000"
|
||||
Value="1.2" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
<Storyboard
|
||||
x:Key="ShowMouseUp"
|
||||
AutoReverse="True">
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00"
|
||||
Storyboard.TargetName="LeftMouseIndicator"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00.1000000"
|
||||
Value="1.35" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00"
|
||||
Storyboard.TargetName="LeftMouseIndicator"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00.1000000"
|
||||
Value="1.35" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
<Storyboard
|
||||
x:Key="ShowToolTipOpened"
|
||||
AutoReverse="True">
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00"
|
||||
Storyboard.TargetName="ToolTipIndicator"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00.2000000"
|
||||
Value="1.4" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
<DoubleAnimationUsingKeyFrames
|
||||
BeginTime="00:00:00"
|
||||
Storyboard.TargetName="ToolTipIndicator"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00"
|
||||
Value="1" />
|
||||
<SplineDoubleKeyFrame
|
||||
KeyTime="00:00:00.2000000"
|
||||
Value="1.4" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</Window.Resources>
|
||||
<Window.Triggers>
|
||||
<EventTrigger
|
||||
RoutedEvent="tb:TaskbarIcon.TrayMouseMove"
|
||||
SourceName="notifyIcon">
|
||||
<BeginStoryboard
|
||||
Storyboard="{StaticResource ShowMovement}" />
|
||||
</EventTrigger>
|
||||
<EventTrigger
|
||||
RoutedEvent="tb:TaskbarIcon.TrayLeftMouseUp"
|
||||
SourceName="notifyIcon">
|
||||
<BeginStoryboard
|
||||
Storyboard="{StaticResource ShowMouseUp}"
|
||||
x:Name="ShowMouseUp_BeginStoryboard" />
|
||||
</EventTrigger>
|
||||
<EventTrigger
|
||||
RoutedEvent="tb:TaskbarIcon.TrayToolTipOpen"
|
||||
SourceName="notifyIcon">
|
||||
<BeginStoryboard
|
||||
Storyboard="{StaticResource ShowToolTipOpened}"
|
||||
x:Name="ShowToolTipOpened_BeginStoryboard" />
|
||||
</EventTrigger>
|
||||
</Window.Triggers>
|
||||
<Grid>
|
||||
|
||||
<!-- the NotifyIcon does not need to be configured here - animations were set up in Blend -->
|
||||
<tb:TaskbarIcon
|
||||
x:Name="notifyIcon"
|
||||
ToolTipText="hello world"
|
||||
IconSource="/Icons/Error.ico" />
|
||||
|
||||
|
||||
|
||||
|
||||
<Ellipse
|
||||
HorizontalAlignment="Left"
|
||||
Margin="24,62,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="19"
|
||||
Height="19"
|
||||
Stroke="#FF549D2D"
|
||||
x:Name="MoveIndicator"
|
||||
RenderTransformOrigin="0.5,0.5">
|
||||
<Ellipse.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform
|
||||
ScaleX="1"
|
||||
ScaleY="1" />
|
||||
<SkewTransform
|
||||
AngleX="0"
|
||||
AngleY="0" />
|
||||
<RotateTransform
|
||||
Angle="0" />
|
||||
<TranslateTransform
|
||||
X="0"
|
||||
Y="0" />
|
||||
</TransformGroup>
|
||||
</Ellipse.RenderTransform>
|
||||
<Ellipse.Fill>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0.528,0.694"
|
||||
StartPoint="-0.056,-0.118">
|
||||
<GradientStop
|
||||
Color="#FFFFFFFF"
|
||||
Offset="0" />
|
||||
<GradientStop
|
||||
Color="#FF65A135"
|
||||
Offset="1" />
|
||||
</LinearGradientBrush>
|
||||
</Ellipse.Fill>
|
||||
</Ellipse>
|
||||
<Ellipse
|
||||
Stroke="#FF549D2D"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="24,106,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="19"
|
||||
Height="19"
|
||||
x:Name="LeftMouseIndicator"
|
||||
RenderTransformOrigin="0.5,0.5">
|
||||
<Ellipse.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform />
|
||||
<SkewTransform
|
||||
AngleX="0"
|
||||
AngleY="0" />
|
||||
<RotateTransform
|
||||
Angle="0" />
|
||||
<TranslateTransform
|
||||
X="0"
|
||||
Y="0" />
|
||||
</TransformGroup>
|
||||
</Ellipse.RenderTransform>
|
||||
<Ellipse.Fill>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0.528,0.694"
|
||||
StartPoint="-0.056,-0.118">
|
||||
<GradientStop
|
||||
Color="#FFFFFFFF"
|
||||
Offset="0" />
|
||||
<GradientStop
|
||||
Color="#FF65A135"
|
||||
Offset="1" />
|
||||
</LinearGradientBrush>
|
||||
</Ellipse.Fill>
|
||||
</Ellipse>
|
||||
<Ellipse
|
||||
Stroke="#FF549D2D"
|
||||
HorizontalAlignment="Left"
|
||||
Margin="24,0,0,94"
|
||||
Width="19"
|
||||
x:Name="ToolTipIndicator"
|
||||
RenderTransformOrigin="0.5,0.5"
|
||||
Height="19"
|
||||
VerticalAlignment="Bottom">
|
||||
<Ellipse.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform
|
||||
ScaleX="1"
|
||||
ScaleY="1" />
|
||||
<SkewTransform
|
||||
AngleX="0"
|
||||
AngleY="0" />
|
||||
<RotateTransform
|
||||
Angle="0" />
|
||||
<TranslateTransform
|
||||
X="0"
|
||||
Y="0" />
|
||||
</TransformGroup>
|
||||
</Ellipse.RenderTransform>
|
||||
<Ellipse.Fill>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0.528,0.694"
|
||||
StartPoint="-0.056,-0.118">
|
||||
<GradientStop
|
||||
Color="#FFFFFFFF"
|
||||
Offset="0" />
|
||||
<GradientStop
|
||||
Color="#FF65A135"
|
||||
Offset="1" />
|
||||
</LinearGradientBrush>
|
||||
</Ellipse.Fill>
|
||||
</Ellipse>
|
||||
<TextBlock
|
||||
Margin="63,62,91,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="19"
|
||||
TextWrapping="Wrap"><Run
|
||||
Language="de-ch"
|
||||
Text="TrayMouseMove Event" /></TextBlock>
|
||||
<TextBlock
|
||||
Margin="63,106,91,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="19"
|
||||
TextWrapping="Wrap"><Run
|
||||
Language="de-ch"
|
||||
Text="TrayLeftMouseUp Event" /></TextBlock>
|
||||
<TextBlock
|
||||
Margin="63,0,91,94"
|
||||
TextWrapping="Wrap"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="19"><Run
|
||||
Language="de-ch"
|
||||
Text="TrayToolTipOpen Event" /></TextBlock>
|
||||
<TextBlock
|
||||
Margin="10,10,10,0"
|
||||
VerticalAlignment="Top"
|
||||
Height="31"
|
||||
TextWrapping="Wrap"
|
||||
FontWeight="Bold"><Run
|
||||
Language="de-ch"
|
||||
Text="The green elipses are animated based on routed events of the NotifyIcon" /></TextBlock>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Samples.Tutorials.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for EventVisualizerWindow.xaml
|
||||
/// </summary>
|
||||
public partial class EventVisualizerWindow : Window
|
||||
{
|
||||
public EventVisualizerWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
notifyIcon.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
<Window
|
||||
x:Class="Samples.Tutorials.DataBinding.DataBoundToolTipWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="300"
|
||||
Width="300">
|
||||
<Grid>
|
||||
|
||||
<!-- the ToolTipText property is bound to the TextBox below -->
|
||||
<tb:TaskbarIcon
|
||||
x:Name="MyNotifyIcon"
|
||||
IconSource="/Icons/Error.ico"
|
||||
ToolTipText="{Binding ElementName=txtToolTip, Path=Text}">
|
||||
|
||||
<!--
|
||||
The TextBlock bound to the ToolTipText property of the NotifyIcon
|
||||
The binding is implicit (using DataContext)
|
||||
-->
|
||||
<tb:TaskbarIcon.TrayToolTip>
|
||||
<Border
|
||||
Background="White"
|
||||
BorderBrush="Orange"
|
||||
BorderThickness="2"
|
||||
CornerRadius="4"
|
||||
Opacity="0.8"
|
||||
Width="160"
|
||||
Height="40">
|
||||
<TextBlock
|
||||
Text="{Binding Path=ToolTipText}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Border>
|
||||
</tb:TaskbarIcon.TrayToolTip>
|
||||
|
||||
</tb:TaskbarIcon>
|
||||
|
||||
|
||||
<!-- the ToolTipText property is bound to the TextBox below -->
|
||||
<tb:TaskbarIcon
|
||||
IconSource="/Icons/Inactive.ico"
|
||||
ToolTipText="{Binding ElementName=txtToolTip, Path=Text}">
|
||||
|
||||
<!--
|
||||
The TextBlock bound to the ToolTipText property of the NotifyIcon
|
||||
The binding is explicit (via attached ParentTaskbarIcon property)
|
||||
-->
|
||||
<tb:TaskbarIcon.TrayToolTip>
|
||||
<Border
|
||||
Background="White"
|
||||
BorderBrush="Orange"
|
||||
BorderThickness="2"
|
||||
CornerRadius="4"
|
||||
Opacity="0.8"
|
||||
Width="160"
|
||||
Height="40">
|
||||
<TextBlock
|
||||
Text="{Binding (tb:TaskbarIcon.ParentTaskbarIcon), Path=ToolTipText}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" />
|
||||
</Border>
|
||||
</tb:TaskbarIcon.TrayToolTip>
|
||||
|
||||
</tb:TaskbarIcon>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<TextBlock
|
||||
Margin="26,26,24,0"
|
||||
VerticalAlignment="Top"
|
||||
TextWrapping="Wrap"
|
||||
FontWeight="Bold"><Run Text="This sample shows data bound ToolTips in two flavors"/><LineBreak/><Run Text=""/><LineBreak/><Run Text="- implicit binding via DataContext"/><LineBreak/><Run Text="- explicit binding via ParentTaskbarIcon (attached property)"/><LineBreak/><Run Text=""/><LineBreak/><Run Text="Move over NotifyIcons (grey / red) to show data bound ToolTip"/></TextBlock>
|
||||
<TextBox
|
||||
Margin="26,0,24,10"
|
||||
Text="hello world"
|
||||
TextWrapping="Wrap"
|
||||
x:Name="txtToolTip" Height="25" VerticalAlignment="Bottom" />
|
||||
<TextBlock
|
||||
Margin="26,0,125,45"
|
||||
VerticalAlignment="Bottom"
|
||||
Height="26"
|
||||
TextWrapping="Wrap"><Run
|
||||
|
||||
Text="ToolTipText:" /></TextBlock>
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace Samples.Tutorials.DataBinding
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for DataBoundToolTipWindow.xaml
|
||||
/// </summary>
|
||||
public partial class DataBoundToolTipWindow : Window
|
||||
{
|
||||
public DataBoundToolTipWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
|
||||
{
|
||||
//clean up notifyicon (would otherwise stay open until application finishes)
|
||||
MyNotifyIcon.Dispose();
|
||||
|
||||
base.OnClosing(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user