/// <summary> /// Event raised on mouse down in the ZoomAndPanControl. /// </summary> private void OnZoomPanMouseDown(object sender, MouseButtonEventArgs e) { svgDrawing.Focus(); Keyboard.Focus(svgDrawing); mouseButtonDown = e.ChangedButton; origZoomAndPanControlMouseDownPoint = e.GetPosition(zoomPanControl); origContentMouseDownPoint = e.GetPosition(svgDrawing); if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0 && (e.ChangedButton == MouseButton.Left || e.ChangedButton == MouseButton.Right)) { // Shift + left- or right-down initiates zooming mode. mouseHandlingMode = MouseHandlingMode.Zooming; } else if (mouseButtonDown == MouseButton.Left) { // Just a plain old left-down initiates panning mode. mouseHandlingMode = MouseHandlingMode.Panning; } if (mouseHandlingMode != MouseHandlingMode.None) { // Capture the mouse so that we eventually receive the mouse up event. zoomPanControl.CaptureMouse(); e.Handled = true; } }
/// <summary> /// Event raised on mouse down in the NetworkView. /// </summary> private void networkControl_MouseDown(object sender, MouseButtonEventArgs e) { networkControl.Focus(); Keyboard.Focus(networkControl); mouseButtonDown = e.ChangedButton; origZoomAndPanControlMouseDownPoint = e.GetPosition(zoomAndPanControl); origContentMouseDownPoint = e.GetPosition(networkControl); if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0 && (e.ChangedButton == MouseButton.Left || e.ChangedButton == MouseButton.Right)) { // Shift + left- or right-down initiates zooming mode. mouseHandlingMode = MouseHandlingMode.Zooming; } else if (mouseButtonDown == MouseButton.Left && (Keyboard.Modifiers & ModifierKeys.Control) == 0) { // // Initiate panning, when control is not held down. // When control is held down left dragging is used for drag selection. // After panning has been initiated the user must drag further than the threshold value to actually start drag panning. // mouseHandlingMode = MouseHandlingMode.Panning; } if (mouseHandlingMode != MouseHandlingMode.None) { // Capture the mouse so that we eventually receive the mouse up event. networkControl.CaptureMouse(); e.Handled = true; } }
/// <summary> /// Event raised on mouse down in the NetworkView. /// </summary> private void NetworkControl_MouseDown(object sender, MouseButtonEventArgs e) { NetworkView networkView = sender as NetworkView; networkView.Focus(); Keyboard.Focus(networkView); mouseButtonDown = e.ChangedButton; origZoomAndPanControlMouseDownPoint = e.GetPosition(zoomAndPanControl); origContentMouseDownPoint = e.GetPosition(networkView); if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0 && (e.ChangedButton == MouseButton.Left || e.ChangedButton == MouseButton.Right)) { // Shift + left- or right-down initiates zooming mode. mouseHandlingMode = MouseHandlingMode.Zooming; } else if (mouseButtonDown == MouseButton.Left && (Keyboard.Modifiers & ModifierKeys.Control) == 0) { // // Initiate panning, when control is not held down. // When control is held down left dragging is used for drag selection. // After panning has been initiated the user must drag further than the threshold value to actually start drag panning. // mouseHandlingMode = MouseHandlingMode.Panning; } if (mouseHandlingMode != MouseHandlingMode.None) { // Capture the mouse so that we eventually receive the mouse up event. networkView.CaptureMouse(); e.Handled = true; } }
// Event raised on mouse down in the ZoomAndPanControl public static void MouseDown(object sender, MouseButtonEventArgs e,Panel p, ZoomAndPanControl z) { p.Focus(); Keyboard.Focus(p); mouseButtonDown = e.ChangedButton; origZoomAndPanControlMouseDownPoint = e.GetPosition(z); origContentMouseDownPoint = e.GetPosition(p); if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0 && (e.ChangedButton == MouseButton.Left || e.ChangedButton == MouseButton.Right)) { // Shift + left- or right-down initiates zooming mode. mouseHandlingMode = MouseHandlingMode.Zooming; } else if (mouseButtonDown == MouseButton.Left) { // Just a plain old left-down initiates panning mode. mouseHandlingMode = MouseHandlingMode.Panning; } if (mouseHandlingMode != MouseHandlingMode.None) { // Capture the mouse so that we eventually receive the mouse up event. z.CaptureMouse(); e.Handled = true; } }
protected override void OnMouseUp(MouseButtonEventArgs e) { if (mouseHandlingMode != MouseHandlingMode.None) { if (mouseHandlingMode == MouseHandlingMode.Zooming) { if (mouseButtonDown == MouseButton.Left) { // Shift + left-click zooms in on the content. ZoomIn(origContentMouseDownPoint); } else if (mouseButtonDown == MouseButton.Right) { // Shift + left-click zooms out from the content. ZoomOut(origContentMouseDownPoint); } } else if (mouseHandlingMode == MouseHandlingMode.DragZooming) { } ReleaseMouseCapture(); mouseHandlingMode = MouseHandlingMode.None; e.Handled = true; } base.OnMouseUp(e); }
protected override void OnMouseDown(System.Windows.Input.MouseButtonEventArgs e) { content.Focus(); Keyboard.Focus(content); mouseButtonDown = e.ChangedButton; origZoomAndPanControlMouseDownPoint = e.GetPosition(this); origContentMouseDownPoint = e.GetPosition(content); if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0 && (e.ChangedButton == MouseButton.Left || e.ChangedButton == MouseButton.Right)) { // Shift + left- or right-down initiates zooming mode. mouseHandlingMode = MouseHandlingMode.Zooming; } else if (mouseButtonDown == MouseButton.Left) { // Just a plain old left-down initiates panning mode. mouseHandlingMode = MouseHandlingMode.Panning; } if (mouseHandlingMode != MouseHandlingMode.None) { // Capture the mouse so that we eventually receive the mouse up event. this.CaptureMouse(); e.Handled = true; } base.OnMouseDown(e); }
// int tt = 0; private void ScrollBox_MouseDown(object sender, MouseButtonEventArgs e) { if (content == null) { return; } // Debug.Print("ScrollBox_MouseDown"); // Debug.Print((tt++).ToString()); // ???? Focus(); Keyboard.Focus(this); var mouseButtonDown = e.ChangedButton; origZoomAndPanControlMouseDownPoint = e.GetPosition(content); origContentMouseDownPoint = e.GetPosition(content); mouseHandlingMode = MouseHandlingMode.None; if (mouseButtonDown == MouseButton.Middle) { mouseHandlingMode = MouseHandlingMode.Dragging; } if (mouseHandlingMode != MouseHandlingMode.None) { CaptureMouse(); e.Handled = true; } }
private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e) { this.content.Focus(); Keyboard.Focus(this.content); mouseButtonDown = e.ChangedButton; origZoomAndPanControlMouseDownPoint = e.GetPosition(zoomAndPanControl); origContentMouseDownPoint = e.GetPosition(this.content); if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0 && (e.ChangedButton == MouseButton.Left || e.ChangedButton == MouseButton.Right)) { // Shift + left- or right-down initiates zooming mode. mouseHandlingMode = MouseHandlingMode.Zooming; } else if (mouseButtonDown == MouseButton.Right) { // Just a plain old left-down initiates panning mode. mouseHandlingMode = MouseHandlingMode.Panning; } if (mouseHandlingMode != MouseHandlingMode.None) { e.Handled = true; } }
private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e) { if (mouseHandlingMode != MouseHandlingMode.None) { if (mouseHandlingMode == MouseHandlingMode.Zooming) { if (mouseButtonDown == MouseButton.Left) { ZoomIn(origContentMouseDownPoint); } else if (mouseButtonDown == MouseButton.Right) { ZoomOut(origContentMouseDownPoint); } } else if (mouseHandlingMode == MouseHandlingMode.DragZooming) { ApplyDragZoomRect(); } zoomAndPanControl.ReleaseMouseCapture(); mouseHandlingMode = MouseHandlingMode.None; e.Handled = true; } }
private void Gizmo_TransformationChanged(object sender, TransformationEvent transformationEvent) { switch (transformationEvent) { case TransformationEvent.TranslationStarted: TranslateAction translation = new TranslateAction(_vm.SelectedEntities, _vm); translation.TransformStartPoint = _vm.SelectionLocation; GlobalManagement.Instance.CurrentAction = translation; break; case TransformationEvent.TranslationEnded: GlobalManagement.Instance.UndoStack.Push(GlobalManagement.Instance.CurrentAction); GlobalManagement.Instance.CurrentAction = null; break; case TransformationEvent.RotationStarted: RotateAction rotation = new RotateAction(_vm.SelectedEntities, _vm); mouseHandlingMode = MouseHandlingMode.RotateObject; rotation.StartRotation = _vm.GizmoOrientation; rotation.PivotPoint = _vm.SelectionLocation; GlobalManagement.Instance.CurrentAction = rotation; break; case TransformationEvent.RotationEnded: mouseHandlingMode = MouseHandlingMode.None; GlobalManagement.Instance.UndoStack.Push(GlobalManagement.Instance.CurrentAction); GlobalManagement.Instance.CurrentAction = null; break; } }
/// <summary> /// Event raised on mouse up in the ZoomAndPanControl. /// </summary> /// <param name="pSender">The modified control.</param> /// <param name="pEventArgs">The event arguments.</param> private void OnZoomAndPanControlMouseUp(object pSender, MouseButtonEventArgs pEventArgs) { if (this.mMouseHandlingMode != MouseHandlingMode.None) { this.mMouseHandlingMode = MouseHandlingMode.None; } }
private void NodeView_OnConnectorOutMouseDown(object sender, MouseButtonEventArgs e) { if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0) { return; } if (mouseHandlingMode != MouseHandlingMode.None) { return; } origContentMouseDownPoint = e.GetPosition(DiagramGrid); if (sender is NodeView node) { if (e.ChangedButton == MouseButton.Left) { ConnectionViewModel connectionViewModel = new ConnectionViewModel(node.ViewModel) { IsHitTestVisible = false }; ViewModel.RoutedConnectionViewModel = connectionViewModel; mouseHandlingMode = MouseHandlingMode.ConnectionRoute; } else if (e.ChangedButton == MouseButton.Right) { RotateNodeView = node; mouseHandlingMode = MouseHandlingMode.OutConnectorRotate; } e.Handled = true; } }
/// <summary> /// Event raised on mouse up in the ZoomAndPanControl. /// </summary> protected void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e) { if (mouseHandlingMode != MouseHandlingMode.None) { if (mouseHandlingMode == MouseHandlingMode.Zooming) { if (mouseButtonDown == MouseButton.Left) { // Shift + left-click zooms in on the content. ZoomIn(origContentMouseDownPoint); } else if (mouseButtonDown == MouseButton.Right) { // Shift + left-click zooms out from the content. ZoomOut(origContentMouseDownPoint); } } else if (mouseHandlingMode == MouseHandlingMode.DragZooming) { } ZoomAndPanControl.ReleaseMouseCapture(); mouseHandlingMode = MouseHandlingMode.None; e.Handled = true; } }
private void NodeView_OnRectSizeMouseDown(object sender, MouseButtonEventArgs e) { if (e.LeftButton != MouseButtonState.Pressed) { return; } if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0) { return; } if (mouseHandlingMode != MouseHandlingMode.None) { return; } origContentMouseDownPoint = e.GetPosition(DiagramGrid); if (sender is NodeView node) { node.CaptureMouse(); node.ViewModel.OldSize = node.ViewModel.Size; mouseHandlingMode = MouseHandlingMode.ResizeNode; ResizeNodeView = node; e.Handled = true; } }
private void ZoomAndPanControl_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { GetZoomAndPanControl().SaveZoom(); _mouseHandlingMode = MouseHandlingMode.Panning; _origContentMouseDownPoint = e.GetPosition(_viewportCanvas); if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0) { // Shift + left- or right-down initiates zooming mode. _mouseHandlingMode = MouseHandlingMode.DragZooming; _dragBorder.Visibility = Visibility.Hidden; _sizingBorder.Visibility = Visibility.Visible; Canvas.SetLeft(_sizingBorder, _origContentMouseDownPoint.X); Canvas.SetTop(_sizingBorder, _origContentMouseDownPoint.Y); _sizingBorder.Width = 0; _sizingBorder.Height = 0; } else { // Just a plain old left-down initiates panning mode. _mouseHandlingMode = MouseHandlingMode.Panning; } if (_mouseHandlingMode != MouseHandlingMode.None) { // Capture the mouse so that we eventually receive the mouse up event. _viewportCanvas.CaptureMouse(); e.Handled = true; } }
/// <summary> /// Event raised on mouse up in the ZoomAndPanControl. /// </summary> private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e) { if (mouseHandlingMode != MouseHandlingMode.None) { if (mouseHandlingMode == MouseHandlingMode.Zooming) { if (mouseButtonDown == MouseButton.Left) { // Shift + left-click zooms in on the content. ZoomIn(origContentMouseDownPoint); } else if (mouseButtonDown == MouseButton.Right) { // Shift + left-click zooms out from the content. ZoomOut(origContentMouseDownPoint); } } else if (mouseHandlingMode == MouseHandlingMode.DragZooming) { // When drag-zooming has finished we zoom in on the rectangle that was highlighted by the user. ApplyDragZoomRect(); } zoomAndPanControl.ReleaseMouseCapture(); mouseHandlingMode = MouseHandlingMode.None; e.Handled = true; } }
/// <summary> /// Event raised when a mouse button is clicked down over a Rectangle. /// </summary> private void Rectangle_MouseDown(object sender, MouseButtonEventArgs e) { content.Focus(); Keyboard.Focus(content); if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0) { // // When the shift key is held down special zooming logic is executed in content_MouseDown, // so don't handle mouse input here. // return; } if (mouseHandlingMode != MouseHandlingMode.None) { // // We are in some other mouse handling mode, don't do anything. return; } mouseHandlingMode = MouseHandlingMode.DraggingRectangles; origContentMouseDownPoint = e.GetPosition(content); Rectangle rectangle = (Rectangle)sender; rectangle.CaptureMouse(); e.Handled = true; }
// Event raised on mouse move in the NetworkView. private void networkControl_MouseMove(object sender, MouseEventArgs e) { if (mouseHandlingMode == MouseHandlingMode.Panning) { System.Windows.Point curZoomAndPanControlMousePoint = e.GetPosition(zoomAndPanControl); Vector dragOffset = curZoomAndPanControlMousePoint - origZoomAndPanControlMouseDownPoint; double dragThreshold = 10; if (Math.Abs(dragOffset.X) > dragThreshold || Math.Abs(dragOffset.Y) > dragThreshold) { // The user has dragged the cursor further than the threshold distance, initiate // drag panning. mouseHandlingMode = MouseHandlingMode.DragPanning; networkControl.IsClearSelectionOnEmptySpaceClickEnabled = false; Mouse.OverrideCursor = Cursors.ScrollAll; } e.Handled = true; } else if (mouseHandlingMode == MouseHandlingMode.DragPanning) { // The user is left-dragging the mouse. // Pan the viewport by the appropriate amount. System.Windows.Point curContentMousePoint = e.GetPosition(networkControl); Vector dragOffset = curContentMousePoint - origContentMouseDownPoint; zoomAndPanControl.ContentOffsetX -= dragOffset.X; zoomAndPanControl.ContentOffsetY -= dragOffset.Y; e.Handled = true; } else if (mouseHandlingMode == MouseHandlingMode.Zooming) { System.Windows.Point curZoomAndPanControlMousePoint = e.GetPosition(zoomAndPanControl); Vector dragOffset = curZoomAndPanControlMousePoint - origZoomAndPanControlMouseDownPoint; double dragThreshold = 10; if (mouseButtonDown == MouseButton.Left && (Math.Abs(dragOffset.X) > dragThreshold || Math.Abs(dragOffset.Y) > dragThreshold)) { // When Shift + left-down zooming mode and the user drags beyond the drag threshold, // initiate drag zooming mode where the user can drag out a rectangle to select the area // to zoom in on. mouseHandlingMode = MouseHandlingMode.DragZooming; System.Windows.Point curContentMousePoint = e.GetPosition(networkControl); InitDragZoomRect(origContentMouseDownPoint, curContentMousePoint); } e.Handled = true; } else if (mouseHandlingMode == MouseHandlingMode.DragZooming) { // When in drag zooming mode continously update the position of the rectangle // that the user is dragging out. System.Windows.Point curContentMousePoint = e.GetPosition(networkControl); SetDragZoomRect(origContentMouseDownPoint, curContentMousePoint); e.Handled = true; } }
/// <summary> /// Event raised on mouse up in the ZoomAndPanControl. /// </summary> private void zoomAndPanControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (zoomAndPanControl.ContentScale >= (MinPercentage / 100)) { zoomAndPanControl.ReleaseMouseCapture(); mouseHandlingMode = MouseHandlingMode.None; e.Handled = true; } }
/// <summary> /// Event raised on mouse up in the NetworkView. /// </summary> private void NetworkControl_MouseUp(object sender, MouseButtonEventArgs e) { NetworkView networkView = sender as NetworkView; switch (mouseHandlingMode) { case MouseHandlingMode.None: return; case MouseHandlingMode.Zooming: if (mouseButtonDown == MouseButton.Left) { // Shift + left-click zooms in on the content. ZoomIn(origContentMouseDownPoint); } else if (mouseButtonDown == MouseButton.Right) { // Shift + left-click zooms out from the content. ZoomOut(origContentMouseDownPoint); } break; case MouseHandlingMode.DragZooming: // When drag-zooming has finished we zoom in on the rectangle that was highlighted by the user. ApplyDragZoomRect(); break; case MouseHandlingMode.Panning: // // Panning was initiated but dragging was abandoned before the mouse // cursor was dragged further than the threshold distance. // This means that this basically just a regular left mouse click. // Because it was a mouse click in empty space we need to clear the current selection. // break; default: break; } // // Reenable clearing of selection when empty space is clicked. // This is disabled when drag panning is in progress. // networkView.IsClearSelectionOnEmptySpaceClickEnabled = true; // // Reset the override cursor. // This is set to a special cursor while drag panning is in progress. // Mouse.OverrideCursor = null; networkView.ReleaseMouseCapture(); mouseHandlingMode = MouseHandlingMode.None; e.Handled = true; }
/// <summary> /// Event raised on mouse move in the ZoomAndPanControl. /// </summary> private void ZoomAndPanControl_MouseMove(object sender, MouseEventArgs e) { //shseol85: overlay랑 충돌 //Color c = GetPixelColor(e.GetPosition(ImgCanvas)); //PixelInfo = string.Format("{0}", c.B); if (mouseHandlingMode == MouseHandlingMode.Panning) { // // The user is left-dragging the mouse. // Pan the viewport by the appropriate amount. // Point curContentMousePoint = e.GetPosition(ImgCanvas); Vector dragOffset = curContentMousePoint - origContentMouseDownPoint; zoomAndPanControl.ContentOffsetX -= dragOffset.X; zoomAndPanControl.ContentOffsetY -= dragOffset.Y; e.Handled = true; } else if (mouseHandlingMode == MouseHandlingMode.Zooming) { Point curZoomAndPanControlMousePoint = e.GetPosition(zoomAndPanControl); Vector dragOffset = curZoomAndPanControlMousePoint - origZoomAndPanControlMouseDownPoint; double dragThreshold = 10; if (mouseButtonDown == MouseButton.Left && (Math.Abs(dragOffset.X) > dragThreshold || Math.Abs(dragOffset.Y) > dragThreshold)) { // // When Shift + left-down zooming mode and the user drags beyond the drag threshold, // initiate drag zooming mode where the user can drag out a rectangle to select the area // to zoom in on. // mouseHandlingMode = MouseHandlingMode.DragZooming; Point curContentMousePoint = e.GetPosition(ImgCanvas); //InitDragZoomRect(origContentMouseDownPoint, curContentMousePoint); //LDH9999 추후 } e.Handled = true; } /*LDH9999 추후 * else if (mouseHandlingMode == MouseHandlingMode.DragZooming) * { * // * // When in drag zooming mode continously update the position of the rectangle * // that the user is dragging out. * // * Point curContentMousePoint = e.GetPosition(content); * SetDragZoomRect(origContentMouseDownPoint, curContentMousePoint); * * e.Handled = true; * }*/ }
/// <summary> /// Event raised on mouse move in the ZoomAndPanControl. /// </summary> private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e) { Point curContentMousePoint = e.GetPosition(content); lblXy.Content = $"X:{curContentMousePoint.X:F0} Y:{curContentMousePoint.Y:F0} "; if (mouseHandlingMode == MouseHandlingMode.Panning) { // // The user is left-dragging the mouse. // Pan the viewport by the appropriate amount. // //Point curContentMousePoint = e.GetPosition(content); Vector dragOffset = curContentMousePoint - origContentMouseDownPoint; zoomAndPanControl.ContentOffsetX -= dragOffset.X; zoomAndPanControl.ContentOffsetY -= dragOffset.Y; e.Handled = true; } else if (mouseHandlingMode == MouseHandlingMode.Zooming) { Point curZoomAndPanControlMousePoint = e.GetPosition(zoomAndPanControl); Vector dragOffset = curZoomAndPanControlMousePoint - origZoomAndPanControlMouseDownPoint; double dragThreshold = 10; if (mouseButtonDown == MouseButton.Left && (Math.Abs(dragOffset.X) > dragThreshold || Math.Abs(dragOffset.Y) > dragThreshold)) { // // When Shift + left-down zooming mode and the user drags beyond the drag threshold, // initiate drag zooming mode where the user can drag out a rectangle to select the area // to zoom in on. // mouseHandlingMode = MouseHandlingMode.DragZooming; //Point curContentMousePoint = e.GetPosition(content); InitDragZoomRect(origContentMouseDownPoint, curContentMousePoint); } e.Handled = true; } else if (mouseHandlingMode == MouseHandlingMode.DragZooming) { // // When in drag zooming mode continously update the position of the rectangle // that the user is dragging out. // //Point curContentMousePoint = e.GetPosition(content); SetDragZoomRect(origContentMouseDownPoint, curContentMousePoint); e.Handled = true; } }
/// <summary> /// Event raised on mouse down in the ZoomAndPanControl. /// </summary> private void zoomAndPanControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (zoomAndPanControl.ContentScale <= (MaxPercentage / 100)) { btnZoomIn.IsEnabled = true; } if (zoomAndPanControl.ContentScale >= (MinPercentage / 100)) { btnZoomOut.IsEnabled = true; } if (_timer.IsEnabled) { if (zoomAndPanControl.ContentScale <= (MaxPercentage / 100)) { _timer.Stop(); sb = new Storyboard(); DoubleAnimation db = new DoubleAnimation(); sb.Children.Add(db); sb.Completed += new EventHandler(sb_Completed); db.To = zoomAndPanControl.ContentScale + 0.2; db.Duration = new Duration(TimeSpan.FromSeconds(0.3)); Storyboard.SetTarget(db, zoomAndPanControl); Storyboard.SetTargetProperty(db, new PropertyPath("ContentScale")); sb.Begin(); /*Point curContentMousePoint = e.GetPosition(content); * //zoomAndPanControl.ContentOffsetX = curContentMousePoint.X ; //dragOffset.X; * //zoomAndPanControl.ContentOffsetY = curContentMousePoint.Y ; //dragOffset.Y; * zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, curContentMousePoint);*/ } else { btnZoomIn.IsEnabled = false; //zoomAndPanControl.ContentScale = zoomAndPanControl.ContentScale - 0.2; } } else { _timer.Start(); if (zoomAndPanControl.ContentScale >= (MinPercentage / 100)) { origZoomAndPanControlMouseDownPoint = e.GetPosition(zoomAndPanControl); origContentMouseDownPoint = e.GetPosition(content); mouseHandlingMode = MouseHandlingMode.Panning; if (mouseHandlingMode != MouseHandlingMode.None) { zoomAndPanControl.CaptureMouse(); e.Handled = true; } } } }
private void MapScrollViewer_OnPointerCanceled(object sender, PointerRoutedEventArgs e) { _map.TemporaryGeometry_End(MapController.Instance.MousePosition); MapScrollViewer.ReleasePointerCapture(e.Pointer); e.Handled = true; _map.UnlockAll(); if (_mouseMode == MouseHandlingMode.Panning) { _mouseMode = MouseHandlingMode.None; UncheckTopToolbarButtons(null); } InstanceOnInvalidateMap(); }
private void ZoomAndPanControl_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e) { if (_mouseHandlingMode == MouseHandlingMode.DragZooming) { var zoomAndPanControl = GetZoomAndPanControl(); var curContentPoint = e.GetPosition(_viewportCanvas); var rect = Helpers.Clamp(new Point(0, 0), new Point(_viewportCanvas.Width, _viewportCanvas.Height), curContentPoint, _origContentMouseDownPoint); zoomAndPanControl.AnimatedZoomTo(rect); _dragBorder.Visibility = Visibility.Visible; _sizingBorder.Visibility = Visibility.Hidden; } _mouseHandlingMode = MouseHandlingMode.None; _viewportCanvas.ReleaseMouseCapture(); e.Handled = true; }
/// <summary> /// Initializes a new instance of a <see cref="ManipulationBehavior"/> class. /// </summary> /// <param name="pZoomAndPanControl">The manipulated control.</param> public ManipulationBehavior(ZoomAndPanControl pZoomAndPanControl) { this.mZoomAndPanControl = pZoomAndPanControl; this.mZoomAndPanControl.MouseDown += this.OnZoomAndPanControlMouseDown; this.mZoomAndPanControl.MouseMove += this.OnZoomAndPanControlMouseMove; this.mZoomAndPanControl.MouseUp += this.OnZoomAndPanControlMouseUp; this.mZoomAndPanControl.PreviewMouseWheel += this.OnZoomAndPanControlMouseWheel; FrameworkElement lContent = this.mZoomAndPanControl.Content as FrameworkElement; if (lContent != null) { lContent.MouseWheel += this.OnZoomAndPanControlMouseWheel; } this.mMouseHandlingMode = MouseHandlingMode.None; }
private void HandleEscape() { _vm.SelectedEntities.Clear(); if (GlobalManagement.Instance.CurrentAction != null) { GlobalManagement.Instance.CurrentAction.Undo(); } if (GlobalManagement.Instance.NewRectangleBuilding != null) { _vm.MapEntities.Remove(GlobalManagement.Instance.NewRectangleBuilding); GlobalManagement.Instance.NewRectangleBuilding = null; } if (mouseHandlingMode == MouseHandlingMode.CreateWallAttachable && _vm.CurrentWallAttachable != null) { _vm.MapEntities.Remove(_vm.CurrentWallAttachable); _vm.CurrentWallAttachable = null; } if (_vm.CurrentWall != null) { _vm.MapEntities.Remove(_vm.CurrentWall); _vm.CurrentWall = null; } GlobalManagement.Instance.InTerrainEditingMode = false; mouseHandlingMode = MouseHandlingMode.None; if (_vm is DataModel && ((DataModel)_vm).NewPolygonalBuildingWalls != null) { foreach (WallElement wall in ((DataModel)_vm).NewPolygonalBuildingWalls) { _vm.MapEntities.Remove(wall); } ((DataModel)_vm).NewPolygonalBuildingWalls = null; ((DataModel)_vm).CurrentPolygonWall = null; } // remove all building shape manipulation helpers var items = _vm.MapEntities.Where(item => item is VisualCornerManipulator).ToList(); for (int i = 0; i < items.Count; i++) { _vm.MapEntities.Remove(items[i]); } if (_vm is DataModel) { ((DataModel)_vm).CurrentCorners = null; } }
/// <summary> /// Event raised when a mouse button is released over a Ellipse. /// </summary> private void Ellipse_MouseUp(object sender, MouseButtonEventArgs e) { if (mouseHandlingMode != MouseHandlingMode.DraggingEllipse) { // // We are not in ellipse dragging mode. // return; } mouseHandlingMode = MouseHandlingMode.None; Ellipse ellipse = (Ellipse)sender; ellipse.ReleaseMouseCapture(); e.Handled = true; }
private void Node_OnBorderMoveMouseDown(object sender, MouseButtonEventArgs e) { // DiagramGrid.Focus(); //Keyboard.Focus(DiagramGrid); if (e.LeftButton != MouseButtonState.Pressed) { return; } origContentMouseDownPoint = e.GetPosition(DiagramGrid); if (!(sender is NodeView node)) { return; } if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0) { var oldState = node.ViewModel.SelectMode; node.ViewModel.SelectMode = true; ContextCopy_OnClick(this, null); node.ViewModel.SelectMode = oldState; ContextPaste_OnClick(this, null); } if (mouseHandlingMode != MouseHandlingMode.None) { return; } node.CaptureMouse(); DraggedNodeView = node; DraggedNodeViewModels = node.ViewModel.SelectMode ? ViewModel.Nodes.Where(n => n.SelectMode) : new [] { node.ViewModel }; foreach (var n in DraggedNodeViewModels) { n.OldPosition = n.Position; } mouseHandlingMode = MouseHandlingMode.DraggingNode; e.Handled = true; }
// Event raised on mouse up in the NetworkView. private void networkControl_MouseUp(object sender, MouseButtonEventArgs e) { NodePropertyGrid.SelectedObject = networkControl.SelectedNode != null ? ((NodeViewModel)networkControl.SelectedNode).Module.LibnoiseModule : null; if (mouseHandlingMode != MouseHandlingMode.None) { if (mouseHandlingMode == MouseHandlingMode.Panning) { // Panning was initiated but dragging was abandoned before the mouse // cursor was dragged further than the threshold distance. // This means that this basically just a regular left mouse click. // Because it was a mouse click in empty space we need to clear the current selection. } else if (mouseHandlingMode == MouseHandlingMode.Zooming) { if (mouseButtonDown == MouseButton.Left) { // Shift + left-click zooms in on the content. ZoomIn(origContentMouseDownPoint); } else if (mouseButtonDown == MouseButton.Right) { // Shift + left-click zooms out from the content. ZoomOut(origContentMouseDownPoint); } } else if (mouseHandlingMode == MouseHandlingMode.DragZooming) { // When drag-zooming has finished we zoom in on the rectangle that was highlighted by the user. ApplyDragZoomRect(); } // Reenable clearing of selection when empty space is clicked. // This is disabled when drag panning is in progress. networkControl.IsClearSelectionOnEmptySpaceClickEnabled = true; // Reset the override cursor. // This is set to a special cursor while drag panning is in progress. Mouse.OverrideCursor = null; networkControl.ReleaseMouseCapture(); mouseHandlingMode = MouseHandlingMode.None; e.Handled = true; } }
/// <summary> /// Event raised when a mouse button is released over a Rectangle. /// </summary> private void Rectangle_MouseUp(object sender, MouseButtonEventArgs e) { if (mouseHandlingMode != MouseHandlingMode.DraggingRectangles) { // // We are not in rectangle dragging mode. // return; } mouseHandlingMode = MouseHandlingMode.None; Rectangle rectangle = (Rectangle)sender; rectangle.ReleaseMouseCapture(); e.Handled = true; }
private void ScrollBox_MouseUp(object sender, MouseButtonEventArgs e) { if (content == null) { return; } // Debug.Print("ScrollBox_MouseUp"); // Debug.Print((tt++).ToString()); if (mouseHandlingMode != MouseHandlingMode.None) { //else if (mouseHandlingMode == MouseHandlingMode.Zooming) //{ // if (mouseButtonDown == MouseButton.Left) // { // // Shift + left-click zooms in on the content. // ZoomIn(origContentMouseDownPoint); // } // else if (mouseButtonDown == MouseButton.Right) // { // // Shift + left-click zooms out from the content. // ZoomOut(origContentMouseDownPoint); // } //} //else if (mouseHandlingMode == MouseHandlingMode.DragZooming) //{ // // When drag-zooming has finished we zoom in on the rectangle that was highlighted by the user. // ApplyDragZoomRect(); //} // // Reenable clearing of selection when empty space is clicked. // This is disabled when drag panning is in progress. // //IsClearSelectionOnEmptySpaceClickEnabled = true; // Debug.Print("ReleaseMouseCapture"); mouseHandlingMode = MouseHandlingMode.None; ReleaseMouseCapture(); e.Handled = true; } }
public DrawingPage() { InitializeComponent(); _saveXaml = true; _wpfSettings = new WpfDrawingSettings(); _wpfSettings.CultureInfo = _wpfSettings.NeutralCultureInfo; _fileReader = new FileSvgReader(_wpfSettings); _fileReader.SaveXaml = _saveXaml; _fileReader.SaveZaml = false; mouseHandlingMode = MouseHandlingMode.None; string workDir = Path.Combine(Path.GetDirectoryName( System.Reflection.Assembly.GetExecutingAssembly().Location), "XamlDrawings"); _workingDir = new DirectoryInfo(workDir); this.Loaded += new RoutedEventHandler(OnPageLoaded); }
// Event raised on mouse up in the ZoomAndPanControl public static void MouseUp(object sender, MouseButtonEventArgs e,ZoomAndPanControl z) { if (mouseHandlingMode != MouseHandlingMode.None) { if (mouseHandlingMode == MouseHandlingMode.Zooming) { if (mouseButtonDown == MouseButton.Left) { // Shift + left-click zooms in on the content. ZoomIn(z,origContentMouseDownPoint); } else if (mouseButtonDown == MouseButton.Right) { // Shift + left-click zooms out from the content. ZoomOut(z, origContentMouseDownPoint); } } z.ReleaseMouseCapture(); mouseHandlingMode = MouseHandlingMode.None; e.Handled = true; } }
/// <summary> /// Event raised when a mouse button is released over a Rectangle. /// </summary> private void Rectangle_MouseUp(object sender, MouseButtonEventArgs e) { if (mouseHandlingMode != MouseHandlingMode.DraggingRectangles) { // // We are not in rectangle dragging mode. // return; } mouseHandlingMode = MouseHandlingMode.None; Image rectangle = (Image)sender; rectangle.ReleaseMouseCapture(); e.Handled = true; }
/// <summary> /// Event raised when a mouse button is clicked down over a Rectangle. /// </summary> private void Rectangle_MouseDown(object sender, MouseButtonEventArgs e) { content.Focus(); Keyboard.Focus(content); Image rectangle = (Image)sender; BoardObject myRectangle = (BoardObject)rectangle.DataContext; myRectangle.IsSelected = true; if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0) { // // When the shift key is held down special zooming logic is executed in content_MouseDown, // so don't handle mouse input here. // return; } if (mouseHandlingMode != MouseHandlingMode.None) { // // We are in some other mouse handling mode, don't do anything. return; } mouseHandlingMode = MouseHandlingMode.DraggingRectangles; origContentMouseDownPoint = e.GetPosition(content); rectangle.CaptureMouse(); e.Handled = true; }
private void OnZoomAndPanControlMouseUp(object sender, MouseButtonEventArgs e) { if (this.mouseHandlingMode != MouseHandlingMode.None) { this.mouseHandlingMode = MouseHandlingMode.None; e.Handled = true; } }
protected override void OnMouseMove(MouseEventArgs e) { if (mouseHandlingMode == MouseHandlingMode.Panning) { // // The user is left-dragging the mouse. // Pan the viewport by the appropriate amount. // Point curContentMousePoint = e.GetPosition(content); Vector dragOffset = curContentMousePoint - origContentMouseDownPoint; ContentOffsetX -= dragOffset.X; ContentOffsetY -= dragOffset.Y; e.Handled = true; } else if (mouseHandlingMode == MouseHandlingMode.Zooming) { Point curZoomAndPanControlMousePoint = e.GetPosition(this); Vector dragOffset = curZoomAndPanControlMousePoint - origZoomAndPanControlMouseDownPoint; double dragThreshold = 10; if (mouseButtonDown == MouseButton.Left && (Math.Abs(dragOffset.X) > dragThreshold || Math.Abs(dragOffset.Y) > dragThreshold)) { // // When Shift + left-down zooming mode and the user drags beyond the drag threshold, // initiate drag zooming mode where the user can drag out a rectangle to select the area // to zoom in on. // mouseHandlingMode = MouseHandlingMode.DragZooming; } e.Handled = true; } else if (mouseHandlingMode == MouseHandlingMode.DragZooming) { } base.OnMouseMove(e); }
/// <summary> /// Event raised on mouse down in the ZoomAndPanControl. /// </summary> /// <param name="pSender">The modified control.</param> /// <param name="pEventArgs">The event arguments.</param> private void OnZoomAndPanControlMouseDown(object pSender, MouseButtonEventArgs pEventArgs) { FrameworkElement lContent = this.mZoomAndPanControl.Content as FrameworkElement; if (lContent == null) { return; } lContent.Focus(); Keyboard.Focus(lContent); this.mOrigZoomAndPanControlMouseDownPoint = pEventArgs.GetPosition(this.mZoomAndPanControl); this.mOrigContentMouseDownPoint = pEventArgs.GetPosition(lContent); if (pEventArgs.ChangedButton == MouseButton.Middle) { // Initiates panning mode. this.mMouseHandlingMode = MouseHandlingMode.Panning; } pEventArgs.Handled = true; }
protected virtual void OnMouseDown(MouseButtonEventArgs e, MouseButton changedButton) { Focus(); //had content.Focus #if !SILVERLIGHT Keyboard.Focus(content); #endif mouseButtonDown = changedButton; //at WPF one could also use "e.ChangedButton" origZoomAndPanControlMouseDownPoint = e.GetPosition(this); origContentMouseDownPoint = e.GetPosition(content); // Control + left/right-down initiates zooming mode. if (ContentScalable && ((Keyboard.Modifiers & ModifierKeys.Control) != 0) && (mouseButtonDown == MouseButton.Left || mouseButtonDown == MouseButton.Right)) { Cursor = Cursors.SizeNESW; mouseHandlingMode = MouseHandlingMode.Zooming; } else if (mouseButtonDown == MouseButton.Left) { Cursor = Cursors.Hand; mouseHandlingMode = MouseHandlingMode.Panning; } if (mouseHandlingMode != MouseHandlingMode.None) //if we will be doing something with the mouse { //this.CaptureMouse(); // Capture the mouse so that we keep receiving the mouse up event e.Handled = true; } else e.Handled = false; }
protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); if (!isDefaultMouseHandling) return; #if !SILVERLIGHT if (e.Handled) return; #endif if (mouseHandlingMode == MouseHandlingMode.None) return; Point curContentMousePoint = e.GetPosition(content); switch (mouseHandlingMode) { case MouseHandlingMode.Panning: // The user is left-dragging the mouse. Pan the viewport by the appropriate amount. //Vector dragOffset = curContentMousePoint - origContentMouseDownPoint; //TODO: add Mono's System.Windows.Vector to WPF compatibility and add Point class with extension method for add and subtract to return Vector (get implementation from Mono) ContentOffsetX -= curContentMousePoint.X - origContentMouseDownPoint.X; //dragOffset.X ContentOffsetY -= curContentMousePoint.Y - origContentMouseDownPoint.Y; //dragOffset.Y #if !SILVERLIGHT e.Handled = true; #endif break; case MouseHandlingMode.Zooming: Point curZoomAndPanControlMousePoint = e.GetPosition(this); //Vector dragOffset = curZoomAndPanControlMousePoint - origZoomAndPanControlMouseDownPoint; double dragThreshold = 10; #if !DRAGZOOMRECT if (ContentScalable && (mouseButtonDown == MouseButton.Left)) { if ((curZoomAndPanControlMousePoint.Y - origZoomAndPanControlMouseDownPoint.Y /*dragOffset.X*/) < -dragThreshold) ZoomAboutPoint(ContentScale + 0.02, origContentMouseDownPoint); //CTRL + drag up to zoom in else if ((curZoomAndPanControlMousePoint.Y - origZoomAndPanControlMouseDownPoint.Y /*dragOffset.Y*/) > dragThreshold) ZoomAboutPoint(ContentScale - 0.02, origContentMouseDownPoint); //CTRL + drag down to zoom out } #else //DRAGZOOMRECT if (ContentScalable && mouseButtonDown == MouseButton.Left && (Math.Abs(curZoomAndPanControlMousePoint.X - origZoomAndPanControlMouseDownPoint.X /*dragOffset.X*/) > dragThreshold || Math.Abs(curZoomAndPanControlMousePoint.Y - origZoomAndPanControlMouseDownPoint.Y /*dragOffset.Y*/) > dragThreshold)) { // // When Control + left-down zooming mode and the user drags beyond the drag threshold, // initiate drag zooming mode where the user can drag out a rectangle to select the area // to zoom in on. // mouseHandlingMode = MouseHandlingMode.DragZooming; InitDragZoomRect(origContentMouseDownPoint, curContentMousePoint); } #if !SILVERLIGHT e.Handled = ContentScalable; #endif break; case MouseHandlingMode.DragZooming: // When in drag zooming mode continously update the position of the rectangle that the user is dragging out SetDragZoomRect(origContentMouseDownPoint, curContentMousePoint); #if !SILVERLIGHT e.Handled = ContentScalable; #endif #endif //DRAGZOOMRECT break; #if !SILVERLIGHT default: e.Handled = false; break; #endif } }
/// <summary> /// Event raised on mouse down in the ZoomAndPanControl. /// </summary> private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e) { content.Focus(); Keyboard.Focus(content); mouseButtonDown = e.ChangedButton; origZoomAndPanControlMouseDownPoint = e.GetPosition(zoomAndPanControl); origContentMouseDownPoint = e.GetPosition(content); if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0 && (e.ChangedButton == MouseButton.Left || e.ChangedButton == MouseButton.Right)) { // Shift + left- or right-down initiates zooming mode. mouseHandlingMode = MouseHandlingMode.Zooming; } else if (mouseButtonDown == MouseButton.Left && (Keyboard.Modifiers & ModifierKeys.Control) != 0) { //Build something here: //var b = new BoardObject((int)Math.Round(origContentMouseDownPoint.X), // (int)Math.Round(origContentMouseDownPoint.Y), 100, 100, // WarRoom.GetSelectedBoardObject().Source); var b = WarRoom.GetSelectedBoardObject(); b.X = (int)Math.Round(origContentMouseDownPoint.X); b.Y = (int)Math.Round(origContentMouseDownPoint.Y); b.Width = 100; b.Height = 100; DataModel.AddBoardObject(b); FindTargetsAndShooters(b); } else if (mouseButtonDown == MouseButton.Left) { // Just a plain old left-down initiates panning mode. mouseHandlingMode = MouseHandlingMode.Panning; } if (mouseHandlingMode != MouseHandlingMode.None) { // Capture the mouse so that we eventually receive the mouse up event. zoomAndPanControl.CaptureMouse(); e.Handled = true; } }
public FileConverterOutput() { InitializeComponent(); textEditor.SyntaxHighlighting = HighlightingManager.Instance.GetDefinition("XML"); TextEditorOptions options = textEditor.Options; if (options != null) { options.AllowScrollBelowDocument = true; options.EnableHyperlinks = true; options.EnableEmailHyperlinks = true; //options.ShowSpaces = true; //options.ShowTabs = true; //options.ShowEndOfLine = true; } textEditor.IsReadOnly = true; textEditor.ShowLineNumbers = true; _foldingManager = FoldingManager.Install(textEditor.TextArea); _foldingStrategy = new XmlFoldingStrategy(); _wpfSettings = new WpfDrawingSettings(); _wpfSettings.CultureInfo = _wpfSettings.NeutralCultureInfo; _fileReader = new FileSvgReader(_wpfSettings); _fileReader.SaveXaml = false; _fileReader.SaveZaml = false; mouseHandlingMode = MouseHandlingMode.None; _worker = new BackgroundWorker(); _worker.WorkerReportsProgress = true; _worker.WorkerSupportsCancellation = true; _worker.DoWork += new DoWorkEventHandler(OnWorkerDoWork); _worker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(OnWorkerCompleted); _worker.ProgressChanged += new ProgressChangedEventHandler(OnWorkerProgressChanged); }
/// <summary> /// Event raised when a mouse button is clicked down over a diagram-element. /// </summary> private void OnDiagramElementMouseDown(object sender, MouseButtonEventArgs e) { if (e.LeftButton != MouseButtonState.Pressed) { return; } Grid grid; if (!OnlyAssociationsShouldDrag(sender, out grid)) { return; } this.DiagramSpace.Focus(); Keyboard.Focus(this.DiagramSpace); if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0) { // When the shift key is held down special logic may be applied, // so don't handle mouse input here. return; } if (this.mouseHandlingMode != MouseHandlingMode.None) { // We are in some other mouse handling mode, don't do anything. return; } this.mouseHandlingMode = MouseHandlingMode.DraggingDiagramElements; this.currentlyDraggingElement = grid.DataContext as DiagramElement; if (this.currentlyDraggingElement == null) { throw new InvalidOperationException("Code Error: all data contexts should be Diagram Elements"); } this.currentlyDraggingElement.ZOrder = 99; this.origContentMouseDownPoint = e.GetPosition(this.DiagramSpace); }
/// <summary> /// Event raised on mouse up in the ZoomAndPanControl. /// </summary> private void OnZoomPanMouseUp(object sender, MouseButtonEventArgs e) { if (mouseHandlingMode != MouseHandlingMode.None) { if (mouseHandlingMode == MouseHandlingMode.Zooming) { if (mouseButtonDown == MouseButton.Left) { // Shift + left-click zooms in on the content. ZoomIn(); } else if (mouseButtonDown == MouseButton.Right) { // Shift + left-click zooms out from the content. ZoomOut(); } } zoomPanControl.ReleaseMouseCapture(); mouseHandlingMode = MouseHandlingMode.None; e.Handled = true; } }
/// <summary> /// Event raised when a mouse button is released over a Diagram element. /// </summary> private void OnDiagramElementMouseUp(object sender, MouseButtonEventArgs e) { if (e.LeftButton != MouseButtonState.Pressed) { return; } Grid grid; if (!OnlyAssociationsShouldDrag(sender, out grid)) { return; } if (this.mouseHandlingMode != MouseHandlingMode.DraggingDiagramElements) { // We are not in Diagram-Element dragging mode. return; } this.mouseHandlingMode = MouseHandlingMode.None; this.currentlyDraggingElement = null; e.Handled = true; }
private void OnZoomAndPanControlMouseDown(object sender, MouseButtonEventArgs e) { if (e.LeftButton != MouseButtonState.Pressed) { return; } this.DiagramSpace.Focus(); Keyboard.Focus(this.DiagramSpace); this.origContentMouseDownPoint = e.GetPosition(this.DiagramSpace); // Just a plain old left-down initiates panning mode. this.mouseHandlingMode = MouseHandlingMode.Panning; }
/// <summary> /// Event raised on mouse move in the NetworkView. /// </summary> private void networkControl_MouseMove(object sender, MouseEventArgs e) { if (mouseHandlingMode == MouseHandlingMode.Panning) { Point curZoomAndPanControlMousePoint = e.GetPosition(zoomAndPanControl); Vector dragOffset = curZoomAndPanControlMousePoint - origZoomAndPanControlMouseDownPoint; double dragThreshold = 10; if (Math.Abs(dragOffset.X) > dragThreshold || Math.Abs(dragOffset.Y) > dragThreshold) { // // The user has dragged the cursor further than the threshold distance, initiate // drag panning. // mouseHandlingMode = MouseHandlingMode.DragPanning; networkControl.IsClearSelectionOnEmptySpaceClickEnabled = false; Mouse.OverrideCursor = Cursors.ScrollAll; } e.Handled = true; } else if (mouseHandlingMode == MouseHandlingMode.DragPanning) { // // The user is left-dragging the mouse. // Pan the viewport by the appropriate amount. // Point curContentMousePoint = e.GetPosition(networkControl); Vector dragOffset = curContentMousePoint - origContentMouseDownPoint; zoomAndPanControl.ContentOffsetX -= dragOffset.X; zoomAndPanControl.ContentOffsetY -= dragOffset.Y; e.Handled = true; } else if (mouseHandlingMode == MouseHandlingMode.Zooming) { Point curZoomAndPanControlMousePoint = e.GetPosition(zoomAndPanControl); Vector dragOffset = curZoomAndPanControlMousePoint - origZoomAndPanControlMouseDownPoint; double dragThreshold = 10; if (mouseButtonDown == MouseButton.Left && (Math.Abs(dragOffset.X) > dragThreshold || Math.Abs(dragOffset.Y) > dragThreshold)) { // // When Shift + left-down zooming mode and the user drags beyond the drag threshold, // initiate drag zooming mode where the user can drag out a rectangle to select the area // to zoom in on. // mouseHandlingMode = MouseHandlingMode.DragZooming; Point curContentMousePoint = e.GetPosition(networkControl); InitDragZoomRect(origContentMouseDownPoint, curContentMousePoint); } e.Handled = true; } else if (mouseHandlingMode == MouseHandlingMode.DragZooming) { // // When in drag zooming mode continously update the position of the rectangle // that the user is dragging out. // Point curContentMousePoint = e.GetPosition(networkControl); SetDragZoomRect(origContentMouseDownPoint, curContentMousePoint); e.Handled = true; } }
protected virtual void OnMouseUp(MouseButtonEventArgs e, MouseButton changedButton) { if (mouseHandlingMode == MouseHandlingMode.None) return; //ReleaseMouseCapture(); switch (mouseHandlingMode) { case MouseHandlingMode.Zooming: if (ContentScalable && (mouseButtonDown == MouseButton.Left) && (changedButton == MouseButton.Left)) //at WPF one could also use "e.ChangedButton" { ZoomIn(origContentMouseDownPoint); // Control + left-click zooms in on the content } else if (ContentScalable && (mouseButtonDown == MouseButton.Right) && (changedButton == MouseButton.Right)) //at WPF one could also use "e.ChangedButton" { ZoomOut(origContentMouseDownPoint); // Control + left-click zooms out from the content } e.Handled = ContentScalable; break; case MouseHandlingMode.DragZooming: //drag-zooming has finished ApplyDragZoomRect(); //zoom in on the rectangle that was highlighted by the user. e.Handled = true; break; default: e.Handled = false; break; } Cursor = Cursors.Arrow; mouseHandlingMode = MouseHandlingMode.None; }
/// <summary> /// Event raised on mouse up in the ZoomAndPanControl. /// </summary> private void zoomAndPanControl_MouseUp(object sender, MouseButtonEventArgs e) { if (mouseHandlingMode != MouseHandlingMode.None) { if (mouseHandlingMode == MouseHandlingMode.Zooming) { if (mouseButtonDown == MouseButton.Left) { // Shift + left-click zooms in on the content. ZoomIn(origContentMouseDownPoint); } else if (mouseButtonDown == MouseButton.Right) { // Shift + left-click zooms out from the content. ZoomOut(origContentMouseDownPoint); } } /*else if (mouseHandlingMode == MouseHandlingMode.DragZooming) { // When drag-zooming has finished we zoom in on the rectangle that was highlighted by the user. ApplyDragZoomRect(); }*/ zoomAndPanControl.ReleaseMouseCapture(); mouseHandlingMode = MouseHandlingMode.None; e.Handled = true; } }
/// <summary> /// Event raised on mouse up in the NetworkView. /// </summary> private void networkControl_MouseUp(object sender, MouseButtonEventArgs e) { if (mouseHandlingMode != MouseHandlingMode.None) { if (mouseHandlingMode == MouseHandlingMode.Panning) { // // Panning was initiated but dragging was abandoned before the mouse // cursor was dragged further than the threshold distance. // This means that this basically just a regular left mouse click. // Because it was a mouse click in empty space we need to clear the current selection. // } else if (mouseHandlingMode == MouseHandlingMode.Zooming) { if (mouseButtonDown == MouseButton.Left) { // Shift + left-click zooms in on the content. ZoomIn(origContentMouseDownPoint); } else if (mouseButtonDown == MouseButton.Right) { // Shift + left-click zooms out from the content. ZoomOut(origContentMouseDownPoint); } } else if (mouseHandlingMode == MouseHandlingMode.DragZooming) { // When drag-zooming has finished we zoom in on the rectangle that was highlighted by the user. ApplyDragZoomRect(); } // // Reenable clearing of selection when empty space is clicked. // This is disabled when drag panning is in progress. // networkControl.IsClearSelectionOnEmptySpaceClickEnabled = true; // // Reset the override cursor. // This is set to a special cursor while drag panning is in progress. // Mouse.OverrideCursor = null; networkControl.ReleaseMouseCapture(); mouseHandlingMode = MouseHandlingMode.None; e.Handled = true; } }
/// <summary> /// Event raised on mouse move in the ZoomAndPanControl. /// </summary> private void zoomAndPanControl_MouseMove(object sender, MouseEventArgs e) { if (mouseHandlingMode == MouseHandlingMode.Panning) { // // The user is left-dragging the mouse. // Pan the viewport by the appropriate amount. // Point curContentMousePoint = e.GetPosition(mapCanvas); Vector dragOffset = curContentMousePoint - origContentMouseDownPoint; zoomAndPanControl.ContentOffsetX -= dragOffset.X; zoomAndPanControl.ContentOffsetY -= dragOffset.Y; e.Handled = true; } else if (mouseHandlingMode == MouseHandlingMode.Zooming) { Point curZoomAndPanControlMousePoint = e.GetPosition(zoomAndPanControl); Vector dragOffset = curZoomAndPanControlMousePoint - origZoomAndPanControlMouseDownPoint; double dragThreshold = 10; if (mouseButtonDown == MouseButton.Left && (Math.Abs(dragOffset.X) > dragThreshold || Math.Abs(dragOffset.Y) > dragThreshold)) { // // When Shift + left-down zooming mode and the user drags beyond the drag threshold, // initiate drag zooming mode where the user can drag out a rectangle to select the area // to zoom in on. // mouseHandlingMode = MouseHandlingMode.DragZooming; Point curContentMousePoint = e.GetPosition(mapCanvas); //InitDragZoomRect(origContentMouseDownPoint, curContentMousePoint); } e.Handled = true; } /*else if (mouseHandlingMode == MouseHandlingMode.DragZooming) { // // When in drag zooming mode continously update the position of the rectangle // that the user is dragging out. // Point curContentMousePoint = e.GetPosition(mapCanvas); SetDragZoomRect(origContentMouseDownPoint, curContentMousePoint); e.Handled = true; }*/ }
/// <summary> /// Event raised on mouse down in the ZoomAndPanControl. /// </summary> private void zoomAndPanControl_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { if (zoomAndPanControl.ContentScale <= (MaxPercentage / 100)) btnZoomIn.IsEnabled = true; if (zoomAndPanControl.ContentScale >= (MinPercentage / 100)) btnZoomOut.IsEnabled = true; if (_timer.IsEnabled) { if (zoomAndPanControl.ContentScale <= (MaxPercentage / 100)) { _timer.Stop(); sb = new Storyboard(); DoubleAnimation db = new DoubleAnimation(); sb.Children.Add(db); sb.Completed += new EventHandler(sb_Completed); db.To = zoomAndPanControl.ContentScale + 0.2; db.Duration = new Duration(TimeSpan.FromSeconds(0.3)); Storyboard.SetTarget(db, zoomAndPanControl); Storyboard.SetTargetProperty(db, new PropertyPath("ContentScale")); sb.Begin(); /*Point curContentMousePoint = e.GetPosition(content); //zoomAndPanControl.ContentOffsetX = curContentMousePoint.X ; //dragOffset.X; //zoomAndPanControl.ContentOffsetY = curContentMousePoint.Y ; //dragOffset.Y; zoomAndPanControl.ZoomAboutPoint(zoomAndPanControl.ContentScale + 0.2, curContentMousePoint);*/ } else { btnZoomIn.IsEnabled = false; //zoomAndPanControl.ContentScale = zoomAndPanControl.ContentScale - 0.2; } } else { _timer.Start(); if (zoomAndPanControl.ContentScale >= (MinPercentage / 100)) { origZoomAndPanControlMouseDownPoint = e.GetPosition(zoomAndPanControl); origContentMouseDownPoint = e.GetPosition(content); mouseHandlingMode = MouseHandlingMode.Panning; if (mouseHandlingMode != MouseHandlingMode.None) { zoomAndPanControl.CaptureMouse(); e.Handled = true; } } } }