2 using System.Collections.Generic;
\r
5 using System.Windows;
\r
6 using System.Windows.Controls;
\r
7 using System.Windows.Controls.Primitives;
\r
8 using System.Windows.Data;
\r
9 using System.Windows.Documents;
\r
10 using System.Windows.Input;
\r
11 using System.Windows.Media;
\r
12 using System.Windows.Media.Imaging;
\r
13 using System.Windows.Navigation;
\r
14 using System.Windows.Shapes;
\r
15 using Hardcodet.Wpf.TaskbarNotification;
\r
17 namespace Pithos.Client.WPF.Shell
\r
20 /// Interaction logic for PithosBalloon.xaml
\r
22 public partial class PithosBalloon : UserControl
\r
24 private bool isClosing = false;
\r
26 #region BalloonText dependency property
\r
31 public static readonly DependencyProperty BalloonTextProperty =
\r
32 DependencyProperty.Register("BalloonText",
\r
34 typeof (PithosBalloon),
\r
35 new FrameworkPropertyMetadata(""));
\r
38 /// A property wrapper for the <see cref="BalloonTextProperty"/>
\r
39 /// dependency property:<br/>
\r
42 public string BalloonText
\r
44 get { return (string) GetValue(BalloonTextProperty); }
\r
45 set { SetValue(BalloonTextProperty, value); }
\r
51 public PithosBalloon()
\r
53 InitializeComponent();
\r
54 TaskbarIcon.AddBalloonClosingHandler(this, OnBalloonClosing);
\r
59 /// By subscribing to the <see cref="TaskbarIcon.BalloonClosingEvent"/>
\r
60 /// and setting the "Handled" property to true, we suppress the popup
\r
61 /// from being closed in order to display the fade-out animation.
\r
63 private void OnBalloonClosing(object sender, RoutedEventArgs e)
\r
71 /// Resolves the <see cref="TaskbarIcon"/> that displayed
\r
72 /// the balloon and requests a close action.
\r
74 private void imgClose_MouseDown(object sender, MouseButtonEventArgs e)
\r
76 //the tray icon assigned this attached property to simplify access
\r
77 TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);
\r
78 taskbarIcon.CloseBalloon();
\r
82 /// If the users hovers over the balloon, we don't close it.
\r
84 private void grid_MouseEnter(object sender, MouseEventArgs e)
\r
86 //if we're already running the fade-out animation, do not interrupt anymore
\r
87 //(makes things too complicated for the sample)
\r
88 if (isClosing) return;
\r
90 //the tray icon assigned this attached property to simplify access
\r
91 TaskbarIcon taskbarIcon = TaskbarIcon.GetParentTaskbarIcon(this);
\r
92 taskbarIcon.ResetBalloonCloseTimer();
\r
97 /// Closes the popup once the fade-out animation completed.
\r
98 /// The animation was triggered in XAML through the attached
\r
99 /// BalloonClosing event.
\r
101 private void OnFadeOutCompleted(object sender, EventArgs e)
\r
103 Popup pp = (Popup)Parent;
\r