In System.Windows.Forms:
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / NotifyIcon.cs
index afc90a70ded567c1ca88086098642c3eda14dd67..969e01d877b840039283962ed1ab3aaee943dad0 100644 (file)
 //
 //
 
-// NOT COMPLETE
-
 using System;
 using System.ComponentModel;
 using System.ComponentModel.Design;
 using System.Drawing;
+using System.Drawing.Text;
 
 namespace System.Windows.Forms {
        [DefaultProperty("Text")]
+#if NET_2_0
+       [DefaultEvent("MouseDoubleClick")]
+#else
        [DefaultEvent("MouseDown")]
+#endif
        [Designer ("System.Windows.Forms.Design.NotifyIconDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
        [ToolboxItemFilter("System.Windows.Forms", ToolboxItemFilterType.Allow)]
-       public sealed class NotifyIcon : System.ComponentModel.Component {
+       public sealed class NotifyIcon : Component {
                #region Local Variables
                private ContextMenu             context_menu;
                private Icon                    icon;
@@ -46,10 +49,17 @@ namespace System.Windows.Forms {
                private NotifyIconWindow        window;
                private bool                    systray_active;
                private ToolTip                 tooltip;
+#if NET_2_0
+               private string balloon_text;
+               private string balloon_title;
+               private ToolTipIcon balloon_icon;
+               private ContextMenuStrip        context_menu_strip;
+               private object                  tag;
+#endif
                #endregion      // Local Variables
 
                #region NotifyIconWindow Class
-               internal class NotifyIconWindow : Control {
+               internal class NotifyIconWindow : Form {
                        NotifyIcon      owner;
                        Rectangle       rect;
 
@@ -58,9 +68,10 @@ namespace System.Windows.Forms {
                                is_visible = false;
                                rect = new Rectangle(0, 0, 1, 1);
 
-                               CreateControl();
+                               FormBorderStyle = FormBorderStyle.None;
+
+                               //CreateControl();
 
-                               Paint += new PaintEventHandler(HandlePaint);
                                SizeChanged += new EventHandler(HandleSizeChanged);
 
                                // Events that need to be sent to our parent
@@ -70,6 +81,9 @@ namespace System.Windows.Forms {
                                MouseUp +=new MouseEventHandler(HandleMouseUp);
                                MouseMove +=new MouseEventHandler(HandleMouseMove);
                                ContextMenu = owner.context_menu;
+#if NET_2_0
+                               ContextMenuStrip = owner.context_menu_strip;
+#endif
                        }
 
                        protected override CreateParams CreateParams {
@@ -82,7 +96,7 @@ namespace System.Windows.Forms {
                                        cp.Style = (int)WindowStyles.WS_POPUP;
                                        cp.Style |= (int)WindowStyles.WS_CLIPSIBLINGS;
 
-                                       cp.ExStyle = (int)(WindowStyles.WS_EX_TOOLWINDOW);
+                                       cp.ExStyle = (int)(WindowExStyles.WS_EX_TOOLWINDOW);
 
                                        return cp;
                                }
@@ -90,53 +104,68 @@ namespace System.Windows.Forms {
 
                        protected override void WndProc(ref Message m) {
                                switch((Msg)m.Msg) {
-                                       case Msg.WM_NCPAINT: {
-                                               PaintEventArgs  paint_event;
-
-                                               paint_event = XplatUI.PaintEventStart(Handle, false);
-                                               OnPaint(paint_event);
-                                               XplatUI.PaintEventEnd(Handle, false);
-                                               break;
-                                       }
+                                               //
+                                               //  NotifyIcon does CONTEXTMENU on mouse up, not down
+                                               //  so we swallow the message here, and handle it on our own
+                                               // 
+                                       case Msg.WM_CONTEXTMENU:
+                                               return;
 
                                        case Msg.WM_USER: {
                                                switch ((Msg)m.LParam.ToInt32()) {
                                                        case Msg.WM_LBUTTONDOWN: {
-                                                               HandleMouseDown(this, new MouseEventArgs(MouseButtons.Left, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
+                                                               owner.OnMouseDown (new MouseEventArgs(MouseButtons.Left, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
                                                                return;
                                                        }
 
                                                        case Msg.WM_LBUTTONUP: {
-                                                               HandleMouseUp(this, new MouseEventArgs(MouseButtons.Left, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
-                                                               HandleClick(this, EventArgs.Empty);
+                                                               owner.OnMouseUp (new MouseEventArgs(MouseButtons.Left, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
+                                                               owner.OnClick (EventArgs.Empty);
                                                                return;
                                                        }
 
                                                        case Msg.WM_LBUTTONDBLCLK: {
-                                                               HandleDoubleClick(this, EventArgs.Empty);
+                                                               owner.OnDoubleClick (EventArgs.Empty);
                                                                return;
                                                        }
 
                                                        case Msg.WM_MOUSEMOVE: {
-                                                               HandleMouseMove(this, new MouseEventArgs(MouseButtons.None, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
+                                                               owner.OnMouseMove (new MouseEventArgs(MouseButtons.None, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
                                                                return;
                                                        }
 
                                                        case Msg.WM_RBUTTONDOWN: {
-                                                               HandleMouseDown(this, new MouseEventArgs(MouseButtons.Right, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
+                                                               owner.OnMouseDown (new MouseEventArgs(MouseButtons.Right, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
                                                                return;
                                                        }
 
                                                        case Msg.WM_RBUTTONUP: {
-                                                               HandleMouseUp(this, new MouseEventArgs(MouseButtons.Right, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
-                                                               HandleClick(this, EventArgs.Empty);
+                                                               owner.OnMouseUp (new MouseEventArgs(MouseButtons.Right, 1, Control.MousePosition.X, Control.MousePosition.Y, 0));
+                                                               owner.OnClick (EventArgs.Empty);
                                                                return;
                                                        }
 
                                                        case Msg.WM_RBUTTONDBLCLK: {
-                                                               HandleDoubleClick(this, EventArgs.Empty);
+                                                               owner.OnDoubleClick (EventArgs.Empty);
+                                                               return;
+                                                       }
+#if NET_2_0                                                    
+                                                       case Msg.NIN_BALLOONUSERCLICK: {
+                                                               owner.OnBalloonTipClicked (EventArgs.Empty);
+                                                               return;
+                                                       }
+
+                                                       case Msg.NIN_BALLOONSHOW: {
+                                                               owner.OnBalloonTipShown (EventArgs.Empty);
+                                                               return;
+                                                       }
+
+                                                       case Msg.NIN_BALLOONHIDE:
+                                                       case Msg.NIN_BALLOONTIMEOUT: {
+                                                               owner.OnBalloonTipClosed (EventArgs.Empty);
                                                                return;
                                                        }
+#endif
                                                }
                                                return;
                                        }
@@ -145,114 +174,302 @@ namespace System.Windows.Forms {
                        }
 
                        internal void CalculateIconRect() {
-                               if (owner != null && owner.icon != null) {
-                                       int             x;
-                                       int             y;
-                                       int             size;
-
-                                       // Icons are always square. Try to center them in the window
-                                       if (ClientRectangle.Width < ClientRectangle.Height) {
-                                               size = ClientRectangle.Width;
-                                       } else {
-                                               size = ClientRectangle.Height;
-                                       }
-                                       x = this.ClientRectangle.Width / 2 - size / 2;
-                                       y = this.ClientRectangle.Height / 2 - size / 2;
-                                       rect = new Rectangle(x, y, size, size);
-
-                                       // Force our window to be square
-                                       if (Width != size) {
-                                               this.Width = size;
-                                       }
-
-                                       if (Height != size) {
-                                               this.Height = size;
-                                       }
+                               int             x;
+                               int             y;
+                               int             size;
+
+                               // Icons are always square. Try to center them in the window
+                               if (ClientRectangle.Width < ClientRectangle.Height) {
+                                       size = ClientRectangle.Width;
+                               } else {
+                                       size = ClientRectangle.Height;
                                }
+                               x = this.ClientRectangle.Width / 2 - size / 2;
+                               y = this.ClientRectangle.Height / 2 - size / 2;
+                               rect = new Rectangle(x, y, size, size);
+
+                               Bounds = new Rectangle (0, 0, size, size);
                        }
 
-                       private void HandlePaint(object sender, PaintEventArgs e) {
+                       internal override void OnPaintInternal (PaintEventArgs e) {
                                if (owner.icon != null) {
                                        e.Graphics.FillRectangle(ThemeEngine.Current.ResPool.GetSolidBrush(SystemColors.Window), rect);
-                                       e.Graphics.DrawImage(owner.icon_bitmap, rect);
+                                       e.Graphics.DrawImage(owner.icon_bitmap,
+                                                            rect,
+                                                            new Rectangle (0, 0, owner.icon_bitmap.Width, owner.icon_bitmap.Height),
+                                                            GraphicsUnit.Pixel);
 
                                }
                        }
 
+                       internal void InternalRecreateHandle () {
+                               base.RecreateHandle ();
+                       }
+
+
                        private void HandleSizeChanged(object sender, EventArgs e) {
-                               CalculateIconRect();
+                               owner.Recalculate ();
                        }
 
-                       private void HandleClick(object sender, EventArgs e) {
-                               if (owner.Click != null) {
-                                       owner.Click(owner, e);
-                               }
+                       private void HandleClick (object sender, EventArgs e)
+                       {
+                               owner.OnClick (e);
                        }
 
-                       private void HandleDoubleClick(object sender, EventArgs e) {
-                               if (owner.DoubleClick != null) {
-                                       owner.DoubleClick(owner, e);
-                               }
+                       private void HandleDoubleClick (object sender, EventArgs e)
+                       {
+                               owner.OnDoubleClick (e);
                        }
 
-                       private void HandleMouseDown(object sender, MouseEventArgs e) {
-                               if (owner.MouseDown != null) {
-                                       owner.MouseDown(owner, e);
-                               }
+                       private void HandleMouseDown (object sender, MouseEventArgs e)
+                       {
+                               owner.OnMouseDown (e);
+                       }
+
+                       private void HandleMouseUp (object sender, MouseEventArgs e)
+                       {
+                               owner.OnMouseUp (e);
                        }
 
-                       private void HandleMouseUp(object sender, MouseEventArgs e) {
-                               if (owner.context_menu != null) {
-                                       owner.context_menu.Show(this, new Point(e.X, e.Y));
+                       private void HandleMouseMove (object sender, MouseEventArgs e)
+                       {
+                               owner.OnMouseMove (e);
+                       }
+               }
+               #endregion      // NotifyIconWindow Class
+               
+               #region NotifyIconBalloonWindow Class
+#if NET_2_0
+               internal class BalloonWindow : Form 
+               {
+                       private IntPtr owner;
+                       private Timer timer;
+                       
+                       private string title;
+                       private string text;
+                       private ToolTipIcon icon;
+
+                       public BalloonWindow (IntPtr owner)
+                       {
+                               this.owner = owner;
+                               
+                               StartPosition = FormStartPosition.Manual;
+                               FormBorderStyle = FormBorderStyle.None;
+                               TopMost = true;
+
+                               MouseDown += new MouseEventHandler (HandleMouseDown);
+                               
+                               timer = new Timer ();
+                               timer.Enabled = false;
+                               timer.Tick += new EventHandler (HandleTimer);
+                       }
+
+                       protected override void OnShown (EventArgs e)
+                       {
+                               base.OnShown (e);
+                               timer.Start ();
+                       }
+                       
+                       protected override void OnPaint (PaintEventArgs e) 
+                       {
+                               ThemeEngine.Current.DrawBalloonWindow (e.Graphics, ClientRectangle, this);
+                               base.OnPaint (e);
+                       }
+
+                       private void Recalculate () 
+                       {
+                               Rectangle rect = ThemeEngine.Current.BalloonWindowRect (this);
+                               
+                               Left = rect.Left;
+                               Top = rect.Top;
+                               Width = rect.Width;
+                               Height = rect.Height;
+                       }
+
+                       // To be used when we have a "close button" inside balloon.
+                       //private void HandleClick (object sender, EventArgs e)
+                       //{
+                       //      XplatUI.SendMessage (owner, Msg.WM_USER, IntPtr.Zero, (IntPtr) Msg.NIN_BALLOONHIDE);
+                       //      Close ();
+                       //}
+
+                       private void HandleMouseDown (object sender, MouseEventArgs e)
+                       {
+                               XplatUI.SendMessage (owner, Msg.WM_USER, IntPtr.Zero, (IntPtr) Msg.NIN_BALLOONUSERCLICK);
+                               Close ();
+                       }
+
+                       private void HandleTimer (object sender, EventArgs e)
+                       {
+                               timer.Stop ();
+                               XplatUI.SendMessage (owner, Msg.WM_USER, IntPtr.Zero, (IntPtr) Msg.NIN_BALLOONTIMEOUT);
+                               Close ();
+                       }
+                       
+                       internal StringFormat Format {
+                               get {
+                                       StringFormat format = new StringFormat ();
+                                       format.Alignment = StringAlignment.Near;
+                                       format.HotkeyPrefix = HotkeyPrefix.Hide;
+
+                                       return format;
                                }
+                       }
+
+                       public string Title {
+                               get { return this.title; }
+                               set { 
+                                       if (value == this.title)
+                                               return;
 
-                               if (owner.MouseUp != null) {
-                                       owner.MouseUp(owner, e);
+                                       this.title = value;
+                                       Recalculate ();
                                }
                        }
 
-                       private void HandleMouseMove(object sender, MouseEventArgs e) {
-                               if (owner.MouseMove != null) {
-                                       owner.MouseMove(owner, e);
+                       public string Text {
+                               get { return this.text; }
+                               set { 
+                                       if (value == this.text)
+                                               return;
+
+                                       this.text = value;
+                                       Recalculate ();
+                               }
+                       }
+                       
+                       public int Timeout {
+                               get { return timer.Interval; }
+                               set {
+                                       // Some systems theres a limitiation in timeout, WinXP is between 10k and 30k.
+                                       if (value < 10000)
+                                               timer.Interval = 10000;
+                                       else if (value > 30000)
+                                               timer.Interval = 30000;
+                                       else
+                                               timer.Interval = value;
                                }
                        }
                }
-               #endregion      // NotifyIconWindow Class
+#endif
+               #endregion  // NotifyIconBalloonWindow Class
 
                #region Public Constructors
                public NotifyIcon() {
                        window = new NotifyIconWindow(this);
                        systray_active = false;
+
+#if NET_2_0                    
+                       balloon_title = "";
+                       balloon_text = "";
+#endif
                }
 
                public NotifyIcon(System.ComponentModel.IContainer container) : this() {
                }
                #endregion      // Public Constructors
 
+               #region Public Methods
+#if NET_2_0
+               public void ShowBalloonTip (int timeout)
+               {
+                       ShowBalloonTip(timeout, balloon_title, balloon_text, balloon_icon);
+               }
+
+               public void ShowBalloonTip(int timeout, string title, string text, ToolTipIcon icon)
+               {
+                       XplatUI.SystrayBalloon(window.Handle, timeout, title, text, icon);
+               }
+#endif
+               #endregion Public Methods
+               
                #region Private Methods
-               private void ShowSystray(bool property_changed) {
-                       if (property_changed) {
-                               window.CalculateIconRect();
-                       }
+#if NET_2_0
+               private void OnBalloonTipClicked (EventArgs e)
+               {
+                       EventHandler eh = (EventHandler)(Events [BalloonTipClickedEvent]);
+                       if (eh != null)
+                               eh (this, e);
+               }
 
-                       if (systray_active) {
-                               if (property_changed) {
-                                       UpdateSystray();
-                               }
-                               return;
-                       }
+               private void OnBalloonTipClosed (EventArgs e)
+               {
+                       EventHandler eh = (EventHandler)(Events [BalloonTipClosedEvent]);
+                       if (eh != null)
+                               eh (this, e);
+               }
+
+               private void OnBalloonTipShown (EventArgs e)
+               {
+                       EventHandler eh = (EventHandler)(Events [BalloonTipShownEvent]);
+                       if (eh != null)
+                               eh (this, e);
+               }
+#endif
+               private void OnClick (EventArgs e)
+               {
+                       EventHandler eh = (EventHandler)(Events [ClickEvent]);
+                       if (eh != null)
+                               eh (this, e);
+               }
+
+               private void OnDoubleClick (EventArgs e)
+               {
+                       EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
+                       if (eh != null)
+                               eh (this, e);
+               }
+
+               private void OnMouseDown (MouseEventArgs e)
+               {
+                       MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
+                       if (eh != null)
+                               eh (this, e);
+               }
 
-                       if (icon == null) {
+               private void OnMouseUp (MouseEventArgs e)
+               {
+                       if ((e.Button & MouseButtons.Right) == MouseButtons.Right && context_menu != null)
+                               context_menu.Show (window, new Point(e.X, e.Y));
+#if NET_2_0
+                       else if ((e.Button & MouseButtons.Right) == MouseButtons.Right && context_menu_strip != null)
+                               context_menu_strip.Show (window, new Point (e.X, e.Y), ToolStripDropDownDirection.AboveLeft);
+#endif
+                       
+                       MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
+                       if (eh != null)
+                               eh (this, e);
+               }
+
+               private void OnMouseMove (MouseEventArgs e)
+               {
+                       MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
+                       if (eh != null)
+                               eh (this, e);
+               }
+
+               private void Recalculate () 
+               {
+                       window.CalculateIconRect ();
+
+                       if (systray_active)
+                               UpdateSystray ();
+               }
+
+               private void ShowSystray()
+               {
+                       systray_active = true;
+
+                       if (icon == null)
                                return;
-                       }
 
                        icon_bitmap = icon.ToBitmap();
 
-                       systray_active = true;
                        XplatUI.SystrayAdd(window.Handle, text, icon, out tooltip);
                }
 
-               private void HideSystray() {
+               private void HideSystray()
+               {
                        if (!systray_active) {
                                return;
                        }
@@ -261,7 +478,8 @@ namespace System.Windows.Forms {
                        XplatUI.SystrayRemove(window.Handle, ref tooltip);
                }
 
-               private void UpdateSystray() {
+               private void UpdateSystray()
+               {
                        if (icon_bitmap != null) {
                                icon_bitmap.Dispose();
                        }
@@ -276,7 +494,44 @@ namespace System.Windows.Forms {
                #endregion      // Private Methods
 
                #region Public Instance Properties
+#if NET_2_0
+               public ToolTipIcon BalloonTipIcon {
+                       get { return this.balloon_icon; }
+                       set {
+                               if (value == this.balloon_icon)
+                                       return;
+               
+               this.balloon_icon = value;
+                       }
+               }
+
+               [Localizable(true)]
+               public string BalloonTipText {
+                       get { return this.balloon_text; }
+                       set {
+                               if (value == this.balloon_text)
+                                       return;
+                               
+                               this.balloon_text = value;
+                       }
+               }
+               
+               [Localizable(true)]
+               public string BalloonTipTitle {
+                       get { return this.balloon_title; }
+                       set {
+                               if (value == this.balloon_title)
+                                       return;
+       
+                               this.balloon_title = value;
+                       }
+               }
+#endif
+               
                [DefaultValue(null)]
+#if NET_2_0
+               [Browsable (false)]
+#endif
                public ContextMenu ContextMenu {
                        get {
                                return context_menu;
@@ -290,6 +545,19 @@ namespace System.Windows.Forms {
                        }
                }
 
+#if NET_2_0
+               [DefaultValue (null)]
+               public ContextMenuStrip ContextMenuStrip {
+                       get { return this.context_menu_strip; }
+                       set {
+                               if (this.context_menu_strip != value) {
+                                       this.context_menu_strip = value;
+                                       window.ContextMenuStrip = value;
+                               }
+                       }
+               }
+#endif
+
                [Localizable(true)]
                [DefaultValue(null)]
                public Icon Icon {
@@ -299,16 +567,32 @@ namespace System.Windows.Forms {
 
                        set {
                                if (icon != value) {
-                                       if (icon != null) {
-                                               icon.Dispose();
-                                       }
                                        icon = value;
-                                       ShowSystray(true);
+                                       if (text == string.Empty && icon == null) {
+                                               HideSystray ();
+                                       }
+                                       else {
+                                               Recalculate ();
+                                       }
                                }
                        }
                }
 
-               [Localizable(true)]
+#if NET_2_0
+               [Localizable (false)]
+               [Bindable (true)]
+               [TypeConverter (typeof (StringConverter))]
+               [DefaultValue (null)]
+               public object Tag {
+                       get { return this.tag; }
+                       set { this.tag = value; }
+               }
+
+               [DefaultValue ("")]
+               [Editor ("System.ComponentModel.Design.MultilineStringEditor, " + Consts.AssemblySystem_Design,
+                        typeof (System.Drawing.Design.UITypeEditor))]
+#endif
+               [Localizable (true)]
                public string Text {
                        get {
                                return text;
@@ -323,7 +607,7 @@ namespace System.Windows.Forms {
                                        if (text == string.Empty && icon == null) {
                                                HideSystray();
                                        } else {
-                                               ShowSystray(true);
+                                               Recalculate ();
                                        }
                                }
                        }
@@ -344,7 +628,7 @@ namespace System.Windows.Forms {
                                        window.is_visible = value;
 
                                        if (visible) {
-                                               ShowSystray(false);
+                                               ShowSystray ();
                                        } else {
                                                HideSystray();
                                        }
@@ -355,28 +639,87 @@ namespace System.Windows.Forms {
 
                #region Protected Instance Methods
                protected override void Dispose(bool disposing) {
-                       if (icon != null) {
-                               icon.Dispose();
-                       }
+                       if (visible)
+                               HideSystray();
 
                        if (icon_bitmap != null) {
                                icon_bitmap.Dispose();
                        }
+
+                       if (disposing)
+                               icon = null;
+
                        base.Dispose (disposing);
                }
 
                #endregion      // Protected Instance Methods
 
                #region Events
+               static object ClickEvent = new object ();
+               static object DoubleClickEvent = new object ();
+               static object MouseDownEvent = new object ();
+               static object MouseMoveEvent = new object ();
+               static object MouseUpEvent = new object ();
+
+#if NET_2_0
+               static object BalloonTipClickedEvent = new object ();
+               static object BalloonTipClosedEvent = new object ();
+               static object BalloonTipShownEvent = new object ();
+
+               [MWFCategory("Action")]
+               public event EventHandler BalloonTipClicked {
+                       add { Events.AddHandler (BalloonTipClickedEvent, value); }
+                       remove { Events.RemoveHandler (BalloonTipClickedEvent, value); }
+               }
+
+               [MWFCategory("Action")]
+               public event EventHandler BalloonTipClosed {
+                       add { Events.AddHandler (BalloonTipClosedEvent, value); }
+                       remove { Events.RemoveHandler (BalloonTipClosedEvent, value); }
+               }
+
+               [MWFCategory("Action")]
+               public event EventHandler BalloonTipShown {
+                       add { Events.AddHandler (BalloonTipShownEvent, value); }
+                       remove { Events.RemoveHandler (BalloonTipShownEvent, value); }
+               }
+#endif
+
+#if NET_2_0
+               [MWFCategory("Action")]
+#else
                [Category("Action")]
-               public event EventHandler       Click;
+#endif
+               public event EventHandler Click {
+                       add { Events.AddHandler (ClickEvent, value); }
+                       remove { Events.RemoveHandler (ClickEvent, value); }
+               }
 
+#if NET_2_0
+               [MWFCategory("Action")]
+#else
                [Category("Action")]
-               public event EventHandler       DoubleClick;
+#endif
+               public event EventHandler DoubleClick {
+                       add { Events.AddHandler (DoubleClickEvent, value); }
+                       remove { Events.RemoveHandler (DoubleClickEvent, value); }
+               }
+
+               public event MouseEventHandler MouseDown {
+                       add { Events.AddHandler (MouseDownEvent, value); }
+                       remove { Events.RemoveHandler (MouseDownEvent, value); }
+               }
+
+               public event MouseEventHandler MouseMove {
+                       add { Events.AddHandler (MouseMoveEvent, value); }
+                       remove { Events.RemoveHandler (MouseMoveEvent, value); }
+               }
+
+               public event MouseEventHandler MouseUp {
+                       add { Events.AddHandler (MouseUpEvent, value); }
+                       remove { Events.RemoveHandler (MouseUpEvent, value); }
+               }
 
-               public event MouseEventHandler  MouseDown;
-               public event MouseEventHandler  MouseMove;
-               public event MouseEventHandler  MouseUp;
                #endregion      // Events
        }
 }