* TabControl.cs: Show the tooltip depending on the value
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / NotifyIcon.cs
1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
8 // 
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 // 
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 //
20 // Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
21 //
22 // Authors:
23 //      Peter Bartok    pbartok@novell.com
24 //
25 //
26
27 using System;
28 using System.ComponentModel;
29 using System.ComponentModel.Design;
30 using System.Drawing;
31 using System.Drawing.Text;
32
33 namespace System.Windows.Forms {
34         [DefaultProperty("Text")]
35 #if NET_2_0
36         [DefaultEvent("MouseDoubleClick")]
37 #else
38         [DefaultEvent("MouseDown")]
39 #endif
40         [Designer ("System.Windows.Forms.Design.NotifyIconDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
41         [ToolboxItemFilter("System.Windows.Forms", ToolboxItemFilterType.Allow)]
42         public sealed class NotifyIcon : Component {
43                 #region Local Variables
44                 private ContextMenu             context_menu;
45                 private Icon                    icon;
46                 private Bitmap                  icon_bitmap;
47                 private string                  text;
48                 private bool                    visible;
49                 private NotifyIconWindow        window;
50                 private bool                    systray_active;
51                 private ToolTip                 tooltip;
52                 private bool                    double_click;
53 #if NET_2_0
54                 private string balloon_text;
55                 private string balloon_title;
56                 private ToolTipIcon balloon_icon;
57                 private ContextMenuStrip        context_menu_strip;
58                 private object                  tag;
59 #endif
60                 #endregion      // Local Variables
61
62                 #region NotifyIconWindow Class
63                 internal class NotifyIconWindow : Form {
64                         NotifyIcon      owner;
65                         Rectangle       rect;
66
67                         public NotifyIconWindow(NotifyIcon owner) {
68                                 this.owner = owner;
69                                 is_visible = false;
70                                 rect = new Rectangle(0, 0, 1, 1);
71
72                                 FormBorderStyle = FormBorderStyle.None;
73
74                                 //CreateControl();
75
76                                 SizeChanged += new EventHandler(HandleSizeChanged);
77
78                                 // Events that need to be sent to our parent
79                                 DoubleClick += new EventHandler(HandleDoubleClick);
80                                 MouseDown +=new MouseEventHandler(HandleMouseDown);
81                                 MouseUp +=new MouseEventHandler(HandleMouseUp);
82                                 MouseMove +=new MouseEventHandler(HandleMouseMove);
83                                 ContextMenu = owner.context_menu;
84 #if NET_2_0
85                                 ContextMenuStrip = owner.context_menu_strip;
86 #endif
87                         }
88
89                         protected override CreateParams CreateParams {
90                                 get {
91                                         CreateParams cp;
92
93                                         cp = base.CreateParams;
94
95                                         cp.Parent = IntPtr.Zero;
96                                         cp.Style = (int)WindowStyles.WS_POPUP;
97                                         cp.Style |= (int)WindowStyles.WS_CLIPSIBLINGS;
98
99                                         cp.ExStyle = (int)(WindowExStyles.WS_EX_TOOLWINDOW);
100
101                                         return cp;
102                                 }
103                         }
104
105                         protected override void WndProc(ref Message m) {
106                                 switch((Msg)m.Msg) {
107                                                 //
108                                                 //  NotifyIcon does CONTEXTMENU on mouse up, not down
109                                                 //  so we swallow the message here, and handle it on our own
110                                                 // 
111                                         case Msg.WM_CONTEXTMENU:
112                                                 return;
113
114                                         case Msg.WM_USER: {
115                                                 switch ((Msg)m.LParam.ToInt32()) {
116                                                         case Msg.WM_LBUTTONDOWN: {
117                                                                 owner.OnMouseDown (new MouseEventArgs(MouseButtons.Left, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
118                                                                 return;
119                                                         }
120
121                                                         case Msg.WM_LBUTTONUP: {
122                                                                 owner.OnMouseUp (new MouseEventArgs(MouseButtons.Left, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
123                                                                 return;
124                                                         }
125
126                                                         case Msg.WM_LBUTTONDBLCLK: {
127                                                                 owner.OnDoubleClick (EventArgs.Empty);
128 #if NET_2_0
129                                                                 owner.OnMouseDoubleClick (new MouseEventArgs (MouseButtons.Left, 2, Control.MousePosition.X, Control.MousePosition.Y, 0));
130 #endif
131                                                                 return;
132                                                         }
133
134                                                         case Msg.WM_MOUSEMOVE: {
135                                                                 owner.OnMouseMove (new MouseEventArgs(MouseButtons.None, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
136                                                                 return;
137                                                         }
138
139                                                         case Msg.WM_RBUTTONDOWN: {
140                                                                 owner.OnMouseDown (new MouseEventArgs(MouseButtons.Right, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
141                                                                 return;
142                                                         }
143
144                                                         case Msg.WM_RBUTTONUP: {
145                                                                 owner.OnMouseUp (new MouseEventArgs(MouseButtons.Right, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
146                                                                 return;
147                                                         }
148
149                                                         case Msg.WM_RBUTTONDBLCLK: {
150                                                                 owner.OnDoubleClick (EventArgs.Empty);
151 #if NET_2_0
152                                                                 owner.OnMouseDoubleClick (new MouseEventArgs (MouseButtons.Left, 2, Control.MousePosition.X, Control.MousePosition.Y, 0));
153 #endif
154                                                                 return;
155                                                         }
156 #if NET_2_0                                                     
157                                                         case Msg.NIN_BALLOONUSERCLICK: {
158                                                                 owner.OnBalloonTipClicked (EventArgs.Empty);
159                                                                 return;
160                                                         }
161
162                                                         case Msg.NIN_BALLOONSHOW: {
163                                                                 owner.OnBalloonTipShown (EventArgs.Empty);
164                                                                 return;
165                                                         }
166
167                                                         case Msg.NIN_BALLOONHIDE:
168                                                         case Msg.NIN_BALLOONTIMEOUT: {
169                                                                 owner.OnBalloonTipClosed (EventArgs.Empty);
170                                                                 return;
171                                                         }
172 #endif
173                                                 }
174                                                 return;
175                                         }
176                                 }
177                                 base.WndProc (ref m);
178                         }
179
180                         internal void CalculateIconRect() {
181                                 int             x;
182                                 int             y;
183                                 int             size;
184
185                                 // Icons are always square. Try to center them in the window
186                                 if (ClientRectangle.Width < ClientRectangle.Height) {
187                                         size = ClientRectangle.Width;
188                                 } else {
189                                         size = ClientRectangle.Height;
190                                 }
191                                 x = this.ClientRectangle.Width / 2 - size / 2;
192                                 y = this.ClientRectangle.Height / 2 - size / 2;
193                                 rect = new Rectangle(x, y, size, size);
194
195                                 Bounds = new Rectangle (0, 0, size, size);
196                         }
197
198                         internal override void OnPaintInternal (PaintEventArgs e) {
199                                 if (owner.icon != null) {
200                                         e.Graphics.FillRectangle(ThemeEngine.Current.ResPool.GetSolidBrush(SystemColors.Window), rect);
201                                         e.Graphics.DrawImage(owner.icon_bitmap,
202                                                              rect,
203                                                              new Rectangle (0, 0, owner.icon_bitmap.Width, owner.icon_bitmap.Height),
204                                                              GraphicsUnit.Pixel);
205
206                                 }
207                         }
208
209                         internal void InternalRecreateHandle () {
210                                 base.RecreateHandle ();
211                         }
212
213                         private void HandleSizeChanged(object sender, EventArgs e) {
214                                 owner.Recalculate ();
215                         }
216
217                         private void HandleDoubleClick (object sender, EventArgs e)
218                         {
219                                 owner.OnDoubleClick (e);
220 #if NET_2_0
221                                 owner.OnMouseDoubleClick (new MouseEventArgs (MouseButtons.Left, 2, Control.MousePosition.X, Control.MousePosition.Y, 0));
222 #endif
223                         }
224
225                         private void HandleMouseDown (object sender, MouseEventArgs e)
226                         {
227                                 owner.OnMouseDown (e);
228                         }
229
230                         private void HandleMouseUp (object sender, MouseEventArgs e)
231                         {
232                                 owner.OnMouseUp (e);
233                         }
234
235                         private void HandleMouseMove (object sender, MouseEventArgs e)
236                         {
237                                 owner.OnMouseMove (e);
238                         }
239                 }
240                 #endregion      // NotifyIconWindow Class
241                 
242                 #region NotifyIconBalloonWindow Class
243 #if NET_2_0
244                 internal class BalloonWindow : Form 
245                 {
246                         private IntPtr owner;
247                         private Timer timer;
248                         
249                         private string title;
250                         private string text;
251                         private ToolTipIcon icon;
252
253                         public BalloonWindow (IntPtr owner)
254                         {
255                                 this.owner = owner;
256                                 
257                                 StartPosition = FormStartPosition.Manual;
258                                 FormBorderStyle = FormBorderStyle.None;
259
260                                 MouseDown += new MouseEventHandler (HandleMouseDown);
261                                 
262                                 timer = new Timer ();
263                                 timer.Enabled = false;
264                                 timer.Tick += new EventHandler (HandleTimer);
265                         }
266
267                         public IntPtr OwnerHandle {
268                                 get {
269                                         return owner;
270                                 }
271                         }
272                         
273                         protected override void Dispose (bool disposing)
274                         {
275                                 if (disposing) {
276                                         timer.Stop();
277                                         timer.Dispose();
278                                 }
279                                 base.Dispose (disposing);
280                         }
281
282                         protected override CreateParams CreateParams {
283                                 get {
284                                         CreateParams cp;
285
286                                         cp = base.CreateParams;
287
288                                         cp.Style = (int)WindowStyles.WS_POPUP;
289                                         cp.Style |= (int)WindowStyles.WS_CLIPSIBLINGS;
290
291                                         cp.ExStyle = (int)(WindowExStyles.WS_EX_TOOLWINDOW | WindowExStyles.WS_EX_TOPMOST);
292
293                                         return cp;
294                                 }
295                         }
296
297                         public new void Close () {
298                                 base.Close ();
299                                 XplatUI.SendMessage (owner, Msg.WM_USER, IntPtr.Zero, (IntPtr) Msg.NIN_BALLOONHIDE);
300                         }
301                         
302                         protected override void OnShown (EventArgs e)
303                         {
304                                 base.OnShown (e);
305                                 timer.Start ();
306                         }
307                         
308                         protected override void OnPaint (PaintEventArgs e) 
309                         {
310                                 ThemeEngine.Current.DrawBalloonWindow (e.Graphics, ClientRectangle, this);
311                                 base.OnPaint (e);
312                         }
313
314                         private void Recalculate () 
315                         {
316                                 Rectangle rect = ThemeEngine.Current.BalloonWindowRect (this);
317                                 
318                                 Left = rect.Left;
319                                 Top = rect.Top;
320                                 Width = rect.Width;
321                                 Height = rect.Height;
322                         }
323
324                         // To be used when we have a "close button" inside balloon.
325                         //private void HandleClick (object sender, EventArgs e)
326                         //{
327                         //      Close ();
328                         //}
329
330                         private void HandleMouseDown (object sender, MouseEventArgs e)
331                         {
332                                 XplatUI.SendMessage (owner, Msg.WM_USER, IntPtr.Zero, (IntPtr) Msg.NIN_BALLOONUSERCLICK);
333                                 base.Close ();
334                         }
335
336                         private void HandleTimer (object sender, EventArgs e)
337                         {
338                                 timer.Stop ();
339                                 XplatUI.SendMessage (owner, Msg.WM_USER, IntPtr.Zero, (IntPtr) Msg.NIN_BALLOONTIMEOUT);
340                                 base.Close ();
341                         }
342                         
343                         internal StringFormat Format {
344                                 get {
345                                         StringFormat format = new StringFormat ();
346                                         format.Alignment = StringAlignment.Near;
347                                         format.HotkeyPrefix = HotkeyPrefix.Hide;
348
349                                         return format;
350                                 }
351                         }
352
353                         public new ToolTipIcon Icon {
354                                 get { return this.icon; }
355                                 set { 
356                                         if (value == this.icon)
357                                                 return;
358
359                                         this.icon = value;
360                                         Recalculate ();
361                                 }
362                         }
363
364                         public string Title {
365                                 get { return this.title; }
366                                 set { 
367                                         if (value == this.title)
368                                                 return;
369
370                                         this.title = value;
371                                         Recalculate ();
372                                 }
373                         }
374
375                         public override string Text {
376                                 get { return this.text; }
377                                 set { 
378                                         if (value == this.text)
379                                                 return;
380
381                                         this.text = value;
382                                         Recalculate ();
383                                 }
384                         }
385                         
386                         public int Timeout {
387                                 get { return timer.Interval; }
388                                 set {
389                                         // Some systems theres a limitiation in timeout, WinXP is between 10k and 30k.
390                                         if (value < 10000)
391                                                 timer.Interval = 10000;
392                                         else if (value > 30000)
393                                                 timer.Interval = 30000;
394                                         else
395                                                 timer.Interval = value;
396                                 }
397                         }
398                 }
399 #endif
400                 #endregion  // NotifyIconBalloonWindow Class
401
402                 #region Public Constructors
403                 public NotifyIcon() {
404                         window = new NotifyIconWindow(this);
405                         systray_active = false;
406
407 #if NET_2_0                     
408                         balloon_title = "";
409                         balloon_text = "";
410 #endif
411                 }
412
413                 public NotifyIcon(System.ComponentModel.IContainer container) : this() {
414                 }
415                 #endregion      // Public Constructors
416
417                 #region Public Methods
418 #if NET_2_0
419                 public void ShowBalloonTip (int timeout)
420                 {
421                         ShowBalloonTip(timeout, balloon_title, balloon_text, balloon_icon);
422                 }
423
424                 public void ShowBalloonTip(int timeout, string tipTitle, string tipText, ToolTipIcon tipIcon)
425                 {
426                         XplatUI.SystrayBalloon(window.Handle, timeout, tipTitle, tipText, tipIcon);
427                 }
428 #endif
429                 #endregion Public Methods
430                 
431                 #region Private Methods
432 #if NET_2_0
433                 private void OnBalloonTipClicked (EventArgs e)
434                 {
435                         EventHandler eh = (EventHandler)(Events [BalloonTipClickedEvent]);
436                         if (eh != null)
437                                 eh (this, e);
438                 }
439
440                 private void OnBalloonTipClosed (EventArgs e)
441                 {
442                         EventHandler eh = (EventHandler)(Events [BalloonTipClosedEvent]);
443                         if (eh != null)
444                                 eh (this, e);
445                 }
446
447                 private void OnBalloonTipShown (EventArgs e)
448                 {
449                         EventHandler eh = (EventHandler)(Events [BalloonTipShownEvent]);
450                         if (eh != null)
451                                 eh (this, e);
452                 }
453 #endif
454                 private void OnClick (EventArgs e)
455                 {
456                         EventHandler eh = (EventHandler)(Events [ClickEvent]);
457                         if (eh != null)
458                                 eh (this, e);
459                 }
460
461                 private void OnDoubleClick (EventArgs e)
462                 {
463                         double_click = true;
464                         EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
465                         if (eh != null)
466                                 eh (this, e);
467                 }
468
469 #if NET_2_0
470                 private void OnMouseClick (MouseEventArgs e)
471                 {
472                         MouseEventHandler eh = (MouseEventHandler)(Events[MouseClickEvent]);
473                         if (eh != null)
474                                 eh (this, e);
475                 }
476                 
477                 private void OnMouseDoubleClick (MouseEventArgs e)
478                 {
479                         MouseEventHandler eh = (MouseEventHandler)(Events[MouseDoubleClickEvent]);
480                         if (eh != null)
481                                 eh (this, e);
482                 }
483 #endif
484
485                 private void OnMouseDown (MouseEventArgs e)
486                 {
487                         MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
488                         if (eh != null)
489                                 eh (this, e);
490                 }
491
492                 private void OnMouseUp (MouseEventArgs e)
493                 {
494                         if ((e.Button & MouseButtons.Right) == MouseButtons.Right) {
495                                 if (context_menu != null) {
496                                         XplatUI.SetForegroundWindow (window.Handle);
497                                         context_menu.Show (window, new Point(e.X, e.Y));
498                                 } 
499 #if NET_2_0
500                                 else if (context_menu_strip != null) {
501                                         XplatUI.SetForegroundWindow (window.Handle);
502                                         context_menu_strip.Show (window, new Point (e.X, e.Y), ToolStripDropDownDirection.AboveLeft);
503                                 }
504 #endif
505                         }
506
507                         MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
508                         if (eh != null)
509                                 eh (this, e);
510
511                         if (!double_click) {
512                                 OnClick (EventArgs.Empty);
513 #if NET_2_0
514                                 OnMouseClick (e);
515 #endif
516                                 double_click = false;
517                         }
518                 }
519
520                 private void OnMouseMove (MouseEventArgs e)
521                 {
522                         MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
523                         if (eh != null)
524                                 eh (this, e);
525                 }
526
527                 private void Recalculate () 
528                 {
529                         window.CalculateIconRect ();
530
531                         if (!Visible || (text == string.Empty && icon == null)) {
532                                 HideSystray ();
533                         } else {
534
535                                 if (systray_active)
536                                         UpdateSystray ();
537                                 else
538                                         ShowSystray ();
539                         }
540                 }
541
542                 private void ShowSystray()
543                 {
544                         if (icon == null)
545                                 return;
546
547                         icon_bitmap = icon.ToBitmap();
548
549                         systray_active = true;
550                         XplatUI.SystrayAdd(window.Handle, text, icon, out tooltip);
551                 }
552
553                 private void HideSystray()
554                 {
555                         if (!systray_active) {
556                                 return;
557                         }
558
559                         systray_active = false;
560                         XplatUI.SystrayRemove(window.Handle, ref tooltip);
561                 }
562
563                 private void UpdateSystray()
564                 {
565                         if (icon_bitmap != null) {
566                                 icon_bitmap.Dispose();
567                         }
568
569                         if (icon != null) {
570                                 icon_bitmap = icon.ToBitmap();
571                         }
572
573                         window.Invalidate();
574                         XplatUI.SystrayChange(window.Handle, text, icon, ref tooltip);
575                 }
576                 #endregion      // Private Methods
577
578                 #region Public Instance Properties
579 #if NET_2_0
580                 [DefaultValue ("None")]
581                 public ToolTipIcon BalloonTipIcon {
582                         get { return this.balloon_icon; }
583                         set {
584                                 if (value == this.balloon_icon)
585                                         return;
586                 
587                 this.balloon_icon = value;
588                         }
589                 }
590
591                 [Localizable(true)]
592                 [DefaultValue ("")]
593                 [Editor ("System.ComponentModel.Design.MultilineStringEditor, " + Consts.AssemblySystem_Design,
594                          "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
595                 public string BalloonTipText {
596                         get { return this.balloon_text; }
597                         set {
598                                 if (value == this.balloon_text)
599                                         return;
600                                 
601                                 this.balloon_text = value;
602                         }
603                 }
604                 
605                 [Localizable(true)]
606                 [DefaultValue ("")]
607                 public string BalloonTipTitle {
608                         get { return this.balloon_title; }
609                         set {
610                                 if (value == this.balloon_title)
611                                         return;
612         
613                                 this.balloon_title = value;
614                         }
615                 }
616 #endif
617                 
618                 [DefaultValue(null)]
619 #if NET_2_0
620                 [Browsable (false)]
621 #endif
622                 public ContextMenu ContextMenu {
623                         get {
624                                 return context_menu;
625                         }
626
627                         set {
628                                 if (context_menu != value) {
629                                         context_menu = value;
630                                         window.ContextMenu = value;
631                                 }
632                         }
633                 }
634
635 #if NET_2_0
636                 [DefaultValue (null)]
637                 public ContextMenuStrip ContextMenuStrip {
638                         get { return this.context_menu_strip; }
639                         set {
640                                 if (this.context_menu_strip != value) {
641                                         this.context_menu_strip = value;
642                                         window.ContextMenuStrip = value;
643                                 }
644                         }
645                 }
646 #endif
647
648                 [Localizable(true)]
649                 [DefaultValue(null)]
650                 public Icon Icon {
651                         get {
652                                 return icon;
653                         }
654
655                         set {
656                                 if (icon != value) {
657                                         icon = value;
658                                         Recalculate ();
659                                 }
660                         }
661                 }
662
663 #if NET_2_0
664                 [Localizable (false)]
665                 [Bindable (true)]
666                 [TypeConverter (typeof (StringConverter))]
667                 [DefaultValue (null)]
668                 public object Tag {
669                         get { return this.tag; }
670                         set { this.tag = value; }
671                 }
672
673                 [DefaultValue ("")]
674                 [Editor ("System.ComponentModel.Design.MultilineStringEditor, " + Consts.AssemblySystem_Design,
675                          typeof (System.Drawing.Design.UITypeEditor))]
676 #endif
677                 [Localizable (true)]
678                 public string Text {
679                         get {
680                                 return text;
681                         }
682
683                         set {
684                                 if (text != value) {
685                                         if (value.Length >= 64) {
686                                                 throw new ArgumentException("ToolTip length must be less than 64 characters long", "Text");
687                                         }
688                                         text = value;
689                                         Recalculate ();
690                                 }
691                         }
692                 }
693
694                 [Localizable(true)]
695                 [DefaultValue(false)]
696                 public bool Visible {
697                         get {
698                                 return visible;
699                         }
700
701                         set {
702                                 if (visible != value) {
703                                         visible = value;
704
705                                         // Let our control know, too
706                                         window.is_visible = value;
707
708                                         if (visible) {
709                                                 ShowSystray ();
710                                         } else {
711                                                 HideSystray();
712                                         }
713                                 }
714                         }
715                 }
716                 #endregion      // Public Instance Properties
717
718                 #region Protected Instance Methods
719                 protected override void Dispose(bool disposing) {
720                         if (visible)
721                                 HideSystray();
722
723                         if (icon_bitmap != null) {
724                                 icon_bitmap.Dispose();
725                         }
726
727                         if (disposing)
728                                 icon = null;
729
730                         base.Dispose (disposing);
731                 }
732
733                 #endregion      // Protected Instance Methods
734
735                 #region Events
736                 static object ClickEvent = new object ();
737                 static object DoubleClickEvent = new object ();
738                 static object MouseDownEvent = new object ();
739                 static object MouseMoveEvent = new object ();
740                 static object MouseUpEvent = new object ();
741
742 #if NET_2_0
743                 static object BalloonTipClickedEvent = new object ();
744                 static object BalloonTipClosedEvent = new object ();
745                 static object BalloonTipShownEvent = new object ();
746                 static object MouseClickEvent = new object ();
747                 static object MouseDoubleClickEvent = new object ();
748
749                 [MWFCategory("Action")]
750                 public event EventHandler BalloonTipClicked {
751                         add { Events.AddHandler (BalloonTipClickedEvent, value); }
752                         remove { Events.RemoveHandler (BalloonTipClickedEvent, value); }
753                 }
754
755                 [MWFCategory("Action")]
756                 public event EventHandler BalloonTipClosed {
757                         add { Events.AddHandler (BalloonTipClosedEvent, value); }
758                         remove { Events.RemoveHandler (BalloonTipClosedEvent, value); }
759                 }
760
761                 [MWFCategory("Action")]
762                 public event EventHandler BalloonTipShown {
763                         add { Events.AddHandler (BalloonTipShownEvent, value); }
764                         remove { Events.RemoveHandler (BalloonTipShownEvent, value); }
765                 }
766
767                 [MWFCategory("Action")]
768                 public event MouseEventHandler MouseClick {
769                         add { Events.AddHandler (MouseClickEvent, value); }
770                         remove { Events.RemoveHandler (MouseClickEvent, value); }
771                 }
772
773                 [MWFCategory ("Action")]
774                 public event MouseEventHandler MouseDoubleClick {
775                         add { Events.AddHandler (MouseDoubleClickEvent, value); }
776                         remove { Events.RemoveHandler (MouseDoubleClickEvent, value); }
777                 }
778 #endif
779
780 #if NET_2_0
781                 [MWFCategory("Action")]
782 #else
783                 [Category("Action")]
784 #endif
785                 public event EventHandler Click {
786                         add { Events.AddHandler (ClickEvent, value); }
787                         remove { Events.RemoveHandler (ClickEvent, value); }
788                 }
789
790 #if NET_2_0
791                 [MWFCategory("Action")]
792 #else
793                 [Category("Action")]
794 #endif
795                 public event EventHandler DoubleClick {
796                         add { Events.AddHandler (DoubleClickEvent, value); }
797                         remove { Events.RemoveHandler (DoubleClickEvent, value); }
798                 }
799
800                 public event MouseEventHandler MouseDown {
801                         add { Events.AddHandler (MouseDownEvent, value); }
802                         remove { Events.RemoveHandler (MouseDownEvent, value); }
803                 }
804
805                 public event MouseEventHandler MouseMove {
806                         add { Events.AddHandler (MouseMoveEvent, value); }
807                         remove { Events.RemoveHandler (MouseMoveEvent, value); }
808                 }
809
810                 public event MouseEventHandler MouseUp {
811                         add { Events.AddHandler (MouseUpEvent, value); }
812                         remove { Events.RemoveHandler (MouseUpEvent, value); }
813                 }
814
815                 #endregion      // Events
816         }
817 }