示例#1
0
        /// <summary>
        /// 두 쌍의 <see cref="BindThumb"/>를 시각적으로 이어주는 <see cref="LineConnector"/>를 생성합니다.
        /// </summary>
        /// <param name="output"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        public LineConnector CreateConnectedLine(BindThumb output, BindThumb input)
        {
            if (lineCollection.HasThumbExpression(output, input))
            {
                return(null);
            }

            var connector = new LineConnector(this, output, input);

            if (ZoomPanel != null)
            {
                connector.Line.LineBrush = Brushes.DimGray;

                BindingHelper.SetBinding(
                    ZoomPanel, ZoomPanel.ScaleProperty,
                    connector.Line, BezierLine.StrokeThicknessProperty,
                    converter: new ReciprocalConverter()
                {
                    Factor = 2
                });
            }

            LineLayer.Add(connector.Line);
            lineCollection.Add(connector);

            return(connector);
        }
示例#2
0
        //Creating the Connections and Add into DiagramModel
        private void Connect(Node head, Node tail, SolidColorBrush solidColorBrush, SolidColorBrush solidstorkebursh, DecoratorShape taildecoratorShape, DecoratorShape headdecoratorShape, ConnectorType connectorType)
        {
            LineConnector lc = new LineConnector();

            lc.HeadNode                  = head;
            lc.TailNode                  = tail;
            lc.LineStyle.Fill            = new SolidColorBrush(Colors.Black);
            lc.LineStyle.StrokeThickness = 2;
            lc.ConnectorType             = ConnectorType.Straight;
            //For Applyibf Custom Decorator Shape
            if (headdecoratorShape == DecoratorShape.Custom)
            {
                lc.CustomHeadDecoratorStyle = this.Resources["Shape6"] as Style;
            }
            else
            {
                lc.HeadDecoratorShape = headdecoratorShape;
            }
            if (taildecoratorShape == DecoratorShape.Custom)
            {
                lc.CustomTailDecoratorStyle = this.Resources["Shape4"] as Style;
            }
            else
            {
                lc.TailDecoratorShape = taildecoratorShape;
            }
            lc.HeadDecoratorShape = DecoratorShape.Diamond;
            //Apply style to Decorator Shape
            lc.HeadDecoratorStyle.Fill   = solidColorBrush;
            lc.HeadDecoratorStyle.Stroke = solidstorkebursh;
            lc.TailDecoratorStyle.Fill   = solidColorBrush;
            lc.TailDecoratorStyle.Stroke = solidstorkebursh;
            diagramModel.Connections.Add(lc);
        }
示例#3
0
        /// <summary>
        /// Connect Nodes with connectors
        /// </summary>
        /// <param name="emplysymbol">Parent</param>
        /// <param name="subemplysymbol">Child</param>
        /// <param name="relation">relationship</param>
        private void ConnectNodes(Node emplysymbol, Node subemplysymbol, string relation)
        {
            LineConnector ortholink = new LineConnector(PointF.Empty, new PointF(0, 1));

            ortholink.LineStyle.DashStyle = DashStyle.Solid;

            ortholink.LineStyle.LineWidth = 1f;
            ortholink.LineStyle.LineColor = Color.Black;
            if (relation == "OneToMany")
            {
                ortholink.TailDecorator.DecoratorShape = DecoratorShape.Diamond;
            }
            else
            {
                ortholink.TailDecorator.DecoratorShape = DecoratorShape.FilledDiamond;
            }

            ortholink.HeadDecorator.DecoratorShape = DecoratorShape.FilledDiamond;

            this.diagram1.Model.AppendChild(ortholink);

            if (emplysymbol.CentralPort != null && subemplysymbol.CentralPort != null)
            {
                emplysymbol.CentralPort.TryConnect(ortholink.TailEndPoint);
                subemplysymbol.CentralPort.TryConnect(ortholink.HeadEndPoint);
            }

            this.diagram1.Controller.SendToBack();
        }
示例#4
0
        public MainWindow()
        {
            InitializeComponent();

            Node cp1 = addNodes("MyComputerIcon", "CP1", new Point(250, 150), new Size(75, 75));
            Node cp2 = addNodes("MyComputerIcon", "CP2", new Point(525, 500), new Size(75, 75));
            Node cp3 = addNodes("MyComputerIcon", "CP3", new Point(750, 150), new Size(75, 75));

            Node hub1 = addNodes("HUB", "Hub1", new Point(541, 0), new Size(50, 50));
            Node hub2 = addNodes("HUB", "Hub2", new Point(977, 600), new Size(50, 50));
            Node ser  = addNodes("Server", "Server", new Point(160, 300), new Size(70, 120));
            Node pri  = addNodes("Printer", "Printer", new Point(1081, 100), new Size(90, 100));
            Node mod  = addNodes("ModemIcon", "Modem", new Point(1150, 300), new Size(50, 120));

            LineConnector line = createLineConnector(ser, mod, "LAN Connection");


            ConnectionPort p1 = AddPort(line, 0);
            ConnectionPort p2 = AddPort(line, 1);
            ConnectionPort p3 = AddPort(line, 0.3);
            ConnectionPort p4 = AddPort(line, 0.6);
            ConnectionPort p5 = AddPort(line, 0.8);

            LineConnector  line1 = AddLineConnectorToPort(hub1, p3);
            ConnectionPort lp1   = AddPort(line1, 0.4);
            ConnectionPort lp2   = AddPort(line1, 0.6);

            LineConnector  line2 = AddLineConnectorToPort(cp1, lp1);
            LineConnector  line3 = AddLineConnectorToPort(cp3, lp2);
            LineConnector  line4 = AddLineConnectorToPort(hub2, p4);
            ConnectionPort lp3   = AddPort(line4, 0.6);

            LineConnector line5 = AddLineConnectorToPort(cp2, lp3);
            LineConnector line6 = AddLineConnectorToPort(pri, p5);
        }
示例#5
0
        /// <summary>
        /// Method to connect the parent and sub nodes.
        /// </summary>
        /// <param name="parentNode">From Node</param>
        /// <param name="subNode">To Node</param>
        private void ConnectNodes(Node parentNode, Node subNode)
        {
            if (parentNode.CentralPort == null || subNode.CentralPort == null)
            {
                return;
            }

            if (parentNode.Equals(subNode))
            {
                return;
            }

            // Create directed link
            LineConnector line = new LineConnector(PointF.Empty, new PointF(0F, 1F));

            line.LineStyle.LineColor               = Color.DarkGray;
            line.HeadDecorator.DecoratorShape      = DecoratorShape.FilledFancyArrow;
            line.HeadDecorator.Size                = new SizeF(12F, 9F);
            line.HeadDecorator.FillStyle.Color     = Color.MidnightBlue;
            line.HeadDecorator.LineStyle.LineColor = Color.Transparent;
            this.diagram1.Model.AppendChild(line);
            this.diagram1.Model.SendBackward(line);

            parentNode.CentralPort.TryConnect(line.TailEndPoint);
            subNode.CentralPort.TryConnect(line.HeadEndPoint);
        }
示例#6
0
        //Update the Values
        void diagramView_ConnectorSelected(object sender, ConnectorRoutedEventArgs evtArgs)
        {
            Linegrid.IsEnabled      = true;
            lineexpander.IsEnabled  = true;
            lineexpander.IsExpanded = true;
            LineConnector selectedline = (evtArgs.Connector as LineConnector);

            CustomPortShape.ToolTip = "Select Custom PortShape";
            Linegrid.ToolTip        = "Provide the Custom Values";
            WidthValue.IsEnabled    = false;
            HeightValue.IsEnabled   = false;
            TopValue.IsEnabled      = false;
            LeftValue.IsEnabled     = false;
            top.IsEnabled           = false;
            left.IsEnabled          = false;
            width.IsEnabled         = false;
            height.IsEnabled        = false;
            fill.IsEnabled          = false;
            Fill.IsEnabled          = false;
            fill.Opacity            = 0.1;
            stroke.Opacity          = 0.1;
            stroke.IsEnabled        = false;
            Stroke.IsEnabled        = false;
            portshape.IsEnabled     = false;
            customshape.IsEnabled   = false;
            DefualtShape.IsEnabled  = false;
        }
示例#7
0
        //Creating the connection
        private LineConnector Connect(ConnectorType connType, Node headnode, Node tailnode, ConnectionPort headport, ConnectionPort tailport, string label)
        {
            LineConnector conn = new LineConnector();

            conn.ConnectorType      = connType;
            conn.HeadNode           = headnode;
            conn.TailNode           = tailnode;
            conn.ConnectionHeadPort = headport;
            conn.ConnectionTailPort = tailport;
            conn.HeadDecoratorShape = DecoratorShape.None;
            conn.TailDecoratorShape = DecoratorShape.None;
            conn.LineStyle.Stroke   = new SolidColorBrush(Colors.Brown);
            conn.Label = label;
            conn.FirstSegmentLength       = 20;
            conn.LastSegmentLength        = 20;
            conn.LabelHorizontalAlignment = HorizontalAlignment.Right;
            conn.LabelVerticalAlignment   = VerticalAlignment.Center;
            diagramModel.Connections.Add(conn);
            if (conn.ConnectorType == ConnectorType.Orthogonal)
            {
                //conn.IntermediatePoints.RemoveAt(1);
                conn.AutoAdjustPoints = true;
            }
            return(conn);
        }
示例#8
0
        //Event for changing the LineStyle of the Lien/connector
        void diagramView_BeforeConnectionCreate(object sender, BeforeCreateConnectionRoutedEventArgs evtArgs)
        {
            LineConnector line = evtArgs.Connector;

            line.LineStyle.Stroke          = Brushes.Black;
            line.LineStyle.StrokeThickness = 2;
            line.TailDecoratorShape        = DecoratorShape.None;
        }
示例#9
0
        private void Connect(Node headnode, Node tailnode)
        {
            LineConnector conn = new LineConnector();

            conn.HeadNode = headnode;
            conn.TailNode = tailnode;
            diagramModel.Connections.Add(conn);
        }
示例#10
0
 void IPointerDownHandler.OnPointerDown(PointerEventData eventData)
 {
     if (eventData.button == PointerEventData.InputButton.Left)
     {
         LineConnector newLine = Instantiate(linePrefab);
         lineReferences.Add(newLine);
         newLine.StartLine(this);
     }
 }
示例#11
0
        /// For Chaning a Width, Height and Strokethickness properties of the LineConnector ,it is apllicable when the LineConnector is selected
        private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            TextBox box = (sender as TextBox);

            if (diagramView != null)
            {
                if (diagramView.SelectionList.Count > 0)
                {
                    foreach (object o in diagramView.SelectionList)
                    {
                        if (o is LineConnector)
                        {
                            LineConnector selectedline = (o as LineConnector);
                            if (box.Text != string.Empty)
                            {
                                switch (box.Name)
                                {
                                case "WidthValue":
                                    if (Head.IsChecked == true)
                                    {
                                        selectedline.HeadDecoratorStyle.Width = double.Parse(box.Text);
                                    }
                                    else if (Tail.IsChecked == true)
                                    {
                                        selectedline.TailDecoratorStyle.Width = double.Parse(box.Text);
                                    }
                                    break;

                                case "HeightValue":
                                    if (Head.IsChecked == true)
                                    {
                                        selectedline.HeadDecoratorStyle.Height = double.Parse(box.Text);
                                    }
                                    else if (Tail.IsChecked == true)
                                    {
                                        selectedline.TailDecoratorStyle.Height = double.Parse(box.Text);
                                    }
                                    break;

                                case "ThicknessValue":
                                    if (Head.IsChecked == true)
                                    {
                                        selectedline.HeadDecoratorStyle.StrokeThickness = double.Parse(box.Text);
                                    }
                                    else if (Tail.IsChecked == true)
                                    {
                                        selectedline.TailDecoratorStyle.StrokeThickness = double.Parse(box.Text);
                                    }
                                    break;
                                }
                            }
                            selectedline.UpdateConnectorPathGeometry();
                        }
                    }
                }
            }
        }
示例#12
0
        //Add connectionport to the Node
        private ConnectionPort addPort(Node node, string customstyle, bool head, LineConnector line)
        {
            ConnectionPort cp = null;

            if (head)
            {
                cp           = new ConnectionPort();
                cp.Width     = 20;
                cp.Height    = 20;
                cp.PortShape = PortShapes.Custom;
                if (line.ConnectionHeadPort == null)
                {
                    cp.Top                  = 20;
                    cp.Left                 = 20;
                    cp.CustomPathStyle      = this.Resources[customstyle] as Style;
                    line.ConnectionHeadPort = cp;
                }
                else
                {
                    ConnectionPort headport = (line.ConnectionHeadPort as ConnectionPort);
                    cp.Top  = headport.Top;
                    cp.Left = headport.Left;
                    node.Ports.Remove(headport);
                    cp.CustomPathStyle      = this.Resources[customstyle] as Style;
                    line.ConnectionHeadPort = cp;
                }
                node.Ports.Add(cp);
                cp.Node = node;
            }
            else if (!head)
            {
                cp           = new ConnectionPort();
                cp.Width     = 20;
                cp.Height    = 20;
                cp.PortShape = PortShapes.Custom;
                if (line.ConnectionTailPort == null)
                {
                    cp.Top                  = 20;
                    cp.Left                 = 20;
                    cp.CustomPathStyle      = this.Resources[customstyle] as Style;
                    line.ConnectionTailPort = cp;
                }
                else
                {
                    ConnectionPort tailport = (line.ConnectionTailPort as ConnectionPort);
                    cp.Top  = tailport.Top;
                    cp.Left = tailport.Left;
                    node.Ports.Remove(tailport);
                    cp.CustomPathStyle      = this.Resources[customstyle] as Style;
                    line.ConnectionTailPort = cp;
                }
                node.Ports.Add(cp);
                cp.Node = node;
            }
            return(cp);
        }
示例#13
0
        /// <summary>
        /// 연결된 <see cref="LineConnector"/>를 삭제합니다.
        /// </summary>
        /// <param name="lineConnector"></param>
        public void DeleteConnectedLine(LineConnector lineConnector)
        {
            if (!lineCollection.Contains(lineConnector))
            {
                return;
            }

            LineLayer.Remove(lineConnector.Line);
            lineCollection.Remove(lineConnector);
        }
示例#14
0
        //Add the Lineconnector
        private LineConnector addConnection(Node headnode, Node tailnode, ConnectorType connType, DecoratorShape headdecorator, DecoratorShape taildecorator)
        {
            LineConnector conn = new LineConnector();

            conn.HeadNode      = headnode;
            conn.TailNode      = tailnode;
            conn.ConnectorType = connType;
            diagramModel.Connections.Add(conn);
            return(conn);
        }
示例#15
0
        private ConnectionPort addcport(Node node, PortShapes sp, bool head, LineConnector line)
        {
            ConnectionPort cp = null;

            if (head)
            {
                cp        = new ConnectionPort();
                cp.Width  = 10;
                cp.Height = 10;
                if (line.ConnectionHeadPort == null)
                {
                    cp.Top                  = 20;
                    cp.Left                 = 20;
                    cp.PortShape            = sp;
                    line.ConnectionHeadPort = cp;
                }
                else
                {
                    ConnectionPort headport = (line.ConnectionHeadPort as ConnectionPort);
                    cp.Top  = headport.Top;
                    cp.Left = headport.Left;
                    node.Ports.Remove(headport);
                    cp.PortShape            = sp;
                    line.ConnectionHeadPort = cp;
                }
                node.Ports.Add(cp);
                cp.Node = node;
            }
            else if (!head)
            {
                cp           = new ConnectionPort();
                cp.Width     = 10;
                cp.Height    = 10;
                cp.PortShape = sp;
                if (line.ConnectionTailPort == null)
                {
                    cp.Top                  = 20;
                    cp.Left                 = 20;
                    cp.PortShape            = sp;
                    line.ConnectionTailPort = cp;
                }
                else
                {
                    ConnectionPort tailport = (line.ConnectionTailPort as ConnectionPort);
                    cp.Top  = tailport.Top;
                    cp.Left = tailport.Left;
                    node.Ports.Remove(tailport);
                    cp.PortShape            = sp;
                    line.ConnectionTailPort = cp;
                }
                node.Ports.Add(cp);
                cp.Node = node;
            }
            return(cp);
        }
示例#16
0
        //Add the connection to DiagramModel
        private void Connect(Node headnode, Node tailnode, ConnectorType conntype, String label, DecoratorShape taildeco)
        {
            LineConnector line = new LineConnector();

            line.HeadNode           = headnode;
            line.TailNode           = tailnode;
            line.ConnectorType      = conntype;
            line.Label              = label;
            line.TailDecoratorShape = taildeco;
            diagramModel.Connections.Add(line);
        }
示例#17
0
        //Add the Connections to the DiagramModel
        private LineConnector connection(Node head, Node tail, string label, ConnectorType ct)
        {
            LineConnector flow = new LineConnector();

            flow.AutoAdjustPoints          = true;
            flow.HeadNode                  = head;
            flow.TailNode                  = tail;
            flow.ConnectorType             = ct;
            flow.TailDecoratorStyle.Fill   = new SolidColorBrush(Colors.Black);
            flow.TailDecoratorStyle.Stroke = new SolidColorBrush(Colors.Black);
            flow.HeadDecoratorShape        = DecoratorShape.Circle;
            flow.LineStyle.Stroke          = new SolidColorBrush(Colors.Black);
            flow.HeadDecoratorStyle.Fill   = new SolidColorBrush(Colors.Green);
            flow.HeadDecoratorStyle.Stroke = new SolidColorBrush(Colors.Green);
            flow.Label = label;
            flow.LabelHorizontalAlignment = HorizontalAlignment.Center;
            flow.LabelVerticalAlignment   = VerticalAlignment.Center;
            flow.EnableMultilineLabel     = true;
            flow.LabelTextWrapping        = TextWrapping.Wrap;
            if (label == "Yes" && ct == ConnectorType.Orthogonal)
            {
                flow.IntermediatePoints.RemoveAt(0);
                flow.IntermediatePoints.RemoveAt(0);
                flow.IntermediatePoints.Add(new Point(1, 5.7));
                if (head.Name == "n7" && tail.Name == "n4")
                {
                    flow.HeadDecoratorStyle.Fill   = new SolidColorBrush(Colors.Black);
                    flow.HeadDecoratorStyle.Stroke = new SolidColorBrush(Colors.Black);
                    flow.HeadDecoratorShape        = DecoratorShape.Arrow;
                    flow.TailDecoratorShape        = DecoratorShape.Circle;
                    flow.LineStyle.Stroke          = new SolidColorBrush(Colors.Black);
                    flow.TailDecoratorStyle.Fill   = new SolidColorBrush(Colors.Green);
                    flow.TailDecoratorStyle.Stroke = new SolidColorBrush(Colors.Green);
                }
            }
            if (label == "No" && ct == ConnectorType.Straight && head.Name == "n7" && tail.Name == "n2")
            {
                flow.LineStyle.Stroke = new SolidColorBrush(Colors.Red);
            }
            //if (label == "Yes" && ct == ConnectorType.Orthogonal)
            //{
            //    //ConnectionPort cp = new ConnectionPort(head, new Point(2, 0.3));
            //    //head.Ports.Add(cp);
            //    //cp.Node = head;

            //    //ConnectionPort cp1 = new ConnectionPort(tail, new Point(3, 0.3));
            //    //tail.Ports.Add(cp1);
            //    //cp1.Node = tail;
            //    //flow.ConnectionHeadPort = cp;
            //    //flow.ConnectionTailPort = cp1;
            //}
            diagramModel.Connections.Add(flow);
            return(flow);
        }
示例#18
0
        LineConnector createLineConnector(Node headNode, Node tailNode, string label)
        {
            LineConnector line = new LineConnector();

            line.LineStyle.Stroke = new SolidColorBrush(Colors.Blue);
            line.HeadNode         = headNode;
            line.TailNode         = tailNode;
            line.Label            = label;
            line.ConnectorType    = ConnectorType.Straight;
            diagramModel.Connections.Add(line);
            return(line);
        }
示例#19
0
        public LineSimple CreateLineSimple(Point fromPoint, Point targetPoint)
        {
            var line       = CreateLine();
            var connector1 = new LineConnector(null, line, fromPoint);
            var connector2 = new LineConnector(line, null, targetPoint);

            _canvas.Children.Add(line);
            _canvas.Children.Add(connector1);
            _canvas.Children.Add(connector2);

            return(line);
        }
 /// <summary>
 /// Connects the given nodes with an arrow
 /// </summary>
 /// <param name="parentNode">Parent Node</param>
 /// <param name="childNode">Child node</param>
 /// <param name="connectionColor">Connector Color</param>
 private void connectNodes(Syncfusion.Windows.Forms.Diagram.Node parentNode, Syncfusion.Windows.Forms.Diagram.Node childNode)
 {
     if (parentNode != null && childNode != null)
     {
         LineConnector lConnector = new LineConnector(PointF.Empty, new PointF(0, 1));
         lConnector.HeadDecorator.DecoratorShape  = DecoratorShape.Filled45Arrow;
         lConnector.HeadDecorator.FillStyle.Color = Color.Black;
         parentNode.CentralPort.TryConnect(lConnector.TailEndPoint);
         childNode.CentralPort.TryConnect(lConnector.HeadEndPoint);
         sfDecompositionDiagram.Model.AppendChild(lConnector);
         sfDecompositionDiagram.Model.SendToBack(lConnector);
     }
 }
示例#21
0
 /// <summary>
 /// Connects the given nodes
 /// </summary>
 /// <param name="parentNode">Parent Node</param>
 /// <param name="childNode">Child node</param>
 /// <param name="connectionColor">Connector Color</param>
 private void ConnectNodes(Node parentNode, Node childNode, Color connectionColor)
 {
     if (parentNode != null && childNode != null)
     {
         LineConnector lConnector = new LineConnector(PointF.Empty, new PointF(0, 1));
         lConnector.HeadDecorator.DecoratorShape  = DecoratorShape.Filled45Arrow;
         lConnector.HeadDecorator.FillStyle.Color = Color.White;
         parentNode.CentralPort.TryConnect(lConnector.TailEndPoint);
         childNode.CentralPort.TryConnect(lConnector.HeadEndPoint);
         this.diagram1.Model.AppendChild(lConnector);
         this.diagram1.Model.SendToBack(lConnector);
     }
 }
示例#22
0
        LineConnector AddLineConnectorToPort(Node headNode, ConnectionPort tailPort)
        {
            LineConnector line = new LineConnector();

            line.LineStyle.Stroke          = new SolidColorBrush(Colors.Brown);
            line.TailDecoratorStyle.Stroke = new SolidColorBrush(Colors.Brown);
            line.TailDecoratorStyle.Fill   = new SolidColorBrush(Colors.Brown);
            line.TailDecoratorShape        = Syncfusion.Windows.Diagram.DecoratorShape.None;
            line.HeadNode           = headNode;
            line.ConnectionTailPort = tailPort;
            diagramModel.Connections.Add(line);
            return(line);
        }
示例#23
0
        //Creating connection and adding to the model
        void Connect(Node HeadNode, Node TailNode)
        {
            LineConnector connection = new LineConnector();

            connection.ConnectorType = ConnectorType.Orthogonal;
            // Specify the TailNode node
            connection.TailNode = TailNode;
            //Specifying the Head Node
            connection.HeadNode           = HeadNode;
            connection.TailDecoratorShape = DecoratorShape.Arrow;
            //Adding to the Diagram Model
            diagramModel.Connections.Add(connection);
        }
示例#24
0
        /// <summary>
        /// Connects the nodes
        /// </summary>
        /// <param name="parent">Tail node</param>
        /// <param name="child">Head node</param>
        private void ConnectNodes(Node parent, Node child, bool useOrthogonal)
        {
            ConnectorBase conn;
            if (!useOrthogonal)
                conn = new LineConnector(PointF.Empty, new PointF(0, 1));
            else
                conn = new OrthogonalConnector(parent.PinPoint, child.PinPoint, false);

            conn.HeadDecorator.DecoratorShape = DecoratorShape.Filled45Arrow;
            conn.HeadDecorator.FillStyle.Color = Color.Black;
            diagram1.Model.AppendChild(conn);
            parent.CentralPort.Connect(conn.TailEndPoint);
            child.CentralPort.Connect(conn.HeadEndPoint);
        }
示例#25
0
        //Add Connection to DiagramModel
        private void Connect(Node tailnode, Node headnode, ConnectorType conntype, String label)
        {
            LineConnector conn = new LineConnector();

            conn.TailNode   = tailnode;
            conn.HeadNode   = headnode;
            conn.Label      = label;
            conn.LabelWidth = 30;

            //Applying style to the DecoratorShape of the LineConnector
            conn.TailDecoratorShape = DecoratorShape.Arrow;
            conn.HeadDecoratorShape = DecoratorShape.None;
            diagramModel.Connections.Add(conn);
        }
示例#26
0
        /// <summary>
        /// Initializes the Diagram data
        /// </summary>
        private void InitializeDiagram()
        {
            LineConnector line = new LineConnector(new PointF[] { new PointF(320, 135), new PointF(480, 135) });

            line.HeadDecorator.DecoratorShape = DecoratorShape.Filled45Arrow;
            line.HeadDecorator.Size           = new SizeF(10, 10);
            line.LineStyle.LineWidth          = 1;
            AddLabel(line, "DirectedLink", Position.BottomCenter);
            diagram1.Model.AppendChild(line);

            OrthogonalConnector orthogonalLine = new OrthogonalConnector(new PointF(50, 50), new PointF(245, 135));

            orthogonalLine.HeadDecorator.DecoratorShape = DecoratorShape.OpenFancyArrow;
            orthogonalLine.HeadDecorator.Size           = new SizeF(10, 10);
            orthogonalLine.TailDecorator.DecoratorShape = DecoratorShape.FilledFancyArrow;
            orthogonalLine.TailDecorator.Size           = new SizeF(10, 10);
            orthogonalLine.LineStyle.LineWidth          = 1;
            AddLabel(orthogonalLine, "OrthogonalLink", Position.BottomCenter);
            diagram1.Model.AppendChild(orthogonalLine);

            OrgLineConnector orgLine = new OrgLineConnector(new PointF(245, 200), new PointF(50, 285));

            orgLine.HeadDecorator.DecoratorShape = DecoratorShape.FilledDiamond;
            orgLine.HeadDecorator.Size           = new SizeF(10, 10);
            orgLine.TailDecorator.DecoratorShape = DecoratorShape.Diamond;
            orgLine.TailDecorator.Size           = new SizeF(10, 10);
            orgLine.LineStyle.LineWidth          = 1;
            AddLabel(orgLine, "OrgLineLink", Position.BottomCenter);
            diagram1.Model.AppendChild(orgLine);

            PolyLineConnector polyLine = new PolyLineConnector(new PointF[] { new PointF(320, 225), new PointF(455, 225), new PointF(320, 265), new PointF(455, 265) });

            polyLine.HeadDecorator.DecoratorShape = DecoratorShape.Circle;
            polyLine.HeadDecorator.Size           = new SizeF(10, 10);
            polyLine.TailDecorator.DecoratorShape = DecoratorShape.FilledCircle;
            polyLine.TailDecorator.Size           = new SizeF(10, 10);
            polyLine.LineStyle.LineWidth          = 1;
            AddLabel(polyLine, "PolylineLink", Position.BottomCenter);
            diagram1.Model.AppendChild(polyLine);

            SplineNode spline = new SplineNode(new PointF[] { new PointF(100, 400), new PointF(160, 430), new PointF(100, 480) });

            spline.HeadDecorator.DecoratorShape = DecoratorShape.FilledSquare;
            spline.HeadDecorator.Size           = new SizeF(10, 10);
            spline.TailDecorator.DecoratorShape = DecoratorShape.Square;
            spline.TailDecorator.Size           = new SizeF(10, 10);
            spline.LineStyle.LineWidth          = 1;
            AddLabel(spline, "Spline", Position.BottomCenter);
            diagram1.Model.AppendChild(spline);
        }
示例#27
0
        ConnectionPort AddPort(LineConnector l, double offset)
        {
            ConnectionPort port = new ConnectionPort();

            port.PortStyle.Stroke = new SolidColorBrush(Colors.OrangeRed);
            port.PortStyle.Fill   = new SolidColorBrush(Colors.OrangeRed);
            port.Width            = 10;
            port.Height           = 10;
            port.PortOffset       = offset;
            port.PortVisibility   = PortVisibility.AlwaysVisible;
            l.Ports.Add(port);
            port.Edge = l;
            return(port);
        }
示例#28
0
        //Apply the PortShape to the connectionPorts
        private void PortStyle_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ComboBox cb = (sender as ComboBox);

            if (diagramView.SelectionList.Count > 0)
            {
                foreach (object o in diagramView.SelectionList)
                {
                    if (o is LineConnector)
                    {
                        LineConnector line = (o as LineConnector);

                        //Head port is Selected
                        if (head.IsChecked == true)
                        {
                            ConnectionPort heasdport = (line.ConnectionHeadPort as ConnectionPort);
                            //for applying the custom port shape
                            if (cb.Name == "CustomPortShape")
                            {
                                string port = "port";
                                line.ConnectionHeadPort = addPort((line.HeadNode as Node), port + "" + cb.SelectedIndex, true, line);
                            }
                            else if (cb.Name == "DefualtShape")
                            {
                                Node node = (line.HeadNode as Node);

                                UpdatePortShape(node, cb.SelectedIndex, true, line);
                            }
                        }
                        //Tailport is selected
                        if (tail.IsChecked == true)
                        {
                            ConnectionPort tailport = (line.ConnectionTailPort as ConnectionPort);
                            if (cb.Name == "CustomPortShape")
                            {
                                string port = "port";
                                line.ConnectionTailPort = addPort(line.TailNode as Node, port + "" + cb.SelectedIndex, false, line);
                            }
                            else if (cb.Name == "DefualtShape")
                            {
                                Node node1 = (line.TailNode as Node);

                                UpdatePortShape(node1, cb.SelectedIndex, false, line);
                            }
                        }
                    }
                }
            }
        }
示例#29
0
        //Refreshing the Layout after adding the Node
        private void AddNodeasChild(NodeContent cnt, Node n1, Node head)
        {
            n1.Style = this.Resources["newtemp"] as Style;
            n1.Content = cnt;
            n1.Width = 75;
            n1.Height = 75;
            n1.HorizontalContentAlignment = HorizontalAlignment.Stretch;
            n1.VerticalContentAlignment = VerticalAlignment.Stretch;
            if (n1.ChildCount == 0)
            {
                cnt.Expander = null;
            }
            else
            {
                cnt.Expander = App.Current.Resources["Plus"] as DrawingImage;
            }
            if (head != null)
            {
                if (head.ChildCount == 0)
                {
                    if ((this.FindNameFromContentTemplate(head, "Expander") as Image) != null)
                    {
                        (this.FindNameFromContentTemplate(head, "Expander") as Image).Source = App.Current.Resources["Minus"] as DrawingImage;
                    }
                }
            }
            LineConnector lc = new LineConnector();
            lc.HeadNode = head;
            lc.TailNode = n1;
            lc.TailDecoratorShape = DecoratorShape.Arrow;

            if ((this.FindNameFromContentTemplate(head, "Expander") as Image).Name == "P")
            {
                n1.Visibility = Visibility.Hidden;
                lc.Visibility = Visibility.Hidden;
            }
            else
            {
                Show(n1);
            }

            diagramModel.Nodes.Add(n1);
            n1.AllowSelect = false;
            n1.IsSelected = false;
            n1.MouseRightButtonDown += new MouseButtonEventHandler(newNode_MouseRightButtonDown);
            diagramModel.Connections.Add(lc);
            HierarchicalTreeLayout layout = new HierarchicalTreeLayout(diagramModel, diagramView);
            layout.RefreshLayout();
        }
示例#30
0
 //LineConnectorunselected event
 void diagramView_ConnectorUnSelected(object sender, ConnectorRoutedEventArgs evtArgs)
 {
     selectedline            = (evtArgs.Connector as LineConnector);
     Head.IsChecked          = false;
     Tail.IsChecked          = false;
     WidthValue.Text         = string.Empty;
     HeightValue.Text        = string.Empty;
     ThicknessValue.Text     = string.Empty;
     fill.Color              = Colors.Black;
     stroke.Color            = Colors.Black;
     decoratorgrid.IsEnabled = false;
     Shapegrid.IsEnabled     = false;
     fill.Opacity            = 0.1;
     stroke.Opacity          = 0.1;
 }
示例#31
0
    // Use this for initialization
    void Start()
    {
        SetupGameMode();

        lineConnector = GameObject.FindGameObjectWithTag("LineConnector").GetComponent<LineConnector>();

        sizeX = 11;
        sizeY = 15;

        squares = new GameObject[sizeX, sizeY];

        for (var x = 0; x < sizeX; x++)
        {
            for (var y = 0; y < sizeY; y++)
            {
                CreateSquareAt(x, y);
            }
        }

        clearAudioSource = GetComponent<AudioSource>();

        timeLeft = new TimeSpan(0, 0, 2, 0);
        stopWatch = new Stopwatch();
        stopWatch.Start();
    }
    /// <summary> 
    /// Adjust line connector sprite frame index and location.
    /// </summary>
    private void UpdateEachLine(out LineConnector[] lineCns,  int n, int curline)
    {
        lineCns = new LineConnector[n-1];

        float s = GameVariables.ICON_SIZE / 2;
        Vector2 offset_Zero 	 = new Vector2 (s, 0);
        Vector2 offset_One	 = new Vector2 (s, s);
        Vector2 offset_Two	 = new Vector2 (s, -s);
        Vector2 offset_Three	 = new Vector2 (s, 2 * s);
        Vector2 offset_Four	 = new Vector2 (s, -2 * s);

        for(int j = 0; j < n - 1 ; ++j)
        {
            int curIndex   = m_winLinesToDraw[curline].First[j] ;
            int nextIndex  = m_winLinesToDraw[curline].First[j+1] ;

            // different game type will casue different diff value.
            int diff 		  = ( nextIndex % GameVariables.Instance.NUM_OF_ROWS )
                -(curIndex % GameVariables.Instance.NUM_OF_ROWS );

            lineCns[j].mPos = Icons.Instance.m_Icons[curIndex].position;
            switch(diff)
            {
            case 0:
                lineCns[j].mType = LINE_TYPE.LINE_ZERO;
                lineCns[j].mPos += offset_Zero;
                break;
            case 1:
                lineCns[j].mType = LINE_TYPE.LINE_NEGATIVE_ONE;
                lineCns[j].mPos += offset_Two;
                break;
            case 2:
                lineCns[j].mType = LINE_TYPE.LINE_NEGATIVE_TWO;
                lineCns[j].mPos += offset_Four;
                break;
            case 3:
                lineCns[j].mType = LINE_TYPE.LINE_NEGATIVE_THREE;
                lineCns[j].mPos += offset_Four;
                break;

            case -1:
                lineCns[j].mType = LINE_TYPE.LINE_POSITIVE_ONE;
                lineCns[j].mPos += offset_One;
                break;

            case -2:
                lineCns[j].mType = LINE_TYPE.LINE_POSITIVE_TWO;
                lineCns[j].mPos += offset_Three;
                break;

            case -3:
                lineCns[j].mType = LINE_TYPE.LINE_POSITIVE_THREE;
                lineCns[j].mPos += offset_Three;
                break;

            }
        }
    }