public override void OnMouseDown(MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed || e.MiddleButton == MouseButtonState.Pressed) { clickPoint = MousePositionConverter.GetCursorPosition(); } }
public override void OnMouseMove(MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed || e.MiddleButton == MouseButtonState.Pressed) { var point = MousePositionConverter.GetCursorPosition(); ViewModelMain.Current.BitmapManager.ActiveDocument.ViewportPosition = new System.Windows.Point( point.X - clickPoint.X, point.Y - clickPoint.Y); } }
public override void OnMouseMove(MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { double xPos = MousePositionConverter.GetCursorPosition().X; double rawPercentDifference = (xPos - _startingX) / _pixelsPerZoomMultiplier; //negative - zoom out, positive - zoom in, linear double finalPercentDifference = Math.Pow(2, rawPercentDifference) * 100.0; //less than 100 - zoom out, greater than 100 - zoom in Zoom(finalPercentDifference); } }
public override void OnMouseUp(MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Released && e.RightButton == MouseButtonState.Released && _startingX == MousePositionConverter.GetCursorPosition().X) { if (Keyboard.Modifiers.HasFlag(ModifierKeys.Alt)) { Zoom(85); } else { Zoom(115); } } }
public Color GetColorUnderMouse() { System.Drawing.Color color; using (Bitmap bitmap = new Bitmap(1, 1)) { using (Graphics graphics = Graphics.FromImage(bitmap)) { graphics.CopyFromScreen(MousePositionConverter.GetCursorPosition(), new Point(0, 0), new Size(1, 1)); } color = bitmap.GetPixel(0, 0); } return(Color.FromArgb(color.A, color.R, color.G, color.B)); }
private void Start() { Cursor.visible = false; if (_camera == null) { _camera = Camera.main; } if (_camera.orthographic) { _positionConverter = new OrthographicCameraMousePositionConverter(_camera); } else { _positionConverter = new PerspectiveCameraMousePositionConverter(_camera); } }
public override void OnMouseDown(MouseEventArgs e) { _startingX = MousePositionConverter.GetCursorPosition().X; ViewModelMain.Current.ZoomPercentage = 100; //This resest the value, so callback in MainDrawingPanel can fire again later }