Ejemplo n.º 1
0
        public bool Connect(dynPort p)
        {
            //test if the port that you are connecting too is not the start port or the end port
            //of the current connector
            if (p.Equals(pStart) || p.Equals(pEnd))
            {
                return(false);
            }

            //if the selected connector is also an output connector, return false
            //output ports can't be connected to eachother
            if (p.PortType == PortType.OUTPUT)
            {
                return(false);
            }

            //test if the port that you are connecting to is an input and
            //already has other connectors
            if (p.PortType == PortType.INPUT && p.Connectors.Count > 0)
            {
                return(false);
            }

            //test if the port element at B can connect to the port at A
            //test if you can convert the element at A to the element at b
            if (p.PortType == PortType.INPUT)
            {
                if (!p.Owner.InPortData[p.Index].PortType.IsAssignableFrom(pStart.Owner.OutPortData[pStart.Index].PortType))
                {
                    return(false);
                }
            }
            else if (p.PortType == PortType.STATE)
            {
                if (!p.Owner.StatePortData[p.Index].PortType.IsAssignableFrom(pStart.Owner.OutPortData[pStart.Index].PortType))
                {
                    return(false);
                }
            }

            //turn the line solid
            connector.StrokeDashArray.Clear();

            pEnd = p;

            if (pEnd != null)
            {
                //set the start and end values to equal so this
                //starts evaulating immediately
                pEnd.Owner.InPortData[p.Index].Object = pStart.Owner.OutPortData[pStart.Index].Object;
                p.Connect(this);
                pEnd.Update();
                pEnd.Owner.Update();
            }

            return(true);
        }
Ejemplo n.º 2
0
        public dynConnector(dynPort port, Canvas workBench, Point mousePt)
        {
            //don't allow connections to start at an input port
            if (port.PortType != PortType.INPUT)
            {
                //get start point
                //this.workBench = workBench;
                pStart = port;

                pStart.Connect(this);

                //Create a Bezier;
                connector = new Path();
                connector.Stroke = Brushes.Black;
                connector.StrokeThickness = STROKE_THICKNESS;
                connector.Opacity = .8;

                DoubleCollection dashArray = new DoubleCollection();
                dashArray.Add(5); dashArray.Add(2);
                connector.StrokeDashArray = dashArray;

                PathGeometry connectorGeometry = new PathGeometry();
                connectorPoints = new PathFigure();
                connectorCurve = new BezierSegment();

                connectorPoints.StartPoint = new Point(pStart.Center.X, pStart.Center.Y);
                connectorCurve.Point1 = connectorPoints.StartPoint;
                connectorCurve.Point2 = connectorPoints.StartPoint;
                connectorCurve.Point3 = connectorPoints.StartPoint;

                connectorPoints.Segments.Add(connectorCurve);
                connectorGeometry.Figures.Add(connectorPoints);
                connector.Data = connectorGeometry;
                workBench.Children.Add(connector);

                isDrawing = true;

                //set this to not draggable
                Dynamo.Controls.DragCanvas.SetCanBeDragged(this, false);
                Dynamo.Controls.DragCanvas.SetCanBeDragged(connector, false);

                //set the z order to the front
                Canvas.SetZIndex(this, 300);

                //register an event listener for the start port update
                //this will tell the connector to set the elements at either
                //end to be equal if pStart and pEnd are not null
                //pStart.Owner.Outputs[pStart.Index].dynElementUpdated += new Dynamo.Elements.dynElementUpdatedHandler(StartPortUpdated);
            }
            else
            {
                throw new InvalidPortException();
            }
        }
Ejemplo n.º 3
0
        public dynConnector(dynPort port, Canvas workBench, Point mousePt)
        {
            //don't allow connections to start at an input port
            if (port.PortType != PortType.INPUT)
            {
                //get start point
                //this.workBench = workBench;
                pStart = port;

                pStart.Connect(this);

                //Create a Bezier;
                connector                 = new Path();
                connector.Stroke          = Brushes.Black;
                connector.StrokeThickness = STROKE_THICKNESS;
                connector.Opacity         = .8;

                DoubleCollection dashArray = new DoubleCollection();
                dashArray.Add(5); dashArray.Add(2);
                connector.StrokeDashArray = dashArray;

                PathGeometry connectorGeometry = new PathGeometry();
                connectorPoints = new PathFigure();
                connectorCurve  = new BezierSegment();

                connectorPoints.StartPoint = new Point(pStart.Center.X, pStart.Center.Y);
                connectorCurve.Point1      = connectorPoints.StartPoint;
                connectorCurve.Point2      = connectorPoints.StartPoint;
                connectorCurve.Point3      = connectorPoints.StartPoint;

                connectorPoints.Segments.Add(connectorCurve);
                connectorGeometry.Figures.Add(connectorPoints);
                connector.Data = connectorGeometry;
                workBench.Children.Add(connector);

                isDrawing = true;

                //set this to not draggable
                Dynamo.Controls.DragCanvas.SetCanBeDragged(this, false);
                Dynamo.Controls.DragCanvas.SetCanBeDragged(connector, false);

                //set the z order to the front
                Canvas.SetZIndex(this, 300);

                //register an event listener for the start port update
                //this will tell the connector to set the elements at either
                //end to be equal if pStart and pEnd are not null
                //pStart.Owner.Outputs[pStart.Index].dynElementUpdated += new Dynamo.Elements.dynElementUpdatedHandler(StartPortUpdated);
            }
            else
            {
                throw new InvalidPortException();
            }
        }
Ejemplo n.º 4
0
        public dynConnector(dynPort port, Canvas workBench, Point mousePt)
        {
            //don't allow connections to start at an input port
            if (port.PortType != PortType.INPUT)
            {
                //get start point
                //this.workBench = workBench;
                pStart = port;

                pStart.Connect(this);

                BrushConverter bc = new BrushConverter();
                strokeBrush = (Brush)bc.ConvertFrom("#313131");

                #region bezier creation
                connector = new Path();
                connector.Stroke = strokeBrush;
                connector.StrokeThickness = STROKE_THICKNESS;
                connector.Opacity = STROKE_OPACITY;

                connector.DataContext = this;
                Binding strokeBinding = new Binding("StrokeBrush");
                connector.SetBinding(Path.StrokeProperty, strokeBinding);

                DoubleCollection dashArray = new DoubleCollection();
                dashArray.Add(5); dashArray.Add(2);
                connector.StrokeDashArray = dashArray;

                PathGeometry connectorGeometry = new PathGeometry();
                connectorPoints = new PathFigure();
                connectorCurve = new BezierSegment();

                connectorPoints.StartPoint = new Point(pStart.Center.X, pStart.Center.Y);
                connectorCurve.Point1 = connectorPoints.StartPoint;
                connectorCurve.Point2 = connectorPoints.StartPoint;
                connectorCurve.Point3 = connectorPoints.StartPoint;

                connectorPoints.Segments.Add(connectorCurve);
                connectorGeometry.Figures.Add(connectorPoints);
                connector.Data = connectorGeometry;
                workBench.Children.Add(connector);
                #endregion

                #region polyline creation
                plineConnector = new Path();
                plineConnector.Stroke = strokeBrush;
                plineConnector.StrokeThickness = STROKE_THICKNESS;
                plineConnector.Opacity = STROKE_OPACITY;
                plineConnector.StrokeDashArray = dashArray;

                PathGeometry plineGeometry = new PathGeometry();
                //http://msdn.microsoft.com/en-us/library/system.windows.media.polylinesegment(v=vs.85).aspx
                plineFigure = new PathFigure();
                plineFigure.StartPoint = connectorPoints.StartPoint;
                Point[] polyLinePointArray = new Point[] { connectorPoints.StartPoint,
                connectorPoints.StartPoint,
                connectorPoints.StartPoint};
                pline = new PolyLineSegment(polyLinePointArray, true);
                pline.Points = new PointCollection(polyLinePointArray);
                plineFigure.Segments.Add(pline);
                plineGeometry.Figures.Add(plineFigure);
                plineConnector.Data = plineGeometry;
                dynSettings.Workbench.Children.Add(plineConnector);
                #endregion

                endDot = new Ellipse();
                endDot.Height = 6;
                endDot.Width = 6;
                endDot.Fill = Brushes.Black;
                endDot.StrokeThickness = 2;
                endDot.Stroke = Brushes.Black;
                endDot.IsHitTestVisible = false;
                endDot.MouseDown += new System.Windows.Input.MouseButtonEventHandler(endDot_MouseDown);
                Canvas.SetTop(endDot, connectorCurve.Point3.Y - END_DOT_SIZE / 2);
                Canvas.SetLeft(endDot, connectorCurve.Point3.X - END_DOT_SIZE / 2);
                dynSettings.Workbench.Children.Add(endDot);
                endDot.Opacity = STROKE_OPACITY;

                connector.MouseEnter += delegate { if (pEnd != null) Highlight(); };
                connector.MouseLeave += delegate { Unhighlight(); };
                plineConnector.MouseEnter += delegate { if (pEnd != null) Highlight(); };
                plineConnector.MouseLeave += delegate { Unhighlight(); };

                isDrawing = true;

                //set this to not draggable
                Dynamo.Controls.DragCanvas.SetCanBeDragged(this, false);
                Dynamo.Controls.DragCanvas.SetCanBeDragged(connector, false);

                //set the z order to the front
                Canvas.SetZIndex(connector, 0);
                Canvas.SetZIndex(endDot, 1);

                ConnectorType = dynSettings.Bench.ConnectorType;

            }
            else
            {
                throw new InvalidPortException();
            }
        }
Ejemplo n.º 5
0
        public bool Connect(dynPort p)
        {
            //test if the port that you are connecting too is not the start port or the end port
            //of the current connector
            if (p.Equals(pStart) || p.Equals(pEnd))
            {
                return false;
            }

            //if the selected connector is also an output connector, return false
            //output ports can't be connected to eachother
            if (p.PortType == PortType.OUTPUT)
            {
                return false;
            }

            //test if the port that you are connecting to is an input and
            //already has other connectors
            if (p.PortType == PortType.INPUT && p.Connectors.Count > 0)
            {
                return false;
            }

            //turn the line solid
            connector.StrokeDashArray.Clear();
            plineConnector.StrokeDashArray.Clear();
            pEnd = p;

            if (pEnd != null)
            {
                //set the start and end values to equal so this
                //starts evaulating immediately
                //pEnd.Owner.InPortData[p.Index].Object = pStart.Owner.OutPortData.Object;
                p.Connect(this);
                pEnd.Update();
            }

            return true;
        }
Ejemplo n.º 6
0
        public dynConnector(dynNodeUI start, dynNodeUI end, int startIndex, int endIndex, int portType, bool visible)
        {
            //don't try to create a connector with a bad start,
            //end, or if we're trying to connector the same
            //port to itself.
            if (start == null || end == null || start == end)
            {
                throw new Exception("Attempting to create connector with invalid start or end nodes.");
            }

            pStart = start.OutPorts[startIndex];

            dynPort endPort = null;

            if (portType == 0)
                endPort = end.InPorts[endIndex];

            //connect the two ports
            //get start point

            pStart.Connect(this);

            BrushConverter bc = new BrushConverter();
            strokeBrush = (Brush)bc.ConvertFrom("#313131");

            #region bezier creation
            connector = new Path();
            connector.Stroke = strokeBrush;
            connector.StrokeThickness = STROKE_THICKNESS;
            connector.Opacity = STROKE_OPACITY;

            connector.DataContext = this;
            Binding strokeBinding = new Binding("StrokeBrush");
            connector.SetBinding(Path.StrokeProperty, strokeBinding);

            DoubleCollection dashArray = new DoubleCollection();
            dashArray.Add(5); dashArray.Add(2);
            connector.StrokeDashArray = dashArray;

            PathGeometry connectorGeometry = new PathGeometry();
            connectorPoints = new PathFigure();
            connectorCurve = new BezierSegment();

            connectorPoints.StartPoint = new Point(pStart.Center.X, pStart.Center.Y);
            connectorCurve.Point1 = connectorPoints.StartPoint;
            connectorCurve.Point2 = connectorPoints.StartPoint;
            connectorCurve.Point3 = connectorPoints.StartPoint;

            connectorPoints.Segments.Add(connectorCurve);
            connectorGeometry.Figures.Add(connectorPoints);
            connector.Data = connectorGeometry;
            dynSettings.Workbench.Children.Add(connector);
            #endregion

            #region polyline creation
            plineConnector = new Path();
            plineConnector.Stroke = strokeBrush;
            plineConnector.StrokeThickness = STROKE_THICKNESS;
            plineConnector.Opacity = STROKE_OPACITY;
            plineConnector.StrokeDashArray = dashArray;

            PathGeometry plineGeometry = new PathGeometry();
            //http://msdn.microsoft.com/en-us/library/system.windows.media.polylinesegment(v=vs.85).aspx
            plineFigure = new PathFigure();
            plineFigure.StartPoint = new Point(pStart.Center.X, pStart.Center.Y);
            Point[] polyLinePointArray = new Point[] { connectorPoints.StartPoint,
                connectorPoints.StartPoint,
                connectorPoints.StartPoint};
            pline = new PolyLineSegment(polyLinePointArray, true);
            pline.Points = new PointCollection(polyLinePointArray);
            plineFigure.Segments.Add(pline);
            plineGeometry.Figures.Add(plineFigure);
            plineConnector.Data = plineGeometry;
            dynSettings.Workbench.Children.Add(plineConnector);
            #endregion

            endDot = new Ellipse();
            endDot.Height = 6;
            endDot.Width = 6;
            endDot.Fill = Brushes.Black;
            endDot.StrokeThickness = 2;
            endDot.Stroke = Brushes.Black;
            endDot.IsHitTestVisible = false;
            endDot.MouseDown +=new System.Windows.Input.MouseButtonEventHandler(endDot_MouseDown);
            Canvas.SetTop(endDot, connectorCurve.Point3.Y - END_DOT_SIZE / 2);
            Canvas.SetLeft(endDot, connectorCurve.Point3.X - END_DOT_SIZE / 2);
            dynSettings.Workbench.Children.Add(endDot);
            endDot.Opacity = STROKE_OPACITY;
            endDot.IsHitTestVisible = false;
            endDot.MouseDown += new System.Windows.Input.MouseButtonEventHandler(endDot_MouseDown);

            this.Visible = visible;

            connector.MouseEnter += delegate { if (pEnd != null) Highlight(); };
            connector.MouseLeave += delegate { Unhighlight(); };
            plineConnector.MouseEnter += delegate { if (pEnd != null) Highlight(); };
            plineConnector.MouseLeave += delegate { Unhighlight(); };

            isDrawing = true;

            //set this to not draggable
            Dynamo.Controls.DragCanvas.SetCanBeDragged(this, false);
            Dynamo.Controls.DragCanvas.SetCanBeDragged(connector, false);

            //set the z order to the front
            //Canvas.SetZIndex(this, 300);
            Canvas.SetZIndex(this, 1);

            this.Connect(endPort);

            ConnectorType = dynSettings.Bench.ConnectorType;
        }
Ejemplo n.º 7
0
        public dynConnector(dynElement start, dynElement end, int startIndex, int endIndex, int portType)
        {
            //this.workBench = settings.WorkBench;

            //if (start != null && end != null && start != end)
            //{
                //in the start element, find the out port at the startIndex
                pStart = start.OutPorts[startIndex];

                dynPort endPort = null;

                if (portType == 0)
                    endPort = end.InPorts[endIndex];
                else if (portType == 1)
                    endPort = end.StatePorts[endIndex];

                //connect the two ports
                //get start point

                pStart.Connect(this);

                #region bezier creation
                connector = new Path();
                connector.Stroke = Brushes.Black;
                connector.StrokeThickness = STROKE_THICKNESS;
                connector.Opacity = .8;

                DoubleCollection dashArray = new DoubleCollection();
                dashArray.Add(5); dashArray.Add(2);
                connector.StrokeDashArray = dashArray;

                PathGeometry connectorGeometry = new PathGeometry();
                connectorPoints = new PathFigure();
                connectorCurve = new BezierSegment();

                connectorPoints.StartPoint = new Point(pStart.Center.X, pStart.Center.Y);
                connectorCurve.Point1 = connectorPoints.StartPoint;
                connectorCurve.Point2 = connectorPoints.StartPoint;
                connectorCurve.Point3 = connectorPoints.StartPoint;

                connectorPoints.Segments.Add(connectorCurve);
                connectorGeometry.Figures.Add(connectorPoints);
                connector.Data = connectorGeometry;
                dynElementSettings.SharedInstance.Workbench.Children.Add(connector);

                #endregion

                isDrawing = true;

                //set this to not draggable
                Dynamo.Controls.DragCanvas.SetCanBeDragged(this, false);
                Dynamo.Controls.DragCanvas.SetCanBeDragged(connector, false);

                //set the z order to the front
                Canvas.SetZIndex(this, 300);

                this.Connect(endPort);

            //}
        }
Ejemplo n.º 8
0
        public dynConnector(dynPort port, Canvas workBench, Point mousePt)
        {
            //don't allow connections to start at an input port
             if (port.PortType != PortType.INPUT)
             {
            //get start point
            //this.workBench = workBench;
            pStart = port;

            pStart.Connect(this);

            BrushConverter bc = new BrushConverter();
            Brush strokeBrush = (Brush)bc.ConvertFrom("#313131");

            #region bezier creation
            connector = new Path();

            connector.Stroke = strokeBrush;
            connector.StrokeThickness = STROKE_THICKNESS;
            connector.Opacity = STROKE_OPACITY;

            DoubleCollection dashArray = new DoubleCollection();
            dashArray.Add(5); dashArray.Add(2);
            connector.StrokeDashArray = dashArray;

            PathGeometry connectorGeometry = new PathGeometry();
            connectorPoints = new PathFigure();
            connectorCurve = new BezierSegment();

            connectorPoints.StartPoint = new Point(pStart.Center.X, pStart.Center.Y);
            connectorCurve.Point1 = connectorPoints.StartPoint;
            connectorCurve.Point2 = connectorPoints.StartPoint;
            connectorCurve.Point3 = connectorPoints.StartPoint;

            connectorPoints.Segments.Add(connectorCurve);
            connectorGeometry.Figures.Add(connectorPoints);
            connector.Data = connectorGeometry;
            workBench.Children.Add(connector);
            #endregion

            #region polyline creation
            plineConnector = new Path();
            plineConnector.Stroke = strokeBrush;
            plineConnector.StrokeThickness = STROKE_THICKNESS;
            plineConnector.Opacity = STROKE_OPACITY;
            plineConnector.StrokeDashArray = dashArray;

            PathGeometry plineGeometry = new PathGeometry();
            //http://msdn.microsoft.com/en-us/library/system.windows.media.polylinesegment(v=vs.85).aspx
            plineFigure = new PathFigure();
            plineFigure.StartPoint = connectorPoints.StartPoint;
            Point[] polyLinePointArray = new Point[] { connectorPoints.StartPoint,
                connectorPoints.StartPoint,
                connectorPoints.StartPoint};
            pline = new PolyLineSegment(polyLinePointArray, true);
            pline.Points = new PointCollection(polyLinePointArray);
            plineFigure.Segments.Add(pline);
            plineGeometry.Figures.Add(plineFigure);
            plineConnector.Data = plineGeometry;
            dynElementSettings.SharedInstance.Workbench.Children.Add(plineConnector);
            #endregion

            endDot = new Ellipse();
            endDot.Height = 6;
            endDot.Width = 6;
            endDot.Fill = Brushes.Black;
            endDot.StrokeThickness = 2;
            endDot.Stroke = Brushes.Black;
            Canvas.SetTop(endDot, connectorCurve.Point3.Y - END_DOT_SIZE/2);
            Canvas.SetLeft(endDot, connectorCurve.Point3.X - END_DOT_SIZE/2);
            dynElementSettings.SharedInstance.Workbench.Children.Add(endDot);
            endDot.Opacity = STROKE_OPACITY;

            connector.MouseEnter += delegate { if (pEnd != null) Highlight(); };
            connector.MouseLeave += delegate { Unhighlight(); };
            plineConnector.MouseEnter += delegate { if (pEnd != null) Highlight(); };
            plineConnector.MouseLeave += delegate { Unhighlight(); };

            isDrawing = true;

            //set this to not draggable
            Dynamo.Controls.DragCanvas.SetCanBeDragged(this, false);
            Dynamo.Controls.DragCanvas.SetCanBeDragged(connector, false);

            //set the z order to the front
            Canvas.SetZIndex(connector, 0);
            Canvas.SetZIndex(endDot, 1);

            //register an event listener for the start port update
            //this will tell the connector to set the elements at either
            //end to be equal if pStart and pEnd are not null
            //pStart.Owner.Outputs[pStart.Index].dynElementUpdated += new Dynamo.Elements.dynElementUpdatedHandler(StartPortUpdated);
            this.ConnectorType = dynElementSettings.SharedInstance.Bench.ConnectorType;
            dynElementSettings.SharedInstance.Bench.settings_curves.Checked += new RoutedEventHandler(settings_curves_Checked);
            dynElementSettings.SharedInstance.Bench.settings_plines.Checked += new RoutedEventHandler(settings_plines_Checked);
             }
             else
             {
            throw new InvalidPortException();
             }
        }
Ejemplo n.º 9
0
        public dynConnector(dynNode start, dynNode end, int startIndex, int endIndex, int portType, bool visible)
        {
            //this.workBench = settings.WorkBench;

             //if (start != null && end != null && start != end)
             //{
             //in the start element, find the out port at the startIndex
             pStart = start.OutPort;

             dynPort endPort = null;

             if (portType == 0)
            endPort = end.InPorts[endIndex];
             else if (portType == 1)
            endPort = end.StatePorts[endIndex];

             //connect the two ports
             //get start point

             pStart.Connect(this);

             BrushConverter bc = new BrushConverter();
             Brush strokeBrush = (Brush)bc.ConvertFrom("#313131");

             #region bezier creation
             connector = new Path();
             connector.Stroke = strokeBrush;
             connector.StrokeThickness = STROKE_THICKNESS;
             connector.Opacity = STROKE_OPACITY;

             DoubleCollection dashArray = new DoubleCollection();
             dashArray.Add(5); dashArray.Add(2);
             connector.StrokeDashArray = dashArray;

             PathGeometry connectorGeometry = new PathGeometry();
             connectorPoints = new PathFigure();
             connectorCurve = new BezierSegment();

             connectorPoints.StartPoint = new Point(pStart.Center.X, pStart.Center.Y);
             connectorCurve.Point1 = connectorPoints.StartPoint;
             connectorCurve.Point2 = connectorPoints.StartPoint;
             connectorCurve.Point3 = connectorPoints.StartPoint;

             connectorPoints.Segments.Add(connectorCurve);
             connectorGeometry.Figures.Add(connectorPoints);
             connector.Data = connectorGeometry;
             dynElementSettings.SharedInstance.Workbench.Children.Add(connector);
             #endregion

             #region polyline creation
             plineConnector = new Path();
             plineConnector.Stroke = strokeBrush;
             plineConnector.StrokeThickness = STROKE_THICKNESS;
             plineConnector.Opacity = STROKE_OPACITY;
             plineConnector.StrokeDashArray = dashArray;

             PathGeometry plineGeometry = new PathGeometry();
             //http://msdn.microsoft.com/en-us/library/system.windows.media.polylinesegment(v=vs.85).aspx
             plineFigure = new PathFigure();
             plineFigure.StartPoint = new Point(pStart.Center.X, pStart.Center.Y);
             Point[] polyLinePointArray = new Point[] { connectorPoints.StartPoint,
                connectorPoints.StartPoint,
                connectorPoints.StartPoint};
             pline = new PolyLineSegment(polyLinePointArray, true);
             pline.Points = new PointCollection(polyLinePointArray);
             plineFigure.Segments.Add(pline);
             plineGeometry.Figures.Add(plineFigure);
             plineConnector.Data = plineGeometry;
             dynElementSettings.SharedInstance.Workbench.Children.Add(plineConnector);
             #endregion

             endDot = new Ellipse();
             endDot.Height = 6;
             endDot.Width = 6;
             endDot.Fill = Brushes.Black;
             endDot.StrokeThickness = 2;
             endDot.Stroke = Brushes.Black;
             Canvas.SetTop(endDot, connectorCurve.Point3.Y - END_DOT_SIZE/2);
             Canvas.SetLeft(endDot, connectorCurve.Point3.X - END_DOT_SIZE/2);
             dynElementSettings.SharedInstance.Workbench.Children.Add(endDot);
             endDot.Opacity = STROKE_OPACITY;

             this.Visible = visible;

             connector.MouseEnter += delegate { if (pEnd != null) Highlight(); };
             connector.MouseLeave += delegate { Unhighlight(); };
             plineConnector.MouseEnter += delegate { if (pEnd != null) Highlight(); };
             plineConnector.MouseLeave += delegate { Unhighlight(); };

             isDrawing = true;

             //set this to not draggable
             Dynamo.Controls.DragCanvas.SetCanBeDragged(this, false);
             Dynamo.Controls.DragCanvas.SetCanBeDragged(connector, false);

             //set the z order to the front
             Canvas.SetZIndex(this, 300);

             this.Connect(endPort);

             this.ConnectorType = dynElementSettings.SharedInstance.Bench.ConnectorType;
             dynElementSettings.SharedInstance.Bench.settings_curves.Checked += new RoutedEventHandler(settings_curves_Checked);
             dynElementSettings.SharedInstance.Bench.settings_plines.Checked += new RoutedEventHandler(settings_plines_Checked);
        }
Ejemplo n.º 10
0
        public dynConnector(dynElement start, dynElement end, int startIndex, int endIndex, int portType)
        {
            //this.workBench = settings.WorkBench;

            //if (start != null && end != null && start != end)
            //{
            //in the start element, find the out port at the startIndex
            pStart = start.OutPorts[startIndex];

            dynPort endPort = null;

            if (portType == 0)
            {
                endPort = end.InPorts[endIndex];
            }
            else if (portType == 1)
            {
                endPort = end.StatePorts[endIndex];
            }

            //connect the two ports
            //get start point

            pStart.Connect(this);

            #region bezier creation
            connector                 = new Path();
            connector.Stroke          = Brushes.Black;
            connector.StrokeThickness = STROKE_THICKNESS;
            connector.Opacity         = .8;

            DoubleCollection dashArray = new DoubleCollection();
            dashArray.Add(5); dashArray.Add(2);
            connector.StrokeDashArray = dashArray;

            PathGeometry connectorGeometry = new PathGeometry();
            connectorPoints = new PathFigure();
            connectorCurve  = new BezierSegment();

            connectorPoints.StartPoint = new Point(pStart.Center.X, pStart.Center.Y);
            connectorCurve.Point1      = connectorPoints.StartPoint;
            connectorCurve.Point2      = connectorPoints.StartPoint;
            connectorCurve.Point3      = connectorPoints.StartPoint;

            connectorPoints.Segments.Add(connectorCurve);
            connectorGeometry.Figures.Add(connectorPoints);
            connector.Data = connectorGeometry;
            dynElementSettings.SharedInstance.Workbench.Children.Add(connector);

            #endregion

            isDrawing = true;

            //set this to not draggable
            Dynamo.Controls.DragCanvas.SetCanBeDragged(this, false);
            Dynamo.Controls.DragCanvas.SetCanBeDragged(connector, false);

            //set the z order to the front
            Canvas.SetZIndex(this, 300);

            this.Connect(endPort);

            //}
        }