private void canvas1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (canvas1.IsMouseCaptured) canvas1.ReleaseMouseCapture(); // release mouse capture here to make sure the tools cannot forget Point mousep = e.GetPosition(canvas1); TEMouseArgs ee = e.ToTEMouseArgs(); TheModel.CurrentTool.OnLeftMouseButtonUp(new Point(mousep.X, Height - mousep.Y), ee); e.Handled = ee.Handled; }
/// <summary> /// The standard handling of right click is as follows (with this priority): /// 1. The current tool uses the click. /// 2. Set the tool to the standard tool (move) /// 3. Deselect the CurEditing item. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void canvas1_MouseRightButtonDown(object sender, MouseButtonEventArgs e) { // call right down-method in the current tool Point mousep = e.GetPosition(canvas1); var oo = ObjectAtPosition(mousep); TEMouseArgs ee = e.ToTEMouseArgs(); TheModel.CurrentTool.OnRightMouseButtonDown(oo, new Point(mousep.X, Height - mousep.Y), ee); e.Handled = ee.Handled; // if the tool didn't use the click-> proceed with standard handling if (!e.Handled) { if (Tool == OverlayToolType.move) { //canvas1.ContextMenu.IsEnabled = true; if (TheModel.CurEditing != null) { TheModel.CurEditing = null; PreventContextMenuOpening = true; } } else { Tool = OverlayToolType.move; PreventContextMenuOpening = true; } } else PreventContextMenuOpening = true; }
private void canvas1_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { // for some unknown reason the focus has to be set using the dispatcher... Dispatcher.BeginInvoke(new Action(delegate() { Keyboard.Focus(canvas1); })); // call left down-method in the current tool Point mousep = e.GetPosition(canvas1); var oo = ObjectAtPosition(mousep); TEMouseArgs ee = e.ToTEMouseArgs(); TheModel.CurrentTool.OnLeftMouseButtonDown(oo, new Point(mousep.X, Height - mousep.Y), ee); e.Handled = ee.Handled; }