WPF NotifyIcon

--------------
CHG   Changed show/hide functionality in order to work better with showcase window (which is no longer the app's main window).

git-svn-id: https://svn.evolvesoftware.ch/repos/evolve.net/WPF/NotifyIcon@105 9f600761-6f11-4665-b6dc-0185e9171623
This commit is contained in:
Philipp Sumi
2009-05-16 12:14:02 +00:00
parent 97ef369a02
commit c8c988bb17
16 changed files with 219 additions and 207 deletions

View File

@@ -27,9 +27,14 @@
</Setter>
</Style>
<!-- The taskbar context menu - the first row is a dummy to show of simple data binding -->
<!--
The "shared" directive is needed if we reopen the sample a few times - WPF will otherwise
reuse the same context menu again (which will have its DataContext set to the old TaskbarIcon)
-->
<ContextMenu
x:Shared="false"
x:Key="tbMenu">
<MenuItem
IsEnabled="False"
@@ -43,8 +48,9 @@
</MenuItem>
<MenuItem
Header="Show Main Window"
Command="{Commands:ShowMainWindowCommand}">
Header="Show Showcase Window"
Command="{Commands:ShowSampleWindowCommand}"
CommandParameter="{Binding}">
<MenuItem.Icon>
<Image
Width="16"
@@ -56,8 +62,9 @@
<Separator />
<MenuItem
Header="Hide Main Window"
Command="{Commands:HideMainWindowCommand}">
Header="Hide Showcase Window"
Command="{Commands:HideSampleWindowCommand}"
CommandParameter="{Binding}">
<MenuItem.Icon>
<Image
Width="16"
@@ -68,88 +75,4 @@
</ContextMenu>
<ToolTip
x:Key="tbToolTip"
Background="Transparent"
BorderThickness="0"
HasDropShadow="False"
VerticalOffset="-10"
>
<Grid
>
<Border
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Width="Auto"
Height="Auto"
CornerRadius="6,6,6,6"
BorderThickness="3,3,3,3"
Margin="0,0,5,5">
<Border.Effect>
<DropShadowEffect
Color="#FF7A7A7A" />
</Border.Effect>
<Border.Background>
<LinearGradientBrush
EndPoint="0.5,1"
StartPoint="0.5,0">
<GradientStop
Color="#FFFFD283"
Offset="0" />
<GradientStop
Color="#FFFFFFFF"
Offset="1" />
</LinearGradientBrush>
</Border.Background>
</Border>
<Image
HorizontalAlignment="Left"
Margin="10,10,0,26"
Width="72"
Source="Images\Info.png"
Stretch="Fill"
VerticalAlignment="Top"
RenderTransformOrigin="0.792,0.486" />
<TextBlock
Margin="82,10,20,0"
TextWrapping="Wrap"
Height="32"
VerticalAlignment="Top"
FontSize="16"
FontWeight="Bold"
Foreground="#FF575757"><Run
Text="This is a fancy ToolTip..."
Language="de-ch" /></TextBlock>
<TextBlock
FontSize="12"
FontWeight="Normal"
Foreground="#FF141414"
TextWrapping="Wrap"
Margin="82,52,20,0"
VerticalAlignment="Top"
Text="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type tb:TaskbarIcon}}, Path=ToolTipText}"
/>
</Grid>
</ToolTip>
<!--
As we don't declare the popup with the control, use
commands to trigger an action.
-->
<Popup
x:Key="tbPopupSimple"
PopupAnimation="Slide"
Placement="Mouse"
AllowsTransparency="True"
StaysOpen="False"
>
<Border
Width="200"
Height="200"
Background="Red">
<Button>Click me</Button>
</Border>
</Popup>
</ResourceDictionary>

View File

@@ -70,7 +70,9 @@
Visibility="{Binding Path=IsChecked, Converter={StaticResource BooleanToVisibilityConverter}, ElementName=iconVisibility, Mode=Default}"
MenuActivation="{Binding Path=SelectedItem, ElementName=lstMenuTrigger, Mode=Default}"
PopupActivation="{Binding Path=SelectedItem, ElementName=lstPopupTrigger, Mode=Default}"
DoubleClickCommand="{Commands:ShowMainWindowCommand}">
DoubleClickCommand="{Commands:ShowSampleWindowCommand}"
DoubleClickCommandParameter="{Binding RelativeSource={RelativeSource Self}}"
>
<tb:TaskbarIcon.TrayPopup>
<!-- the control will be put into a popup with an explicit DataContext -->