mirror of
https://github.com/ckaczor/wpf-notifyicon.git
synced 2026-01-24 01:35:39 -05:00
CHG Reformatting code (NTFY-20).
git-svn-id: https://svn.evolvesoftware.ch/repos/evolve.net/WPF/NotifyIcon@192 9f600761-6f11-4665-b6dc-0185e9171623
This commit is contained in:
@@ -1,114 +1,129 @@
|
||||
<UserControl
|
||||
x:Class="Samples.FancyPopup"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="215"
|
||||
Width="300" x:Name="me">
|
||||
<UserControl.Resources>
|
||||
<Storyboard x:Key="RotateIcon">
|
||||
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="image" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
|
||||
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
|
||||
<SplineDoubleKeyFrame KeySpline="0,0.284,0.39,1" KeyTime="00:00:01.4000000" Value="360"/>
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</UserControl.Resources>
|
||||
<UserControl.Triggers>
|
||||
<EventTrigger RoutedEvent="tb:TaskbarIcon.PopupOpened">
|
||||
<BeginStoryboard Storyboard="{StaticResource RotateIcon}" x:Name="RotateIcon_BeginStoryboard"/>
|
||||
</EventTrigger>
|
||||
</UserControl.Triggers>
|
||||
<Grid>
|
||||
<Border
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Width="Auto"
|
||||
Height="Auto"
|
||||
Margin="5,5,5,5"
|
||||
CornerRadius="10,10,10,10">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect
|
||||
Color="#FF474747" />
|
||||
</Border.Effect>
|
||||
<Border.Background>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0.5,1"
|
||||
StartPoint="0.5,0">
|
||||
<GradientStop
|
||||
Color="#FF58C2FF"
|
||||
Offset="0" />
|
||||
<GradientStop
|
||||
Color="#FFFFFFFF"
|
||||
Offset="1" />
|
||||
</LinearGradientBrush>
|
||||
</Border.Background>
|
||||
</Border>
|
||||
<Image
|
||||
HorizontalAlignment="Left"
|
||||
Margin="19,10,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="72"
|
||||
Height="72"
|
||||
Source="/Images/Preferences.png"
|
||||
Stretch="Fill" x:Name="image" RenderTransformOrigin="0.5,0.5" >
|
||||
<Image.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform ScaleX="1" ScaleY="1"/>
|
||||
<SkewTransform AngleX="0" AngleY="0"/>
|
||||
<RotateTransform Angle="0"/>
|
||||
<TranslateTransform X="0" Y="0"/>
|
||||
</TransformGroup>
|
||||
</Image.RenderTransform>
|
||||
</Image>
|
||||
<TextBlock
|
||||
Margin="107,10,20,0"
|
||||
TextWrapping="Wrap"
|
||||
Height="Auto"
|
||||
VerticalAlignment="Top"
|
||||
FontSize="16"
|
||||
FontWeight="Bold"
|
||||
Foreground="#FF575757" HorizontalAlignment="Right"><Run
|
||||
Text="This is a fancy Popup..."
|
||||
Language="de-ch" /></TextBlock>
|
||||
<Button
|
||||
Click="OnButtonClick"
|
||||
ToolTip="{Binding Path=ToolTipText}"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Width="89"
|
||||
Height="29"
|
||||
Content="Click me"
|
||||
Margin="0,0,20,20"
|
||||
BorderBrush="#FFFFFFFF">
|
||||
<Button.Background>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0,1"
|
||||
StartPoint="0,0">
|
||||
<GradientStop
|
||||
Color="#FFFFFFFF"
|
||||
Offset="1" />
|
||||
<GradientStop
|
||||
Color="#FFFFD197"
|
||||
Offset="0.459" />
|
||||
<GradientStop
|
||||
Color="#FFFFDBAD"
|
||||
Offset="0" />
|
||||
<GradientStop
|
||||
Color="#FFF18E23"
|
||||
Offset="0.508" />
|
||||
<GradientStop
|
||||
Color="#FFF9D4AC"
|
||||
Offset="0.954" />
|
||||
</LinearGradientBrush>
|
||||
</Button.Background>
|
||||
</Button>
|
||||
<TextBlock
|
||||
Margin="19,92,10,49"
|
||||
TextWrapping="Wrap"><Run Text="This user control makes use of the " Language="de-ch"/><Run FontStyle="Italic" FontWeight="Bold" Text="PopupOpened " Language="de-ch"/><Run Text="attached routed event . Whenever the popup is opened, this attached event fires and triggers the rotation animation." Language="de-ch"/></TextBlock>
|
||||
<TextBlock Margin="0,52,20,0" VerticalAlignment="Top" Height="Auto" TextWrapping="Wrap" FontWeight="Bold" FontSize="14" HorizontalAlignment="Right" Foreground="#FF575757"><Run Text="Clicks: " Language="de-ch"/><InlineUIContainer>
|
||||
<TextBlock Width="Auto" Height="Auto" Text="{Binding Path=ClickCount, ElementName=me, Mode=Default}" TextWrapping="Wrap"/>
|
||||
</InlineUIContainer></TextBlock>
|
||||
<Image
|
||||
Source="{Binding Path=IconSource}" Width="16" HorizontalAlignment="Left" Margin="19,0,0,23" Height="16" VerticalAlignment="Bottom" />
|
||||
x:Class="Samples.FancyPopup"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:tb="http://www.hardcodet.net/taskbar"
|
||||
Height="215"
|
||||
Width="300" x:Name="me">
|
||||
<UserControl.Resources>
|
||||
<Storyboard x:Key="RotateIcon">
|
||||
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="image"
|
||||
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
|
||||
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0" />
|
||||
<SplineDoubleKeyFrame KeySpline="0,0.284,0.39,1" KeyTime="00:00:01.4000000" Value="360" />
|
||||
</DoubleAnimationUsingKeyFrames>
|
||||
</Storyboard>
|
||||
</UserControl.Resources>
|
||||
<UserControl.Triggers>
|
||||
<EventTrigger RoutedEvent="tb:TaskbarIcon.PopupOpened">
|
||||
<BeginStoryboard Storyboard="{StaticResource RotateIcon}" x:Name="RotateIcon_BeginStoryboard" />
|
||||
</EventTrigger>
|
||||
</UserControl.Triggers>
|
||||
<Grid>
|
||||
<Border
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
Width="Auto"
|
||||
Height="Auto"
|
||||
Margin="5,5,5,5"
|
||||
CornerRadius="10,10,10,10">
|
||||
<Border.Effect>
|
||||
<DropShadowEffect
|
||||
Color="#FF474747" />
|
||||
</Border.Effect>
|
||||
<Border.Background>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0.5,1"
|
||||
StartPoint="0.5,0">
|
||||
<GradientStop
|
||||
Color="#FF58C2FF"
|
||||
Offset="0" />
|
||||
<GradientStop
|
||||
Color="#FFFFFFFF"
|
||||
Offset="1" />
|
||||
</LinearGradientBrush>
|
||||
</Border.Background>
|
||||
</Border>
|
||||
<Image
|
||||
HorizontalAlignment="Left"
|
||||
Margin="19,10,0,0"
|
||||
VerticalAlignment="Top"
|
||||
Width="72"
|
||||
Height="72"
|
||||
Source="/Images/Preferences.png"
|
||||
Stretch="Fill" x:Name="image" RenderTransformOrigin="0.5,0.5">
|
||||
<Image.RenderTransform>
|
||||
<TransformGroup>
|
||||
<ScaleTransform ScaleX="1" ScaleY="1" />
|
||||
<SkewTransform AngleX="0" AngleY="0" />
|
||||
<RotateTransform Angle="0" />
|
||||
<TranslateTransform X="0" Y="0" />
|
||||
</TransformGroup>
|
||||
</Image.RenderTransform>
|
||||
</Image>
|
||||
<TextBlock
|
||||
Margin="107,10,20,0"
|
||||
TextWrapping="Wrap"
|
||||
Height="Auto"
|
||||
VerticalAlignment="Top"
|
||||
FontSize="16"
|
||||
FontWeight="Bold"
|
||||
Foreground="#FF575757" HorizontalAlignment="Right">
|
||||
<Run
|
||||
Text="This is a fancy Popup..."
|
||||
Language="de-ch" />
|
||||
</TextBlock>
|
||||
<Button
|
||||
Click="OnButtonClick"
|
||||
ToolTip="{Binding Path=ToolTipText}"
|
||||
HorizontalAlignment="Right"
|
||||
VerticalAlignment="Bottom"
|
||||
Width="89"
|
||||
Height="29"
|
||||
Content="Click me"
|
||||
Margin="0,0,20,20"
|
||||
BorderBrush="#FFFFFFFF">
|
||||
<Button.Background>
|
||||
<LinearGradientBrush
|
||||
EndPoint="0,1"
|
||||
StartPoint="0,0">
|
||||
<GradientStop
|
||||
Color="#FFFFFFFF"
|
||||
Offset="1" />
|
||||
<GradientStop
|
||||
Color="#FFFFD197"
|
||||
Offset="0.459" />
|
||||
<GradientStop
|
||||
Color="#FFFFDBAD"
|
||||
Offset="0" />
|
||||
<GradientStop
|
||||
Color="#FFF18E23"
|
||||
Offset="0.508" />
|
||||
<GradientStop
|
||||
Color="#FFF9D4AC"
|
||||
Offset="0.954" />
|
||||
</LinearGradientBrush>
|
||||
</Button.Background>
|
||||
</Button>
|
||||
<TextBlock
|
||||
Margin="19,92,10,49"
|
||||
TextWrapping="Wrap">
|
||||
<Run Text="This user control makes use of the " Language="de-ch" />
|
||||
<Run FontStyle="Italic" FontWeight="Bold" Text="PopupOpened " Language="de-ch" />
|
||||
<Run
|
||||
Text="attached routed event . Whenever the popup is opened, this attached event fires and triggers the rotation animation."
|
||||
Language="de-ch" />
|
||||
</TextBlock>
|
||||
<TextBlock Margin="0,52,20,0" VerticalAlignment="Top" Height="Auto" TextWrapping="Wrap" FontWeight="Bold"
|
||||
FontSize="14" HorizontalAlignment="Right" Foreground="#FF575757">
|
||||
<Run Text="Clicks: " Language="de-ch" />
|
||||
<InlineUIContainer>
|
||||
<TextBlock Width="Auto" Height="Auto" Text="{Binding Path=ClickCount, ElementName=me, Mode=Default}"
|
||||
TextWrapping="Wrap" />
|
||||
</InlineUIContainer>
|
||||
</TextBlock>
|
||||
<Image
|
||||
Source="{Binding Path=IconSource}" Width="16" HorizontalAlignment="Left" Margin="19,0,0,23" Height="16"
|
||||
VerticalAlignment="Bottom" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
</UserControl>
|
||||
@@ -2,44 +2,44 @@
|
||||
|
||||
namespace Samples
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for FancyPopup.xaml
|
||||
/// </summary>
|
||||
public partial class FancyPopup
|
||||
{
|
||||
#region ClickCount dependency property
|
||||
|
||||
/// <summary>
|
||||
/// The number of clicks on the popup button.
|
||||
/// Interaction logic for FancyPopup.xaml
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ClickCountProperty =
|
||||
DependencyProperty.Register("ClickCount",
|
||||
typeof (int),
|
||||
typeof (FancyPopup),
|
||||
new FrameworkPropertyMetadata(0));
|
||||
|
||||
/// <summary>
|
||||
/// A property wrapper for the <see cref="ClickCountProperty"/>
|
||||
/// dependency property:<br/>
|
||||
/// The number of clicks on the popup button.
|
||||
/// </summary>
|
||||
public int ClickCount
|
||||
public partial class FancyPopup
|
||||
{
|
||||
get { return (int) GetValue(ClickCountProperty); }
|
||||
set { SetValue(ClickCountProperty, value); }
|
||||
}
|
||||
#region ClickCount dependency property
|
||||
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// The number of clicks on the popup button.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ClickCountProperty =
|
||||
DependencyProperty.Register("ClickCount",
|
||||
typeof (int),
|
||||
typeof (FancyPopup),
|
||||
new FrameworkPropertyMetadata(0));
|
||||
|
||||
public FancyPopup()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
/// <summary>
|
||||
/// A property wrapper for the <see cref="ClickCountProperty"/>
|
||||
/// dependency property:<br/>
|
||||
/// The number of clicks on the popup button.
|
||||
/// </summary>
|
||||
public int ClickCount
|
||||
{
|
||||
get { return (int) GetValue(ClickCountProperty); }
|
||||
set { SetValue(ClickCountProperty, value); }
|
||||
}
|
||||
|
||||
private void OnButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//just increment a counter - will be displayed on screen
|
||||
ClickCount++;
|
||||
#endregion
|
||||
|
||||
public FancyPopup()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void OnButtonClick(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//just increment a counter - will be displayed on screen
|
||||
ClickCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,33 +7,33 @@ using WindowsFormsSample.Properties;
|
||||
|
||||
namespace WindowsFormsSample
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
private TaskbarIcon notifyIcon;
|
||||
|
||||
public Form1()
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
InitializeComponent();
|
||||
private TaskbarIcon notifyIcon;
|
||||
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
notifyIcon = new TaskbarIcon();
|
||||
notifyIcon.Icon = Resources.Led;
|
||||
notifyIcon.ToolTipText = "Left-click to open popup";
|
||||
notifyIcon.Visibility = Visibility.Visible;
|
||||
|
||||
notifyIcon.TrayPopup = new FancyPopup();
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
base.OnClosed(e);
|
||||
|
||||
//the notify icon only closes automatically on WPF applications
|
||||
//-> dispose the notify icon manually
|
||||
notifyIcon.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
base.OnLoad(e);
|
||||
notifyIcon = new TaskbarIcon();
|
||||
notifyIcon.Icon = Resources.Led;
|
||||
notifyIcon.ToolTipText = "Left-click to open popup";
|
||||
notifyIcon.Visibility = Visibility.Visible;
|
||||
|
||||
notifyIcon.TrayPopup = new FancyPopup();
|
||||
}
|
||||
|
||||
protected override void OnClosed(EventArgs e)
|
||||
{
|
||||
base.OnClosed(e);
|
||||
|
||||
//the notify icon only closes automatically on WPF applications
|
||||
//-> dispose the notify icon manually
|
||||
notifyIcon.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,17 +4,17 @@ using Samples;
|
||||
|
||||
namespace WindowsFormsSample
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
internal static class Program
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
private static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new Form1());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using System.Runtime.InteropServices;
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
|
||||
[assembly: AssemblyTitle("WindowsFormsSample")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
@@ -17,9 +18,11 @@ using System.Runtime.InteropServices;
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
|
||||
[assembly: Guid("072bbfa0-9b8b-48df-bf88-3e4806b3e3e8")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
@@ -32,5 +35,6 @@ using System.Runtime.InteropServices;
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
@@ -1,7 +1,8 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
</SettingsFile>
|
||||
Reference in New Issue
Block a user