void DrawingCanvas_MouseDown(object sender, MouseButtonEventArgs e) { this.Focus(); if (e.ChangedButton == MouseButton.Left) { if (e.ClickCount == 2) { HandleDoubleClick(e); // special case for GraphicsText } else { Point loc = e.GetPosition(this); if (CurrentRuler.IsSnapping) { CurrentSnapPosition = new Point(-1, -1); Point snap = new Point(loc.X, loc.Y); if (CurrentRuler.GuideManager.Intersection_GetNearst(ref snap)) { CurrentSnapPosition = snap; CurrentPosition = loc; CurrentTool.OnMouseDown(this, CurrentSnapPosition); return; } Guideline gl = CurrentRuler.GuideManager.GetSnapGuide(loc); if (gl != null) { gl.GetNearestPos(ref snap, CurrentRuler.dPicCapture); CurrentSnapPosition = snap; CurrentPosition = loc; CurrentTool.OnMouseDown(this, CurrentSnapPosition); return; } } CurrentPosition = loc; CurrentTool.OnMouseDown(this, CurrentPosition); } } else if (e.ChangedButton == MouseButton.Right) { //CurrentRuler.IsOnGuide(); //show guide menu //CurrentRuler.ContextMenu.PlacementTarget = CurrentRuler; //CurrentRuler.ContextMenu.IsOpen = true; this.ContextMenu.IsOpen = true; } e.Handled = true; }
void DrawingCanvas_MouseMove(object sender, MouseEventArgs e) { Point loc = e.GetPosition(this); //CurrentUnityPosition = Container.ConvertToUnity(CurrentPosition); if (e.MiddleButton == MouseButtonState.Released && e.RightButton == MouseButtonState.Released) { if (CurrentRuler.IsSnapping) { CurrentSnapPosition = new Point(-1, -1); Point snap = new Point(loc.X, loc.Y); if (CurrentRuler.GuideManager.Intersection_GetNearst(ref snap)) { CurrentSnapPosition = snap; CurrentPosition = loc; CurrentTool.OnMouseMove(this, CurrentSnapPosition, e.LeftButton, e.RightButton); return; } Guideline gl = CurrentRuler.GuideManager.GetSnapGuide(loc); if (gl != null) { gl.GetNearestPos(ref snap, CurrentRuler.dPicCapture); CurrentSnapPosition = snap; CurrentPosition = loc; CurrentTool.OnMouseMove(this, CurrentSnapPosition, e.LeftButton, e.RightButton); return; } } CurrentPosition = loc; CurrentTool.OnMouseMove(this, CurrentPosition, e.LeftButton, e.RightButton); } else { this.Cursor = Cursors.Arrow; } }
void DrawingCanvas_MouseUp(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left) { Point loc = e.GetPosition(this); if (CurrentRuler.IsSnapping) { CurrentSnapPosition = new Point(-1, -1); Point snap = new Point(loc.X, loc.Y); if (CurrentRuler.GuideManager.Intersection_GetNearst(ref snap)) { CurrentSnapPosition = snap; CurrentPosition = loc; CurrentTool.OnMouseUp(this, CurrentSnapPosition); return; } Guideline gl = CurrentRuler.GuideManager.GetSnapGuide(loc); if (gl != null) { gl.GetNearestPos(ref snap, CurrentRuler.dPicCapture); CurrentSnapPosition = snap; CurrentPosition = loc; CurrentTool.OnMouseUp(this, CurrentSnapPosition); return; } } CurrentPosition = loc; CurrentTool.OnMouseUp(this, CurrentPosition); //CurrentTool.OnMouseUp(this, e); } }