root / trunk / NotifyIconWpf / TaskbarIcon.Declarations.cs @ 049333d2
History | View | Annotate | Download (66.3 kB)
1 |
// hardcodet.net NotifyIcon for WPF |
---|---|
2 |
// Copyright (c) 2009 Philipp Sumi |
3 |
// Contact and Information: http://www.hardcodet.net |
4 |
// |
5 |
// This library is free software; you can redistribute it and/or |
6 |
// modify it under the terms of the Code Project Open License (CPOL); |
7 |
// either version 1.0 of the License, or (at your option) any later |
8 |
// version. |
9 |
// |
10 |
// The above copyright notice and this permission notice shall be |
11 |
// included in all copies or substantial portions of the Software. |
12 |
// |
13 |
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
14 |
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
15 |
// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
16 |
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
17 |
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
18 |
// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
19 |
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
20 |
// OTHER DEALINGS IN THE SOFTWARE. |
21 |
// |
22 |
// THIS COPYRIGHT NOTICE MAY NOT BE REMOVED FROM THIS FILE |
23 |
|
24 |
|
25 |
|
26 |
using System; |
27 |
using System.ComponentModel; |
28 |
using System.Drawing; |
29 |
using System.Windows; |
30 |
using System.Windows.Controls; |
31 |
using System.Windows.Controls.Primitives; |
32 |
using System.Windows.Input; |
33 |
using System.Windows.Media; |
34 |
using Hardcodet.Wpf.TaskbarNotification.Interop; |
35 |
|
36 |
namespace Hardcodet.Wpf.TaskbarNotification |
37 |
{ |
38 |
/// <summary> |
39 |
/// Contains declarations of WPF dependency properties |
40 |
/// and events. |
41 |
/// </summary> |
42 |
partial class TaskbarIcon |
43 |
{ |
44 |
/// <summary> |
45 |
/// Category name that is set on designer properties. |
46 |
/// </summary> |
47 |
public const string CategoryName = "NotifyIcon"; |
48 |
|
49 |
|
50 |
//POPUP CONTROLS |
51 |
|
52 |
#region TrayPopupResolved |
53 |
|
54 |
/// <summary> |
55 |
/// TrayPopupResolved Read-Only Dependency Property |
56 |
/// </summary> |
57 |
private static readonly DependencyPropertyKey TrayPopupResolvedPropertyKey |
58 |
= DependencyProperty.RegisterReadOnly("TrayPopupResolved", typeof(Popup), typeof(TaskbarIcon), |
59 |
new FrameworkPropertyMetadata(null)); |
60 |
|
61 |
|
62 |
/// <summary> |
63 |
/// A read-only dependency property that returns the <see cref="Popup"/> |
64 |
/// that is being displayed in the taskbar area based on a user action. |
65 |
/// </summary> |
66 |
public static readonly DependencyProperty TrayPopupResolvedProperty |
67 |
= TrayPopupResolvedPropertyKey.DependencyProperty; |
68 |
|
69 |
/// <summary> |
70 |
/// Gets the TrayPopupResolved property. Returns |
71 |
/// a <see cref="Popup"/> which is either the |
72 |
/// <see cref="TrayPopup"/> control itself or a |
73 |
/// <see cref="Popup"/> control that contains the |
74 |
/// <see cref="TrayPopup"/>. |
75 |
/// </summary> |
76 |
[Category(CategoryName)] |
77 |
public Popup TrayPopupResolved |
78 |
{ |
79 |
get { return (Popup)GetValue(TrayPopupResolvedProperty); } |
80 |
} |
81 |
|
82 |
/// <summary> |
83 |
/// Provides a secure method for setting the TrayPopupResolved property. |
84 |
/// This dependency property indicates .... |
85 |
/// </summary> |
86 |
/// <param name="value">The new value for the property.</param> |
87 |
protected void SetTrayPopupResolved(Popup value) |
88 |
{ |
89 |
SetValue(TrayPopupResolvedPropertyKey, value); |
90 |
} |
91 |
|
92 |
#endregion |
93 |
|
94 |
#region TrayToolTipResolved |
95 |
|
96 |
/// <summary> |
97 |
/// TrayToolTipResolved Read-Only Dependency Property |
98 |
/// </summary> |
99 |
private static readonly DependencyPropertyKey TrayToolTipResolvedPropertyKey |
100 |
= DependencyProperty.RegisterReadOnly("TrayToolTipResolved", typeof(ToolTip), typeof(TaskbarIcon), |
101 |
new FrameworkPropertyMetadata(null )); |
102 |
|
103 |
|
104 |
/// <summary> |
105 |
/// A read-only dependency property that returns the <see cref="ToolTip"/> |
106 |
/// that is being displayed. |
107 |
/// </summary> |
108 |
public static readonly DependencyProperty TrayToolTipResolvedProperty |
109 |
= TrayToolTipResolvedPropertyKey.DependencyProperty; |
110 |
|
111 |
/// <summary> |
112 |
/// Gets the TrayToolTipResolved property. Returns |
113 |
/// a <see cref="ToolTip"/> control that was created |
114 |
/// in order to display either <see cref="TrayToolTip"/> |
115 |
/// or <see cref="ToolTipText"/>. |
116 |
/// </summary> |
117 |
[Category(CategoryName)] |
118 |
[Browsable(true)] |
119 |
[Bindable(true)] |
120 |
public ToolTip TrayToolTipResolved |
121 |
{ |
122 |
get { return (ToolTip)GetValue(TrayToolTipResolvedProperty); } |
123 |
} |
124 |
|
125 |
/// <summary> |
126 |
/// Provides a secure method for setting the <see cref="TrayToolTipResolved"/> |
127 |
/// property. |
128 |
/// </summary> |
129 |
/// <param name="value">The new value for the property.</param> |
130 |
protected void SetTrayToolTipResolved(ToolTip value) |
131 |
{ |
132 |
SetValue(TrayToolTipResolvedPropertyKey, value); |
133 |
} |
134 |
|
135 |
#endregion |
136 |
|
137 |
#region CustomBalloon |
138 |
|
139 |
/// <summary> |
140 |
/// CustomBalloon Read-Only Dependency Property |
141 |
/// </summary> |
142 |
private static readonly DependencyPropertyKey CustomBalloonPropertyKey |
143 |
= DependencyProperty.RegisterReadOnly("CustomBalloon", typeof(Popup), typeof(TaskbarIcon), |
144 |
new FrameworkPropertyMetadata(null)); |
145 |
|
146 |
public static readonly DependencyProperty CustomBalloonProperty |
147 |
= CustomBalloonPropertyKey.DependencyProperty; |
148 |
|
149 |
/// <summary> |
150 |
/// A custom popup that is being displayed in the tray area in order |
151 |
/// to display messages to the user. |
152 |
/// </summary> |
153 |
public Popup CustomBalloon |
154 |
{ |
155 |
get { return (Popup)GetValue(CustomBalloonProperty); } |
156 |
} |
157 |
|
158 |
/// <summary> |
159 |
/// Provides a secure method for setting the <see cref="CustomBalloon"/> property. |
160 |
/// </summary> |
161 |
/// <param name="value">The new value for the property.</param> |
162 |
protected void SetCustomBalloon(Popup value) |
163 |
{ |
164 |
SetValue(CustomBalloonPropertyKey, value); |
165 |
} |
166 |
|
167 |
#endregion |
168 |
|
169 |
|
170 |
|
171 |
//DEPENDENCY PROPERTIES |
172 |
|
173 |
#region Icon property / IconSource dependency property |
174 |
|
175 |
private Icon icon; |
176 |
|
177 |
/// <summary> |
178 |
/// Gets or sets the icon to be displayed. This is not a |
179 |
/// dependency property - if you want to assign the property |
180 |
/// through XAML, please use the <see cref="IconSource"/> |
181 |
/// dependency property. |
182 |
/// </summary> |
183 |
[Browsable(false)] |
184 |
public Icon Icon |
185 |
{ |
186 |
get { return icon; } |
187 |
set |
188 |
{ |
189 |
icon = value; |
190 |
iconData.IconHandle = value == null ? IntPtr.Zero : icon.Handle; |
191 |
|
192 |
Util.WriteIconData(ref iconData, NotifyCommand.Modify, IconDataMembers.Icon); |
193 |
} |
194 |
} |
195 |
|
196 |
|
197 |
/// <summary> |
198 |
/// Resolves an image source and updates the <see cref="Icon" /> property accordingly. |
199 |
/// </summary> |
200 |
public static readonly DependencyProperty IconSourceProperty = |
201 |
DependencyProperty.Register("IconSource", |
202 |
typeof(ImageSource), |
203 |
typeof(TaskbarIcon), |
204 |
new FrameworkPropertyMetadata(null, IconSourcePropertyChanged)); |
205 |
|
206 |
/// <summary> |
207 |
/// A property wrapper for the <see cref="IconSourceProperty"/> |
208 |
/// dependency property:<br/> |
209 |
/// Resolves an image source and updates the <see cref="Icon" /> property accordingly. |
210 |
/// </summary> |
211 |
[Category(CategoryName)] |
212 |
[Description("Sets the displayed taskbar icon.")] |
213 |
public ImageSource IconSource |
214 |
{ |
215 |
get { return (ImageSource)GetValue(IconSourceProperty); } |
216 |
set { SetValue(IconSourceProperty, value); } |
217 |
} |
218 |
|
219 |
|
220 |
/// <summary> |
221 |
/// A static callback listener which is being invoked if the |
222 |
/// <see cref="IconSourceProperty"/> dependency property has |
223 |
/// been changed. Invokes the <see cref="OnIconSourcePropertyChanged"/> |
224 |
/// instance method of the changed instance. |
225 |
/// </summary> |
226 |
/// <param name="d">The currently processed owner of the property.</param> |
227 |
/// <param name="e">Provides information about the updated property.</param> |
228 |
private static void IconSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
229 |
{ |
230 |
TaskbarIcon owner = (TaskbarIcon)d; |
231 |
owner.OnIconSourcePropertyChanged(e); |
232 |
} |
233 |
|
234 |
|
235 |
/// <summary> |
236 |
/// Handles changes of the <see cref="IconSourceProperty"/> dependency property. As |
237 |
/// WPF internally uses the dependency property system and bypasses the |
238 |
/// <see cref="IconSource"/> property wrapper, updates of the property's value |
239 |
/// should be handled here. |
240 |
/// </summary |
241 |
/// <param name="e">Provides information about the updated property.</param> |
242 |
private void OnIconSourcePropertyChanged(DependencyPropertyChangedEventArgs e) |
243 |
{ |
244 |
ImageSource newValue = (ImageSource)e.NewValue; |
245 |
|
246 |
//resolving the ImageSource at design time is unlikely to work |
247 |
if (!Util.IsDesignMode) Icon = newValue.ToIcon(); |
248 |
} |
249 |
|
250 |
#endregion |
251 |
|
252 |
#region ToolTipText dependency property |
253 |
|
254 |
/// <summary> |
255 |
/// A tooltip text that is being displayed if no custom <see cref="ToolTip"/> |
256 |
/// was set or if custom tooltips are not supported. |
257 |
/// </summary> |
258 |
public static readonly DependencyProperty ToolTipTextProperty = |
259 |
DependencyProperty.Register("ToolTipText", |
260 |
typeof (string), |
261 |
typeof (TaskbarIcon), |
262 |
new FrameworkPropertyMetadata(String.Empty, ToolTipTextPropertyChanged)); |
263 |
|
264 |
|
265 |
/// <summary> |
266 |
/// A property wrapper for the <see cref="ToolTipTextProperty"/> |
267 |
/// dependency property:<br/> |
268 |
/// A tooltip text that is being displayed if no custom <see cref="ToolTip"/> |
269 |
/// was set or if custom tooltips are not supported. |
270 |
/// </summary> |
271 |
[Category(CategoryName)] |
272 |
[Description("Alternative to a fully blown ToolTip, which is only displayed on Vista and above.")] |
273 |
public string ToolTipText |
274 |
{ |
275 |
get { return (string) GetValue(ToolTipTextProperty); } |
276 |
set { SetValue(ToolTipTextProperty, value); } |
277 |
} |
278 |
|
279 |
|
280 |
/// <summary> |
281 |
/// A static callback listener which is being invoked if the |
282 |
/// <see cref="ToolTipTextProperty"/> dependency property has |
283 |
/// been changed. Invokes the <see cref="OnToolTipTextPropertyChanged"/> |
284 |
/// instance method of the changed instance. |
285 |
/// </summary> |
286 |
/// <param name="d">The currently processed owner of the property.</param> |
287 |
/// <param name="e">Provides information about the updated property.</param> |
288 |
private static void ToolTipTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
289 |
{ |
290 |
TaskbarIcon owner = (TaskbarIcon) d; |
291 |
owner.OnToolTipTextPropertyChanged(e); |
292 |
} |
293 |
|
294 |
|
295 |
/// <summary> |
296 |
/// Handles changes of the <see cref="ToolTipTextProperty"/> dependency property. As |
297 |
/// WPF internally uses the dependency property system and bypasses the |
298 |
/// <see cref="ToolTipText"/> property wrapper, updates of the property's value |
299 |
/// should be handled here. |
300 |
/// </summary |
301 |
/// <param name="e">Provides information about the updated property.</param> |
302 |
private void OnToolTipTextPropertyChanged(DependencyPropertyChangedEventArgs e) |
303 |
{ |
304 |
//only recreate tooltip if we're not using a custom control |
305 |
if (TrayToolTipResolved == null || TrayToolTipResolved.Content is string) |
306 |
{ |
307 |
CreateCustomToolTip(); |
308 |
} |
309 |
|
310 |
WriteToolTipSettings(); |
311 |
} |
312 |
|
313 |
#endregion |
314 |
|
315 |
#region TrayToolTip dependency property |
316 |
|
317 |
/// <summary> |
318 |
/// A custom UI element that is displayed as a tooltip if the user hovers over the taskbar icon. |
319 |
/// Works only with Vista and above. Accordingly, you should make sure that |
320 |
/// the <see cref="ToolTipText"/> property is set as well. |
321 |
/// </summary> |
322 |
public static readonly DependencyProperty TrayToolTipProperty = |
323 |
DependencyProperty.Register("TrayToolTip", |
324 |
typeof (UIElement), |
325 |
typeof (TaskbarIcon), |
326 |
new FrameworkPropertyMetadata(null, TrayToolTipPropertyChanged)); |
327 |
|
328 |
/// <summary> |
329 |
/// A property wrapper for the <see cref="TrayToolTipProperty"/> |
330 |
/// dependency property:<br/> |
331 |
/// A custom UI element that is displayed as a tooltip if the user hovers over the taskbar icon. |
332 |
/// Works only with Vista and above. Accordingly, you should make sure that |
333 |
/// the <see cref="ToolTipText"/> property is set as well. |
334 |
/// </summary> |
335 |
[Category(CategoryName)] |
336 |
[Description("Custom UI element that is displayed as a tooltip. Only on Vista and above")] |
337 |
public UIElement TrayToolTip |
338 |
{ |
339 |
get { return (UIElement) GetValue(TrayToolTipProperty); } |
340 |
set { SetValue(TrayToolTipProperty, value); } |
341 |
} |
342 |
|
343 |
|
344 |
/// <summary> |
345 |
/// A static callback listener which is being invoked if the |
346 |
/// <see cref="TrayToolTipProperty"/> dependency property has |
347 |
/// been changed. Invokes the <see cref="OnTrayToolTipPropertyChanged"/> |
348 |
/// instance method of the changed instance. |
349 |
/// </summary> |
350 |
/// <param name="d">The currently processed owner of the property.</param> |
351 |
/// <param name="e">Provides information about the updated property.</param> |
352 |
private static void TrayToolTipPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
353 |
{ |
354 |
TaskbarIcon owner = (TaskbarIcon) d; |
355 |
owner.OnTrayToolTipPropertyChanged(e); |
356 |
} |
357 |
|
358 |
|
359 |
/// <summary> |
360 |
/// Handles changes of the <see cref="TrayToolTipProperty"/> dependency property. As |
361 |
/// WPF internally uses the dependency property system and bypasses the |
362 |
/// <see cref="TrayToolTip"/> property wrapper, updates of the property's value |
363 |
/// should be handled here. |
364 |
/// </summary |
365 |
/// <param name="e">Provides information about the updated property.</param> |
366 |
private void OnTrayToolTipPropertyChanged(DependencyPropertyChangedEventArgs e) |
367 |
{ |
368 |
//recreate tooltip control |
369 |
CreateCustomToolTip(); |
370 |
|
371 |
if (e.OldValue != null) |
372 |
{ |
373 |
//remove the taskbar icon reference from the previously used element |
374 |
SetParentTaskbarIcon((DependencyObject) e.OldValue, null); |
375 |
} |
376 |
|
377 |
|
378 |
if (e.NewValue != null) |
379 |
{ |
380 |
//set this taskbar icon as a reference to the new tooltip element |
381 |
SetParentTaskbarIcon((DependencyObject) e.NewValue, this); |
382 |
} |
383 |
|
384 |
|
385 |
//update tooltip settings - needed to make sure a string is set, even |
386 |
//if the ToolTipText property is not set. Otherwise, the event that |
387 |
//triggers tooltip display is never fired. |
388 |
WriteToolTipSettings(); |
389 |
} |
390 |
|
391 |
#endregion |
392 |
|
393 |
#region TrayPopup dependency property |
394 |
|
395 |
/// <summary> |
396 |
/// A control that is displayed as a popup when the taskbar icon is clicked. |
397 |
/// </summary> |
398 |
public static readonly DependencyProperty TrayPopupProperty = |
399 |
DependencyProperty.Register("TrayPopup", |
400 |
typeof(UIElement), |
401 |
typeof (TaskbarIcon), |
402 |
new FrameworkPropertyMetadata(null, TrayPopupPropertyChanged)); |
403 |
|
404 |
/// <summary> |
405 |
/// A property wrapper for the <see cref="TrayPopupProperty"/> |
406 |
/// dependency property:<br/> |
407 |
/// A control that is displayed as a popup when the taskbar icon is clicked. |
408 |
/// </summary> |
409 |
[Category(CategoryName)] |
410 |
[Description("Displayed as a Popup if the user clicks on the taskbar icon.")] |
411 |
public UIElement TrayPopup |
412 |
{ |
413 |
get { return (UIElement)GetValue(TrayPopupProperty); } |
414 |
set { SetValue(TrayPopupProperty, value); } |
415 |
} |
416 |
|
417 |
|
418 |
/// <summary> |
419 |
/// A static callback listener which is being invoked if the |
420 |
/// <see cref="TrayPopupProperty"/> dependency property has |
421 |
/// been changed. Invokes the <see cref="OnTrayPopupPropertyChanged"/> |
422 |
/// instance method of the changed instance. |
423 |
/// </summary> |
424 |
/// <param name="d">The currently processed owner of the property.</param> |
425 |
/// <param name="e">Provides information about the updated property.</param> |
426 |
private static void TrayPopupPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
427 |
{ |
428 |
TaskbarIcon owner = (TaskbarIcon) d; |
429 |
owner.OnTrayPopupPropertyChanged(e); |
430 |
} |
431 |
|
432 |
|
433 |
/// <summary> |
434 |
/// Handles changes of the <see cref="TrayPopupProperty"/> dependency property. As |
435 |
/// WPF internally uses the dependency property system and bypasses the |
436 |
/// <see cref="TrayPopup"/> property wrapper, updates of the property's value |
437 |
/// should be handled here. |
438 |
/// </summary |
439 |
/// <param name="e">Provides information about the updated property.</param> |
440 |
private void OnTrayPopupPropertyChanged(DependencyPropertyChangedEventArgs e) |
441 |
{ |
442 |
if (e.OldValue != null) |
443 |
{ |
444 |
//remove the taskbar icon reference from the previously used element |
445 |
SetParentTaskbarIcon((DependencyObject)e.OldValue, null); |
446 |
} |
447 |
|
448 |
|
449 |
if (e.NewValue != null) |
450 |
{ |
451 |
//set this taskbar icon as a reference to the new tooltip element |
452 |
SetParentTaskbarIcon((DependencyObject)e.NewValue, this); |
453 |
} |
454 |
|
455 |
//create a pop |
456 |
CreatePopup(); |
457 |
} |
458 |
|
459 |
#endregion |
460 |
|
461 |
|
462 |
#region MenuActivation dependency property |
463 |
|
464 |
/// <summary> |
465 |
/// Defines what mouse events display the context menu. |
466 |
/// Defaults to <see cref="PopupActivationMode.RightClick"/>. |
467 |
/// </summary> |
468 |
public static readonly DependencyProperty MenuActivationProperty = |
469 |
DependencyProperty.Register("MenuActivation", |
470 |
typeof (PopupActivationMode), |
471 |
typeof (TaskbarIcon), |
472 |
new FrameworkPropertyMetadata(PopupActivationMode.RightClick)); |
473 |
|
474 |
/// <summary> |
475 |
/// A property wrapper for the <see cref="MenuActivationProperty"/> |
476 |
/// dependency property:<br/> |
477 |
/// Defines what mouse events display the context menu. |
478 |
/// Defaults to <see cref="PopupActivationMode.RightClick"/>. |
479 |
/// </summary> |
480 |
[Category(CategoryName)] |
481 |
[Description("Defines what mouse events display the context menu.")] |
482 |
public PopupActivationMode MenuActivation |
483 |
{ |
484 |
get { return (PopupActivationMode) GetValue(MenuActivationProperty); } |
485 |
set { SetValue(MenuActivationProperty, value); } |
486 |
} |
487 |
|
488 |
#endregion |
489 |
|
490 |
#region PopupActivation dependency property |
491 |
|
492 |
/// <summary> |
493 |
/// Defines what mouse events trigger the <see cref="TrayPopup" />. |
494 |
/// Default is <see cref="PopupActivationMode.LeftClick" />. |
495 |
/// </summary> |
496 |
public static readonly DependencyProperty PopupActivationProperty = |
497 |
DependencyProperty.Register("PopupActivation", |
498 |
typeof (PopupActivationMode), |
499 |
typeof (TaskbarIcon), |
500 |
new FrameworkPropertyMetadata(PopupActivationMode.LeftClick)); |
501 |
|
502 |
/// <summary> |
503 |
/// A property wrapper for the <see cref="PopupActivationProperty"/> |
504 |
/// dependency property:<br/> |
505 |
/// Defines what mouse events trigger the <see cref="TrayPopup" />. |
506 |
/// Default is <see cref="PopupActivationMode.LeftClick" />. |
507 |
/// </summary> |
508 |
[Category(CategoryName)] |
509 |
[Description("Defines what mouse events display the TaskbarIconPopup.")] |
510 |
public PopupActivationMode PopupActivation |
511 |
{ |
512 |
get { return (PopupActivationMode) GetValue(PopupActivationProperty); } |
513 |
set { SetValue(PopupActivationProperty, value); } |
514 |
} |
515 |
|
516 |
#endregion |
517 |
|
518 |
|
519 |
#region Visibility dependency property override |
520 |
|
521 |
/// <summary> |
522 |
/// A static callback listener which is being invoked if the |
523 |
/// <see cref="UIElement.VisibilityProperty"/> dependency property has |
524 |
/// been changed. Invokes the <see cref="OnVisibilityPropertyChanged"/> |
525 |
/// instance method of the changed instance. |
526 |
/// </summary> |
527 |
/// <param name="d">The currently processed owner of the property.</param> |
528 |
/// <param name="e">Provides information about the updated property.</param> |
529 |
private static void VisibilityPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
530 |
{ |
531 |
TaskbarIcon owner = (TaskbarIcon) d; |
532 |
owner.OnVisibilityPropertyChanged(e); |
533 |
} |
534 |
|
535 |
|
536 |
/// <summary> |
537 |
/// Handles changes of the <see cref="UIElement.VisibilityProperty"/> dependency property. As |
538 |
/// WPF internally uses the dependency property system and bypasses the |
539 |
/// <see cref="Visibility"/> property wrapper, updates of the property's value |
540 |
/// should be handled here. |
541 |
/// </summary |
542 |
/// <param name="e">Provides information about the updated property.</param> |
543 |
private void OnVisibilityPropertyChanged(DependencyPropertyChangedEventArgs e) |
544 |
{ |
545 |
Visibility newValue = (Visibility) e.NewValue; |
546 |
|
547 |
//update |
548 |
if (newValue == Visibility.Visible) |
549 |
{ |
550 |
CreateTaskbarIcon(); |
551 |
} |
552 |
else |
553 |
{ |
554 |
RemoveTaskbarIcon(); |
555 |
} |
556 |
} |
557 |
|
558 |
#endregion |
559 |
|
560 |
#region DataContext dependency property override / target update |
561 |
|
562 |
/// <summary> |
563 |
/// Updates the <see cref="FrameworkElement.DataContextProperty"/> of a given |
564 |
/// <see cref="FrameworkElement"/>. This method only updates target elements |
565 |
/// that do not already have a data context of their own, and either assigns |
566 |
/// the <see cref="FrameworkElement.DataContext"/> of the NotifyIcon, or the |
567 |
/// NotifyIcon itself, if no data context was assigned at all. |
568 |
/// </summary> |
569 |
private void UpdateDataContext(FrameworkElement target, object oldDataContextValue, object newDataContextValue) |
570 |
{ |
571 |
//if there is no target or it's data context is determined through a binding |
572 |
//of its own, keep it |
573 |
if (target == null || target.IsDataContextDataBound()) return; |
574 |
|
575 |
//if the target's data context is the NotifyIcon's old DataContext or the NotifyIcon itself, |
576 |
//update it |
577 |
if (ReferenceEquals(this, target.DataContext) || Equals(oldDataContextValue, target.DataContext)) |
578 |
{ |
579 |
//assign own data context, if available. If there is no data |
580 |
//context at all, assign NotifyIcon itself. |
581 |
target.DataContext = newDataContextValue ?? this; |
582 |
} |
583 |
} |
584 |
|
585 |
/// <summary> |
586 |
/// A static callback listener which is being invoked if the |
587 |
/// <see cref="FrameworkElement.DataContextProperty"/> dependency property has |
588 |
/// been changed. Invokes the <see cref="OnDataContextPropertyChanged"/> |
589 |
/// instance method of the changed instance. |
590 |
/// </summary> |
591 |
/// <param name="d">The currently processed owner of the property.</param> |
592 |
/// <param name="e">Provides information about the updated property.</param> |
593 |
private static void DataContextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
594 |
{ |
595 |
TaskbarIcon owner = (TaskbarIcon) d; |
596 |
owner.OnDataContextPropertyChanged(e); |
597 |
} |
598 |
|
599 |
|
600 |
/// <summary> |
601 |
/// Handles changes of the <see cref="FrameworkElement.DataContextProperty"/> dependency property. As |
602 |
/// WPF internally uses the dependency property system and bypasses the |
603 |
/// <see cref="FrameworkElement.DataContext"/> property wrapper, updates of the property's value |
604 |
/// should be handled here. |
605 |
/// </summary |
606 |
/// <param name="e">Provides information about the updated property.</param> |
607 |
private void OnDataContextPropertyChanged(DependencyPropertyChangedEventArgs e) |
608 |
{ |
609 |
object newValue = e.NewValue; |
610 |
object oldValue = e.OldValue; |
611 |
|
612 |
//replace custom data context for ToolTips, Popup, and |
613 |
//ContextMenu |
614 |
UpdateDataContext(TrayPopupResolved, oldValue, newValue); |
615 |
UpdateDataContext(TrayToolTipResolved, oldValue, newValue); |
616 |
UpdateDataContext(ContextMenu, oldValue, newValue); |
617 |
} |
618 |
|
619 |
#endregion |
620 |
|
621 |
#region ContextMenu dependency property override |
622 |
|
623 |
/// <summary> |
624 |
/// A static callback listener which is being invoked if the |
625 |
/// <see cref="FrameworkElement.ContextMenuProperty"/> dependency property has |
626 |
/// been changed. Invokes the <see cref="OnContextMenuPropertyChanged"/> |
627 |
/// instance method of the changed instance. |
628 |
/// </summary> |
629 |
/// <param name="d">The currently processed owner of the property.</param> |
630 |
/// <param name="e">Provides information about the updated property.</param> |
631 |
private static void ContextMenuPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
632 |
{ |
633 |
TaskbarIcon owner = (TaskbarIcon)d; |
634 |
owner.OnContextMenuPropertyChanged(e); |
635 |
} |
636 |
|
637 |
|
638 |
/// <summary> |
639 |
/// Releases the old and updates the new <see cref="ContextMenu"/> property |
640 |
/// in order to reflect both the NotifyIcon's <see cref="FrameworkElement.DataContext"/> |
641 |
/// property and have the <see cref="ParentTaskbarIconProperty"/> assigned. |
642 |
/// </summary> |
643 |
/// <param name="e">Provides information about the updated property.</param> |
644 |
private void OnContextMenuPropertyChanged(DependencyPropertyChangedEventArgs e) |
645 |
{ |
646 |
if (e.OldValue != null) |
647 |
{ |
648 |
//remove the taskbar icon reference from the previously used element |
649 |
SetParentTaskbarIcon((DependencyObject)e.OldValue, null); |
650 |
} |
651 |
|
652 |
if (e.NewValue != null) |
653 |
{ |
654 |
//set this taskbar icon as a reference to the new tooltip element |
655 |
SetParentTaskbarIcon((DependencyObject)e.NewValue, this); |
656 |
} |
657 |
|
658 |
UpdateDataContext((ContextMenu) e.NewValue, null, DataContext); |
659 |
} |
660 |
|
661 |
#endregion |
662 |
|
663 |
|
664 |
|
665 |
#region DoubleClickCommand dependency property |
666 |
|
667 |
/// <summary> |
668 |
/// Associates a command that is being executed if the tray icon is being |
669 |
/// double clicked. |
670 |
/// </summary> |
671 |
public static readonly DependencyProperty DoubleClickCommandProperty = |
672 |
DependencyProperty.Register("DoubleClickCommand", |
673 |
typeof (ICommand), |
674 |
typeof (TaskbarIcon), |
675 |
new FrameworkPropertyMetadata(null)); |
676 |
|
677 |
/// <summary> |
678 |
/// A property wrapper for the <see cref="DoubleClickCommandProperty"/> |
679 |
/// dependency property:<br/> |
680 |
/// Associates a command that is being executed if the tray icon is being |
681 |
/// double clicked. |
682 |
/// </summary> |
683 |
public ICommand DoubleClickCommand |
684 |
{ |
685 |
get { return (ICommand) GetValue(DoubleClickCommandProperty); } |
686 |
set { SetValue(DoubleClickCommandProperty, value); } |
687 |
} |
688 |
|
689 |
#endregion |
690 |
|
691 |
#region DoubleClickCommandParameter dependency property |
692 |
|
693 |
/// <summary> |
694 |
/// Command parameter for the <see cref="DoubleClickCommand"/>. |
695 |
/// </summary> |
696 |
public static readonly DependencyProperty DoubleClickCommandParameterProperty = |
697 |
DependencyProperty.Register("DoubleClickCommandParameter", |
698 |
typeof (object), |
699 |
typeof (TaskbarIcon), |
700 |
new FrameworkPropertyMetadata(null)); |
701 |
|
702 |
/// <summary> |
703 |
/// A property wrapper for the <see cref="DoubleClickCommandParameterProperty"/> |
704 |
/// dependency property:<br/> |
705 |
/// Command parameter for the <see cref="DoubleClickCommand"/>. |
706 |
/// </summary> |
707 |
public object DoubleClickCommandParameter |
708 |
{ |
709 |
get { return GetValue(DoubleClickCommandParameterProperty); } |
710 |
set { SetValue(DoubleClickCommandParameterProperty, value); } |
711 |
} |
712 |
|
713 |
#endregion |
714 |
|
715 |
#region DoubleClickCommandTarget dependency property |
716 |
|
717 |
/// <summary> |
718 |
/// The target of the command that is fired if the notify icon is double clicked. |
719 |
/// </summary> |
720 |
public static readonly DependencyProperty DoubleClickCommandTargetProperty = |
721 |
DependencyProperty.Register("DoubleClickCommandTarget", |
722 |
typeof (IInputElement), |
723 |
typeof (TaskbarIcon), |
724 |
new FrameworkPropertyMetadata(null)); |
725 |
|
726 |
/// <summary> |
727 |
/// A property wrapper for the <see cref="DoubleClickCommandTargetProperty"/> |
728 |
/// dependency property:<br/> |
729 |
/// The target of the command that is fired if the notify icon is double clicked. |
730 |
/// </summary> |
731 |
public IInputElement DoubleClickCommandTarget |
732 |
{ |
733 |
get { return (IInputElement) GetValue(DoubleClickCommandTargetProperty); } |
734 |
set { SetValue(DoubleClickCommandTargetProperty, value); } |
735 |
} |
736 |
|
737 |
#endregion |
738 |
|
739 |
|
740 |
|
741 |
#region LeftClickCommand dependency property |
742 |
|
743 |
/// <summary> |
744 |
/// Associates a command that is being executed if the tray icon is being |
745 |
/// double clicked. |
746 |
/// </summary> |
747 |
public static readonly DependencyProperty LeftClickCommandProperty = |
748 |
DependencyProperty.Register("LeftClickCommand", |
749 |
typeof (ICommand), |
750 |
typeof (TaskbarIcon), |
751 |
new FrameworkPropertyMetadata(null)); |
752 |
|
753 |
/// <summary> |
754 |
/// A property wrapper for the <see cref="LeftClickCommandProperty"/> |
755 |
/// dependency property:<br/> |
756 |
/// Associates a command that is being executed if the tray icon is being |
757 |
/// double clicked. |
758 |
/// </summary> |
759 |
public ICommand LeftClickCommand |
760 |
{ |
761 |
get { return (ICommand) GetValue(LeftClickCommandProperty); } |
762 |
set { SetValue(LeftClickCommandProperty, value); } |
763 |
} |
764 |
|
765 |
#endregion |
766 |
|
767 |
#region LeftClickCommandParameter dependency property |
768 |
|
769 |
/// <summary> |
770 |
/// Command parameter for the <see cref="LeftClickCommand"/>. |
771 |
/// </summary> |
772 |
public static readonly DependencyProperty LeftClickCommandParameterProperty = |
773 |
DependencyProperty.Register("LeftClickCommandParameter", |
774 |
typeof (object), |
775 |
typeof (TaskbarIcon), |
776 |
new FrameworkPropertyMetadata(null)); |
777 |
|
778 |
/// <summary> |
779 |
/// A property wrapper for the <see cref="LeftClickCommandParameterProperty"/> |
780 |
/// dependency property:<br/> |
781 |
/// Command parameter for the <see cref="LeftClickCommand"/>. |
782 |
/// </summary> |
783 |
public object LeftClickCommandParameter |
784 |
{ |
785 |
get { return GetValue(LeftClickCommandParameterProperty); } |
786 |
set { SetValue(LeftClickCommandParameterProperty, value); } |
787 |
} |
788 |
|
789 |
#endregion |
790 |
|
791 |
#region LeftClickCommandTarget dependency property |
792 |
|
793 |
/// <summary> |
794 |
/// The target of the command that is fired if the notify icon is clicked. |
795 |
/// </summary> |
796 |
public static readonly DependencyProperty LeftClickCommandTargetProperty = |
797 |
DependencyProperty.Register("LeftClickCommandTarget", |
798 |
typeof (IInputElement), |
799 |
typeof (TaskbarIcon), |
800 |
new FrameworkPropertyMetadata(null)); |
801 |
|
802 |
/// <summary> |
803 |
/// A property wrapper for the <see cref="LeftClickCommandTargetProperty"/> |
804 |
/// dependency property:<br/> |
805 |
/// The target of the command that is fired if the notify icon is clicked. |
806 |
/// </summary> |
807 |
public IInputElement LeftClickCommandTarget |
808 |
{ |
809 |
get { return (IInputElement) GetValue(LeftClickCommandTargetProperty); } |
810 |
set { SetValue(LeftClickCommandTargetProperty, value); } |
811 |
} |
812 |
|
813 |
#endregion |
814 |
|
815 |
|
816 |
|
817 |
//EVENTS |
818 |
|
819 |
#region TrayLeftMouseDown |
820 |
|
821 |
/// <summary> |
822 |
/// TrayLeftMouseDown Routed Event |
823 |
/// </summary> |
824 |
public static readonly RoutedEvent TrayLeftMouseDownEvent = EventManager.RegisterRoutedEvent("TrayLeftMouseDown", |
825 |
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
826 |
|
827 |
/// <summary> |
828 |
/// Occurs when the user presses the left mouse button. |
829 |
/// </summary> |
830 |
[Category(CategoryName)] |
831 |
public event RoutedEventHandler TrayLeftMouseDown |
832 |
{ |
833 |
add { AddHandler(TrayLeftMouseDownEvent, value); } |
834 |
remove { RemoveHandler(TrayLeftMouseDownEvent, value); } |
835 |
} |
836 |
|
837 |
/// <summary> |
838 |
/// A helper method to raise the TrayLeftMouseDown event. |
839 |
/// </summary> |
840 |
protected RoutedEventArgs RaiseTrayLeftMouseDownEvent() |
841 |
{ |
842 |
RoutedEventArgs args = RaiseTrayLeftMouseDownEvent(this); |
843 |
return args; |
844 |
} |
845 |
|
846 |
/// <summary> |
847 |
/// A static helper method to raise the TrayLeftMouseDown event on a target element. |
848 |
/// </summary> |
849 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
850 |
internal static RoutedEventArgs RaiseTrayLeftMouseDownEvent(DependencyObject target) |
851 |
{ |
852 |
if (target == null) return null; |
853 |
|
854 |
RoutedEventArgs args = new RoutedEventArgs(); |
855 |
args.RoutedEvent = TrayLeftMouseDownEvent; |
856 |
RoutedEventHelper.RaiseEvent(target, args); |
857 |
return args; |
858 |
} |
859 |
|
860 |
#endregion |
861 |
|
862 |
#region TrayRightMouseDown |
863 |
|
864 |
/// <summary> |
865 |
/// TrayRightMouseDown Routed Event |
866 |
/// </summary> |
867 |
public static readonly RoutedEvent TrayRightMouseDownEvent = EventManager.RegisterRoutedEvent("TrayRightMouseDown", |
868 |
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
869 |
|
870 |
/// <summary> |
871 |
/// Occurs when the presses the right mouse button. |
872 |
/// </summary> |
873 |
public event RoutedEventHandler TrayRightMouseDown |
874 |
{ |
875 |
add { AddHandler(TrayRightMouseDownEvent, value); } |
876 |
remove { RemoveHandler(TrayRightMouseDownEvent, value); } |
877 |
} |
878 |
|
879 |
/// <summary> |
880 |
/// A helper method to raise the TrayRightMouseDown event. |
881 |
/// </summary> |
882 |
protected RoutedEventArgs RaiseTrayRightMouseDownEvent() |
883 |
{ |
884 |
return RaiseTrayRightMouseDownEvent(this); |
885 |
} |
886 |
|
887 |
/// <summary> |
888 |
/// A static helper method to raise the TrayRightMouseDown event on a target element. |
889 |
/// </summary> |
890 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
891 |
internal static RoutedEventArgs RaiseTrayRightMouseDownEvent(DependencyObject target) |
892 |
{ |
893 |
if (target == null) return null; |
894 |
|
895 |
RoutedEventArgs args = new RoutedEventArgs(); |
896 |
args.RoutedEvent = TrayRightMouseDownEvent; |
897 |
RoutedEventHelper.RaiseEvent(target, args); |
898 |
return args; |
899 |
} |
900 |
|
901 |
#endregion |
902 |
|
903 |
#region TrayMiddleMouseDown |
904 |
|
905 |
/// <summary> |
906 |
/// TrayMiddleMouseDown Routed Event |
907 |
/// </summary> |
908 |
public static readonly RoutedEvent TrayMiddleMouseDownEvent = EventManager.RegisterRoutedEvent("TrayMiddleMouseDown", |
909 |
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
910 |
|
911 |
/// <summary> |
912 |
/// Occurs when the user presses the middle mouse button. |
913 |
/// </summary> |
914 |
public event RoutedEventHandler TrayMiddleMouseDown |
915 |
{ |
916 |
add { AddHandler(TrayMiddleMouseDownEvent, value); } |
917 |
remove { RemoveHandler(TrayMiddleMouseDownEvent, value); } |
918 |
} |
919 |
|
920 |
/// <summary> |
921 |
/// A helper method to raise the TrayMiddleMouseDown event. |
922 |
/// </summary> |
923 |
protected RoutedEventArgs RaiseTrayMiddleMouseDownEvent() |
924 |
{ |
925 |
return RaiseTrayMiddleMouseDownEvent(this); |
926 |
} |
927 |
|
928 |
/// <summary> |
929 |
/// A static helper method to raise the TrayMiddleMouseDown event on a target element. |
930 |
/// </summary> |
931 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
932 |
internal static RoutedEventArgs RaiseTrayMiddleMouseDownEvent(DependencyObject target) |
933 |
{ |
934 |
if (target == null) return null; |
935 |
|
936 |
RoutedEventArgs args = new RoutedEventArgs(); |
937 |
args.RoutedEvent = TrayMiddleMouseDownEvent; |
938 |
RoutedEventHelper.RaiseEvent(target, args); |
939 |
return args; |
940 |
} |
941 |
|
942 |
#endregion |
943 |
|
944 |
|
945 |
#region TrayLeftMouseUp |
946 |
|
947 |
/// <summary> |
948 |
/// TrayLeftMouseUp Routed Event |
949 |
/// </summary> |
950 |
public static readonly RoutedEvent TrayLeftMouseUpEvent = EventManager.RegisterRoutedEvent("TrayLeftMouseUp", |
951 |
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
952 |
|
953 |
/// <summary> |
954 |
/// Occurs when the user releases the left mouse button. |
955 |
/// </summary> |
956 |
public event RoutedEventHandler TrayLeftMouseUp |
957 |
{ |
958 |
add { AddHandler(TrayLeftMouseUpEvent, value); } |
959 |
remove { RemoveHandler(TrayLeftMouseUpEvent, value); } |
960 |
} |
961 |
|
962 |
/// <summary> |
963 |
/// A helper method to raise the TrayLeftMouseUp event. |
964 |
/// </summary> |
965 |
protected RoutedEventArgs RaiseTrayLeftMouseUpEvent() |
966 |
{ |
967 |
return RaiseTrayLeftMouseUpEvent(this); |
968 |
} |
969 |
|
970 |
/// <summary> |
971 |
/// A static helper method to raise the TrayLeftMouseUp event on a target element. |
972 |
/// </summary> |
973 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
974 |
internal static RoutedEventArgs RaiseTrayLeftMouseUpEvent(DependencyObject target) |
975 |
{ |
976 |
if (target == null) return null; |
977 |
|
978 |
RoutedEventArgs args = new RoutedEventArgs(); |
979 |
args.RoutedEvent = TrayLeftMouseUpEvent; |
980 |
RoutedEventHelper.RaiseEvent(target, args); |
981 |
return args; |
982 |
} |
983 |
|
984 |
#endregion |
985 |
|
986 |
#region TrayRightMouseUp |
987 |
|
988 |
/// <summary> |
989 |
/// TrayRightMouseUp Routed Event |
990 |
/// </summary> |
991 |
public static readonly RoutedEvent TrayRightMouseUpEvent = EventManager.RegisterRoutedEvent("TrayRightMouseUp", |
992 |
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
993 |
|
994 |
/// <summary> |
995 |
/// Occurs when the user releases the right mouse button. |
996 |
/// </summary> |
997 |
public event RoutedEventHandler TrayRightMouseUp |
998 |
{ |
999 |
add { AddHandler(TrayRightMouseUpEvent, value); } |
1000 |
remove { RemoveHandler(TrayRightMouseUpEvent, value); } |
1001 |
} |
1002 |
|
1003 |
/// <summary> |
1004 |
/// A helper method to raise the TrayRightMouseUp event. |
1005 |
/// </summary> |
1006 |
protected RoutedEventArgs RaiseTrayRightMouseUpEvent() |
1007 |
{ |
1008 |
return RaiseTrayRightMouseUpEvent(this); |
1009 |
} |
1010 |
|
1011 |
/// <summary> |
1012 |
/// A static helper method to raise the TrayRightMouseUp event on a target element. |
1013 |
/// </summary> |
1014 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
1015 |
internal static RoutedEventArgs RaiseTrayRightMouseUpEvent(DependencyObject target) |
1016 |
{ |
1017 |
if (target == null) return null; |
1018 |
|
1019 |
RoutedEventArgs args = new RoutedEventArgs(); |
1020 |
args.RoutedEvent = TrayRightMouseUpEvent; |
1021 |
RoutedEventHelper.RaiseEvent(target, args); |
1022 |
return args; |
1023 |
} |
1024 |
|
1025 |
#endregion |
1026 |
|
1027 |
#region TrayMiddleMouseUp |
1028 |
|
1029 |
/// <summary> |
1030 |
/// TrayMiddleMouseUp Routed Event |
1031 |
/// </summary> |
1032 |
public static readonly RoutedEvent TrayMiddleMouseUpEvent = EventManager.RegisterRoutedEvent("TrayMiddleMouseUp", |
1033 |
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
1034 |
|
1035 |
/// <summary> |
1036 |
/// Occurs when the user releases the middle mouse button. |
1037 |
/// </summary> |
1038 |
public event RoutedEventHandler TrayMiddleMouseUp |
1039 |
{ |
1040 |
add { AddHandler(TrayMiddleMouseUpEvent, value); } |
1041 |
remove { RemoveHandler(TrayMiddleMouseUpEvent, value); } |
1042 |
} |
1043 |
|
1044 |
/// <summary> |
1045 |
/// A helper method to raise the TrayMiddleMouseUp event. |
1046 |
/// </summary> |
1047 |
protected RoutedEventArgs RaiseTrayMiddleMouseUpEvent() |
1048 |
{ |
1049 |
return RaiseTrayMiddleMouseUpEvent(this); |
1050 |
} |
1051 |
|
1052 |
/// <summary> |
1053 |
/// A static helper method to raise the TrayMiddleMouseUp event on a target element. |
1054 |
/// </summary> |
1055 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
1056 |
internal static RoutedEventArgs RaiseTrayMiddleMouseUpEvent(DependencyObject target) |
1057 |
{ |
1058 |
if (target == null) return null; |
1059 |
|
1060 |
RoutedEventArgs args = new RoutedEventArgs(); |
1061 |
args.RoutedEvent = TrayMiddleMouseUpEvent; |
1062 |
RoutedEventHelper.RaiseEvent(target, args); |
1063 |
return args; |
1064 |
} |
1065 |
|
1066 |
#endregion |
1067 |
|
1068 |
|
1069 |
#region TrayMouseDoubleClick |
1070 |
|
1071 |
/// <summary> |
1072 |
/// TrayMouseDoubleClick Routed Event |
1073 |
/// </summary> |
1074 |
public static readonly RoutedEvent TrayMouseDoubleClickEvent = EventManager.RegisterRoutedEvent("TrayMouseDoubleClick", |
1075 |
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
1076 |
|
1077 |
/// <summary> |
1078 |
/// Occurs when the user double-clicks the taskbar icon. |
1079 |
/// </summary> |
1080 |
public event RoutedEventHandler TrayMouseDoubleClick |
1081 |
{ |
1082 |
add { AddHandler(TrayMouseDoubleClickEvent, value); } |
1083 |
remove { RemoveHandler(TrayMouseDoubleClickEvent, value); } |
1084 |
} |
1085 |
|
1086 |
/// <summary> |
1087 |
/// A helper method to raise the TrayMouseDoubleClick event. |
1088 |
/// </summary> |
1089 |
protected RoutedEventArgs RaiseTrayMouseDoubleClickEvent() |
1090 |
{ |
1091 |
RoutedEventArgs args = RaiseTrayMouseDoubleClickEvent(this); |
1092 |
DoubleClickCommand.ExecuteIfEnabled(DoubleClickCommandParameter, DoubleClickCommandTarget ?? this); |
1093 |
return args; |
1094 |
} |
1095 |
|
1096 |
/// <summary> |
1097 |
/// A static helper method to raise the TrayMouseDoubleClick event on a target element. |
1098 |
/// </summary> |
1099 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
1100 |
internal static RoutedEventArgs RaiseTrayMouseDoubleClickEvent(DependencyObject target) |
1101 |
{ |
1102 |
if (target == null) return null; |
1103 |
|
1104 |
RoutedEventArgs args = new RoutedEventArgs(); |
1105 |
args.RoutedEvent = TrayMouseDoubleClickEvent; |
1106 |
RoutedEventHelper.RaiseEvent(target, args); |
1107 |
return args; |
1108 |
} |
1109 |
|
1110 |
#endregion |
1111 |
|
1112 |
#region TrayMouseMove |
1113 |
|
1114 |
/// <summary> |
1115 |
/// TrayMouseMove Routed Event |
1116 |
/// </summary> |
1117 |
public static readonly RoutedEvent TrayMouseMoveEvent = EventManager.RegisterRoutedEvent("TrayMouseMove", |
1118 |
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
1119 |
|
1120 |
/// <summary> |
1121 |
/// Occurs when the user moves the mouse over the taskbar icon. |
1122 |
/// </summary> |
1123 |
public event RoutedEventHandler TrayMouseMove |
1124 |
{ |
1125 |
add { AddHandler(TrayMouseMoveEvent, value); } |
1126 |
remove { RemoveHandler(TrayMouseMoveEvent, value); } |
1127 |
} |
1128 |
|
1129 |
/// <summary> |
1130 |
/// A helper method to raise the TrayMouseMove event. |
1131 |
/// </summary> |
1132 |
protected RoutedEventArgs RaiseTrayMouseMoveEvent() |
1133 |
{ |
1134 |
return RaiseTrayMouseMoveEvent(this); |
1135 |
} |
1136 |
|
1137 |
/// <summary> |
1138 |
/// A static helper method to raise the TrayMouseMove event on a target element. |
1139 |
/// </summary> |
1140 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
1141 |
internal static RoutedEventArgs RaiseTrayMouseMoveEvent(DependencyObject target) |
1142 |
{ |
1143 |
if (target == null) return null; |
1144 |
|
1145 |
RoutedEventArgs args = new RoutedEventArgs(); |
1146 |
args.RoutedEvent = TrayMouseMoveEvent; |
1147 |
RoutedEventHelper.RaiseEvent(target, args); |
1148 |
return args; |
1149 |
} |
1150 |
|
1151 |
#endregion |
1152 |
|
1153 |
|
1154 |
#region TrayBalloonTipShown |
1155 |
|
1156 |
/// <summary> |
1157 |
/// TrayBalloonTipShown Routed Event |
1158 |
/// </summary> |
1159 |
public static readonly RoutedEvent TrayBalloonTipShownEvent = EventManager.RegisterRoutedEvent("TrayBalloonTipShown", |
1160 |
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
1161 |
|
1162 |
/// <summary> |
1163 |
/// Occurs when a balloon ToolTip is displayed. |
1164 |
/// </summary> |
1165 |
public event RoutedEventHandler TrayBalloonTipShown |
1166 |
{ |
1167 |
add { AddHandler(TrayBalloonTipShownEvent, value); } |
1168 |
remove { RemoveHandler(TrayBalloonTipShownEvent, value); } |
1169 |
} |
1170 |
|
1171 |
/// <summary> |
1172 |
/// A helper method to raise the TrayBalloonTipShown event. |
1173 |
/// </summary> |
1174 |
protected RoutedEventArgs RaiseTrayBalloonTipShownEvent() |
1175 |
{ |
1176 |
return RaiseTrayBalloonTipShownEvent(this); |
1177 |
} |
1178 |
|
1179 |
/// <summary> |
1180 |
/// A static helper method to raise the TrayBalloonTipShown event on a target element. |
1181 |
/// </summary> |
1182 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
1183 |
internal static RoutedEventArgs RaiseTrayBalloonTipShownEvent(DependencyObject target) |
1184 |
{ |
1185 |
if (target == null) return null; |
1186 |
|
1187 |
RoutedEventArgs args = new RoutedEventArgs(); |
1188 |
args.RoutedEvent = TrayBalloonTipShownEvent; |
1189 |
RoutedEventHelper.RaiseEvent(target, args); |
1190 |
return args; |
1191 |
} |
1192 |
|
1193 |
#endregion |
1194 |
|
1195 |
#region TrayBalloonTipClosed |
1196 |
|
1197 |
/// <summary> |
1198 |
/// TrayBalloonTipClosed Routed Event |
1199 |
/// </summary> |
1200 |
public static readonly RoutedEvent TrayBalloonTipClosedEvent = EventManager.RegisterRoutedEvent("TrayBalloonTipClosed", |
1201 |
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
1202 |
|
1203 |
/// <summary> |
1204 |
/// Occurs when a balloon ToolTip was closed. |
1205 |
/// </summary> |
1206 |
public event RoutedEventHandler TrayBalloonTipClosed |
1207 |
{ |
1208 |
add { AddHandler(TrayBalloonTipClosedEvent, value); } |
1209 |
remove { RemoveHandler(TrayBalloonTipClosedEvent, value); } |
1210 |
} |
1211 |
|
1212 |
/// <summary> |
1213 |
/// A helper method to raise the TrayBalloonTipClosed event. |
1214 |
/// </summary> |
1215 |
protected RoutedEventArgs RaiseTrayBalloonTipClosedEvent() |
1216 |
{ |
1217 |
return RaiseTrayBalloonTipClosedEvent(this); |
1218 |
} |
1219 |
|
1220 |
/// <summary> |
1221 |
/// A static helper method to raise the TrayBalloonTipClosed event on a target element. |
1222 |
/// </summary> |
1223 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
1224 |
internal static RoutedEventArgs RaiseTrayBalloonTipClosedEvent(DependencyObject target) |
1225 |
{ |
1226 |
if (target == null) return null; |
1227 |
|
1228 |
RoutedEventArgs args = new RoutedEventArgs(); |
1229 |
args.RoutedEvent = TrayBalloonTipClosedEvent; |
1230 |
RoutedEventHelper.RaiseEvent(target, args); |
1231 |
return args; |
1232 |
} |
1233 |
|
1234 |
#endregion |
1235 |
|
1236 |
#region TrayBalloonTipClicked |
1237 |
|
1238 |
/// <summary> |
1239 |
/// TrayBalloonTipClicked Routed Event |
1240 |
/// </summary> |
1241 |
public static readonly RoutedEvent TrayBalloonTipClickedEvent = EventManager.RegisterRoutedEvent("TrayBalloonTipClicked", |
1242 |
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
1243 |
|
1244 |
/// <summary> |
1245 |
/// Occurs when the user clicks on a balloon ToolTip. |
1246 |
/// </summary> |
1247 |
public event RoutedEventHandler TrayBalloonTipClicked |
1248 |
{ |
1249 |
add { AddHandler(TrayBalloonTipClickedEvent, value); } |
1250 |
remove { RemoveHandler(TrayBalloonTipClickedEvent, value); } |
1251 |
} |
1252 |
|
1253 |
/// <summary> |
1254 |
/// A helper method to raise the TrayBalloonTipClicked event. |
1255 |
/// </summary> |
1256 |
protected RoutedEventArgs RaiseTrayBalloonTipClickedEvent() |
1257 |
{ |
1258 |
return RaiseTrayBalloonTipClickedEvent(this); |
1259 |
} |
1260 |
|
1261 |
/// <summary> |
1262 |
/// A static helper method to raise the TrayBalloonTipClicked event on a target element. |
1263 |
/// </summary> |
1264 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
1265 |
internal static RoutedEventArgs RaiseTrayBalloonTipClickedEvent(DependencyObject target) |
1266 |
{ |
1267 |
if (target == null) return null; |
1268 |
|
1269 |
RoutedEventArgs args = new RoutedEventArgs(); |
1270 |
args.RoutedEvent = TrayBalloonTipClickedEvent; |
1271 |
RoutedEventHelper.RaiseEvent(target, args); |
1272 |
return args; |
1273 |
} |
1274 |
|
1275 |
#endregion |
1276 |
|
1277 |
|
1278 |
#region TrayContextMenuOpen (and PreviewTrayContextMenuOpen) |
1279 |
|
1280 |
/// <summary> |
1281 |
/// TrayContextMenuOpen Routed Event |
1282 |
/// </summary> |
1283 |
public static readonly RoutedEvent TrayContextMenuOpenEvent = EventManager.RegisterRoutedEvent("TrayContextMenuOpen", |
1284 |
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
1285 |
|
1286 |
/// <summary> |
1287 |
/// Bubbled event that occurs when the context menu of the taskbar icon is being displayed. |
1288 |
/// </summary> |
1289 |
public event RoutedEventHandler TrayContextMenuOpen |
1290 |
{ |
1291 |
add { AddHandler(TrayContextMenuOpenEvent, value); } |
1292 |
remove { RemoveHandler(TrayContextMenuOpenEvent, value); } |
1293 |
} |
1294 |
|
1295 |
/// <summary> |
1296 |
/// A helper method to raise the TrayContextMenuOpen event. |
1297 |
/// </summary> |
1298 |
protected RoutedEventArgs RaiseTrayContextMenuOpenEvent() |
1299 |
{ |
1300 |
return RaiseTrayContextMenuOpenEvent(this); |
1301 |
} |
1302 |
|
1303 |
/// <summary> |
1304 |
/// A static helper method to raise the TrayContextMenuOpen event on a target element. |
1305 |
/// </summary> |
1306 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
1307 |
internal static RoutedEventArgs RaiseTrayContextMenuOpenEvent(DependencyObject target) |
1308 |
{ |
1309 |
if (target == null) return null; |
1310 |
|
1311 |
RoutedEventArgs args = new RoutedEventArgs(); |
1312 |
args.RoutedEvent = TrayContextMenuOpenEvent; |
1313 |
RoutedEventHelper.RaiseEvent(target, args); |
1314 |
return args; |
1315 |
} |
1316 |
|
1317 |
/// <summary> |
1318 |
/// PreviewTrayContextMenuOpen Routed Event |
1319 |
/// </summary> |
1320 |
public static readonly RoutedEvent PreviewTrayContextMenuOpenEvent = EventManager.RegisterRoutedEvent("PreviewTrayContextMenuOpen", |
1321 |
RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
1322 |
|
1323 |
/// <summary> |
1324 |
/// Tunneled event that occurs when the context menu of the taskbar icon is being displayed. |
1325 |
/// </summary> |
1326 |
public event RoutedEventHandler PreviewTrayContextMenuOpen |
1327 |
{ |
1328 |
add { AddHandler(PreviewTrayContextMenuOpenEvent, value); } |
1329 |
remove { RemoveHandler(PreviewTrayContextMenuOpenEvent, value); } |
1330 |
} |
1331 |
|
1332 |
/// <summary> |
1333 |
/// A helper method to raise the PreviewTrayContextMenuOpen event. |
1334 |
/// </summary> |
1335 |
protected RoutedEventArgs RaisePreviewTrayContextMenuOpenEvent() |
1336 |
{ |
1337 |
return RaisePreviewTrayContextMenuOpenEvent(this); |
1338 |
} |
1339 |
|
1340 |
/// <summary> |
1341 |
/// A static helper method to raise the PreviewTrayContextMenuOpen event on a target element. |
1342 |
/// </summary> |
1343 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
1344 |
internal static RoutedEventArgs RaisePreviewTrayContextMenuOpenEvent(DependencyObject target) |
1345 |
{ |
1346 |
if (target == null) return null; |
1347 |
|
1348 |
RoutedEventArgs args = new RoutedEventArgs(); |
1349 |
args.RoutedEvent = PreviewTrayContextMenuOpenEvent; |
1350 |
RoutedEventHelper.RaiseEvent(target, args); |
1351 |
return args; |
1352 |
} |
1353 |
|
1354 |
#endregion |
1355 |
|
1356 |
#region TrayPopupOpen (and PreviewTrayPopupOpen) |
1357 |
|
1358 |
/// <summary> |
1359 |
/// TrayPopupOpen Routed Event |
1360 |
/// </summary> |
1361 |
public static readonly RoutedEvent TrayPopupOpenEvent = EventManager.RegisterRoutedEvent("TrayPopupOpen", |
1362 |
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
1363 |
|
1364 |
/// <summary> |
1365 |
/// Bubbled event that occurs when the custom popup is being opened. |
1366 |
/// </summary> |
1367 |
public event RoutedEventHandler TrayPopupOpen |
1368 |
{ |
1369 |
add { AddHandler(TrayPopupOpenEvent, value); } |
1370 |
remove { RemoveHandler(TrayPopupOpenEvent, value); } |
1371 |
} |
1372 |
|
1373 |
/// <summary> |
1374 |
/// A helper method to raise the TrayPopupOpen event. |
1375 |
/// </summary> |
1376 |
protected RoutedEventArgs RaiseTrayPopupOpenEvent() |
1377 |
{ |
1378 |
return RaiseTrayPopupOpenEvent(this); |
1379 |
} |
1380 |
|
1381 |
/// <summary> |
1382 |
/// A static helper method to raise the TrayPopupOpen event on a target element. |
1383 |
/// </summary> |
1384 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
1385 |
internal static RoutedEventArgs RaiseTrayPopupOpenEvent(DependencyObject target) |
1386 |
{ |
1387 |
if (target == null) return null; |
1388 |
|
1389 |
RoutedEventArgs args = new RoutedEventArgs(); |
1390 |
args.RoutedEvent = TrayPopupOpenEvent; |
1391 |
RoutedEventHelper.RaiseEvent(target, args); |
1392 |
return args; |
1393 |
} |
1394 |
|
1395 |
/// <summary> |
1396 |
/// PreviewTrayPopupOpen Routed Event |
1397 |
/// </summary> |
1398 |
public static readonly RoutedEvent PreviewTrayPopupOpenEvent = EventManager.RegisterRoutedEvent("PreviewTrayPopupOpen", |
1399 |
RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
1400 |
|
1401 |
/// <summary> |
1402 |
/// Tunneled event that occurs when the custom popup is being opened. |
1403 |
/// </summary> |
1404 |
public event RoutedEventHandler PreviewTrayPopupOpen |
1405 |
{ |
1406 |
add { AddHandler(PreviewTrayPopupOpenEvent, value); } |
1407 |
remove { RemoveHandler(PreviewTrayPopupOpenEvent, value); } |
1408 |
} |
1409 |
|
1410 |
/// <summary> |
1411 |
/// A helper method to raise the PreviewTrayPopupOpen event. |
1412 |
/// </summary> |
1413 |
protected RoutedEventArgs RaisePreviewTrayPopupOpenEvent() |
1414 |
{ |
1415 |
return RaisePreviewTrayPopupOpenEvent(this); |
1416 |
} |
1417 |
|
1418 |
/// <summary> |
1419 |
/// A static helper method to raise the PreviewTrayPopupOpen event on a target element. |
1420 |
/// </summary> |
1421 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
1422 |
internal static RoutedEventArgs RaisePreviewTrayPopupOpenEvent(DependencyObject target) |
1423 |
{ |
1424 |
if (target == null) return null; |
1425 |
|
1426 |
RoutedEventArgs args = new RoutedEventArgs(); |
1427 |
args.RoutedEvent = PreviewTrayPopupOpenEvent; |
1428 |
RoutedEventHelper.RaiseEvent(target, args); |
1429 |
return args; |
1430 |
} |
1431 |
|
1432 |
#endregion |
1433 |
|
1434 |
|
1435 |
#region TrayToolTipOpen (and PreviewTrayToolTipOpen) |
1436 |
|
1437 |
/// <summary> |
1438 |
/// TrayToolTipOpen Routed Event |
1439 |
/// </summary> |
1440 |
public static readonly RoutedEvent TrayToolTipOpenEvent = EventManager.RegisterRoutedEvent("TrayToolTipOpen", |
1441 |
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
1442 |
|
1443 |
/// <summary> |
1444 |
/// Bubbled event that occurs when the custom ToolTip is being displayed. |
1445 |
/// </summary> |
1446 |
public event RoutedEventHandler TrayToolTipOpen |
1447 |
{ |
1448 |
add { AddHandler(TrayToolTipOpenEvent, value); } |
1449 |
remove { RemoveHandler(TrayToolTipOpenEvent, value); } |
1450 |
} |
1451 |
|
1452 |
/// <summary> |
1453 |
/// A helper method to raise the TrayToolTipOpen event. |
1454 |
/// </summary> |
1455 |
protected RoutedEventArgs RaiseTrayToolTipOpenEvent() |
1456 |
{ |
1457 |
return RaiseTrayToolTipOpenEvent(this); |
1458 |
} |
1459 |
|
1460 |
/// <summary> |
1461 |
/// A static helper method to raise the TrayToolTipOpen event on a target element. |
1462 |
/// </summary> |
1463 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
1464 |
internal static RoutedEventArgs RaiseTrayToolTipOpenEvent(DependencyObject target) |
1465 |
{ |
1466 |
if (target == null) return null; |
1467 |
|
1468 |
RoutedEventArgs args = new RoutedEventArgs(); |
1469 |
args.RoutedEvent = TrayToolTipOpenEvent; |
1470 |
RoutedEventHelper.RaiseEvent(target, args); |
1471 |
return args; |
1472 |
} |
1473 |
|
1474 |
/// <summary> |
1475 |
/// PreviewTrayToolTipOpen Routed Event |
1476 |
/// </summary> |
1477 |
public static readonly RoutedEvent PreviewTrayToolTipOpenEvent = EventManager.RegisterRoutedEvent("PreviewTrayToolTipOpen", |
1478 |
RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
1479 |
|
1480 |
/// <summary> |
1481 |
/// Tunneled event that occurs when the custom ToolTip is being displayed. |
1482 |
/// </summary> |
1483 |
public event RoutedEventHandler PreviewTrayToolTipOpen |
1484 |
{ |
1485 |
add { AddHandler(PreviewTrayToolTipOpenEvent, value); } |
1486 |
remove { RemoveHandler(PreviewTrayToolTipOpenEvent, value); } |
1487 |
} |
1488 |
|
1489 |
/// <summary> |
1490 |
/// A helper method to raise the PreviewTrayToolTipOpen event. |
1491 |
/// </summary> |
1492 |
protected RoutedEventArgs RaisePreviewTrayToolTipOpenEvent() |
1493 |
{ |
1494 |
return RaisePreviewTrayToolTipOpenEvent(this); |
1495 |
} |
1496 |
|
1497 |
/// <summary> |
1498 |
/// A static helper method to raise the PreviewTrayToolTipOpen event on a target element. |
1499 |
/// </summary> |
1500 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
1501 |
internal static RoutedEventArgs RaisePreviewTrayToolTipOpenEvent(DependencyObject target) |
1502 |
{ |
1503 |
if (target == null) return null; |
1504 |
|
1505 |
RoutedEventArgs args = new RoutedEventArgs(); |
1506 |
args.RoutedEvent = PreviewTrayToolTipOpenEvent; |
1507 |
RoutedEventHelper.RaiseEvent(target, args); |
1508 |
return args; |
1509 |
} |
1510 |
|
1511 |
#endregion |
1512 |
|
1513 |
#region TrayToolTipClose (and PreviewTrayToolTipClose) |
1514 |
|
1515 |
/// <summary> |
1516 |
/// TrayToolTipClose Routed Event |
1517 |
/// </summary> |
1518 |
public static readonly RoutedEvent TrayToolTipCloseEvent = EventManager.RegisterRoutedEvent("TrayToolTipClose", |
1519 |
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
1520 |
|
1521 |
/// <summary> |
1522 |
/// Bubbled event that occurs when a custom tooltip is being closed. |
1523 |
/// </summary> |
1524 |
public event RoutedEventHandler TrayToolTipClose |
1525 |
{ |
1526 |
add { AddHandler(TrayToolTipCloseEvent, value); } |
1527 |
remove { RemoveHandler(TrayToolTipCloseEvent, value); } |
1528 |
} |
1529 |
|
1530 |
/// <summary> |
1531 |
/// A helper method to raise the TrayToolTipClose event. |
1532 |
/// </summary> |
1533 |
protected RoutedEventArgs RaiseTrayToolTipCloseEvent() |
1534 |
{ |
1535 |
return RaiseTrayToolTipCloseEvent(this); |
1536 |
} |
1537 |
|
1538 |
/// <summary> |
1539 |
/// A static helper method to raise the TrayToolTipClose event on a target element. |
1540 |
/// </summary> |
1541 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
1542 |
internal static RoutedEventArgs RaiseTrayToolTipCloseEvent(DependencyObject target) |
1543 |
{ |
1544 |
if (target == null) return null; |
1545 |
|
1546 |
RoutedEventArgs args = new RoutedEventArgs(); |
1547 |
args.RoutedEvent = TrayToolTipCloseEvent; |
1548 |
RoutedEventHelper.RaiseEvent(target, args); |
1549 |
return args; |
1550 |
} |
1551 |
|
1552 |
/// <summary> |
1553 |
/// PreviewTrayToolTipClose Routed Event |
1554 |
/// </summary> |
1555 |
public static readonly RoutedEvent PreviewTrayToolTipCloseEvent = EventManager.RegisterRoutedEvent("PreviewTrayToolTipClose", |
1556 |
RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
1557 |
|
1558 |
/// <summary> |
1559 |
/// Tunneled event that occurs when a custom tooltip is being closed. |
1560 |
/// </summary> |
1561 |
public event RoutedEventHandler PreviewTrayToolTipClose |
1562 |
{ |
1563 |
add { AddHandler(PreviewTrayToolTipCloseEvent, value); } |
1564 |
remove { RemoveHandler(PreviewTrayToolTipCloseEvent, value); } |
1565 |
} |
1566 |
|
1567 |
/// <summary> |
1568 |
/// A helper method to raise the PreviewTrayToolTipClose event. |
1569 |
/// </summary> |
1570 |
protected RoutedEventArgs RaisePreviewTrayToolTipCloseEvent() |
1571 |
{ |
1572 |
return RaisePreviewTrayToolTipCloseEvent(this); |
1573 |
} |
1574 |
|
1575 |
/// <summary> |
1576 |
/// A static helper method to raise the PreviewTrayToolTipClose event on a target element. |
1577 |
/// </summary> |
1578 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
1579 |
internal static RoutedEventArgs RaisePreviewTrayToolTipCloseEvent(DependencyObject target) |
1580 |
{ |
1581 |
if (target == null) return null; |
1582 |
|
1583 |
RoutedEventArgs args = new RoutedEventArgs(); |
1584 |
args.RoutedEvent = PreviewTrayToolTipCloseEvent; |
1585 |
RoutedEventHelper.RaiseEvent(target, args); |
1586 |
return args; |
1587 |
} |
1588 |
|
1589 |
#endregion |
1590 |
|
1591 |
|
1592 |
//ATTACHED EVENTS |
1593 |
|
1594 |
#region PopupOpened |
1595 |
|
1596 |
/// <summary> |
1597 |
/// PopupOpened Attached Routed Event |
1598 |
/// </summary> |
1599 |
public static readonly RoutedEvent PopupOpenedEvent = EventManager.RegisterRoutedEvent("PopupOpened", |
1600 |
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
1601 |
|
1602 |
/// <summary> |
1603 |
/// Adds a handler for the PopupOpened attached event |
1604 |
/// </summary> |
1605 |
/// <param name="element">UIElement or ContentElement that listens to the event</param> |
1606 |
/// <param name="handler">Event handler to be added</param> |
1607 |
public static void AddPopupOpenedHandler(DependencyObject element, RoutedEventHandler handler) |
1608 |
{ |
1609 |
RoutedEventHelper.AddHandler(element, PopupOpenedEvent, handler); |
1610 |
} |
1611 |
|
1612 |
/// <summary> |
1613 |
/// Removes a handler for the PopupOpened attached event |
1614 |
/// </summary> |
1615 |
/// <param name="element">UIElement or ContentElement that listens to the event</param> |
1616 |
/// <param name="handler">Event handler to be removed</param> |
1617 |
public static void RemovePopupOpenedHandler(DependencyObject element, RoutedEventHandler handler) |
1618 |
{ |
1619 |
RoutedEventHelper.RemoveHandler(element, PopupOpenedEvent, handler); |
1620 |
} |
1621 |
|
1622 |
/// <summary> |
1623 |
/// A static helper method to raise the PopupOpened event on a target element. |
1624 |
/// </summary> |
1625 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
1626 |
internal static RoutedEventArgs RaisePopupOpenedEvent(DependencyObject target) |
1627 |
{ |
1628 |
if (target == null) return null; |
1629 |
|
1630 |
RoutedEventArgs args = new RoutedEventArgs(); |
1631 |
args.RoutedEvent = PopupOpenedEvent; |
1632 |
RoutedEventHelper.RaiseEvent(target, args); |
1633 |
return args; |
1634 |
} |
1635 |
|
1636 |
#endregion |
1637 |
|
1638 |
#region ToolTipOpened |
1639 |
|
1640 |
/// <summary> |
1641 |
/// ToolTipOpened Attached Routed Event |
1642 |
/// </summary> |
1643 |
public static readonly RoutedEvent ToolTipOpenedEvent = EventManager.RegisterRoutedEvent("ToolTipOpened", |
1644 |
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
1645 |
|
1646 |
/// <summary> |
1647 |
/// Adds a handler for the ToolTipOpened attached event |
1648 |
/// </summary> |
1649 |
/// <param name="element">UIElement or ContentElement that listens to the event</param> |
1650 |
/// <param name="handler">Event handler to be added</param> |
1651 |
public static void AddToolTipOpenedHandler(DependencyObject element, RoutedEventHandler handler) |
1652 |
{ |
1653 |
RoutedEventHelper.AddHandler(element, ToolTipOpenedEvent, handler); |
1654 |
} |
1655 |
|
1656 |
/// <summary> |
1657 |
/// Removes a handler for the ToolTipOpened attached event |
1658 |
/// </summary> |
1659 |
/// <param name="element">UIElement or ContentElement that listens to the event</param> |
1660 |
/// <param name="handler">Event handler to be removed</param> |
1661 |
public static void RemoveToolTipOpenedHandler(DependencyObject element, RoutedEventHandler handler) |
1662 |
{ |
1663 |
RoutedEventHelper.RemoveHandler(element, ToolTipOpenedEvent, handler); |
1664 |
} |
1665 |
|
1666 |
/// <summary> |
1667 |
/// A static helper method to raise the ToolTipOpened event on a target element. |
1668 |
/// </summary> |
1669 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
1670 |
internal static RoutedEventArgs RaiseToolTipOpenedEvent(DependencyObject target) |
1671 |
{ |
1672 |
if (target == null) return null; |
1673 |
|
1674 |
RoutedEventArgs args = new RoutedEventArgs(); |
1675 |
args.RoutedEvent = ToolTipOpenedEvent; |
1676 |
RoutedEventHelper.RaiseEvent(target, args); |
1677 |
return args; |
1678 |
} |
1679 |
|
1680 |
#endregion |
1681 |
|
1682 |
#region ToolTipClose |
1683 |
|
1684 |
/// <summary> |
1685 |
/// ToolTipClose Attached Routed Event |
1686 |
/// </summary> |
1687 |
public static readonly RoutedEvent ToolTipCloseEvent = EventManager.RegisterRoutedEvent("ToolTipClose", |
1688 |
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
1689 |
|
1690 |
/// <summary> |
1691 |
/// Adds a handler for the ToolTipClose attached event |
1692 |
/// </summary> |
1693 |
/// <param name="element">UIElement or ContentElement that listens to the event</param> |
1694 |
/// <param name="handler">Event handler to be added</param> |
1695 |
public static void AddToolTipCloseHandler(DependencyObject element, RoutedEventHandler handler) |
1696 |
{ |
1697 |
RoutedEventHelper.AddHandler(element, ToolTipCloseEvent, handler); |
1698 |
} |
1699 |
|
1700 |
/// <summary> |
1701 |
/// Removes a handler for the ToolTipClose attached event |
1702 |
/// </summary> |
1703 |
/// <param name="element">UIElement or ContentElement that listens to the event</param> |
1704 |
/// <param name="handler">Event handler to be removed</param> |
1705 |
public static void RemoveToolTipCloseHandler(DependencyObject element, RoutedEventHandler handler) |
1706 |
{ |
1707 |
RoutedEventHelper.RemoveHandler(element, ToolTipCloseEvent, handler); |
1708 |
} |
1709 |
|
1710 |
/// <summary> |
1711 |
/// A static helper method to raise the ToolTipClose event on a target element. |
1712 |
/// </summary> |
1713 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
1714 |
internal static RoutedEventArgs RaiseToolTipCloseEvent(DependencyObject target) |
1715 |
{ |
1716 |
if (target == null) return null; |
1717 |
|
1718 |
RoutedEventArgs args = new RoutedEventArgs(); |
1719 |
args.RoutedEvent = ToolTipCloseEvent; |
1720 |
RoutedEventHelper.RaiseEvent(target, args); |
1721 |
return args; |
1722 |
} |
1723 |
|
1724 |
#endregion |
1725 |
|
1726 |
#region BalloonShowing |
1727 |
|
1728 |
/// <summary> |
1729 |
/// BalloonShowing Attached Routed Event |
1730 |
/// </summary> |
1731 |
public static readonly RoutedEvent BalloonShowingEvent = EventManager.RegisterRoutedEvent("BalloonShowing", |
1732 |
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
1733 |
|
1734 |
/// <summary> |
1735 |
/// Adds a handler for the BalloonShowing attached event |
1736 |
/// </summary> |
1737 |
/// <param name="element">UIElement or ContentElement that listens to the event</param> |
1738 |
/// <param name="handler">Event handler to be added</param> |
1739 |
public static void AddBalloonShowingHandler(DependencyObject element, RoutedEventHandler handler) |
1740 |
{ |
1741 |
RoutedEventHelper.AddHandler(element, BalloonShowingEvent, handler); |
1742 |
} |
1743 |
|
1744 |
/// <summary> |
1745 |
/// Removes a handler for the BalloonShowing attached event |
1746 |
/// </summary> |
1747 |
/// <param name="element">UIElement or ContentElement that listens to the event</param> |
1748 |
/// <param name="handler">Event handler to be removed</param> |
1749 |
public static void RemoveBalloonShowingHandler(DependencyObject element, RoutedEventHandler handler) |
1750 |
{ |
1751 |
RoutedEventHelper.RemoveHandler(element, BalloonShowingEvent, handler); |
1752 |
} |
1753 |
|
1754 |
/// <summary> |
1755 |
/// A static helper method to raise the BalloonShowing event on a target element. |
1756 |
/// </summary> |
1757 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
1758 |
/// <param name="source">The <see cref="TaskbarIcon"/> instance that manages the balloon.</param> |
1759 |
internal static RoutedEventArgs RaiseBalloonShowingEvent(DependencyObject target, TaskbarIcon source) |
1760 |
{ |
1761 |
if (target == null) return null; |
1762 |
|
1763 |
RoutedEventArgs args = new RoutedEventArgs(BalloonShowingEvent, source); |
1764 |
RoutedEventHelper.RaiseEvent(target, args); |
1765 |
return args; |
1766 |
} |
1767 |
|
1768 |
#endregion |
1769 |
|
1770 |
#region BalloonClosing |
1771 |
|
1772 |
/// <summary> |
1773 |
/// BalloonClosing Attached Routed Event |
1774 |
/// </summary> |
1775 |
public static readonly RoutedEvent BalloonClosingEvent = EventManager.RegisterRoutedEvent("BalloonClosing", |
1776 |
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon)); |
1777 |
|
1778 |
/// <summary> |
1779 |
/// Adds a handler for the BalloonClosing attached event |
1780 |
/// </summary> |
1781 |
/// <param name="element">UIElement or ContentElement that listens to the event</param> |
1782 |
/// <param name="handler">Event handler to be added</param> |
1783 |
public static void AddBalloonClosingHandler(DependencyObject element, RoutedEventHandler handler) |
1784 |
{ |
1785 |
RoutedEventHelper.AddHandler(element, BalloonClosingEvent, handler); |
1786 |
} |
1787 |
|
1788 |
/// <summary> |
1789 |
/// Removes a handler for the BalloonClosing attached event |
1790 |
/// </summary> |
1791 |
/// <param name="element">UIElement or ContentElement that listens to the event</param> |
1792 |
/// <param name="handler">Event handler to be removed</param> |
1793 |
public static void RemoveBalloonClosingHandler(DependencyObject element, RoutedEventHandler handler) |
1794 |
{ |
1795 |
RoutedEventHelper.RemoveHandler(element, BalloonClosingEvent, handler); |
1796 |
} |
1797 |
|
1798 |
/// <summary> |
1799 |
/// A static helper method to raise the BalloonClosing event on a target element. |
1800 |
/// </summary> |
1801 |
/// <param name="target">UIElement or ContentElement on which to raise the event</param> |
1802 |
/// <param name="source">The <see cref="TaskbarIcon"/> instance that manages the balloon.</param> |
1803 |
internal static RoutedEventArgs RaiseBalloonClosingEvent(DependencyObject target, TaskbarIcon source) |
1804 |
{ |
1805 |
if (target == null) return null; |
1806 |
|
1807 |
RoutedEventArgs args = new RoutedEventArgs(BalloonClosingEvent, source); |
1808 |
RoutedEventHelper.RaiseEvent(target, args); |
1809 |
return args; |
1810 |
} |
1811 |
|
1812 |
#endregion |
1813 |
|
1814 |
|
1815 |
|
1816 |
//ATTACHED PROPERTIES |
1817 |
|
1818 |
#region ParentTaskbarIcon |
1819 |
|
1820 |
/// <summary> |
1821 |
/// An attached property that is assigned to |
1822 |
/// </summary> |
1823 |
public static readonly DependencyProperty ParentTaskbarIconProperty = |
1824 |
DependencyProperty.RegisterAttached("ParentTaskbarIcon", typeof (TaskbarIcon), typeof (TaskbarIcon)); |
1825 |
|
1826 |
/// <summary> |
1827 |
/// Gets the ParentTaskbarIcon property. This dependency property |
1828 |
/// indicates .... |
1829 |
/// </summary> |
1830 |
public static TaskbarIcon GetParentTaskbarIcon(DependencyObject d) |
1831 |
{ |
1832 |
return (TaskbarIcon)d.GetValue(ParentTaskbarIconProperty); |
1833 |
} |
1834 |
|
1835 |
/// <summary> |
1836 |
/// Sets the ParentTaskbarIcon property. This dependency property |
1837 |
/// indicates .... |
1838 |
/// </summary> |
1839 |
public static void SetParentTaskbarIcon(DependencyObject d, TaskbarIcon value) |
1840 |
{ |
1841 |
d.SetValue(ParentTaskbarIconProperty, value); |
1842 |
} |
1843 |
|
1844 |
#endregion |
1845 |
|
1846 |
|
1847 |
//BASE CLASS PROPERTY OVERRIDES |
1848 |
|
1849 |
/// <summary> |
1850 |
/// Registers properties. |
1851 |
/// </summary> |
1852 |
static TaskbarIcon() |
1853 |
{ |
1854 |
//register change listener for the Visibility property |
1855 |
PropertyMetadata md = new PropertyMetadata(Visibility.Visible, VisibilityPropertyChanged); |
1856 |
VisibilityProperty.OverrideMetadata(typeof(TaskbarIcon), md); |
1857 |
|
1858 |
//register change listener for the DataContext property |
1859 |
md = new FrameworkPropertyMetadata(new PropertyChangedCallback(DataContextPropertyChanged)); |
1860 |
DataContextProperty.OverrideMetadata(typeof(TaskbarIcon), md); |
1861 |
|
1862 |
//register change listener for the ContextMenu property |
1863 |
md = new FrameworkPropertyMetadata(new PropertyChangedCallback(ContextMenuPropertyChanged)); |
1864 |
ContextMenuProperty.OverrideMetadata(typeof(TaskbarIcon), md); |
1865 |
} |
1866 |
|
1867 |
|
1868 |
} |
1869 |
} |