/// <summary> /// Event raised on mouse down in the ZoomAndPanControl. /// </summary> private void zoomAndPanControl_MouseDown(object sender, MouseButtonEventArgs e) { ContentListBox.Focus(); Keyboard.Focus(ContentListBox); mouseButtonDown = e.ChangedButton; origZoomAndPanControlMouseDownPoint = e.GetPosition(ZoomAndPanControl); origContentMouseDownPoint = e.GetPosition(ContentListBox); 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. ZoomAndPanControl.CaptureMouse(); e.Handled = true; } }
/// <summary> /// Event raised when a mouse button is clicked down over a Ellipse. /// </summary> private void Ellipse_MouseDown(object sender, MouseButtonEventArgs e) { mouseButtonDown = e.ChangedButton; if (mouseButtonDown == MouseButton.Left) { ContentListBox.Focus(); Keyboard.Focus(ContentListBox); Grid grid = (Grid)sender; var ellipse = grid.Children.Cast <Ellipse>().FirstOrDefault(); Spot spot = (Spot)ellipse.DataContext; if (spot.IsSelected) { spot.Width = 20; spot.Height = 20; spot.IsSelected = false; _mainViewModel.SelectedSpots.Remove(spot); } else { spot.IsSelected = true; spot.Width = 26; spot.Height = 26; _mainViewModel.SelectedSpots.Add(spot); } } e.Handled = 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.DraggingEllipse; //origContentMouseDownPoint = e.GetPosition(ContentListBox); //ellipse.CaptureMouse(); }