Models an edge connecting two nodes in the view. In the pipeline model, edges are not modelled explictly but implied by the Node.Input.Source property.
Inheritance: Caliburn.Micro.PropertyChangedBase, IDisposable
Example #1
0
        /// <summary>
        /// Connects the dragged edge to the in-/output, if valid.
        /// </summary>
        public void InOutputMouseUp(InOutputViewModel inOut)
        {
            if (DraggedEdge == null)
            {
                return;
            }

            DraggedEdge.EndViewModel = inOut;
            InOutputViewModel inputVM, outputVM;


            if (DraggedEdge.GetInOut(out inputVM, out outputVM))
            {
                var output = (Node.Output)outputVM.Model;
                if (Parent.Model.Graph.CanAddEdge(output.Node, inputVM.Parent.Model))
                {
                    if (inputVM.IsFake)
                    {
                        inputVM.Parent.AddInput(output);
                    }
                    else
                    {
                        ((Node.Input)inputVM.Model).Source = output;
                    }

                    CullInputs();
                    NotifyOfPropertyChange(() => Edges);
                    Parent.SaveSnapshot();
                }
            }
            DraggedEdge = null;
        }
Example #2
0
 /// <summary>
 /// Starts dragging the connected edge, if any, or a new one.
 /// </summary>
 public void InOutputMouseDown(InOutputViewModel inOut)
 {
     /* Only allow this if pipeline is not rendering */
     if (!Parent.Model.IsPlaying)
     {
         InOutputViewModel start = inOut;
         // If the input is already connected, drag the existing edge
         if (inOut.Model is Node.Input)
         {
             start = GetOutputViewModel(((Node.Input)inOut.Model).Source) ?? start;
             ((Node.Input)inOut.Model).Source = null;
             NotifyOfPropertyChange(() => Edges);
             // remember the end of the grabbed edge
             draggedEdgeEndNodeVM = inOut.Parent;
         }
         DraggedEdge = new EdgeViewModel {
             StartViewModel = start, EndViewModel = inOut
         };
     }
 }
Example #3
0
        /// <summary>
        /// Updates the position of the dragged edge or node.
        /// </summary>
        public void MouseMove(IMouseEventInfo e)
        {
            if (e.LeftButton != MouseButtonState.Pressed)
            {
                draggedNode = null;
                DraggedEdge = null;
                // removes unnecessary inputs
                CullInputs();
                return;
            }

            if (draggedNode != null)
            {
                draggedNode.Position = e.GetPosition(relativeTo: this) - dragMouseOffset;
            }
            else if (DraggedEdge != null)
            {
                if (DraggedEdge.Status != EdgeStatus.Indeterminate)
                {
                    DraggedEdge.Status = EdgeStatus.Indeterminate;
                }
                DraggedEdge.EndPoint = e.GetPosition(relativeTo: this);
            }
        }
Example #4
0
 /// <summary>
 /// Cancels any drag operations.
 /// </summary>
 public void MouseUp()
 {
     CullInputs();
     draggedNode = null;
     DraggedEdge = null;
 }