コード例 #1
0
        /// <summary>
        /// Registers the <see cref="GraphEditorInputMode"/> as the <see cref="CanvasControl.InputMode"/>
        /// and initializes the marquee input mode that clears the area of the marquee rectangle.
        /// </summary>
        private void InitializeInputModes()
        {
            // enable undo/redo support
            GraphControl.Graph.SetUndoEngineEnabled(true);

            // create an input mode to edit graphs
            var editMode = new GraphEditorInputMode();

            // create an input mode to clear the area of a marquee rectangle
            // using the right mouse button
            var marqueeClearInputMode = new MarqueeSelectionInputMode {
                PressedRecognizer  = MouseEventRecognizers.RightPressed,
                DraggedRecognizer  = MouseEventRecognizers.RightDragged,
                ReleasedRecognizer = MouseEventRecognizers.RightReleased,
                CancelRecognizer   = KeyEventRecognizers.EscapePressed.Or(MouseEventRecognizers.LostCaptureDuringDrag),
                Template           = GraphControl.FindResource(ClearRectTemplateKey) as DataTemplate
            };

            // handle dragging the marquee
            marqueeClearInputMode.DragStarting += OnDragStarting;
            marqueeClearInputMode.Dragged      += OnDragged;
            marqueeClearInputMode.DragCanceled += OnDragCanceled;
            marqueeClearInputMode.DragFinished += OnDragFinished;
            // add this mode to the edit mode
            editMode.Add(marqueeClearInputMode);

            // and install the edit mode into the canvas
            GraphControl.InputMode = editMode;
        }