示例#1
0
        public void CreateEdgeToNextSibling()
        {
            DotEdge Edge = new DotEdge(node.GetEndId(), node.GetNextId());

            Edge.Label = "Loop End";
            DotDefinition.Add(Edge);
        }
示例#2
0
        public void CreateTrueEdge()
        {
            DotEdge edge = new DotEdge(node.Id, node.children[0].Id);

            edge.Label = "True";
            DotDefinition.Add(edge);
        }
        public void CreateLoopEdge()
        {
            DotEdge edge2 = new DotEdge(node.GetEndId(), node.Id);

            edge2.Label = $"Next Item From {node.Condition}";
            DotDefinition.Add(edge2);
        }
示例#4
0
        public void CreateFinallyEdge(Node FinallyNode)
        {
            // throw new System.NotImplementedException();
            DotEdge edge = new DotEdge(node.GetEndId(), FinallyNode.Id);

            DotDefinition.Add(edge);
        }
示例#5
0
        public void ModifyEdgeWithNullNodesThrowsException()
        {
            var edge = new DotEdge(new DotNode("left"), new DotNode("right"));

            Check.ThatCode(() => edge.Left  = null).Throws <ArgumentNullException>();
            Check.ThatCode(() => edge.Right = null).Throws <ArgumentNullException>();
        }
示例#6
0
        /// <summary>
        /// Метод инвертирования ребра
        /// </summary>
        /// <param name="window"></param>
        public void Invert(Visio.Window window)
        {
            if (window != null)
            {
                // Для всех выделенных фигур
                foreach (Visio.Shape shape in window.Selection)
                {
                    // Проверяем, что это ребро
                    if (edges.ContainsValue(shape))
                    {
                        foreach (var edge in edges)
                        {
                            if (edge.Value == shape)
                            {
                                // Инвертируем ребро
                                Visio.Cell beginXCell = shape.get_CellsSRC((short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowXForm1D, (short)Visio.VisCellIndices.vis1DBeginX);
                                beginXCell.GlueTo(vertices[edge.Key.Destination].get_CellsSRC((short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowXFormOut, (short)Visio.VisCellIndices.visXFormPinX));
                                Visio.Cell endXCell = shape.get_CellsSRC((short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowXForm1D, (short)Visio.VisCellIndices.vis1DEndX);
                                endXCell.GlueTo(vertices[edge.Key.Source].get_CellsSRC((short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowXFormOut, (short)Visio.VisCellIndices.visXFormPinX));

                                // Заменяем старое ребро новым инвертированным
                                DotEdge <string> invertedEdge = new DotEdge <string>(edge.Key.Destination, edge.Key.Source, edge.Key.Attributes);
                                break;
                            }
                        }
                    }
                    else
                    {
                        throw new ArgumentException("Допустимо только инвертирование ребер!");
                    }
                }
            }
        }
示例#7
0
        public void CreateFalseEdge()
        {
            Node nextnode = node.GetNextNode();

            // Fix issue #17
            // if no nextnode present
            if (nextnode == null)
            {
                DotEdge edge = new DotEdge(node.Id, node.parent.GetEndId());
                edge.Label = "False";
                DotDefinition.Add(edge);
            }
            else
            {
                if (nextnode.GetType() == typeof(ElseNode))
                {
                    DotEdge edge = new DotEdge(node.Id, node.GetNextNode().children[0].Id);
                    edge.Label = "False";
                    DotDefinition.Add(edge);
                }
                else
                {
                    DotEdge edge = new DotEdge(node.Id, node.GetNextNode().Id);
                    edge.Label = "False";
                    DotDefinition.Add(edge);
                }
            }
        }
示例#8
0
        public void CreateLoopEdge()
        {
            DotEdge edge2 = new DotEdge(node.GetEndId(), node.Id);

            edge2.Label = node.Iterator;
            DotDefinition.Add(edge2);
        }
示例#9
0
        public void CreateSpecialEdge()
        {
            DotEdge specialedge = new DotEdge(node.Id, "end_of_script");

            specialedge.Label = "Exit";
            DotDefinition.Add(specialedge);
        }
示例#10
0
        public void CreateEdgeToNextSibling()
        {
            DotEdge edge = new DotEdge(node.Id, node.GetNextId());

            edge.Label = "False";
            DotDefinition.Add(edge);
        }
示例#11
0
        public void CreateEdgeToNextSibling()
        {
            // si y a un sibling, on fait des petits points..
            DotEdge edge = new DotEdge(node.GetEndId(), node.GetNextId());

            edge.Style = DotEdgeStyle.Dotted;
            DotDefinition.Add(edge);
        }
        private DotEdge CreateGeneralizationEdge(string from, string to, string label)
        {
            var edge = new DotEdge(from, to);

            edge.StyleProperties["style"]     = "dashed";
            edge.StyleProperties["arrowhead"] = "empty";
            return(edge);
        }
        private DotEdge CreateDependencyEdge(string from, string to, string label)
        {
            var edge = new DotEdge(from, to);

            edge.StyleProperties["style"]     = "dotted";
            edge.StyleProperties["arrowhead"] = "vee";
            return(edge);
        }
示例#14
0
        public void CreateTrueEdge()
        {
            // throw new System.NotImplementedException();
            DotEdge edge = new DotEdge(node.Id, node.children[0].Id);

            edge.Label = "True";
            DotDefinition.Add(edge);
        }
        private DotEdge CreateCompositionEdge(string from, string to, string label)
        {
            var edge = new DotEdge(from, to);

            edge.StyleProperties["arrowhead"] = "none";
            edge.StyleProperties["arrowhead"] = "diamond";
            return(edge);
        }
示例#16
0
        public void CreateEdgeToFirstChildren()
        {
            // throw new System.NotImplementedException();
            Node    child = node.children.Find(x => x.GetType() != typeof(CatchNode) || x.GetType() != typeof(FinallyNode));
            DotEdge edge  = new DotEdge(node.Id, child.Id);

            DotDefinition.Add(edge);
        }
示例#17
0
        public void TestPathAndEndEdgeEndProperties()
        {
            var edge = new DotEdge<int>(new DotVertex<int>(0), new DotVertex<int>(1));
            edge.Attributes.Add("pos", "e,2,3 1.14,3.14 9,8.7");

            Assert.AreEqual(new Point(1.14, 3.14), edge.Path[0]);
            Assert.AreEqual(new Point(9, 8.7), edge.Path[1]);
            Assert.AreEqual(new Point(2, 3), edge.DestinationArrowEnd);
        }
示例#18
0
        public void TestPositionWithExponent()
        {
            var edge = new DotEdge <int>(new DotVertex <int>(0), new DotVertex <int>(1));

            edge.Attributes.Add("pos", "e,2,3 2608.6,2.8422e-014");

            Assert.AreEqual(new Point(2608.6, 2.8422e-014), edge.Path[0]);
            Assert.AreEqual(new Point(2, 3), edge.DestinationArrowEnd);
        }
示例#19
0
        public void TestPathAndEndEdgeEndProperties()
        {
            var edge = new DotEdge <int>(new DotVertex <int>(0), new DotVertex <int>(1));

            edge.Attributes.Add("pos", "e,2,3 1.14,3.14 9,8.7");

            Assert.AreEqual(new Point(1.14, 3.14), edge.Path[0]);
            Assert.AreEqual(new Point(9, 8.7), edge.Path[1]);
            Assert.AreEqual(new Point(2, 3), edge.DestinationArrowEnd);
        }
示例#20
0
        public void CreateCatchEdge()
        {
            // throw new System.NotImplementedException();
            List <Node> catchnodes = node.children.FindAll(x => x.GetType() == typeof(CatchNode));

            foreach (var item in catchnodes)
            {
                DotEdge edge = new DotEdge(node.Id, item.Id);
                edge.Label = "Catches Error";
                DotDefinition.Add(edge);
            }
        }
示例#21
0
        private void CompileEdge(StringBuilder builder, DotEdge edge)
        {
            CompileEdgeEndPoint(builder, edge.Left);

            builder.Append(_graph.Directed ? " -> " : " -- ");

            CompileEdgeEndPoint(builder, edge.Right);

            CompileAttributes(builder, edge.Attributes);

            builder.Append("; ");
        }
示例#22
0
        public override void BuildEdge(Point[] path, IEdge originalEdge, DotEdge <int> edge)
        {
#if SILVERLIGHT
            var data = new StringToPathGeometryConverter().Convert(TransformCoordinates(path, this.canvas));
#else
            var data = Geometry.Parse(TransformCoordinates(path, this.canvas));
#endif
            var edgeElement = this.elementsFactory.CreateEdge(new EdgeViewModel(data, originalEdge));
            if (edge.Label != "blind")
            {
                this.canvas.Children.Add(edgeElement);
            }

            if (edge.DestinationArrowEnd.HasValue)
            {
                CreateArrow(
                    TransformCoordinates(edge.DestinationArrowEnd.Value, canvas),
                    TransformCoordinates(path.Last(), canvas),
                    edge.Destination,
                    this.elementsFactory.CreateEdgeArrow(new EdgeArrowViewModel(originalEdge, originalEdge.DestinationArrow)),
                    this.canvas);
            }

            if (edge.SourceArrowEnd.HasValue)
            {
                CreateArrow(
                    TransformCoordinates(edge.SourceArrowEnd.Value, canvas),
                    TransformCoordinates(path.First(), canvas),
                    edge.Source,
                    this.elementsFactory.CreateEdgeArrow(new EdgeArrowViewModel(originalEdge, originalEdge.SourceArrow)),
                    this.canvas);
            }

            if (edge.LabelPos.HasValue && edge.Label != "blind")
            {
                var labelElement = this.elementsFactory.CreateEdgeLabel(new EdgeLabelViewModel(edge.Label, edge.labelToolTip, originalEdge));
                this.CreateLabel(edge.LabelPos.Value, labelElement);
            }

            if (edge.SourceArrowLabelPosition.HasValue)
            {
                var viewModel    = new EdgeArrowLabelViewModel(edge.SourceArrowLabel, originalEdge, edge.SourceArrow);
                var labelElement = this.elementsFactory.CreateEdgeArrowLabel(viewModel);
                this.CreateLabel(edge.SourceArrowLabelPosition.Value, labelElement);
            }

            if (edge.DestinationArrowLabelPosition.HasValue)
            {
                var viewModel    = new EdgeArrowLabelViewModel(edge.DestinationArrowLabel, originalEdge, originalEdge.DestinationArrow);
                var labelElement = this.elementsFactory.CreateEdgeArrowLabel(viewModel);
                this.CreateLabel(edge.DestinationArrowLabelPosition.Value, labelElement);
            }
        }
示例#23
0
 private void BuildEdges()
 {
     foreach (IEdge edge in dotGraph.Edges)
     {
         if (edge is DotEdge <int> )
         {
             DotEdge <int> dotEdge = (DotEdge <int>)edge;
             Contract.Assert(0 <= dotEdge.Id && dotEdge.Id < originalGraphElementsMap.Length, "The id of an edge is not in the range of originalGraphElementsMap.");
             Contract.Assert(originalGraphElementsMap[dotEdge.Id] is IEdge, "The id of an edge does not point to an IEdge in originalGraphElementsMap.");
             builder.BuildEdge(dotEdge.Path, (IEdge)originalGraphElementsMap[dotEdge.Id], dotEdge);
         }
     }
 }
示例#24
0
        /// <summary>
        /// Метод, вызывающийся при добавлении нового ребра между ребрами графа
        /// </summary>
        /// <param name="connects">Коннектор</param>
        public void AddEdge(Visio.Connects connects)
        {
            // Если соединение добавлено с использованием существующей соединительной линии, т.е. добавляем вторую вершину
            if (newEdges.ContainsKey(connects.FromSheet))
            {
                // Добавляем вторую вершину в пару связанных вершин
                newEdges[connects.FromSheet].Add(connects.ToSheet);

                // Если обе соединенные фигуры - это вершины нашего графа
                if (vertices.ContainsValue(newEdges[connects.FromSheet][0]) && vertices.ContainsValue(newEdges[connects.FromSheet][1]))
                {
                    DotVertex <string> from = new DotVertex <string>("");
                    DotVertex <string> to   = new DotVertex <string>("");

                    // Ищем, каким вершинам они соответствуют
                    foreach (var node in vertices)
                    {
                        if (node.Value == newEdges[connects.FromSheet][0])
                        {
                            from = node.Key;
                        }
                        if (node.Value == newEdges[connects.FromSheet][1])
                        {
                            to = node.Key;
                        }
                    }

                    // Добавляем ребро с данными вершинами
                    DotEdge <string> edge = new DotEdge <string>(from, to);
                    graph.AddEdge(edge);

                    // Добавляем новое ребро в список ребер
                    edges.Add(edge, connects.FromSheet);
                }

                // Удаляем пару
                newEdges.Remove(connects.FromSheet);
            }
            else
            {
                // Применяем стили к коннектору
                connects.FromSheet.get_Cells("ConLineRouteExt").FormulaU = "2";
                connects.FromSheet.get_Cells("EndArrow").Formula         = "=5";

                // Добавляем новый коннектор в словарь + вершину, от которой он стартовал, ожидая соединения ее со второй вершиной
                List <Visio.Shape> listOfConnectingNodes = new List <Visio.Shape>();
                listOfConnectingNodes.Add(connects.ToSheet);
                newEdges.Add(connects.FromSheet, listOfConnectingNodes);
            }
        }
示例#25
0
        private void CompileEdge(StringBuilder builder, DotEdge edge, bool indented, int indentationLevel, bool formatStrings)
        {
            builder.AddIndentation(indented, indentationLevel);

            CompileEdgeEndPoint(builder, edge.Left, formatStrings);

            builder.Append(_graph.Directed ? " -> " : " -- ");

            CompileEdgeEndPoint(builder, edge.Right, formatStrings);

            CompileAttributes(builder, edge.Attributes, formatStrings);

            builder.Append("; ");

            builder.AddIndentationNewLine(indented);
        }
示例#26
0
        public void CreateEdgeToNextSibling()
        {
            Node FinallyNode = node.children.Find(x => x.GetType() == typeof(FinallyNode));

            if (FinallyNode != null)
            {
                CreateFinallyEdge(FinallyNode);
            }
            else
            {
                DotEdge edge = new DotEdge(node.GetEndId(), node.GetNextId());
                DotDefinition.Add(edge);
            }

            // throw new System.NotImplementedException();
        }
示例#27
0
        public override void BuildEdge(Primitives.Point[] path, IEdge originalEdge, DotEdge <int> edge)
        {
            var data        = Geometry.Parse(TransformCoordinates(path, this.canvas));
            var edgeElement = this.elementsFactory.CreateEdge(new EdgeViewModel(data, originalEdge));

            this.canvas.Children.Add(edgeElement);

            if (edge.DestinationArrowEnd.HasValue)
            {
                CreateArrow(
                    TransformCoordinates(edge.DestinationArrowEnd.Value, canvas),
                    TransformCoordinates(path.Last(), canvas),
                    edge.Destination,
                    this.elementsFactory.CreateEdgeArrow(new EdgeArrowViewModel(originalEdge, originalEdge.DestinationArrow)),
                    this.canvas);
            }

            if (edge.SourceArrowEnd.HasValue)
            {
                CreateArrow(
                    TransformCoordinates(edge.SourceArrowEnd.Value, canvas),
                    TransformCoordinates(path.First(), canvas),
                    edge.Source,
                    this.elementsFactory.CreateEdgeArrow(new EdgeArrowViewModel(originalEdge, originalEdge.SourceArrow)),
                    this.canvas);
            }

            if (edge.LabelPos.HasValue)
            {
                var labelElement = this.elementsFactory.CreateEdgeLabel(new EdgeLabelViewModel(edge.Label, originalEdge));
                this.CreateLabel(edge.LabelPos.Value, labelElement);
            }

            if (edge.SourceArrowLabelPosition.HasValue)
            {
                var viewModel    = new EdgeArrowLabelViewModel(edge.SourceArrowLabel, originalEdge, edge.SourceArrow);
                var labelElement = this.elementsFactory.CreateEdgeArrowLabel(viewModel);
                this.CreateLabel(edge.SourceArrowLabelPosition.Value, labelElement);
            }

            if (edge.DestinationArrowLabelPosition.HasValue)
            {
                var viewModel    = new EdgeArrowLabelViewModel(edge.DestinationArrowLabel, originalEdge, originalEdge.DestinationArrow);
                var labelElement = this.elementsFactory.CreateEdgeArrowLabel(viewModel);
                this.CreateLabel(edge.DestinationArrowLabelPosition.Value, labelElement);
            }
        }
示例#28
0
        public (DotGraph GeneratedGraph, string ConversionErrors) Convert(ExcelRowsWithDependencies excelRowsWithDependencies)
        {
            var directedGraph = new DotGraph("DependentExcelRows", true);
            Dictionary <ExcelRow, DotNode> rowsInGraph = new Dictionary <ExcelRow, DotNode>();
            StringBuilder conversionFailures           = null;

            foreach (ExcelRow row in excelRowsWithDependencies)
            {
                DotNode nodeOfCurrentRow = CreateNode(row);
                directedGraph.Elements.Add(nodeOfCurrentRow);
                rowsInGraph.Add(row, nodeOfCurrentRow);
            }

            foreach (ExcelRow row in excelRowsWithDependencies)
            {
                (Dictionary <ExcelRow, DotNode> Parents, string Failures)getParentsResult = GetAllParents(row, rowsInGraph);
                Dictionary <ExcelRow, DotNode> parentEntries = getParentsResult.Parents;
                if (getParentsResult.Failures != null)
                {
                    if (conversionFailures == null)
                    {
                        conversionFailures = new StringBuilder();
                    }

                    conversionFailures.AppendLine(getParentsResult.Failures);
                }

                var node = directedGraph.Elements.FirstOrDefault(elm =>
                                                                 typeof(DotNode) == elm.GetType() && ((DotNode)elm).Label.Text == row.Key.ToString());
                if (node == null)
                {
                    throw new Exception("couldn't find node");
                }

                var nodeOfCurrentRow = node as DotNode;
                foreach (var parentNode in parentEntries.Values)
                {
                    DotEdge parentEdge = CreateEdgeFromParentToCurrentRow(parentNode, nodeOfCurrentRow, row.EffortEstimate);
                    directedGraph.Elements.Add(parentEdge);
                }
            }

            string errors = conversionFailures?.ToString();

            return(directedGraph, errors);
        }
示例#29
0
        public void IndentedEdgeWithAttributes()
        {
            var graph = new DotGraph("TestGraph");

            var edge = new DotEdge("A", "B")
            {
                Style = DotEdgeStyle.Dashed,
                Color = Color.Red
            };

            graph.Elements.Add(edge);

            var compiled = graph.Compile(true);

            _output.WriteLine(compiled);

            Check.That(compiled).HasSameValueAs("graph TestGraph { \n\tA -- B[style=dashed,color=\"#FF0000\"]; \n}");
        }
示例#30
0
        private void AddModeledImages(DotGraph graph, PlatformInfo[] platforms)
        {
            IEnumerable <IEnumerable <string> > images = platforms.Select(platform => platform.Tags.Select(tag => tag.FullyQualifiedName));

            LoadImageManifests(images);

            foreach (PlatformInfo platform in platforms)
            {
                IEnumerable <string> tags = platform.Tags.Select(tag => tag.FullyQualifiedName);
                DotNode imageNode         = AddImageNode(graph, tags, Color.Navy, platform.FinalStageFromImage);

                var myEdge = new DotEdge(imageNode.Id, _nodeCache[platform.FinalStageFromImage].Id);
                myEdge.Attributes.ArrowHead = DotArrowType.Normal;
                myEdge.Attributes.ArrowTail = DotArrowType.None;
                myEdge.Attributes.Color     = Color.Black;
                myEdge.Attributes.Style     = DotStyle.Dashed;
                graph.Edges.Add(myEdge);
            }
        }
示例#31
0
        public void CreateSpecialEdge()
        {
            Node    ContinueNode = null;
            DotEdge specialedge  = null;

            if (node.label == null)
            {
                // fix issue #17
                ContinueNode = node.FindNodesUp(x => x is ForeachNode || x is WhileNode || x is DoWhileNode || x is DoUntilNode || x is ForNode || x is SwitchNode);
                specialedge  = new DotEdge(node.Id, ContinueNode.Id);
                // specialedge.Label = $"Continue To {node.Label}";
                specialedge.Label = $"Continue to next element";
            }
            else
            {
                ContinueNode = node.FindNodesUp(x => x.label == node.label);
                specialedge  = new DotEdge(node.Id, ContinueNode.Id);
            }
            DotDefinition.Add(specialedge);
        }