/// <summary> Event handler for pressing the mouse button. A double click with the left mouse button results in /// zooming in the map. A double click with the right mouse button results in zooming out the map. Pressing the /// left button and the shift key, the zooming rectangle is shown on the map. </summary> /// <param name="sender"> Sender of the MouseDown event. </param> /// <param name="e"> Event parameters. </param> private void source_MouseDown(object sender, MouseButtonEventArgs e) { if (!IsActive) { return; } mapView.Focus(); // NEW: Skip MouseDragMode == None if (MouseDragMode == DragMode.None) { e.Handled = true; return; } if (ZoomOnDoubleClick && e.ClickCount == 2) { Point p = MapView.CanvasToPtvMercator(MapView.GeoCanvas, e.GetPosition(MapView.GeoCanvas)); if (e.RightButton == MouseButtonState.Pressed) { MapView.ZoomAround(p, MapView.FinalZoom + -1, Map.UseAnimation); e.Handled = true; return; } if (e.LeftButton == MouseButtonState.Pressed) { MapView.ZoomAround(p, MapView.FinalZoom + 1, Map.UseAnimation); e.Handled = true; return; } } // Save starting point, used later when determining how much to scroll. ScreenStartPoint = e.GetPosition(mapView); WorldStartPoint = mapView.CanvasToPtvMercator(mapView, e.GetPosition(mapView)); // NEW: check for MouseDragMode if (e.LeftButton == MouseButtonState.Pressed && (MouseDragMode == DragMode.Select || MouseDragMode == DragMode.SelectOnShift && (Keyboard.Modifiers & ModifierKeys.Shift) > 0)) // was && (Keyboard.Modifiers & ModifierKeys.Shift) > 0)) { mapView.Cursor = Cursors.Arrow; if (dragRectangle != null) { mapView.ForePaneCanvas.Children.Remove(dragRectangle); } dragRectangle = new Rectangle(); dragRectangle.IsHitTestVisible = false; dragRectangle.Fill = new SolidColorBrush(Color.FromArgb(0x3e, 0x11, 0x57, 0xdc)); dragRectangle.Stroke = new SolidColorBrush(Color.FromArgb(0x55, 0x07, 0x81, 0xf7)); dragRectangle.StrokeDashArray = new DoubleCollection(new double[] { 20, 8 }); dragRectangle.StrokeEndLineCap = PenLineCap.Round; dragRectangle.StrokeDashCap = PenLineCap.Round; dragRectangle.StrokeThickness = 1.5; dragRectangle.RadiusX = 8; dragRectangle.RadiusY = 8; Panel.SetZIndex(dragRectangle, 266); Canvas.SetLeft(dragRectangle, ScreenStartPoint.X); Canvas.SetTop(dragRectangle, ScreenStartPoint.Y); mapView.ForePaneCanvas.Children.Add(dragRectangle); dragMode = DragMode.Select; mapView.CaptureMouse(); } else if (e.LeftButton == MouseButtonState.Pressed && mapView.CaptureMouse()) { mapView.Cursor = Cursors.Hand; dragMode = DragMode.Pan; wasPanned = false; } }