protected void OnHooverValue(HooverValueEventArgs e) { if (HooverValue != null) HooverValue(this, e); }
public bool PreFilterMessage(ref Message m) { if (!this._bMouseTrackingOn) return false; if (m.Msg == (int) Msg.WM_MOUSEMOVE) { int X = 0; int Y = 0; // The mouse coordinate are measured in screen coordinates because thats what // Control.MousePosition returns. The Message,LParam value is not used because // it returns the mouse position relative to the control the mouse is over. // Chalk and cheese. Point pointScreen = Control.MousePosition; // Get the origin of this control in screen coordinates so that later we can // compare it against the mouse point to determine it we've hit this control. Point pointClientOrigin = new Point(X, Y); pointClientOrigin = PointToScreen(pointClientOrigin); _bDrawLine = false; _bInControl = false; HooverValueEventArgs eHoover = null; // Work out whether the mouse is within the Y-axis bounds of a vertical ruler or // within the X-axis bounds of a horizontal ruler if (this.Orientation == OrientationMode.Horizontal) { _bDrawLine = (pointScreen.X >= pointClientOrigin.X) && (pointScreen.X <= pointClientOrigin.X + this.Width); } else { _bDrawLine = (pointScreen.Y >= pointClientOrigin.Y) && (pointScreen.Y <= pointClientOrigin.Y + this.Height); } // If the mouse is in valid position... if (_bDrawLine) { // ...workout the position of the mouse relative to the X = pointScreen.X - pointClientOrigin.X; Y = pointScreen.Y - pointClientOrigin.Y; // Determine whether the mouse is within the bounds of the control itself _bInControl = (this.ClientRectangle.Contains(new Point(X, Y))); // Make the relative mouse position available in pixel relative to this control's origin ChangeMousePosition((this.Orientation == OrientationMode.Horizontal) ? X : Y); eHoover = new HooverValueEventArgs(CalculateValue(_iMousePosition)); } else { ChangeMousePosition(-1); eHoover = new HooverValueEventArgs(_iMousePosition); } // Paint directly by calling the OnPaint() method. This way the background is not // hosed by the call to Invalidate() so paining occurs without the hint of a flicker PaintEventArgs e = null; try { e = new PaintEventArgs(this.CreateGraphics(), this.ClientRectangle); OnPaint(e); } finally { e.Graphics.Dispose(); } OnHooverValue(eHoover); } if ((m.Msg == (int) Msg.WM_MOUSELEAVE) || (m.Msg == (int) Msg.WM_NCMOUSELEAVE)) { _bDrawLine = false; PaintEventArgs paintArgs = null; try { paintArgs = new PaintEventArgs(this.CreateGraphics(), this.ClientRectangle); this.OnPaint(paintArgs); } finally { paintArgs.Graphics.Dispose(); } } return false; // Whether or not the message is filtered }
public bool PreFilterMessage(ref Message m) { if (!this._bMouseTrackingOn) { return(false); } if (m.Msg == (int)Msg.WM_MOUSEMOVE) { int X = 0; int Y = 0; // The mouse coordinate are measured in screen coordinates because thats what // Control.MousePosition returns. The Message,LParam value is not used because // it returns the mouse position relative to the control the mouse is over. // Chalk and cheese. Point pointScreen = Control.MousePosition; // Get the origin of this control in screen coordinates so that later we can // compare it against the mouse point to determine it we've hit this control. Point pointClientOrigin = new Point(X, Y); pointClientOrigin = PointToScreen(pointClientOrigin); _bDrawLine = false; _bInControl = false; HooverValueEventArgs eHoover = null; // Work out whether the mouse is within the Y-axis bounds of a vertical ruler or // within the X-axis bounds of a horizontal ruler if (this.Orientation == OrientationMode.Horizontal) { _bDrawLine = (pointScreen.X >= pointClientOrigin.X) && (pointScreen.X <= pointClientOrigin.X + this.Width); } else { _bDrawLine = (pointScreen.Y >= pointClientOrigin.Y) && (pointScreen.Y <= pointClientOrigin.Y + this.Height); } // If the mouse is in valid position... if (_bDrawLine) { // ...workout the position of the mouse relative to the X = pointScreen.X - pointClientOrigin.X; Y = pointScreen.Y - pointClientOrigin.Y; // Determine whether the mouse is within the bounds of the control itself _bInControl = (this.ClientRectangle.Contains(new Point(X, Y))); // Make the relative mouse position available in pixel relative to this control's origin ChangeMousePosition((this.Orientation == OrientationMode.Horizontal) ? X : Y); eHoover = new HooverValueEventArgs(CalculateValue(_iMousePosition)); } else { ChangeMousePosition(-1); eHoover = new HooverValueEventArgs(_iMousePosition); } // Paint directly by calling the OnPaint() method. This way the background is not // hosed by the call to Invalidate() so paining occurs without the hint of a flicker PaintEventArgs e = null; try { e = new PaintEventArgs(this.CreateGraphics(), this.ClientRectangle); OnPaint(e); } finally { e.Graphics.Dispose(); } OnHooverValue(eHoover); } if ((m.Msg == (int)Msg.WM_MOUSELEAVE) || (m.Msg == (int)Msg.WM_NCMOUSELEAVE)) { _bDrawLine = false; PaintEventArgs paintArgs = null; try { paintArgs = new PaintEventArgs(this.CreateGraphics(), this.ClientRectangle); this.OnPaint(paintArgs); } finally { paintArgs.Graphics.Dispose(); } } return(false); // Whether or not the message is filtered }
internal void OnHooverValue(HooverValueEventArgs e) { if (HooverValue != null) HooverValue(this, e); }
public bool PreFilterMessage(ref Message m) { if (!this._bMouseTrackingOn) { return(false); } if (m.Msg == (int)Msg.WM_MOUSEMOVE) { int X = 0; int Y = 0; Point pointScreen = Control.MousePosition; Point pointClientOrigin = new Point(X, Y); pointClientOrigin = PointToScreen(pointClientOrigin); _bDrawLine = false; _bInControl = false; HooverValueEventArgs eHoover = null; if (this.Orientation == enumOrientation.orHorizontal) { _bDrawLine = (pointScreen.X >= pointClientOrigin.X) && (pointScreen.X <= pointClientOrigin.X + this.Width); } else { _bDrawLine = (pointScreen.Y >= pointClientOrigin.Y) && (pointScreen.Y <= pointClientOrigin.Y + this.Height); } if (_bDrawLine) { X = pointScreen.X - pointClientOrigin.X; Y = pointScreen.Y - pointClientOrigin.Y; _bInControl = (this.ClientRectangle.Contains(new Point(X, Y))); ChangeMousePosition((this.Orientation == enumOrientation.orHorizontal) ? X : Y); eHoover = new HooverValueEventArgs(CalculateValue(_iMousePosition)); } else { ChangeMousePosition(-1); eHoover = new HooverValueEventArgs(_iMousePosition); } PaintEventArgs e = null; try { e = new PaintEventArgs(this.CreateGraphics(), this.ClientRectangle); OnPaint(e); } finally { e.Graphics.Dispose(); } OnHooverValue(eHoover); } if ((m.Msg == (int)Msg.WM_MOUSELEAVE) || (m.Msg == (int)Msg.WM_NCMOUSELEAVE)) { _bDrawLine = false; PaintEventArgs paintArgs = null; try { paintArgs = new PaintEventArgs(this.CreateGraphics(), this.ClientRectangle); this.OnPaint(paintArgs); } finally { paintArgs.Graphics.Dispose(); } } return(false); }