WPF NotifyIcon

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

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

View File

@@ -10,7 +10,9 @@ Contact and Information: http://www.hardcodet.net
CHG DataContext is also assigned to ContextMenu, and properly coerced for CHG DataContext is also assigned to ContextMenu, and properly coerced for
ToolTips and Popups. Also checks whether target item has a binding ToolTips and Popups. Also checks whether target item has a binding
on the DataContext (does not just override if DataContext is null). on the DataContext (does not just override if DataContext is null).
CHG The LeftClickCommand now executes with a delay in order to mak sure
it's not a double-click.
FIX Removed debug output in WindowMessageSink.
---------------------------------------------------------------------------- ----------------------------------------------------------------------------

View File

@@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<ClassDiagram MajorVersion="1" MinorVersion="1"> <ClassDiagram MajorVersion="1" MinorVersion="1">
<Class Name="Hardcodet.Wpf.TaskbarNotification.TaskbarIcon"> <Class Name="Hardcodet.Wpf.TaskbarNotification.TaskbarIcon">
<Position X="0.5" Y="0.5" Width="3.5" /> <Position X="1" Y="0.5" Width="3.5" />
<Compartments> <Compartments>
<Compartment Name="Fields" Collapsed="true" /> <Compartment Name="Fields" Collapsed="true" />
<Compartment Name="Methods" Collapsed="true" />
<Compartment Name="Properties" Collapsed="true" /> <Compartment Name="Properties" Collapsed="true" />
</Compartments> </Compartments>
<TypeIdentifier> <TypeIdentifier>
@@ -14,11 +13,18 @@
<Lollipop Position="0.2" /> <Lollipop Position="0.2" />
</Class> </Class>
<Enum Name="Hardcodet.Wpf.TaskbarNotification.PopupActivationMode"> <Enum Name="Hardcodet.Wpf.TaskbarNotification.PopupActivationMode">
<Position X="5.25" Y="0.5" Width="2" /> <Position X="6.75" Y="0.5" Width="2" />
<TypeIdentifier> <TypeIdentifier>
<HashCode>ABAEAAAAAAAAAAABAAAAAAAAAAAAAAAAAIAKAIAAAAA=</HashCode> <HashCode>ABAEAAAAAAAAAAABAAAAAAAAAAAAAAAAAIAKAIAAAAA=</HashCode>
<FileName>PopupActivationMode.cs</FileName> <FileName>PopupActivationMode.cs</FileName>
</TypeIdentifier> </TypeIdentifier>
</Enum> </Enum>
<Enum Name="Hardcodet.Wpf.TaskbarNotification.BalloonIcon">
<Position X="9.25" Y="0.5" Width="1.5" />
<TypeIdentifier>
<HashCode>AAAAAAAAAAAAAQAAAAAAABAAAAAAAAAAAAAAAEEAAAA=</HashCode>
<FileName>BalloonIcon.cs</FileName>
</TypeIdentifier>
</Enum>
<Font Name="Segoe UI" Size="9" /> <Font Name="Segoe UI" Size="9" />
</ClassDiagram> </ClassDiagram>

View File

@@ -233,17 +233,14 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
switch (lParam) switch (lParam)
{ {
case 0x200: case 0x200:
// Debug.WriteLine("MOVE");
MouseEventReceived(MouseEvent.MouseMove); MouseEventReceived(MouseEvent.MouseMove);
break; break;
case 0x201: case 0x201:
Debug.WriteLine("left down 1");
MouseEventReceived(MouseEvent.IconLeftMouseDown); MouseEventReceived(MouseEvent.IconLeftMouseDown);
break; break;
case 0x202: case 0x202:
Debug.WriteLine("left up");
if (!isDoubleClick) if (!isDoubleClick)
{ {
MouseEventReceived(MouseEvent.IconLeftMouseUp); MouseEventReceived(MouseEvent.IconLeftMouseUp);
@@ -252,69 +249,57 @@ namespace Hardcodet.Wpf.TaskbarNotification.Interop
break; break;
case 0x203: case 0x203:
Debug.WriteLine("left click 2");
isDoubleClick = true; isDoubleClick = true;
MouseEventReceived(MouseEvent.IconDoubleClick); MouseEventReceived(MouseEvent.IconDoubleClick);
break; break;
case 0x204: case 0x204:
Debug.WriteLine("right click 1");
MouseEventReceived(MouseEvent.IconRightMouseDown); MouseEventReceived(MouseEvent.IconRightMouseDown);
break; break;
case 0x205: case 0x205:
Console.Out.WriteLine("right mouse up");
MouseEventReceived(MouseEvent.IconRightMouseUp); MouseEventReceived(MouseEvent.IconRightMouseUp);
break; break;
case 0x206: case 0x206:
//double click with right mouse button - do not trigger event //double click with right mouse button - do not trigger event
Debug.WriteLine("right click 2");
break; break;
case 0x207: case 0x207:
Debug.WriteLine("middle click 1");
MouseEventReceived(MouseEvent.IconMiddleMouseDown); MouseEventReceived(MouseEvent.IconMiddleMouseDown);
break; break;
case 520: case 520:
Debug.WriteLine("mouse up middle");
MouseEventReceived(MouseEvent.IconMiddleMouseUp); MouseEventReceived(MouseEvent.IconMiddleMouseUp);
break; break;
case 0x209: case 0x209:
//double click with middle mouse button - do not trigger event //double click with middle mouse button - do not trigger event
Debug.WriteLine("middle click 2");
break; break;
case 0x402: case 0x402:
Debug.WriteLine("balloon shown");
BallonToolTipChanged(true); BallonToolTipChanged(true);
break; break;
case 0x403: case 0x403:
case 0x404: case 0x404:
Debug.WriteLine("balloon close");
BallonToolTipChanged(false); BallonToolTipChanged(false);
break; break;
case 0x405: case 0x405:
Debug.WriteLine("balloon clicked");
MouseEventReceived(MouseEvent.BalloonToolTipClicked); MouseEventReceived(MouseEvent.BalloonToolTipClicked);
break; break;
case 0x406: case 0x406:
Debug.WriteLine("show custom tooltip");
ChangeToolTipStateRequest(true); ChangeToolTipStateRequest(true);
break; break;
case 0x407: case 0x407:
Debug.WriteLine("close custom tooltip");
ChangeToolTipStateRequest(false); ChangeToolTipStateRequest(false);
break; break;
default: default:
Debug.WriteLine("Unhandled message ID: " + lParam); Debug.WriteLine("Unhandled NotifyIcon message ID: " + lParam);
break; break;
} }

View File

@@ -156,6 +156,7 @@ namespace Hardcodet.Wpf.TaskbarNotification
/// <param name="balloon"></param> /// <param name="balloon"></param>
/// <param name="animation">An optional animation for the popup.</param> /// <param name="animation">An optional animation for the popup.</param>
/// <param name="timeout">The time after which the popup is being closed. /// <param name="timeout">The time after which the popup is being closed.
/// Submit null in order to keep the balloon open inde
/// </param> /// </param>
/// <exception cref="ArgumentNullException">If <paramref name="balloon"/> /// <exception cref="ArgumentNullException">If <paramref name="balloon"/>
/// is a null reference.</exception> /// is a null reference.</exception>

View File

@@ -1,12 +1,12 @@
<Application x:Class="Samples.App" <Application x:Class="Samples.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Window1.xaml"> StartupUri="Main.xaml">
<Application.Resources> <Application.Resources>
<ResourceDictionary> <ResourceDictionary>
<ResourceDictionary.MergedDictionaries> <ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="TaskbarIconResources.xaml"/> <ResourceDictionary Source="Showcase/NotifyIconResources.xaml"/>
</ResourceDictionary.MergedDictionaries> </ResourceDictionary.MergedDictionaries>
</ResourceDictionary> </ResourceDictionary>

View File

@@ -4,6 +4,7 @@ using System.Configuration;
using System.Data; using System.Data;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using Hardcodet.Wpf.TaskbarNotification;
namespace Samples namespace Samples
{ {
@@ -12,5 +13,6 @@ namespace Samples
/// </summary> /// </summary>
public partial class App : Application public partial class App : Application
{ {
} }
} }

View File

@@ -1,4 +1,6 @@
using System; using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Markup; using System.Windows.Markup;
@@ -58,7 +60,18 @@ namespace Samples.Commands
/// </param> /// </param>
public virtual bool CanExecute(object parameter) 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;
}
} }
} }
} }

View File

@@ -18,7 +18,7 @@ namespace Samples.Commands
public override bool CanExecute(object parameter) public override bool CanExecute(object parameter)
{ {
return Application.Current.MainWindow.IsVisible; return !IsDesignMode && Application.Current.MainWindow.IsVisible;
} }

View File

@@ -20,7 +20,7 @@ namespace Samples.Commands
public override bool CanExecute(object parameter) public override bool CanExecute(object parameter)
{ {
return Application.Current.MainWindow.IsVisible == false; return !IsDesignMode && Application.Current.MainWindow.IsVisible == false;
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

View 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 &quot;Tutorials&quot; 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>

View 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;
}
}
}

View File

@@ -62,16 +62,16 @@
<Resource Include="Icons\Inactive.ico" /> <Resource Include="Icons\Inactive.ico" />
<Resource Include="Icons\Error.ico" /> <Resource Include="Icons\Error.ico" />
<Resource Include="Images\Info.png" /> <Resource Include="Images\Info.png" />
<Resource Include="Images\preferences.png" /> <Resource Include="Images\Preferences.png" />
<Page Include="FancyToolTip.xaml"> <Page Include="Showcase\FancyToolTip.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Include="TaskbarIconResources.xaml"> <Page Include="Showcase\NotifyIconResources.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Compile Include="FancyToolTip.xaml.cs"> <Compile Include="Showcase\FancyToolTip.xaml.cs">
<DependentUpon>FancyToolTip.xaml</DependentUpon> <DependentUpon>FancyToolTip.xaml</DependentUpon>
</Compile> </Compile>
</ItemGroup> </ItemGroup>
@@ -80,15 +80,27 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</ApplicationDefinition> </ApplicationDefinition>
<Page Include="FancyBalloon.xaml"> <Page Include="Showcase\FancyBalloon.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="FancyPopup.xaml"> <Page Include="Showcase\FancyPopup.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </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> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
@@ -96,11 +108,39 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="WelcomeBalloon.xaml"> <Page Include="Tutorials\02 - ToolTips\InlineToolTipWindow.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </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> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
@@ -108,21 +148,24 @@
<SubType>Code</SubType> <SubType>Code</SubType>
<DependentUpon>App.xaml</DependentUpon> <DependentUpon>App.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Window1.xaml.cs"> <Compile Include="Showcase\ShowcaseWindow.xaml.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
<DependentUpon>Window1.xaml</DependentUpon> <DependentUpon>ShowcaseWindow.xaml</DependentUpon>
</Compile> </Compile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Commands\CommandBase.cs" /> <Compile Include="Commands\CommandBase.cs" />
<Compile Include="Commands\HideMainWindowCommand.cs" /> <Compile Include="Commands\HideMainWindowCommand.cs" />
<Compile Include="Commands\ShowMainWindowCommand.cs" /> <Compile Include="Commands\ShowMainWindowCommand.cs" />
<Compile Include="FancyBalloon.xaml.cs"> <Compile Include="Showcase\FancyBalloon.xaml.cs">
<DependentUpon>FancyBalloon.xaml</DependentUpon> <DependentUpon>FancyBalloon.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="FancyPopup.xaml.cs"> <Compile Include="Showcase\FancyPopup.xaml.cs">
<DependentUpon>FancyPopup.xaml</DependentUpon> <DependentUpon>FancyPopup.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Main.xaml.cs">
<DependentUpon>Main.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs"> <Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
@@ -136,13 +179,38 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput> <DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon> <DependentUpon>Settings.settings</DependentUpon>
</Compile> </Compile>
<Compile Include="Tutorials\01 - Declaration\Window1.xaml.cs"> <Compile Include="Tutorials\01 - Declaration\SimpleWindowWithNotifyIcon.xaml.cs">
<DependentUpon>Window1.xaml</DependentUpon> <DependentUpon>SimpleWindowWithNotifyIcon.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="Tutorials\02 - ToolTips\SimpleUserControl.xaml.cs"> <Compile Include="Tutorials\02 - ToolTips\SimpleUserControl.xaml.cs">
<DependentUpon>SimpleUserControl.xaml</DependentUpon> <DependentUpon>SimpleUserControl.xaml</DependentUpon>
</Compile> </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> <DependentUpon>WelcomeBalloon.xaml</DependentUpon>
</Compile> </Compile>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">

View File

@@ -84,7 +84,7 @@
HorizontalAlignment="Left" HorizontalAlignment="Left"
Margin="0,10,0,0" Margin="0,10,0,0"
Width="72" Width="72"
Source="Images\Info.png" Source="/Images/Info.png"
Stretch="Fill" Height="72" VerticalAlignment="Top" /> Stretch="Fill" Height="72" VerticalAlignment="Top" />
<TextBlock <TextBlock
Margin="72,49.2,10,0" Margin="72,49.2,10,0"
@@ -112,7 +112,7 @@
</Path.Stroke> </Path.Stroke>
</Path> </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"/> <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> </Grid>
</UserControl> </UserControl>

View File

@@ -49,7 +49,7 @@
VerticalAlignment="Top" VerticalAlignment="Top"
Width="72" Width="72"
Height="72" Height="72"
Source="Images\preferences.png" Source="/Images/Preferences.png"
Stretch="Fill" x:Name="image" RenderTransformOrigin="0.5,0.5" > Stretch="Fill" x:Name="image" RenderTransformOrigin="0.5,0.5" >
<Image.RenderTransform> <Image.RenderTransform>
<TransformGroup> <TransformGroup>

View File

@@ -71,7 +71,7 @@
HorizontalAlignment="Left" HorizontalAlignment="Left"
Margin="10,10,0,26" Margin="10,10,0,26"
Width="72" Width="72"
Source="Images\Info.png" Source="/Images/Info.png"
Stretch="Fill" Stretch="Fill"
VerticalAlignment="Top" VerticalAlignment="Top"
RenderTransformOrigin="0.792,0.486" x:Name="image" Height="72" > RenderTransformOrigin="0.792,0.486" x:Name="image" Height="72" >

View File

@@ -1,11 +1,11 @@
<Window <Window
x:Class="Samples.Window1" x:Class="Samples.ShowcaseWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar" xmlns:tb="http://www.hardcodet.net/taskbar"
xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="WPF NotifyIcon Sample" Title="WPF NotifyIcon Sample"
Height="938" Height="874"
Width="880" Width="880"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 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 <Grid
Margin="486.5,617.58,0,0" Margin="486.5,578.58,0,0"
VerticalAlignment="Top" VerticalAlignment="Top"
Height="248" Height="248"
x:Name="Balloons" x:Name="Balloons"
@@ -202,7 +202,7 @@
</Grid> </Grid>
<Grid <Grid
HorizontalAlignment="Left" HorizontalAlignment="Left"
Margin="12,582.88,0,0" Margin="12,543.88,0,0"
VerticalAlignment="Top" VerticalAlignment="Top"
Width="445.5" Width="445.5"
Height="282.7" Height="282.7"
@@ -254,7 +254,7 @@
Text="Popup Controls" /></TextBlock> Text="Popup Controls" /></TextBlock>
</Grid> </Grid>
<Grid <Grid
Margin="10,317,0,0" Margin="10,278,0,0"
x:Name="ToolTips" x:Name="ToolTips"
Height="255.88" Height="255.88"
VerticalAlignment="Top" VerticalAlignment="Top"
@@ -336,7 +336,7 @@
</Grid> </Grid>
<Grid <Grid
HorizontalAlignment="Left" HorizontalAlignment="Left"
Margin="488,153.5,0,0" Margin="488,114.5,0,0"
Width="370.5" Width="370.5"
x:Name="ContextMenus" x:Name="ContextMenus"
Height="255.88" Height="255.88"
@@ -392,41 +392,27 @@
Height="Auto" Height="Auto"
TextWrapping="Wrap" TextWrapping="Wrap"
FontWeight="Bold" FontWeight="Bold"
FontSize="14" FontSize="16"
Width="309"
HorizontalAlignment="Left"><Run HorizontalAlignment="Left"><Run
Text="WPF NotifyIcon 1.0.1" /></TextBlock> Text="WPF NotifyIcon 1.0.1" /></TextBlock>
<TextBlock <TextBlock
Margin="12,38.62,0,0" Margin="12,57.62,15.5,0"
VerticalAlignment="Top" VerticalAlignment="Top"
Height="104.88"
FontSize="14" FontSize="14"
FontStyle="Italic" FontStyle="Italic"
Foreground="#FF303030" Foreground="#FF303030"
TextWrapping="Wrap" TextWrapping="Wrap"
HorizontalAlignment="Left" HorizontalAlignment="Stretch"><Run
Width="846.5"><Run
Text="This " /><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="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="example" /><Run
Text=", have a look at" /><Run Text=", " /><Run
Text=" " /><Hyperlink Language="de-ch"
Text="check out " /><Hyperlink
NavigateUri="http://www.hardcodet.net/netdrives/"><Run NavigateUri="http://www.hardcodet.net/netdrives/"><Run
Text="NetDrives" /></Hyperlink><LineBreak /><Run Text="NetDrives" /></Hyperlink></TextBlock>
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 <Grid
Margin="486.5,419.38,0,0" Margin="486.5,380.38,0,0"
x:Name="CustomBalloons" x:Name="CustomBalloons"
Height="188.2" Height="188.2"
VerticalAlignment="Top" VerticalAlignment="Top"
@@ -492,7 +478,7 @@
Text="Custom Balloons" /></TextBlock> Text="Custom Balloons" /></TextBlock>
</Grid> </Grid>
<Grid <Grid
Margin="10,153.5,0,0" Margin="10,114.5,0,0"
VerticalAlignment="Top" VerticalAlignment="Top"
Height="138.38" Height="138.38"
x:Name="Common" x:Name="Common"
@@ -524,12 +510,12 @@
Width="16" Width="16"
Margin="0,4,0,0" Margin="0,4,0,0"
Height="16" Height="16"
Source="Icons\Inactive.ico" /> Source="/Icons/Inactive.ico" />
<Image <Image
Width="16" Width="16"
Margin="0,4,0,0" Margin="0,4,0,0"
Height="16" Height="16"
Source="Icons\Error.ico" /> Source="/Icons/Error.ico" />
</ListBox> </ListBox>
<TextBlock <TextBlock

View File

@@ -1,18 +1,17 @@
using System.Diagnostics; using System.Diagnostics;
using System.Windows; using System.Windows;
using System.Windows.Controls.Primitives; using System.Windows.Controls.Primitives;
using System.Windows.Documents;
using System.Windows.Navigation; using System.Windows.Navigation;
using Hardcodet.Wpf.TaskbarNotification; using Hardcodet.Wpf.TaskbarNotification;
namespace Samples namespace Samples
{ {
/// <summary> /// <summary>
/// Interaction logic for Window1.xaml /// Interaction logic for ShowcaseWindow.xaml
/// </summary> /// </summary>
public partial class Window1 : Window public partial class ShowcaseWindow : Window
{ {
public Window1() public ShowcaseWindow()
{ {
InitializeComponent(); InitializeComponent();
@@ -82,5 +81,13 @@ namespace Samples
Process.Start(e.Uri.ToString()); Process.Start(e.Uri.ToString());
e.Handled = true; 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);
}
} }
} }

View File

@@ -0,0 +1,10 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar">
<!-- Globally declared notify icon (ResourceDictionary is not in use, example only) -->
<tb:TaskbarIcon x:Key="MyNotifyIcon"
IconSource="/Icons/Error.ico"
ToolTipText="hello world" />
</ResourceDictionary>

View File

@@ -1,5 +1,5 @@
<Window <Window
x:Class="Samples.Tutorials.SimpleDirectDeclaration" x:Class="Samples.Tutorials.SimpleWindowWithNotifyIcon"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar" xmlns:tb="http://www.hardcodet.net/taskbar"
@@ -10,8 +10,10 @@
<!-- in order to declare a NotifyIcon, all you need is the <!-- in order to declare a NotifyIcon, all you need is the
namespace declaration (see above on line 5) and a single line --> namespace declaration (see above on line 5) and a single line -->
<tb:TaskbarIcon <tb:TaskbarIcon
x:Name="MyNotifyIcon"
IconSource="/Icons/Error.ico" IconSource="/Icons/Error.ico"
ToolTipText="hello world" /> 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> </Grid>
</Window> </Window>

View File

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

View File

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

View File

@@ -0,0 +1,40 @@
<Window
x:Class="Samples.Tutorials.ToolTips.InlineToolTipWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Height="300"
Width="300">
<Grid>
<tb:TaskbarIcon
x:Name="MyNotifyIcon"
IconSource="/Icons/Error.ico"
ToolTipText="hello world">
<!--
We can use arbitrary UI elements as ToolTips.
Let's use a semi-transparent border.
-->
<tb:TaskbarIcon.TrayToolTip>
<Border
Background="White"
BorderBrush="Orange"
BorderThickness="2"
CornerRadius="4"
Opacity="0.8"
Width="160"
Height="40">
<TextBlock
Text="hello world"
HorizontalAlignment="Center"
VerticalAlignment="Center"
/>
</Border>
</tb:TaskbarIcon.TrayToolTip>
</tb:TaskbarIcon>
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap"><Run Text="Move mouse over NotifyIcon to show ToolTip" Language="de-ch"/></TextBlock>
</Grid>
</Window>

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,25 @@
<Window
x:Class="Samples.Tutorials.ToolTips.UserControlToolTipWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
xmlns:local="clr-namespace:Samples.Tutorials.ToolTips"
Height="300"
Width="300">
<Grid>
<tb:TaskbarIcon
x:Name="MyNotifyIcon"
IconSource="/Icons/Error.ico"
ToolTipText="hello world">
<!-- assign user control as ToolTip -->
<tb:TaskbarIcon.TrayToolTip>
<local:SimpleUserControl />
</tb:TaskbarIcon.TrayToolTip>
</tb:TaskbarIcon>
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap"><Run Text="Move mouse over NotifyIcon to show ToolTip" Language="de-ch"/></TextBlock>
</Grid>
</Window>

View File

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

View File

@@ -0,0 +1,39 @@
<Window
x:Class="Samples.Tutorials.Popups.InlinePopupWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Height="300"
Width="300">
<Grid>
<tb:TaskbarIcon
x:Name="MyNotifyIcon"
IconSource="/Icons/Error.ico"
ToolTipText="hello world"
>
<!--
We can use arbitrary UI elements as Popups.
Popups stay open if the user moves away from the tray area
-->
<tb:TaskbarIcon.TrayPopup>
<Border
Background="White"
BorderBrush="Orange"
BorderThickness="2"
CornerRadius="4"
Width="160"
Height="40">
<Button
Content="Click Me!"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
</tb:TaskbarIcon.TrayPopup>
</tb:TaskbarIcon>
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap"><Run Language="de-ch" Text="Left-Click NotifyIcon to open popup."/></TextBlock>
</Grid>
</Window>

View File

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

View File

@@ -0,0 +1,27 @@
<Window
x:Class="Samples.Tutorials.ContextMenus.InlineContextMenuWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Height="300"
Width="300">
<Grid>
<tb:TaskbarIcon
x:Name="MyNotifyIcon"
IconSource="/Icons/Error.ico"
ToolTipText="hello world">
<!-- Set a simple context menu -->
<tb:TaskbarIcon.ContextMenu>
<ContextMenu>
<MenuItem Header="First Menu Item" />
<MenuItem Header="Second Menu Item" />
</ContextMenu>
</tb:TaskbarIcon.ContextMenu>
</tb:TaskbarIcon>
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap"><Run Language="de-ch" Text="Right-click on NotifyIcon to open Context Menu"/></TextBlock>
</Grid>
</Window>

View File

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

View File

@@ -0,0 +1,54 @@
<Window
x:Class="Samples.Tutorials.Balloons.BalloonSampleWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Height="300"
Width="300">
<Grid>
<!-- the ToolTipText property is bound to the TextBox below -->
<tb:TaskbarIcon
x:Name="MyNotifyIcon"
IconSource="/Icons/Error.ico"
ToolTipText="Balloon Sample Icon" />
<Button
x:Name="btnShowStandardBalloon"
Click="btnShowStandardBalloon_Click"
Margin="26,74,29,0"
Content="Show Standard Balloon" Height="29" VerticalAlignment="Top"
/>
<Button
x:Name="btnShowCustomBalloon"
Click="btnShowCustomBalloon_Click"
Margin="26,0,29,49"
VerticalAlignment="Bottom"
Height="27"
Content="Show Custom Balloon"
/>
<TextBlock
Margin="26,26,24,0"
VerticalAlignment="Top"
FontWeight="Bold"
TextWrapping="Wrap"><Run
Language="de-ch"
Text="Clicking on buttons shows balloon tips" /></TextBlock>
<Button
x:Name="btnHideStandardBalloon"
Click="btnHideStandardBalloon_Click"
Margin="26,113,29,122"
Content="Hide Standard Balloon"
/>
<Button
x:Name="btnCloseCustomBalloon"
Click="btnCloseCustomBalloon_Click"
Margin="26,0,29,12"
VerticalAlignment="Bottom"
Height="27"
Content="Close Custom Balloon"
/>
</Grid>
</Window>

View File

@@ -0,0 +1,67 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Hardcodet.Wpf.TaskbarNotification;
namespace Samples.Tutorials.Balloons
{
/// <summary>
/// Interaction logic for BalloonSampleWindow.xaml
/// </summary>
public partial class BalloonSampleWindow : Window
{
public BalloonSampleWindow()
{
InitializeComponent();
}
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//clean up notifyicon (would otherwise stay open until application finishes)
MyNotifyIcon.Dispose();
base.OnClosing(e);
}
private void btnShowCustomBalloon_Click(object sender, RoutedEventArgs e)
{
FancyBalloon balloon = new FancyBalloon();
balloon.BalloonText = "Custom Balloon";
//show balloon and close it after 4 seconds
MyNotifyIcon.ShowCustomBalloon(balloon, PopupAnimation.Slide, 4000);
}
private void btnHideStandardBalloon_Click(object sender, RoutedEventArgs e)
{
MyNotifyIcon.HideBalloonTip();
}
private void btnShowStandardBalloon_Click(object sender, RoutedEventArgs e)
{
string title = "WPF NotifyIcon";
string text = "This is a standard balloon";
MyNotifyIcon.ShowBalloonTip(title, text, MyNotifyIcon.Icon);
}
private void btnCloseCustomBalloon_Click(object sender, RoutedEventArgs e)
{
MyNotifyIcon.CloseBalloon();
}
}
}

View File

@@ -0,0 +1,30 @@
<Window
x:Class="Samples.Tutorials.Commands.CommandWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
xmlns:local="clr-namespace:Samples.Tutorials.Commands"
Height="300"
Width="300">
<Grid>
<!-- declare the command as a local resource -->
<Grid.Resources>
<local:ShowMessageCommand
x:Key="MessageCommand" />
</Grid.Resources>
<!-- declare the NotifyIcon and configure commands with parameters -->
<tb:TaskbarIcon
x:Name="MyNotifyIcon"
IconSource="/Icons/Error.ico"
LeftClickCommand="{StaticResource MessageCommand}"
LeftClickCommandParameter="Left mouse button was clicked"
DoubleClickCommand="{StaticResource MessageCommand}"
DoubleClickCommandParameter="Double click on NotifyIcon" />
<TextBlock Margin="26,26,24,0" VerticalAlignment="Top" FontWeight="Bold" TextWrapping="Wrap"><Run Language="de-ch" Text="Left / Double clicks on NotifyIcon executes commands."/></TextBlock>
</Grid>
</Window>

View File

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

View File

@@ -0,0 +1,25 @@
using System;
using System.Windows;
using System.Windows.Input;
namespace Samples.Tutorials.Commands
{
/// <summary>
/// A simple command that displays the command parameter as
/// a dialog message.
/// </summary>
public class ShowMessageCommand : ICommand
{
public void Execute(object parameter)
{
MessageBox.Show(parameter.ToString());
}
public bool CanExecute(object parameter)
{
return true;
}
public event EventHandler CanExecuteChanged;
}
}

View File

@@ -0,0 +1,261 @@
<Window
x:Class="Samples.Tutorials.Events.EventVisualizerWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Height="300"
Width="300">
<Window.Resources>
<Storyboard
x:Key="ShowMovement"
AutoReverse="True">
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="MoveIndicator"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:00.1000000"
Value="1.2" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="MoveIndicator"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:00.1000000"
Value="1.2" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard
x:Key="ShowMouseUp"
AutoReverse="True">
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="LeftMouseIndicator"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:00.1000000"
Value="1.35" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="LeftMouseIndicator"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:00.1000000"
Value="1.35" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
<Storyboard
x:Key="ShowToolTipOpened"
AutoReverse="True">
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="ToolTipIndicator"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:00.2000000"
Value="1.4" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="ToolTipIndicator"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:00.2000000"
Value="1.4" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<Window.Triggers>
<EventTrigger
RoutedEvent="tb:TaskbarIcon.TrayMouseMove"
SourceName="notifyIcon">
<BeginStoryboard
Storyboard="{StaticResource ShowMovement}" />
</EventTrigger>
<EventTrigger
RoutedEvent="tb:TaskbarIcon.TrayLeftMouseUp"
SourceName="notifyIcon">
<BeginStoryboard
Storyboard="{StaticResource ShowMouseUp}"
x:Name="ShowMouseUp_BeginStoryboard" />
</EventTrigger>
<EventTrigger
RoutedEvent="tb:TaskbarIcon.TrayToolTipOpen"
SourceName="notifyIcon">
<BeginStoryboard
Storyboard="{StaticResource ShowToolTipOpened}"
x:Name="ShowToolTipOpened_BeginStoryboard" />
</EventTrigger>
</Window.Triggers>
<Grid>
<!-- the NotifyIcon does not need to be configured here - animations were set up in Blend -->
<tb:TaskbarIcon
x:Name="notifyIcon"
ToolTipText="hello world"
IconSource="/Icons/Error.ico" />
<Ellipse
HorizontalAlignment="Left"
Margin="24,62,0,0"
VerticalAlignment="Top"
Width="19"
Height="19"
Stroke="#FF549D2D"
x:Name="MoveIndicator"
RenderTransformOrigin="0.5,0.5">
<Ellipse.RenderTransform>
<TransformGroup>
<ScaleTransform
ScaleX="1"
ScaleY="1" />
<SkewTransform
AngleX="0"
AngleY="0" />
<RotateTransform
Angle="0" />
<TranslateTransform
X="0"
Y="0" />
</TransformGroup>
</Ellipse.RenderTransform>
<Ellipse.Fill>
<LinearGradientBrush
EndPoint="0.528,0.694"
StartPoint="-0.056,-0.118">
<GradientStop
Color="#FFFFFFFF"
Offset="0" />
<GradientStop
Color="#FF65A135"
Offset="1" />
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Ellipse
Stroke="#FF549D2D"
HorizontalAlignment="Left"
Margin="24,106,0,0"
VerticalAlignment="Top"
Width="19"
Height="19"
x:Name="LeftMouseIndicator"
RenderTransformOrigin="0.5,0.5">
<Ellipse.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform
AngleX="0"
AngleY="0" />
<RotateTransform
Angle="0" />
<TranslateTransform
X="0"
Y="0" />
</TransformGroup>
</Ellipse.RenderTransform>
<Ellipse.Fill>
<LinearGradientBrush
EndPoint="0.528,0.694"
StartPoint="-0.056,-0.118">
<GradientStop
Color="#FFFFFFFF"
Offset="0" />
<GradientStop
Color="#FF65A135"
Offset="1" />
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
<Ellipse
Stroke="#FF549D2D"
HorizontalAlignment="Left"
Margin="24,0,0,94"
Width="19"
x:Name="ToolTipIndicator"
RenderTransformOrigin="0.5,0.5"
Height="19"
VerticalAlignment="Bottom">
<Ellipse.RenderTransform>
<TransformGroup>
<ScaleTransform
ScaleX="1"
ScaleY="1" />
<SkewTransform
AngleX="0"
AngleY="0" />
<RotateTransform
Angle="0" />
<TranslateTransform
X="0"
Y="0" />
</TransformGroup>
</Ellipse.RenderTransform>
<Ellipse.Fill>
<LinearGradientBrush
EndPoint="0.528,0.694"
StartPoint="-0.056,-0.118">
<GradientStop
Color="#FFFFFFFF"
Offset="0" />
<GradientStop
Color="#FF65A135"
Offset="1" />
</LinearGradientBrush>
</Ellipse.Fill>
</Ellipse>
<TextBlock
Margin="63,62,91,0"
VerticalAlignment="Top"
Height="19"
TextWrapping="Wrap"><Run
Language="de-ch"
Text="TrayMouseMove Event" /></TextBlock>
<TextBlock
Margin="63,106,91,0"
VerticalAlignment="Top"
Height="19"
TextWrapping="Wrap"><Run
Language="de-ch"
Text="TrayLeftMouseUp Event" /></TextBlock>
<TextBlock
Margin="63,0,91,94"
TextWrapping="Wrap"
VerticalAlignment="Bottom"
Height="19"><Run
Language="de-ch"
Text="TrayToolTipOpen Event" /></TextBlock>
<TextBlock
Margin="10,10,10,0"
VerticalAlignment="Top"
Height="31"
TextWrapping="Wrap"
FontWeight="Bold"><Run
Language="de-ch"
Text="The green elipses are animated based on routed events of the NotifyIcon" /></TextBlock>
</Grid>
</Window>

View File

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

View File

@@ -0,0 +1,89 @@
<Window
x:Class="Samples.Tutorials.DataBinding.DataBoundToolTipWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Height="300"
Width="300">
<Grid>
<!-- the ToolTipText property is bound to the TextBox below -->
<tb:TaskbarIcon
x:Name="MyNotifyIcon"
IconSource="/Icons/Error.ico"
ToolTipText="{Binding ElementName=txtToolTip, Path=Text}">
<!--
The TextBlock bound to the ToolTipText property of the NotifyIcon
The binding is implicit (using DataContext)
-->
<tb:TaskbarIcon.TrayToolTip>
<Border
Background="White"
BorderBrush="Orange"
BorderThickness="2"
CornerRadius="4"
Opacity="0.8"
Width="160"
Height="40">
<TextBlock
Text="{Binding Path=ToolTipText}"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
</tb:TaskbarIcon.TrayToolTip>
</tb:TaskbarIcon>
<!-- the ToolTipText property is bound to the TextBox below -->
<tb:TaskbarIcon
IconSource="/Icons/Inactive.ico"
ToolTipText="{Binding ElementName=txtToolTip, Path=Text}">
<!--
The TextBlock bound to the ToolTipText property of the NotifyIcon
The binding is explicit (via attached ParentTaskbarIcon property)
-->
<tb:TaskbarIcon.TrayToolTip>
<Border
Background="White"
BorderBrush="Orange"
BorderThickness="2"
CornerRadius="4"
Opacity="0.8"
Width="160"
Height="40">
<TextBlock
Text="{Binding (tb:TaskbarIcon.ParentTaskbarIcon), Path=ToolTipText}"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
</tb:TaskbarIcon.TrayToolTip>
</tb:TaskbarIcon>
<TextBlock
Margin="26,26,24,0"
VerticalAlignment="Top"
TextWrapping="Wrap"
FontWeight="Bold"><Run Text="This sample shows data bound ToolTips in two flavors"/><LineBreak/><Run Text=""/><LineBreak/><Run Text="- implicit binding via DataContext"/><LineBreak/><Run Text="- explicit binding via ParentTaskbarIcon (attached property)"/><LineBreak/><Run Text=""/><LineBreak/><Run Text="Move over NotifyIcons (grey / red) to show data bound ToolTip"/></TextBlock>
<TextBox
Margin="26,0,24,10"
Text="hello world"
TextWrapping="Wrap"
x:Name="txtToolTip" Height="25" VerticalAlignment="Bottom" />
<TextBlock
Margin="26,0,125,45"
VerticalAlignment="Bottom"
Height="26"
TextWrapping="Wrap"><Run
Text="ToolTipText:" /></TextBlock>
</Grid>
</Window>

View File

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