Files
wpf-notifyicon/Source/Sample Project/Window1.xaml
Philipp Sumi 354ba1ca43 NotifyWPF
---------
CHG   Lot of plumbing, some fixes
CHG   Work on sample project.
CHG   Popups and ContextMenu now store coordinates - otherwise delayed opending may happen elsewhere.

git-svn-id: https://svn.evolvesoftware.ch/repos/evolve.net/WPF/NotifyIcon@55 9f600761-6f11-4665-b6dc-0185e9171623
2009-03-31 22:20:07 +00:00

439 lines
13 KiB
XML

<Window
x:Class="Sample_Project.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="Window1"
Height="808"
Width="769"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:local="clr-namespace:Sample_Project">
<Window.Resources>
<BooleanToVisibilityConverter
x:Key="BooleanToVisibilityConverter" />
<ObjectDataProvider
MethodName="GetValues"
ObjectType="{x:Type sys:Enum}"
x:Key="ActivationModes">
<ObjectDataProvider.MethodParameters>
<x:Type
TypeName="tb:PopupActivationMode" />
</ObjectDataProvider.MethodParameters>
</ObjectDataProvider>
<Storyboard
x:Key="OnTaskbarIconLeftMouseUp1">
<BooleanAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="popup"
Storyboard.TargetProperty="(Popup.IsOpen)">
<DiscreteBooleanKeyFrame
KeyTime="00:00:00"
Value="True" />
<DiscreteBooleanKeyFrame
KeyTime="00:00:02"
Value="False" />
</BooleanAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="ellipse"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="0" />
<SplineDoubleKeyFrame
KeyTime="00:00:01"
Value="74" />
<SplineDoubleKeyFrame
KeyTime="00:00:01.5000000"
Value="26" />
<SplineDoubleKeyFrame
KeyTime="00:00:02"
Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="ellipse"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="0" />
<SplineDoubleKeyFrame
KeyTime="00:00:01"
Value="106" />
<SplineDoubleKeyFrame
KeyTime="00:00:01.5000000"
Value="151" />
<SplineDoubleKeyFrame
KeyTime="00:00:02"
Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="popup"
Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="0.1" />
<SplineDoubleKeyFrame
KeyTime="00:00:02"
Value="1" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="ellipse"
Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="0.47" />
<SplineDoubleKeyFrame
KeyTime="00:00:01"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:01.5000000"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:02"
Value="0.685" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames
BeginTime="00:00:00"
Storyboard.TargetName="border"
Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame
KeyTime="00:00:00"
Value="1" />
<SplineDoubleKeyFrame
KeyTime="00:00:01"
Value="0.515" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<Window.Triggers>
<EventTrigger
RoutedEvent="tb:TaskbarIcon.TaskbarIconLeftMouseUp"
SourceName="tb">
<BeginStoryboard
Storyboard="{StaticResource OnTaskbarIconLeftMouseUp1}" />
</EventTrigger>
</Window.Triggers>
<Grid>
<tb:TaskbarIcon
x:Name="tb"
VerticalAlignment="Top"
IconSource="{Binding Path=SelectedItem.Source, ElementName=iconList, Mode=Default}"
ContextMenu="{DynamicResource tbMenu}"
ToolTip="hello world"
ToolTipText="{Binding Path=Text, ElementName=txtToolTipText, Mode=Default}"
Visibility="{Binding Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, ElementName=iconVisibility, Mode=Default}"
MenuActivation="{Binding Path=SelectedItem, ElementName=lstMenuTrigger, Mode=Default}"
PopupActivation="{Binding Path=SelectedItem, ElementName=lstPopupTrigger, Mode=Default}">
<tb:TaskbarIcon.TaskbarIconPopup>
<local:FancyPopup />
</tb:TaskbarIcon.TaskbarIconPopup>
<tb:TaskbarIcon.TaskbarIconToolTip>
<!-- the control will be put into a tooltip with an explicit DataContext -->
<local:FancyToolTip
Opacity="0.85"
InfoText="{Binding Path=ToolTipText}" />
</tb:TaskbarIcon.TaskbarIconToolTip>
</tb:TaskbarIcon>
<Button
x:Name="btn"
Click="OnClick"
Content="Click me"
Height="24"
Margin="0,70,68,0"
VerticalAlignment="Top"
Width="73"
HorizontalAlignment="Right" />
<Button
Height="23"
HorizontalAlignment="Right"
Margin="0,116,66,0"
x:Name="button1"
VerticalAlignment="Top"
Width="75"
Content="Button" />
<Popup
x:Name="popup"
Margin="-231,-276,231,0"
VerticalAlignment="Top"
Height="549"
d:IsHidden="True"
d:IsLocked="True">
<Grid
Width="180"
Height="227">
<Border
CornerRadius="10,10,10,10"
x:Name="border">
<Border.Background>
<LinearGradientBrush
EndPoint="0.5,1"
StartPoint="0.5,0">
<GradientStop
Color="#FFF4B569"
Offset="0" />
<GradientStop
Color="#FFFFFFFF"
Offset="1" />
</LinearGradientBrush>
</Border.Background>
</Border>
<Ellipse
Fill="#FFC13E3E"
Stroke="#FF000000"
VerticalAlignment="Top"
Height="58"
Margin="51,19,75,0"
x:Name="ellipse"
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>
</Grid>
</Popup>
<CheckBox
HorizontalAlignment="Left"
Margin="8,116,0,0"
VerticalAlignment="Top"
Width="155.42"
Content="Taskbar Icon Visible"
x:Name="iconVisibility"
IsChecked="True" />
<ListBox
HorizontalAlignment="Left"
Margin="8,171,0,0"
Width="123"
IsSynchronizedWithCurrentItem="True"
Height="51"
VerticalAlignment="Top"
x:Name="iconList"
SelectedIndex="0">
<Image
Width="16"
Margin="0,4,0,0"
Height="16"
Source="Icons\Inactive.ico" />
<Image
Width="16"
Margin="0,4,0,0"
Height="16"
Source="Icons\Error.ico" />
</ListBox>
<TextBlock
HorizontalAlignment="Left"
Margin="8,149,0,0"
VerticalAlignment="Top"
Width="Auto"
Height="22"
TextWrapping="Wrap"><Run
Text="Taskbar Icon:"
Language="de-ch" /></TextBlock>
<Grid
Margin="0,0,10,24"
VerticalAlignment="Bottom"
Height="242"
Width="358"
HorizontalAlignment="Right"
x:Name="Balloons">
<Border
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
BorderBrush="#FF000000"
BorderThickness="2,2,2,2" />
<TextBox
Margin="127,20,15,0"
x:Name="txtBalloonTitle"
VerticalAlignment="Top"
Height="23" />
<TextBox
Margin="127,65,15,97"
x:Name="txtBalloonText" />
<RadioButton
HorizontalAlignment="Left"
Margin="14,0,0,54"
VerticalAlignment="Bottom"
Width="111"
Height="22"
Content="Show as Info"
IsChecked="True" />
<TextBlock
HorizontalAlignment="Left"
Margin="14,20,0,0"
VerticalAlignment="Top"
Width="85"
Height="23"
TextWrapping="Wrap"><Run
Text="Balloon Title"
Language="de-ch" /></TextBlock>
<TextBlock
Margin="14,65,0,0"
VerticalAlignment="Top"
Height="23"
TextWrapping="Wrap"
HorizontalAlignment="Left"
Width="85"><Run
Text="Balloon Text"
Language="de-ch" /></TextBlock>
<RadioButton
Margin="14,0,0,32"
VerticalAlignment="Bottom"
Height="22"
Content="Show as Error"
HorizontalAlignment="Left"
Width="111" />
<RadioButton
Margin="14,0,0,10"
VerticalAlignment="Bottom"
Height="22"
Content="Show Custom Icon"
HorizontalAlignment="Left"
Width="130" />
<Button
HorizontalAlignment="Right"
Margin="0,0,21,12.52"
x:Name="showBalloonTip"
Width="120"
Content="Show Balloon Tip"
VerticalAlignment="Bottom"
Height="23" />
</Grid>
<Grid
HorizontalAlignment="Left"
Margin="12,0,0,24"
VerticalAlignment="Bottom"
Width="307"
Height="242"
x:Name="Popups">
<Border
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
BorderBrush="#FF000000"
BorderThickness="2,2,2,2" />
<ListBox
IsSynchronizedWithCurrentItem="False"
x:Name="lstPopupTrigger"
ItemsSource="{Binding Mode=OneWay, Source={StaticResource ActivationModes}}"
Margin="14,115,97,10"
SelectedIndex="0" />
<RadioButton
HorizontalAlignment="Left"
Margin="14,19,0,0"
VerticalAlignment="Top"
Width="Auto"
Height="22"
Content="Use simple Popup"
IsChecked="True" />
<RadioButton
Margin="14,41,97,0"
VerticalAlignment="Top"
Height="22"
Content="Use Popup with Storyboard" />
<TextBlock
Margin="14,83,106,0"
TextWrapping="Wrap"
VerticalAlignment="Top"
Height="22"><Run
Text="Display Popup on:"
Language="de-ch" /></TextBlock>
</Grid>
<Grid
Margin="0,323,10,276"
Width="358"
HorizontalAlignment="Right"
x:Name="ToolTips">
<Border
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
BorderBrush="#FF000000"
BorderThickness="2,2,2,2" />
<RadioButton
Margin="14,38,10,42"
Content="Use custom ToolTip on MouseOver (Vista and above)" />
<RadioButton
Margin="14,60,97,0"
VerticalAlignment="Top"
Height="22"
Content="Use custom ToolTip with Storyboard" />
<RadioButton
Margin="14,16,10,0"
Content="Only use ToolTipText (no custom tooltip)"
VerticalAlignment="Top"
Height="22"
IsChecked="True" />
<TextBox
Margin="14,0,21,19"
x:Name="txtToolTipText"
VerticalAlignment="Bottom"
Height="23"
Text="Click to open tooltip" />
<TextBlock
Margin="14,0,157,52"
VerticalAlignment="Bottom"
Height="16"
TextWrapping="Wrap"><Run
Text="ToolTip Text:"
Language="de-ch" /></TextBlock>
</Grid>
<Grid
HorizontalAlignment="Left"
Margin="12,323,0,276"
Width="307"
x:Name="ContextMenus">
<Border
BorderBrush="#FF000000"
BorderThickness="2,2,2,2" />
<ListBox
Margin="10,0,128,10"
IsSynchronizedWithCurrentItem="False"
x:Name="lstMenuTrigger"
ItemsSource="{Binding Mode=OneWay, Source={StaticResource ActivationModes}}"
Height="124"
VerticalAlignment="Bottom"
SelectedIndex="1" />
<TextBlock
Margin="10,10,110,0"
VerticalAlignment="Top"
Height="22"
TextWrapping="Wrap"><Run
Text="Trigger Context Menu:"
Language="de-ch" /></TextBlock>
</Grid>
<TextBlock
Margin="10,10,45,0"
VerticalAlignment="Top"
Height="Auto"
TextWrapping="Wrap"
FontWeight="Bold"
FontSize="14"><Run
Text="This window only contains the plumbing. In order to keep things separated, I created a few user controls for the popups and the TaskbarIcon instance."
Language="de-ch" /></TextBlock>
</Grid>
</Window>