예제 #1
0
 public override void ProcessInteraction(DiagramInteractionEventArguments interaction)
 {
     if (interaction.Type == InteractionType.KeyUp)
     {
         _shouldStopInteraction = true;
     }
 }
예제 #2
0
 public override void ProcessInteraction(DiagramInteractionEventArguments interaction)
 {
     if (interaction.ViewModelUnderMouse is Wire wire)
     {
         wire.DisconnectWire();
         interaction.Diagram.RemoveWire(wire);
     }
 }
예제 #3
0
        /// <summary>
        /// Adds a node to the diagram interactively, allowing the user to move the mouse and click to choose the final position for the node.
        /// </summary>
        /// <param name="node">The node to add.</param>
        public void AddNodeInteractively(Node node)
        {
            AddNode(node);

            var interaction = new DiagramInteractionEventArguments(InteractionType.NodeInserted);

            DiagramInteractionManager.HandleDiagramInput(interaction, this);
        }
예제 #4
0
 /// <inheritdoc/>
 public override bool ShouldStartInteraction(DiagramInteractionEventArguments interaction)
 {
     return(interaction.Type == InteractionType.KeyDown &&
            !interaction.IsAltKeyPressed &&
            !interaction.IsShiftKeyPressed &&
            interaction.IsCtrlKeyPressed &&
            interaction.Key == System.Windows.Input.Key.Left);
 }
예제 #5
0
        private void KeyInputHandler(KeyEventArgs e, InteractionType type)
        {
            var interaction = new DiagramInteractionEventArguments(type)
            {
                Key = e.Key
            };

            DiagramInteractionManager.HandleDiagramInput(interaction, this);
        }
예제 #6
0
        private void KeyInputHandler(IInputElement sender, KeyEventArgs e, InteractionType type)
        {
            var mousePosition = Mouse.GetPosition(sender);
            var interaction   = new DiagramInteractionEventArguments(type)
            {
                MousePosition = mousePosition,
                Key           = e.Key
            };

            DiagramInteractionManager.HandleDiagramInput(interaction, this);
        }
 public override void StartInteraction(DiagramInteractionEventArguments interaction)
 {
     if (interaction.ViewModelUnderMouse is IMouseEnterLeaveReaction reaction)
     {
         if (reaction != ReactionMouseIsCurrentlyIn)
         {
             ReactionMouseIsCurrentlyIn?.MouseLeft();
             ReactionMouseIsCurrentlyIn = reaction;
             ReactionMouseIsCurrentlyIn.MouseEntered();
         }
     }
 }
예제 #8
0
        public void AddNode(Node node)
        {
            if (node.Model == null)
            {
                throw new InvalidOperationException("Can not add a node to the diagram before it has been initialized");
            }
            Model.AddNode(node.Model);
            AddNodeViewModel(node);

            var interaction = new DiagramInteractionEventArguments(InteractionType.NodeInserted);

            DiagramInteractionManager.HandleDiagramInput(interaction, this);
        }
예제 #9
0
        private void MouseInputHandler(object sender, MouseEventArgs e, InteractionType interactionType)
        {
            var relativeMousePosition = e.GetPosition((IInputElement)sender);
            var interaction           = new DiagramInteractionEventArguments(interactionType)
            {
                MousePosition = relativeMousePosition
            };

            if (e is MouseWheelEventArgs mouseWheelEventArguments)
            {
                interaction.MouseWheelDelta = mouseWheelEventArguments.Delta;
            }
            DiagramInteractionManager.HandleDiagramInput(interaction, this);
        }
예제 #10
0
        public override void ProcessInteraction(DiagramInteractionEventArguments interaction)
        {
            var diagram       = interaction.Diagram;
            var mousePosition = interaction.MousePosition;
            var diagramStartX = diagram.GetDiagramPointFromViewPointX(mousePosition.X);
            var diagramStartY = diagram.GetDiagramPointFromViewPointY(mousePosition.Y);

            var zoom    = interaction.MouseWheelDelta > 0 ? 1.0 + ZoomAmount : 1.0 - ZoomAmount;
            var newZoom = diagram.Zoom * zoom;

            SetZoom(diagram, newZoom);

            var diagramEndX = diagram.GetDiagramPointFromViewPointX(mousePosition.X);
            var diagramEndY = diagram.GetDiagramPointFromViewPointY(mousePosition.Y);

            diagram.PanX -= diagramStartX - diagramEndX;
            diagram.PanY -= diagramStartY - diagramEndY;
        }
 /// <inheritdoc/>
 public override void ProcessInteraction(DiagramInteractionEventArguments interaction)
 {
 }
예제 #12
0
 public override void StartInteraction(DiagramInteractionEventArguments interaction)
 {
     X = (interaction.Diagram.ViewWidth / 2) - 250;
     Y = (interaction.Diagram.ViewHeight / 2) - 200;
     _shouldStopInteraction = false;
 }
예제 #13
0
 public override bool ShouldStartInteraction(DiagramInteractionEventArguments interaction)
 {
     return(interaction.Type == InteractionType.KeyDown && interaction.Key == System.Windows.Input.Key.Oem2);
 }
예제 #14
0
 /// <inheritdoc/>
 public override void ProcessInteraction(DiagramInteractionEventArguments interaction)
 {
     interaction.Diagram.RequestClose();
 }
예제 #15
0
 /// <inheritdoc/>
 public override bool ShouldStopInteraction(DiagramInteractionEventArguments interaction)
 {
     return(true);
 }
 /// <inheritdoc/>
 public override bool ShouldStopInteraction(DiagramInteractionEventArguments interaction)
 {
     return(interaction.Type == InteractionType.MouseMoved);
 }
 /// <inheritdoc/>
 public override void StopInteraction(DiagramInteractionEventArguments interaction)
 {
 }
예제 #18
0
 public override bool ShouldStartInteraction(DiagramInteractionEventArguments interaction)
 {
     return(interaction.Type == InteractionType.LeftMouseDown &&
            interaction.IsCtrlKeyPressed &&
            interaction.ViewModelUnderMouse is Wire wire);
 }