Files
wpf-notifyicon/Source/Sample Project/Window1.xaml.cs
Philipp Sumi f349d3d339 WPF NotifyIcon
--------------
CHG   Generally improved sample project - added more bindings, welcome balloon, changed layout.
CHG   Changed namespace in sample project. Preparing tutorials.

git-svn-id: https://svn.evolvesoftware.ch/repos/evolve.net/WPF/NotifyIcon@101 9f600761-6f11-4665-b6dc-0185e9171623
2009-05-13 09:32:55 +00:00

86 lines
2.1 KiB
C#

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
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
Loaded += delegate
{
//show balloon at startup
var balloon = new WelcomeBalloon();
tb.ShowCustomBalloon(balloon, PopupAnimation.Slide, 12000);
};
}
/// <summary>
/// Displays a balloon tip.
/// </summary>
private void showBalloonTip_Click(object sender, RoutedEventArgs e)
{
string title = txtBalloonTitle.Text;
string message = txtBalloonText.Text;
if (rbCustomIcon.IsChecked == true)
{
//just display the icon on the tray
var icon = tb.Icon;
tb.ShowBalloonTip(title, message, icon);
}
else
{
BalloonIcon bi = rbInfo.IsChecked == true ? BalloonIcon.Info : BalloonIcon.Error;
tb.ShowBalloonTip(title, message, bi);
}
}
private void hideBalloonTip_Click(object sender, RoutedEventArgs e)
{
tb.HideBalloonTip();
}
/// <summary>
/// Resets the tooltip.
/// </summary>
private void removeToolTip_Click(object sender, RoutedEventArgs e)
{
tb.TrayToolTip = null;
}
private void showCustomBalloon_Click(object sender, RoutedEventArgs e)
{
FancyBalloon balloon = new FancyBalloon();
balloon.BalloonText = customBalloonTitle.Text;
//show and close after 2.5 seconds
tb.ShowCustomBalloon(balloon, PopupAnimation.Slide, 5000);
}
private void hideCustomBalloon_Click(object sender, RoutedEventArgs e)
{
tb.CloseBalloon();
}
private void OnNavigationRequest(object sender, RequestNavigateEventArgs e)
{
Process.Start(e.Uri.ToString());
e.Handled = true;
}
}
}