Exemplo n.º 1
0
        /// <summary>
        /// Delegate called when the mouse isup on the working canvas.
        /// </summary>
        /// <param name="pSender">The event sender.</param>
        /// <param name="pEventArgs">The event arguments.</param>
        private void OnWorkingCanvasMouseUp(object pSender, MouseButtonEventArgs pEventArgs)
        {
            // Release the mouse capture.
            this.WorkingCanvas.ReleaseMouseCapture();
            this.WorkingCanvas.MouseMove  -= this.OnWorkingCanvasMouseMove;
            this.WorkingCanvas.MouseUp    -= this.OnWorkingCanvasMouseUp;
            this.WorkingCanvas.Visibility  = Visibility.Collapsed;
            this.ConnectingLine.Visibility = Visibility.Collapsed;

            // Trying to create the final connection.
            if (this.mSourceConnector != null && this.mTargetConnector != null)
            {
                // Both defined means the connection can be created. Test have been made in the mouse move event handler.
                AGraphViewModel lGraphViewModel = this.ParentView.DataContext as AGraphViewModel;
                if (lGraphViewModel == null)
                {
                    return;
                }

                PortViewModel lSourceViewModel = this.mSourceConnector.ParentPort.Content as PortViewModel;
                PortViewModel lTargetViewModel = this.mTargetConnector.ParentPort.Content as PortViewModel;

                // Requesting connection creation.
                lGraphViewModel.RequestConnectionCreation(lSourceViewModel, lTargetViewModel);
            }

            // Forget the reference on connectors.
            this.mSourceConnector = null;
            this.mTargetConnector = null;
        }
Exemplo n.º 2
0
        public Connection(OutputConnector output, InputConnector input)
        {
            Bezier = new BezierSegment()
            {
                IsStroked = true
            };

            // Set up the Path to insert the segments
            PathGeometry pathGeometry = new PathGeometry();

            PathFigure          = new PathFigure();
            PathFigure.IsClosed = false;
            pathGeometry.Figures.Add(PathFigure);

            this.InputConnector  = input;
            this.OutputConnector = output;
            if (input == null || output == null)
            {
                Current = this;
            }

            PathFigure.Segments.Add(Bezier);
            Path = new Path();
            Path.IsHitTestVisible = false;
            Path.Stroke           = Graph.context.getPipeColor((input != null) ? input.type : output.type);
            Path.StrokeThickness  = 2;
            Path.Data             = pathGeometry;

            Graph.canvas.Children.Add(Path);
            ((UIElement)Graph.canvas.Parent).MouseMove += Canvas_MouseMove;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Delegate called when the mouse move on the working canvas.
        /// </summary>
        /// <param name="pSender">The event sender.</param>
        /// <param name="pEventArgs">The event arguments.</param>
        private void OnWorkingCanvasMouseMove(object pSender, MouseEventArgs pEventArgs)
        {
            if (pEventArgs.LeftButton == MouseButtonState.Pressed)
            {
                // Create a path according to the source and the end.
                this.ConnectingLine.To = pEventArgs.GetPosition(this.WorkingCanvas);

                // Updating the cursor.
                this.mTargetConnector = this.TryHitInputConnector();
                if (this.mTargetConnector != null)
                {
                    PortViewModel lTargetViewModel = this.mTargetConnector.ParentPort.Content as PortViewModel;
                    PortViewModel lSourceViewModel = this.mSourceConnector.ParentPort.Content as PortViewModel;
                    if (lSourceViewModel.CanBeConnectedTo(lTargetViewModel))
                    {
                        this.WorkingCanvas.Cursor = Cursors.Cross;
                    }
                    else
                    {
                        this.WorkingCanvas.Cursor = Cursors.No;
                        this.mTargetConnector     = null;
                    }
                }
                else
                {
                    this.WorkingCanvas.Cursor = Cursors.Cross;
                }
            }
        }
Exemplo n.º 4
0
 // Use this for initialization
 void Start()
 {
     input         = input.GetComponent <InputConnector>();
     output        = output.GetComponent <OutputConnecter>();
     output.Data   = new string[2];
     output.DataId = new string[2] {
         "Input.Speed",
         "Input.Rotation"
     };
 }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ConnectionCreationBehavior"/> class.
        /// </summary>
        /// <param name="pParent">The behavior parent view.</param>
        /// <param name="pWorkingCanvas">The canvas containing the connection line to work with.</param>
        public ConnectionCreationBehavior(SimpleGraphView pParent, Canvas pWorkingCanvas)
            : base(pParent)
        {
            this.WorkingCanvas             = pWorkingCanvas;
            this.WorkingCanvas.Visibility  = Visibility.Collapsed;
            this.ConnectingLine.Visibility = Visibility.Collapsed;

            this.mSourceConnector = null;
            this.mTargetConnector = null;
        }
Exemplo n.º 6
0
        public Connector addInput(int type)
        {
            InputConnector dock = new InputConnector(this, type);

            node.Inputs.Children.Add(dock);
            //stackInputs.UpdateLayout();
            //RenderSize = MeasureOverride(RenderSize);
            //RenderSize = ArrangeOverride(new Size(double.MaxValue, double.MaxValue));
            //Measure(new Size(double.MaxValue, double.MaxValue));
            return(dock);
        }
Exemplo n.º 7
0
 //30w by 20h pixelscreen
 void Start()
 {
     ResetScreen();
     input         = input.GetComponent <InputConnector>();
     output        = output.GetComponent <OutputConnecter>();
     output.Data   = new string[2];
     output.DataId = new string[2] {
         "Input.ScreenGetX",
         "Input.ScreenGetY"
     };
 }
Exemplo n.º 8
0
 // Use this for initialization
 void Start()
 {
     input         = input.GetComponent <InputConnector>();
     output        = output.GetComponent <OutputConnecter>();
     output.Data   = new string[3];
     output.DataId = new string[3] {
         "Input.HorizontalRotation",
         "Input.VerticalRotation",
         "Input.AdjustClaw"
     };
 }
 // Use this for initialization
 void Start()
 {
     Canvas     = GameObject.Find("Canvas").transform;
     input1     = input1.GetComponent <InputConnector>();
     input2     = input2.GetComponent <InputConnector>();
     output     = output.GetComponent <OutputConnecter>();
     ErrorList1 = new List <string>();
     ErrorList2 = new List <string>();
     oldInput1  = input1.name;
     oldInput2  = input2.name;
 }
Exemplo n.º 10
0
        public MidiMessageFilter(Guid nodeId) : base(nodeId)
        {
            _subject = new Subject <MidiMessage>();
            var output = new OutputConnector <MidiMessage>(_subject.Where(Valid), Guid.Parse("{B7B1B419-1AEC-444F-8554-67415AB8F4F4}"));

            _outputs.Add(output);

            // StreamNote: PatteKi "und auch hier war ich :D" (2020-06-30 22:25)
            // StreamNote: m4cx: "Da war ich auch dran ;)" (2020-06-30 22:26)

            var input = new InputConnector <MidiMessage>(_subject, Guid.Parse("{482E6ABA-F11E-44CB-B945-D5DC6AE50286}"));

            _inputs.Add(input);
        }
    // Use this for initialization
    void Start()
    {
        TempN1  = new string[0];
        TempV1  = new string[0];
        TempN2  = new string[0];
        TempV2  = new string[0];
        input   = input.GetComponent <InputConnector>();
        output1 = output1.GetComponent <OutputConnecter>();
        output2 = output2.GetComponent <OutputConnecter>();

        /*output.Data = new string[3];
         * output.DataId = new string[3] {
         *      "Input.HorizontalRotation",
         *      "Input.VerticalRotation",
         *      "Input.AdjustClaw"
         * };*/
        TemporaryNameSave1  = new List <string>();
        TemporaryValueSave1 = new List <string>();
        TemporaryNameSave2  = new List <string>();
        TemporaryValueSave2 = new List <string>();
    }
 public void Break()
 {
     InputConnector.RemoveConnection(this);
     OutputConnector.RemoveConnection(this);
     OnBreak?.Invoke(this, new EventArgs());
 }
Exemplo n.º 13
0
 internal Input(CodecApiElement parent, string propertyName)
     : base(parent, propertyName)
 {
     _connectors = new InputConnector(this, "Connectors");
 }
Exemplo n.º 14
0
 private void OnInputConnectorLoaded(object sender, RoutedEventArgs e)
 {
     _inputConnector.Loaded -= OnInputConnectorLoaded;
     SetAnchorPointB(InputConnector.GetAboluteCenterPosition());
 }
Exemplo n.º 15
0
 private void OnInputNodeMoved(Node node)
 {
     SetAnchorPointB(InputConnector.GetAboluteCenterPosition());
 }