2008-03-27 Carlos Alberto Cortez <calberto.cortez@gmail.com>
[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 #if NET_2_0
53                 private string balloon_text;
54                 private string balloon_title;
55                 private ToolTipIcon balloon_icon;
56                 private ContextMenuStrip        context_menu_strip;
57                 private object                  tag;
58 #endif
59                 #endregion      // Local Variables
60
61                 #region NotifyIconWindow Class
62                 internal class NotifyIconWindow : Form {
63                         NotifyIcon      owner;
64                         Rectangle       rect;
65
66                         public NotifyIconWindow(NotifyIcon owner) {
67                                 this.owner = owner;
68                                 is_visible = false;
69                                 rect = new Rectangle(0, 0, 1, 1);
70
71                                 FormBorderStyle = FormBorderStyle.None;
72
73                                 //CreateControl();
74
75                                 SizeChanged += new EventHandler(HandleSizeChanged);
76
77                                 // Events that need to be sent to our parent
78                                 Click += new EventHandler(HandleClick);
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                                                                 owner.OnClick (EventArgs.Empty);
124 #if NET_2_0
125                                                                 owner.OnMouseClick (new MouseEventArgs (MouseButtons.Left, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
126 #endif
127                                                                 return;
128                                                         }
129
130                                                         case Msg.WM_LBUTTONDBLCLK: {
131                                                                 owner.OnDoubleClick (EventArgs.Empty);
132 #if NET_2_0
133                                                                 owner.OnMouseDoubleClick (new MouseEventArgs (MouseButtons.Left, 2, Control.MousePosition.X, Control.MousePosition.Y, 0));
134 #endif
135                                                                 return;
136                                                         }
137
138                                                         case Msg.WM_MOUSEMOVE: {
139                                                                 owner.OnMouseMove (new MouseEventArgs(MouseButtons.None, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
140                                                                 return;
141                                                         }
142
143                                                         case Msg.WM_RBUTTONDOWN: {
144                                                                 owner.OnMouseDown (new MouseEventArgs(MouseButtons.Right, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
145                                                                 return;
146                                                         }
147
148                                                         case Msg.WM_RBUTTONUP: {
149                                                                 owner.OnMouseUp (new MouseEventArgs(MouseButtons.Right, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
150                                                                 owner.OnClick (EventArgs.Empty);
151 #if NET_2_0
152                                                                 owner.OnMouseClick (new MouseEventArgs (MouseButtons.Right, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
153 #endif
154                                                                 return;
155                                                         }
156
157                                                         case Msg.WM_RBUTTONDBLCLK: {
158                                                                 owner.OnDoubleClick (EventArgs.Empty);
159 #if NET_2_0
160                                                                 owner.OnMouseDoubleClick (new MouseEventArgs (MouseButtons.Left, 2, Control.MousePosition.X, Control.MousePosition.Y, 0));
161 #endif
162                                                                 return;
163                                                         }
164 #if NET_2_0                                                     
165                                                         case Msg.NIN_BALLOONUSERCLICK: {
166                                                                 owner.OnBalloonTipClicked (EventArgs.Empty);
167                                                                 return;
168                                                         }
169
170                                                         case Msg.NIN_BALLOONSHOW: {
171                                                                 owner.OnBalloonTipShown (EventArgs.Empty);
172                                                                 return;
173                                                         }
174
175                                                         case Msg.NIN_BALLOONHIDE:
176                                                         case Msg.NIN_BALLOONTIMEOUT: {
177                                                                 owner.OnBalloonTipClosed (EventArgs.Empty);
178                                                                 return;
179                                                         }
180 #endif
181                                                 }
182                                                 return;
183                                         }
184                                 }
185                                 base.WndProc (ref m);
186                         }
187
188                         internal void CalculateIconRect() {
189                                 int             x;
190                                 int             y;
191                                 int             size;
192
193                                 // Icons are always square. Try to center them in the window
194                                 if (ClientRectangle.Width < ClientRectangle.Height) {
195                                         size = ClientRectangle.Width;
196                                 } else {
197                                         size = ClientRectangle.Height;
198                                 }
199                                 x = this.ClientRectangle.Width / 2 - size / 2;
200                                 y = this.ClientRectangle.Height / 2 - size / 2;
201                                 rect = new Rectangle(x, y, size, size);
202
203                                 Bounds = new Rectangle (0, 0, size, size);
204                         }
205
206                         internal override void OnPaintInternal (PaintEventArgs e) {
207                                 if (owner.icon != null) {
208                                         e.Graphics.FillRectangle(ThemeEngine.Current.ResPool.GetSolidBrush(SystemColors.Window), rect);
209                                         e.Graphics.DrawImage(owner.icon_bitmap,
210                                                              rect,
211                                                              new Rectangle (0, 0, owner.icon_bitmap.Width, owner.icon_bitmap.Height),
212                                                              GraphicsUnit.Pixel);
213
214                                 }
215                         }
216
217                         internal void InternalRecreateHandle () {
218                                 base.RecreateHandle ();
219                         }
220
221
222                         private void HandleSizeChanged(object sender, EventArgs e) {
223                                 owner.Recalculate ();
224                         }
225
226                         private void HandleClick (object sender, EventArgs e)
227                         {
228                                 owner.OnClick (e);
229 #if NET_2_0
230                                 owner.OnMouseClick (new MouseEventArgs (MouseButtons.Left, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
231 #endif
232                         }
233
234                         private void HandleDoubleClick (object sender, EventArgs e)
235                         {
236                                 owner.OnDoubleClick (e);
237 #if NET_2_0
238                                 owner.OnMouseDoubleClick (new MouseEventArgs (MouseButtons.Left, 2, Control.MousePosition.X, Control.MousePosition.Y, 0));
239 #endif
240                         }
241
242                         private void HandleMouseDown (object sender, MouseEventArgs e)
243                         {
244                                 owner.OnMouseDown (e);
245                         }
246
247                         private void HandleMouseUp (object sender, MouseEventArgs e)
248                         {
249                                 owner.OnMouseUp (e);
250                         }
251
252                         private void HandleMouseMove (object sender, MouseEventArgs e)
253                         {
254                                 owner.OnMouseMove (e);
255                         }
256                 }
257                 #endregion      // NotifyIconWindow Class
258                 
259                 #region NotifyIconBalloonWindow Class
260 #if NET_2_0
261                 internal class BalloonWindow : Form 
262                 {
263                         private IntPtr owner;
264                         private Timer timer;
265                         
266                         private string title;
267                         private string text;
268                         private ToolTipIcon icon;
269
270                         public BalloonWindow (IntPtr owner)
271                         {
272                                 this.owner = owner;
273                                 
274                                 StartPosition = FormStartPosition.Manual;
275                                 FormBorderStyle = FormBorderStyle.None;
276
277                                 MouseDown += new MouseEventHandler (HandleMouseDown);
278                                 
279                                 timer = new Timer ();
280                                 timer.Enabled = false;
281                                 timer.Tick += new EventHandler (HandleTimer);
282                         }
283                         
284                         protected override void Dispose (bool disposing)
285                         {
286                                 if (disposing) {
287                                         timer.Stop();
288                                         timer.Dispose();
289                                 }
290                                 base.Dispose (disposing);
291                         }
292
293                         protected override CreateParams CreateParams {
294                                 get {
295                                         CreateParams cp;
296
297                                         cp = base.CreateParams;
298
299                                         cp.Style = (int)WindowStyles.WS_POPUP;
300                                         cp.Style |= (int)WindowStyles.WS_CLIPSIBLINGS;
301
302                                         cp.ExStyle = (int)(WindowExStyles.WS_EX_TOOLWINDOW | WindowExStyles.WS_EX_TOPMOST);
303
304                                         return cp;
305                                 }
306                         }
307
308                         public new void Close () {
309                                 base.Close ();
310                                 XplatUI.SendMessage (owner, Msg.WM_USER, IntPtr.Zero, (IntPtr) Msg.NIN_BALLOONHIDE);
311                         }
312                         
313                         protected override void OnShown (EventArgs e)
314                         {
315                                 base.OnShown (e);
316                                 timer.Start ();
317                         }
318                         
319                         protected override void OnPaint (PaintEventArgs e) 
320                         {
321                                 ThemeEngine.Current.DrawBalloonWindow (e.Graphics, ClientRectangle, this);
322                                 base.OnPaint (e);
323                         }
324
325                         private void Recalculate () 
326                         {
327                                 Rectangle rect = ThemeEngine.Current.BalloonWindowRect (this);
328                                 
329                                 Left = rect.Left;
330                                 Top = rect.Top;
331                                 Width = rect.Width;
332                                 Height = rect.Height;
333                         }
334
335                         // To be used when we have a "close button" inside balloon.
336                         //private void HandleClick (object sender, EventArgs e)
337                         //{
338                         //      Close ();
339                         //}
340
341                         private void HandleMouseDown (object sender, MouseEventArgs e)
342                         {
343                                 XplatUI.SendMessage (owner, Msg.WM_USER, IntPtr.Zero, (IntPtr) Msg.NIN_BALLOONUSERCLICK);
344                                 base.Close ();
345                         }
346
347                         private void HandleTimer (object sender, EventArgs e)
348                         {
349                                 timer.Stop ();
350                                 XplatUI.SendMessage (owner, Msg.WM_USER, IntPtr.Zero, (IntPtr) Msg.NIN_BALLOONTIMEOUT);
351                                 base.Close ();
352                         }
353                         
354                         internal StringFormat Format {
355                                 get {
356                                         StringFormat format = new StringFormat ();
357                                         format.Alignment = StringAlignment.Near;
358                                         format.HotkeyPrefix = HotkeyPrefix.Hide;
359
360                                         return format;
361                                 }
362                         }
363
364                         public new ToolTipIcon Icon {
365                                 get { return this.icon; }
366                                 set { 
367                                         if (value == this.icon)
368                                                 return;
369
370                                         this.icon = value;
371                                         Recalculate ();
372                                 }
373                         }
374
375                         public string Title {
376                                 get { return this.title; }
377                                 set { 
378                                         if (value == this.title)
379                                                 return;
380
381                                         this.title = value;
382                                         Recalculate ();
383                                 }
384                         }
385
386                         public override string Text {
387                                 get { return this.text; }
388                                 set { 
389                                         if (value == this.text)
390                                                 return;
391
392                                         this.text = value;
393                                         Recalculate ();
394                                 }
395                         }
396                         
397                         public int Timeout {
398                                 get { return timer.Interval; }
399                                 set {
400                                         // Some systems theres a limitiation in timeout, WinXP is between 10k and 30k.
401                                         if (value < 10000)
402                                                 timer.Interval = 10000;
403                                         else if (value > 30000)
404                                                 timer.Interval = 30000;
405                                         else
406                                                 timer.Interval = value;
407                                 }
408                         }
409                 }
410 #endif
411                 #endregion  // NotifyIconBalloonWindow Class
412
413                 #region Public Constructors
414                 public NotifyIcon() {
415                         window = new NotifyIconWindow(this);
416                         systray_active = false;
417
418 #if NET_2_0                     
419                         balloon_title = "";
420                         balloon_text = "";
421 #endif
422                 }
423
424                 public NotifyIcon(System.ComponentModel.IContainer container) : this() {
425                 }
426                 #endregion      // Public Constructors
427
428                 #region Public Methods
429 #if NET_2_0
430                 public void ShowBalloonTip (int timeout)
431                 {
432                         ShowBalloonTip(timeout, balloon_title, balloon_text, balloon_icon);
433                 }
434
435                 public void ShowBalloonTip(int timeout, string tipTitle, string tipText, ToolTipIcon tipIcon)
436                 {
437                         XplatUI.SystrayBalloon(window.Handle, timeout, tipTitle, tipText, tipIcon);
438                 }
439 #endif
440                 #endregion Public Methods
441                 
442                 #region Private Methods
443 #if NET_2_0
444                 private void OnBalloonTipClicked (EventArgs e)
445                 {
446                         EventHandler eh = (EventHandler)(Events [BalloonTipClickedEvent]);
447                         if (eh != null)
448                                 eh (this, e);
449                 }
450
451                 private void OnBalloonTipClosed (EventArgs e)
452                 {
453                         EventHandler eh = (EventHandler)(Events [BalloonTipClosedEvent]);
454                         if (eh != null)
455                                 eh (this, e);
456                 }
457
458                 private void OnBalloonTipShown (EventArgs e)
459                 {
460                         EventHandler eh = (EventHandler)(Events [BalloonTipShownEvent]);
461                         if (eh != null)
462                                 eh (this, e);
463                 }
464 #endif
465                 private void OnClick (EventArgs e)
466                 {
467                         EventHandler eh = (EventHandler)(Events [ClickEvent]);
468                         if (eh != null)
469                                 eh (this, e);
470                 }
471
472                 private void OnDoubleClick (EventArgs e)
473                 {
474                         EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
475                         if (eh != null)
476                                 eh (this, e);
477                 }
478
479 #if NET_2_0
480                 private void OnMouseClick (MouseEventArgs e)
481                 {
482                         MouseEventHandler eh = (MouseEventHandler)(Events[MouseClickEvent]);
483                         if (eh != null)
484                                 eh (this, e);
485                 }
486                 
487                 private void OnMouseDoubleClick (MouseEventArgs e)
488                 {
489                         MouseEventHandler eh = (MouseEventHandler)(Events[MouseDoubleClickEvent]);
490                         if (eh != null)
491                                 eh (this, e);
492                 }
493 #endif
494
495                 private void OnMouseDown (MouseEventArgs e)
496                 {
497                         MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
498                         if (eh != null)
499                                 eh (this, e);
500                 }
501
502                 private void OnMouseUp (MouseEventArgs e)
503                 {
504                         if ((e.Button & MouseButtons.Right) == MouseButtons.Right && context_menu != null)
505                                 context_menu.Show (window, new Point(e.X, e.Y));
506 #if NET_2_0
507                         else if ((e.Button & MouseButtons.Right) == MouseButtons.Right && context_menu_strip != null)
508                                 context_menu_strip.Show (window, new Point (e.X, e.Y), ToolStripDropDownDirection.AboveLeft);
509 #endif
510                         
511                         MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
512                         if (eh != null)
513                                 eh (this, e);
514                 }
515
516                 private void OnMouseMove (MouseEventArgs e)
517                 {
518                         MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
519                         if (eh != null)
520                                 eh (this, e);
521                 }
522
523                 private void Recalculate () 
524                 {
525                         window.CalculateIconRect ();
526
527                         if (!Visible || (text == string.Empty && icon == null)) {
528                                 HideSystray ();
529                         } else {
530
531                                 if (systray_active)
532                                         UpdateSystray ();
533                                 else
534                                         ShowSystray ();
535                         }
536                 }
537
538                 private void ShowSystray()
539                 {
540                         if (icon == null)
541                                 return;
542
543                         icon_bitmap = icon.ToBitmap();
544
545                         systray_active = true;
546                         XplatUI.SystrayAdd(window.Handle, text, icon, out tooltip);
547                 }
548
549                 private void HideSystray()
550                 {
551                         if (!systray_active) {
552                                 return;
553                         }
554
555                         systray_active = false;
556                         XplatUI.SystrayRemove(window.Handle, ref tooltip);
557                 }
558
559                 private void UpdateSystray()
560                 {
561                         if (icon_bitmap != null) {
562                                 icon_bitmap.Dispose();
563                         }
564
565                         if (icon != null) {
566                                 icon_bitmap = icon.ToBitmap();
567                         }
568
569                         window.Invalidate();
570                         XplatUI.SystrayChange(window.Handle, text, icon, ref tooltip);
571                 }
572                 #endregion      // Private Methods
573
574                 #region Public Instance Properties
575 #if NET_2_0
576                 [DefaultValue ("None")]
577                 public ToolTipIcon BalloonTipIcon {
578                         get { return this.balloon_icon; }
579                         set {
580                                 if (value == this.balloon_icon)
581                                         return;
582                 
583                 this.balloon_icon = value;
584                         }
585                 }
586
587                 [Localizable(true)]
588                 [DefaultValue ("")]
589                 [Editor ("System.ComponentModel.Design.MultilineStringEditor, " + Consts.AssemblySystem_Design,
590                          "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
591                 public string BalloonTipText {
592                         get { return this.balloon_text; }
593                         set {
594                                 if (value == this.balloon_text)
595                                         return;
596                                 
597                                 this.balloon_text = value;
598                         }
599                 }
600                 
601                 [Localizable(true)]
602                 [DefaultValue ("")]
603                 public string BalloonTipTitle {
604                         get { return this.balloon_title; }
605                         set {
606                                 if (value == this.balloon_title)
607                                         return;
608         
609                                 this.balloon_title = value;
610                         }
611                 }
612 #endif
613                 
614                 [DefaultValue(null)]
615 #if NET_2_0
616                 [Browsable (false)]
617 #endif
618                 public ContextMenu ContextMenu {
619                         get {
620                                 return context_menu;
621                         }
622
623                         set {
624                                 if (context_menu != value) {
625                                         context_menu = value;
626                                         window.ContextMenu = value;
627                                 }
628                         }
629                 }
630
631 #if NET_2_0
632                 [DefaultValue (null)]
633                 public ContextMenuStrip ContextMenuStrip {
634                         get { return this.context_menu_strip; }
635                         set {
636                                 if (this.context_menu_strip != value) {
637                                         this.context_menu_strip = value;
638                                         window.ContextMenuStrip = value;
639                                 }
640                         }
641                 }
642 #endif
643
644                 [Localizable(true)]
645                 [DefaultValue(null)]
646                 public Icon Icon {
647                         get {
648                                 return icon;
649                         }
650
651                         set {
652                                 if (icon != value) {
653                                         icon = value;
654                                         Recalculate ();
655                                 }
656                         }
657                 }
658
659 #if NET_2_0
660                 [Localizable (false)]
661                 [Bindable (true)]
662                 [TypeConverter (typeof (StringConverter))]
663                 [DefaultValue (null)]
664                 public object Tag {
665                         get { return this.tag; }
666                         set { this.tag = value; }
667                 }
668
669                 [DefaultValue ("")]
670                 [Editor ("System.ComponentModel.Design.MultilineStringEditor, " + Consts.AssemblySystem_Design,
671                          typeof (System.Drawing.Design.UITypeEditor))]
672 #endif
673                 [Localizable (true)]
674                 public string Text {
675                         get {
676                                 return text;
677                         }
678
679                         set {
680                                 if (text != value) {
681                                         if (value.Length >= 64) {
682                                                 throw new ArgumentException("ToolTip length must be less than 64 characters long", "Text");
683                                         }
684                                         text = value;
685                                         Recalculate ();
686                                 }
687                         }
688                 }
689
690                 [Localizable(true)]
691                 [DefaultValue(false)]
692                 public bool Visible {
693                         get {
694                                 return visible;
695                         }
696
697                         set {
698                                 if (visible != value) {
699                                         visible = value;
700
701                                         // Let our control know, too
702                                         window.is_visible = value;
703
704                                         if (visible) {
705                                                 ShowSystray ();
706                                         } else {
707                                                 HideSystray();
708                                         }
709                                 }
710                         }
711                 }
712                 #endregion      // Public Instance Properties
713
714                 #region Protected Instance Methods
715                 protected override void Dispose(bool disposing) {
716                         if (visible)
717                                 HideSystray();
718
719                         if (icon_bitmap != null) {
720                                 icon_bitmap.Dispose();
721                         }
722
723                         if (disposing)
724                                 icon = null;
725
726                         base.Dispose (disposing);
727                 }
728
729                 #endregion      // Protected Instance Methods
730
731                 #region Events
732                 static object ClickEvent = new object ();
733                 static object DoubleClickEvent = new object ();
734                 static object MouseDownEvent = new object ();
735                 static object MouseMoveEvent = new object ();
736                 static object MouseUpEvent = new object ();
737
738 #if NET_2_0
739                 static object BalloonTipClickedEvent = new object ();
740                 static object BalloonTipClosedEvent = new object ();
741                 static object BalloonTipShownEvent = new object ();
742                 static object MouseClickEvent = new object ();
743                 static object MouseDoubleClickEvent = new object ();
744
745                 [MWFCategory("Action")]
746                 public event EventHandler BalloonTipClicked {
747                         add { Events.AddHandler (BalloonTipClickedEvent, value); }
748                         remove { Events.RemoveHandler (BalloonTipClickedEvent, value); }
749                 }
750
751                 [MWFCategory("Action")]
752                 public event EventHandler BalloonTipClosed {
753                         add { Events.AddHandler (BalloonTipClosedEvent, value); }
754                         remove { Events.RemoveHandler (BalloonTipClosedEvent, value); }
755                 }
756
757                 [MWFCategory("Action")]
758                 public event EventHandler BalloonTipShown {
759                         add { Events.AddHandler (BalloonTipShownEvent, value); }
760                         remove { Events.RemoveHandler (BalloonTipShownEvent, value); }
761                 }
762
763                 [MWFCategory("Action")]
764                 public event MouseEventHandler MouseClick {
765                         add { Events.AddHandler (MouseClickEvent, value); }
766                         remove { Events.RemoveHandler (MouseClickEvent, value); }
767                 }
768
769                 [MWFCategory ("Action")]
770                 public event MouseEventHandler MouseDoubleClick {
771                         add { Events.AddHandler (MouseDoubleClickEvent, value); }
772                         remove { Events.RemoveHandler (MouseDoubleClickEvent, value); }
773                 }
774 #endif
775
776 #if NET_2_0
777                 [MWFCategory("Action")]
778 #else
779                 [Category("Action")]
780 #endif
781                 public event EventHandler Click {
782                         add { Events.AddHandler (ClickEvent, value); }
783                         remove { Events.RemoveHandler (ClickEvent, value); }
784                 }
785
786 #if NET_2_0
787                 [MWFCategory("Action")]
788 #else
789                 [Category("Action")]
790 #endif
791                 public event EventHandler DoubleClick {
792                         add { Events.AddHandler (DoubleClickEvent, value); }
793                         remove { Events.RemoveHandler (DoubleClickEvent, value); }
794                 }
795
796                 public event MouseEventHandler MouseDown {
797                         add { Events.AddHandler (MouseDownEvent, value); }
798                         remove { Events.RemoveHandler (MouseDownEvent, value); }
799                 }
800
801                 public event MouseEventHandler MouseMove {
802                         add { Events.AddHandler (MouseMoveEvent, value); }
803                         remove { Events.RemoveHandler (MouseMoveEvent, value); }
804                 }
805
806                 public event MouseEventHandler MouseUp {
807                         add { Events.AddHandler (MouseUpEvent, value); }
808                         remove { Events.RemoveHandler (MouseUpEvent, value); }
809                 }
810
811                 #endregion      // Events
812         }
813 }