コード例 #1
0
 public void Register(HandleInputMode inputMode)
 {
     this.inputMode          = inputMode;
     inputMode.DragStarted  += InputModeOnDragStarted;
     inputMode.DragCanceled += InputModeOnDragCanceled;
     inputMode.DragFinished += InputModeOnDragFinished;
 }
コード例 #2
0
        /// <summary>
        /// Adds the input modes that handle the resizing and movement of the rectangular area.
        /// </summary>
        /// <param name="inputMode"></param>
        private void AddClearRectInputModes(MultiplexingInputMode inputMode)
        {
            // create handles for interactively resizing the rectangle
            var rectangleHandles = new RectangleReshapeHandleProvider(clearRect)
            {
                MinimumSize = new SizeD(10, 10)
            };

            // create a mode that deals with the handles
            var handleInputMode = new HandleInputMode {
                Priority = 1
            };

            // add it to the graph editor mode
            inputMode.Add(handleInputMode);

            // now the handles
            var inputModeContext = Contexts.CreateInputModeContext(handleInputMode);

            handleInputMode.Handles = new DefaultObservableCollection <IHandle> {
                rectangleHandles.GetHandle(inputModeContext, HandlePositions.NorthEast),
                rectangleHandles.GetHandle(inputModeContext, HandlePositions.NorthWest),
                rectangleHandles.GetHandle(inputModeContext, HandlePositions.SouthEast),
                rectangleHandles.GetHandle(inputModeContext, HandlePositions.SouthWest),
            };

            // create a mode that allows for dragging the rectangle at the sides
            var moveInputMode = new MoveInputMode {
                PositionHandler = new RectanglePositionHandler(clearRect),
                HitTestable     = HitTestables.Create((context, location) => clearRect.Contains(location)),
                Priority        = 41
            };

            // handle dragging the rectangle
            moveInputMode.DragStarting += OnDragStarting;
            moveInputMode.Dragged      += OnDragged;
            moveInputMode.DragCanceled += OnDragCanceled;
            moveInputMode.DragFinished += OnDragFinished;

            // handle resizing the rectangle
            handleInputMode.DragStarting += OnDragStarting;
            handleInputMode.Dragged      += OnDragged;
            handleInputMode.DragCanceled += OnDragCanceled;
            handleInputMode.DragFinished += OnDragFinished;

            // add it to the edit mode
            inputMode.Add(moveInputMode);
        }
コード例 #3
0
        /// <summary>
        /// Adds the view modes that handle the resizing and movement of the export rectangle.
        /// </summary>
        /// <param name="inputMode"></param>
        private void AddExportRectInputModes(MultiplexingInputMode inputMode)
        {
            // create handles for interactivel resizing the export rectangle
            var rectangleHandles = new RectangleReshapeHandleProvider(exportRect)
            {
                MinimumSize = new SizeD(1, 1)
            };

            // create a mode that deals with the handles
            var exportHandleInputMode = new HandleInputMode {
                Priority = 1
            };

            // add it to the graph editor mode
            inputMode.Add(exportHandleInputMode);

            // now the handles
            var inputModeContext = Contexts.CreateInputModeContext(exportHandleInputMode);

            exportHandleInputMode.Handles = new DefaultObservableCollection <IHandle>
            {
                rectangleHandles.GetHandle(inputModeContext, HandlePositions.NorthEast),
                rectangleHandles.GetHandle(inputModeContext, HandlePositions.NorthWest),
                rectangleHandles.GetHandle(inputModeContext, HandlePositions.SouthEast),
                rectangleHandles.GetHandle(inputModeContext, HandlePositions.SouthWest),
            };

            // create a mode that allows for dragging the export rectangle at the sides

            var moveInputMode = new MoveInputMode
            {
                PositionHandler = new ExportRectanglePositionHandler(exportRect),
                HitTestable     = HitTestables.Create(
                    (context, location) => {
                    var path = new GeneralPath(5);
                    path.AppendRectangle(exportRect, false);
                    return(path.PathContains(location, context.HitTestRadius));
                }),
                Priority = 41
            };

            // add it to the edit mode
            inputMode.Add(moveInputMode);
        }
コード例 #4
0
        public void Uninstall(IInputModeContext context)
        {
            context.GetGraph().NodeLayoutChanged -= NodeLayoutChanged;
            var geim = context.ParentInputMode as GraphEditorInputMode;

            geim.MultiSelectionStarted  -= MultiSelectionStarted;
            geim.MultiSelectionFinished -= MultiSelectionFinished;
            ((GraphControl)context.CanvasControl).Selection.ItemSelectionChanged -= ItemSelectionChanged;

            handleInputMode.DragStarted  -= RegisterReshapedNodes;
            handleInputMode.DragStarting -= moveHandleOrthogonalHelper.Starting;
            handleInputMode.DragFinished -= moveHandleOrthogonalHelper.Finished;
            handleInputMode.DragCanceled -= moveHandleOrthogonalHelper.Canceled;
            handleInputMode.DragStarted  -= moveHandleOrthogonalHelper.Started;

            RemoveRectangleVisualization();
            handleInputMode.Uninstall(context);
            handleInputMode  = null;
            InputModeContext = null;
        }
コード例 #5
0
        public void Install(IInputModeContext context, ConcurrencyController controller)
        {
            InputModeContext = context;
            var geim = context.ParentInputMode as GraphEditorInputMode;

            if (geim == null)
            {
                throw new InvalidOperationException("NodeGroupResizingInputMode must be installed as child mode of GraphEditorInputMode");
            }

            // create own HandleInputMode for the handles
            handleInputMode = new HandleInputMode {
                Priority = 1
            };

            // notify the GraphSnapContext which nodes are resized and shouldn't provide SnapLines
            handleInputMode.DragStarted += RegisterReshapedNodes;

            // forward events to OrthogonalEdgeEditingContext so it can handle keeping edges at reshaped nodes orthogonal
            handleInputMode.DragStarting += moveHandleOrthogonalHelper.Starting;
            handleInputMode.DragStarted  += moveHandleOrthogonalHelper.Started;
            handleInputMode.DragFinished += moveHandleOrthogonalHelper.Finished;
            handleInputMode.DragCanceled += moveHandleOrthogonalHelper.Canceled;

            handleInputMode.Install(context, controller);
            handleInputMode.Enabled = false;

            // update handles depending on the changed node selection
            geim.MultiSelectionStarted  += MultiSelectionStarted;
            geim.MultiSelectionFinished += MultiSelectionFinished;
            ((GraphControl)context.CanvasControl).Selection.ItemSelectionChanged += ItemSelectionChanged;

            // add a NodeLayoutChanged listener so the reshape rect is updated when the nodes are moved (e.g. through
            // layout animations or MoveInputMode).
            context.GetGraph().NodeLayoutChanged += NodeLayoutChanged;
        }