예제 #1
0
        public string BuildDiagram(List <Method> allMethods, bool closeAfterBuild, string diagramFilepath)
        {
            try
            {
                VisioManipulator.OpenDocument();
            }
            catch
            {
                VisioManipulator.AbortOpenDocument();
                throw;
            }

            var currentPos = StartPoint;

            foreach (var method in allMethods)
            {
                if (!method.MethodSignature.Equals("main()"))
                {
                    PlaceTextField(method.MethodSignature, currentPos);
                    currentPos.Offset(0, -0.4);
                }

                var treeContext = PlaceBeginShape(currentPos);
                foreach (var node in method.MethodNodes)
                {
                    treeContext                = BuildTree(node, treeContext);
                    treeContext.BranchPos      = default;
                    treeContext.BranchParent   = null;
                    treeContext.BranchRelation = NodesBranchRelation.OTHER_BRANCH;
                }
                PlaceEndShape(treeContext);
                MoveCordsToNewMethod(currentPos);
            }

            string diagramFilename;

            if (closeAfterBuild)
            {
                diagramFilename = VisioManipulator.CloseDiagramDocument(diagramFilepath);
            }
            else
            {
                diagramFilename = VisioManipulator.SaveDiagramDocument(diagramFilepath);
            }

            return(diagramFilename);
        }
        public string BuildDiagram(List <Method> allMethods, bool closeAfterBuild, string diagramFilepath)
        {
            try
            {
                VisioManipulator.OpenDocument();
            }
            catch
            {
                VisioManipulator.AbortOpenDocument();
                throw;
            }

            var currentPos = new Point(StartX, StartY);

            foreach (var method in allMethods)
            {
                if (method.MethodType == MethodType.COMMON)
                {
                    VisioManipulator.DropTextField(method.MethodSignature, currentPos);
                    currentPos.Offset(0, -0.4);
                }

                var initShape   = VisioManipulator.DropSimpleShape("", new Point(currentPos.X, currentPos.Y - 0.25), ShapeForm.INIT_SHAPE);
                var treeContext = new BranchContext(null, initShape, initShape);
                foreach (var node in method.MethodNodes)
                {
                    treeContext = BuildTree(node, treeContext);
                    treeContext = new BranchContext(null, treeContext.LastBranchShape, treeContext.ShapeToContinueThree,
                                                    NodesBranchRelation.OTHER_BRANCH);
                }
                MoveCordsToNextMethod(currentPos);
            }

            string diagramFilename;

            if (closeAfterBuild)
            {
                diagramFilename = VisioManipulator.CloseDiagramDocument(diagramFilepath);
            }
            else
            {
                diagramFilename = VisioManipulator.SaveDiagramDocument(diagramFilepath);
            }

            return(diagramFilename);
        }