private void plotter_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e) { // this will prevent other tools like PointSelector from // wrong actuations if (contextMenuOpen) { plotter.Focus(); e.Handled = true; } }
private void plotter_PreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e) { Point position = e.GetPosition(plotter); if (mousePos == position) { hitResults.Clear(); VisualTreeHelper.HitTest(plotter, null, CollectAllVisuals_Callback, new PointHitTestParameters(position)); dynamicMenuItems.Clear(); var dynamicItems = hitResults.Where(r => { var items = GetPlotterContextMenu(r); return(items != null && items.Count > 0); }).SelectMany(r => GetPlotterContextMenu(r)); foreach (var item in dynamicItems) { dynamicMenuItems.Add(item); } staticMenuItems.AddMany(dynamicMenuItems); plotter.Focus(); plotter.ContextMenu.IsOpen = true; e.Handled = true; } }
protected virtual void StopPanning(MouseButtonEventArgs e) { Plotter2D.UndoProvider.CaptureNewValue(Plotter2D.Viewport, Viewport2D.VisibleProperty, Viewport.Visible); Plotter2D.Focus(); ReleaseMouseCapture(); ClearValue(CursorProperty); }
private void plotter_PreviewMouseRightButtonUp(object sender, MouseButtonEventArgs e) { Point position = e.GetPosition(plotter); if (mousePos == position) { hitResults.Clear(); VisualTreeHelper.HitTest(plotter, null, CollectAllVisuals_Callback, new PointHitTestParameters(position)); foreach (var item in dynamicMenuItems) { staticMenuItems.Remove(item); } dynamicMenuItems.Clear(); var dynamicItems = (hitResults.Where(r => { var items = GetPlotterContextMenu(r); return(items != null && items.Count > 0); }).SelectMany(r => GetPlotterContextMenu(r))).ToList(); foreach (var item in dynamicItems) { dynamicMenuItems.Add(item); } staticMenuItems.AddMany(dynamicMenuItems); plotter.Focus(); plotter.ContextMenu.IsOpen = true; e.Handled = true; } else { // this is to prevent showing menu when RMB was pressed, then moved and now is releasing. e.Handled = true; } }