コード例 #1
0
        /// <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;
        }