private System.Drawing.Point GetMousePosition(System.Drawing.Point p) { if (myBindControl != null) { p = myBindControl.PointToClient(p); } return(MoveInto(p, this.myClipRectangle)); }
/// <summary> /// Handles all move related events. /// </summary> /// <param name="e">If <see cref="e.Handled"/> is true, it will be ignored, otherwise if the reference element is focused, the event will be handled and <see cref="e.Handled"/> will be set to true.</param> public void HandleMouseMove(System.Windows.Forms.MouseEventArgs e) { var m = _mouseState; var pos = _focusElement.PointToClient(System.Windows.Forms.Cursor.Position); _mouseState = new MouseState((int)pos.X, (int)pos.Y, m.ScrollWheelValue, m.LeftButton, m.MiddleButton, m.RightButton, m.XButton1, m.XButton2); }
void MouseTimerTick(object sender, EventArgs e) { _mouseTimer.Stop(); if (_parentForm != null && _parentForm.ContainsFocus && IsLeftMouseButtonDown()) { var p = _ownerControl.PointToClient(System.Windows.Forms.Control.MousePosition); if (p.X > 0 && p.X < _ownerControl.Width && p.Y > 0 && p.Y < _ownerControl.Height) { if (IsPlaying) { Pause(); } else { Play(); } int i = 0; while (IsLeftMouseButtonDown() && i < 200) { System.Threading.Thread.Sleep(2); System.Windows.Forms.Application.DoEvents(); i++; } } } _mouseTimer.Start(); }
public static Limaki.View.DragDrop.DragEventArgs ToXwt(this System.Windows.Forms.DragEventArgs args, System.Windows.Forms.Control control) { var pt = control.PointToClient(new System.Drawing.Point(args.X, args.Y)); var result = new Limaki.View.DragDrop.DragEventArgs(pt.ToXwt(), new SwfTransferDataStore(args.Data), args.Effect.ToXwt()) { }; return(result); }
public void Update() { if (onControl) { System.Drawing.Point p = control.PointToClient(System.Windows.Forms.Control.MousePosition); Position = new Vector2(p.X, p.Y); var buttons = System.Windows.Forms.Control.MouseButtons; LeftButton = (buttons & System.Windows.Forms.MouseButtons.Left) == System.Windows.Forms.MouseButtons.Left ? ButtonState.Pressed : ButtonState.Released; MiddleButton = (buttons & System.Windows.Forms.MouseButtons.Middle) == System.Windows.Forms.MouseButtons.Middle ? ButtonState.Pressed : ButtonState.Released; RightButton = (buttons & System.Windows.Forms.MouseButtons.Right) == System.Windows.Forms.MouseButtons.Right ? ButtonState.Pressed : ButtonState.Released; } else { LeftButton = RightButton = MiddleButton = ButtonState.Released; } }
public static void ScreenToAbsolute(int screenX, int screenY, ref float x, ref float y, float z, Camera camera, System.Windows.Forms.Control form, bool fullscreen) { System.Drawing.Point point = new System.Drawing.Point(screenX, screenY); point = form.PointToClient(point); if (fullscreen) { // maximized, so scale the position point.X = (int)(screenX * form.ClientRectangle.Width / (float)System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Width ); point.Y = (int)(screenY * form.ClientRectangle.Height / (float)System.Windows.Forms.SystemInformation.PrimaryMonitorSize.Height ); } x = camera.XEdge * (point.X * 2.0f - form.ClientRectangle.Width) / form.ClientRectangle.Width; y = -camera.YEdge * (point.Y * 2.0f - form.ClientRectangle.Height) / form.ClientRectangle.Height; }