mirror of
https://github.com/ckaczor/wpf-notifyicon.git
synced 2026-01-14 10:00:10 -05:00
-------------- ADD Added ParentTaskbarIcon attached dependency property which is set for tooltips, popups, and custom balloons. CHG Made CloseBalloon public. CHG Changed sample, cleaned up commands pattern. git-svn-id: https://svn.evolvesoftware.ch/repos/evolve.net/WPF/NotifyIcon@93 9f600761-6f11-4665-b6dc-0185e9171623
75 lines
1.8 KiB
C#
75 lines
1.8 KiB
C#
using System.Windows;
|
|
using System.Windows.Controls.Primitives;
|
|
using Hardcodet.Wpf.TaskbarNotification;
|
|
|
|
namespace Sample_Project
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for Window1.xaml
|
|
/// </summary>
|
|
public partial class Window1 : Window
|
|
{
|
|
public Window1()
|
|
{
|
|
InitializeComponent();
|
|
|
|
|
|
Loaded += delegate
|
|
{
|
|
//show balloon at startup, pointing to the icon
|
|
showBalloonTip_Click(null, null);
|
|
};
|
|
}
|
|
|
|
|
|
/// <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();
|
|
}
|
|
}
|
|
} |