public static MouseLocationType locationType(Rectangle rect, Point mouseLocation) { int num = 3; MouseLocationType mouseLocationType = MouseLocationType.EXTERNAL; if (Math.Abs(mouseLocation.X - rect.Left) < num) { mouseLocationType |= MouseLocationType.LEFT; } if (Math.Abs(mouseLocation.X - rect.Right) < num) { mouseLocationType |= MouseLocationType.RIGHT; } if (Math.Abs(mouseLocation.Y - rect.Top) < num) { mouseLocationType |= MouseLocationType.TOP; } if (Math.Abs(mouseLocation.Y - rect.Bottom) < num) { mouseLocationType |= MouseLocationType.BOTTOM; } if (mouseLocation.X > rect.Left + num && mouseLocation.X < rect.Right - num && (mouseLocation.Y > rect.Top + num && mouseLocation.Y < rect.Bottom - num)) { mouseLocationType = MouseLocationType.INNER; } return(mouseLocationType); }
public static Cursor getCursor8LocationType(MouseLocationType type, Cursor cursor) { switch (type) { case MouseLocationType.LEFT: case MouseLocationType.RIGHT: return(Cursors.SizeWE); case MouseLocationType.TOP: case MouseLocationType.BOTTOM: return(Cursors.SizeNS); case MouseLocationType.INNER: return(Cursors.SizeAll); default: if ((type & MouseLocationType.LEFT) == MouseLocationType.LEFT) { if ((type & MouseLocationType.TOP) == MouseLocationType.TOP) { return(Cursors.SizeNWSE); } if ((type & MouseLocationType.BOTTOM) == MouseLocationType.BOTTOM) { return(Cursors.SizeNESW); } } else if ((type & MouseLocationType.RIGHT) == MouseLocationType.RIGHT) { if ((type & MouseLocationType.TOP) == MouseLocationType.TOP) { return(Cursors.SizeNESW); } if ((type & MouseLocationType.BOTTOM) == MouseLocationType.BOTTOM) { return(Cursors.SizeNWSE); } } return(cursor); } }
private static void onRectChanged(ref HNStruct.HNRectRatio rectRatio, MouseLocationType mouseType, float ratioX, float ratioY) { if (mouseType == MouseLocationType.INNER) { if ((double)rectRatio.l + (double)ratioX >= 0.0 && (double)rectRatio.r + (double)ratioX <= 1.0) { rectRatio.l += ratioX; rectRatio.r += ratioX; } if ((double)rectRatio.t + (double)ratioY >= 0.0 && (double)rectRatio.b + (double)ratioY <= 1.0) { rectRatio.t += ratioY; rectRatio.b += ratioY; } } else { if ((mouseType & MouseLocationType.LEFT) == MouseLocationType.LEFT && (double)ratioX != 0.0) { if ((double)rectRatio.l + (double)ratioX < 0.0) { rectRatio.l = 0.0f; } else if ((double)rectRatio.l + (double)ratioX > (double)rectRatio.r) { rectRatio.l = rectRatio.r; } else { rectRatio.l += ratioX; } } if ((mouseType & MouseLocationType.RIGHT) == MouseLocationType.RIGHT && (double)ratioX != 0.0) { if ((double)rectRatio.r + (double)ratioX > 1.0) { rectRatio.r = 1f; } else if ((double)rectRatio.r + (double)ratioX < (double)rectRatio.l) { rectRatio.r = rectRatio.l; } else { rectRatio.r += ratioX; } } if ((mouseType & MouseLocationType.TOP) == MouseLocationType.TOP && (double)ratioY != 0.0) { if ((double)rectRatio.t + (double)ratioY < 0.0) { rectRatio.t = 0.0f; } else if ((double)rectRatio.t + (double)ratioY > (double)rectRatio.b) { rectRatio.t = rectRatio.b; } else { rectRatio.t += ratioY; } } if ((mouseType & MouseLocationType.BOTTOM) == MouseLocationType.BOTTOM && (double)ratioY != 0.0) { if ((double)rectRatio.b + (double)ratioY > 1.0) { rectRatio.b = 1f; } else if ((double)rectRatio.b + (double)ratioY < (double)rectRatio.t) { rectRatio.b = rectRatio.t; } else { rectRatio.b += ratioY; } } } rectRatio.l = (float)Math.Round((double)rectRatio.l, 3); rectRatio.t = (float)Math.Round((double)rectRatio.t, 3); rectRatio.r = (float)Math.Round((double)rectRatio.r, 3); rectRatio.b = (float)Math.Round((double)rectRatio.b, 3); }
protected override void OnMouseUp(MouseEventArgs e) { base.OnMouseUp(e); this.mMouseButton = MouseButtons.None; this.locationType = MouseLocationType.EXTERNAL; }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); TimerSession.userOperation(); if (this.mMouseButton == MouseButtons.Left) { Point location = e.Location; int num1 = location.X - this.mMouseLocation.X; location = e.Location; int num2 = location.Y - this.mMouseLocation.Y; float ratioX = (float)Math.Round((double)num1 / (double)this.mScreenRect.Width, 3); float ratioY = (float)Math.Round((double)num2 / (double)this.mScreenRect.Height, 3); if (this.mMouseInRect == this.mScreenDrawRect) { onRectChanged(ref this.mScreenRectRatio, this.locationType, ratioX, ratioY); } else if (this.mMouseInRect == this.mDeviceDrawRect) { onRectChanged(ref this.mDeviceDrawRectRatio, this.locationType, ratioX, ratioY); } this.mMouseLocation = e.Location; if (this.mMouseInRect == this.mScreenDrawRect) { this.measureScreenRect(); this.mMouseInRect = this.mScreenDrawRect; } else { if (!(this.mMouseInRect == this.mDeviceDrawRect)) { return; } this.measureDeviceRect(); this.mMouseInRect = this.mDeviceDrawRect; } } else { if (this.mMouseInRect != Rectangle.Empty) { this.locationType = ViewUtils.locationType(this.mMouseInRect, e.Location); if (this.locationType == MouseLocationType.EXTERNAL) { this.mMouseInRect = Rectangle.Empty; } else { this.Cursor = ViewUtils.getCursor8LocationType(this.locationType, this.Cursor); return; } } this.locationType = ViewUtils.locationType(this.mScreenDrawRect, e.Location); if (this.locationType == MouseLocationType.EXTERNAL) { this.mMouseInRect = Rectangle.Empty; this.locationType = ViewUtils.locationType(this.mDeviceDrawRect, e.Location); if (this.locationType == MouseLocationType.EXTERNAL) { this.Cursor = Cursors.Default; this.mMouseInRect = Rectangle.Empty; } else { this.mMouseInRect = this.mDeviceDrawRect; this.Cursor = ViewUtils.getCursor8LocationType(this.locationType, this.Cursor); } } else { this.mMouseInRect = this.mScreenDrawRect; this.Cursor = ViewUtils.getCursor8LocationType(this.locationType, this.Cursor); } } }