private void OnCanvasMouseWheel(object sender, MouseWheelEventArgs e) { var canvasMousePos = e.GetPosition(TheCanvas); var scrollerMousePos = e.GetPosition(SV_Container); if (e.Delta > 0) { ZoomFactor *= 1.5; } else { var z = ZoomFactor; z /= 1.5; ZoomFactor = z < 1 ? 1 : z; } SV_Container.ScrollToVerticalOffset(canvasMousePos.Y * _scale - scrollerMousePos.Y); SV_Container.ScrollToHorizontalOffset(canvasMousePos.X * _scale - scrollerMousePos.X); }
private void TheCanvas_OnMouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { var pos = e.GetPosition(SV_Container); var canvasPos = e.GetPosition(TheCanvas); if (_draggedShape != null) { DotX = canvasPos.X; DotY = canvasPos.Y; } else if (_dragActive) { SV_Container.ScrollToVerticalOffset(_vOffsetOrigin + _start.Y - pos.Y); SV_Container.ScrollToHorizontalOffset(_hOffsetOrigin + _start.X - pos.X); } } else { _dragActive = false; _draggedShape = null; } }