Exemple #1
0
        private void CreateLink(XPathNavigator childNav, int linkID, Dictionary<int, DiagramNode> docNodes, int fromID, int toID)
        {
            DiagramLink newLink;
            DiagramNode toNode, fromNode;
            String firstParam;

            newLink = new DiagramLink(linkID);
            newLink.ToArrow = true;
            newLink.PenWidth = 2;

            XPathNavigator pnav = childNav.SelectSingleNode("LinkParameters/Parameter/Parameter");
            if (pnav != null)
            {
                firstParam = "[ " + pnav.GetAttribute("value", pnav.NamespaceURI) + " ]";

                GoText label = new GoText();
                label.Text = firstParam;
                label.Selectable = false;
                newLink.MidLabel = label;
            }

            if (docNodes.ContainsKey(toID) && docNodes.ContainsKey(fromID))
            {
                toNode = docNodes[toID];
                fromNode = docNodes[fromID];

                newLink.ToPort = toNode.Port;
                newLink.FromPort = fromNode.Port;

                this.Document.Add(newLink);
            }
        }
Exemple #2
0
        private void Diagram_LinkRelinked(object sender, GoSelectionEventArgs e)
        {
            myController.TurnViewUpdateOff();

            DiagramLink link = (DiagramLink)e.GoObject;
            this.Document.Remove(link);

            DiagramNode to = (DiagramNode)link.ToNode;
            DiagramNode from = (DiagramNode)link.FromNode;

            if (this.Tool is GoToolRelinking)
            {
                GoToolRelinking castTool = (GoToolRelinking)this.Tool;

                GoPort start, end;

                if (castTool.Forwards)
                {
                    start = (GoPort)castTool.OriginalStartPort;
                    end = (GoPort)castTool.OriginalEndPort;
                }
                else
                {
                    //swap
                    start = (GoPort)castTool.OriginalEndPort;
                    end = (GoPort)castTool.OriginalStartPort;
                }

                DiagramNode startNode = (DiagramNode)start.Node;
                DiagramNode endNode = (DiagramNode)end.Node;

                try
                {
                    // record the relink in the database
                    this.myController.Connect(this.RootID, from.NodeID, to.NodeID, DiagramName);

                    // and remove the old link
                    this.Controller.DeleteLink(link.LinkID);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Unable to create link", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    // the old link was removed from the display on the unsuccessful relink
                    // recreate it (it's still in the db, but this is more efficient)

                    DiagramLink newLink = new DiagramLink();
                    newLink.ToArrow = true;

                    newLink.FromPort = startNode.Port;
                    newLink.ToPort = endNode.Port;

                    this.Document.Add(newLink);
                }
            }
            myController.TurnViewUpdateOn();
        }