示例#1
0
        private void ParseMethodBlock(SequenceDiagramComposite composite, SDBlock block)
        {
            var sequenceDiagramBlock = composite.AddBlock(block.Expression);

            foreach (var statement in block.Statements)
            {
                ParseCall(statement, sequenceDiagramBlock);
            }
        }
        private void OpenBlock(SequenceDiagramComposite block)
        {
            var textWidth = block.Text.GetWidth(12, Fonts.FontLight);
            var text      = new SvgText(_svgRoot, block.Text, 20 + _openBlocks * 15, _diagramSize.Height + 10);

            text.FontSize = 10;
            _svgGraphic.Add(text);

            // Setzen der Breite des Diagramms auf die eventuell größere Breite des Textes
            if ((textWidth + 20 + _openBlocks * 15) > _diagramSize.Width)
            {
                _diagramSize.Width = textWidth + 20 + _openBlocks * 15 + 10;
            }

            _diagramSize.Height += 20;
            _openBlocks++;
        }
        private Size OpenBlock(SequenceDiagramComposite block, Size size)
        {
            var text = new FormattedText(block.Text, CultureInfo.CurrentCulture, FlowDirection.LeftToRight, Fonts.FontLight, 10, Brushes.DimGray);

            _context.DrawText(text, new Point(20 + _openBlocks * 15, size.Height));

            // Setzen der Breite des Diagramms auf die eventuell größere Breite des Textes
            if ((text.Width + 20 + _openBlocks * 15) > size.Width)
            {
                size.Width = text.Width + 20 + _openBlocks * 15 + 10;
            }

            size.Height += 20;
            _openBlocks++;

            return(size);
        }
示例#4
0
        private void ParseConditionalMethodBlock(SequenceDiagramComposite composite, SDConditionalBlock conditionalBlock)
        {
            var sequenceDiagramBlock = composite.AddBlock(string.Format("if ({0})", conditionalBlock.Expression));

            foreach (var statement in conditionalBlock.TrueStatements)
            {
                ParseCall(statement, sequenceDiagramBlock);
            }

            if (NodeNotEmpty(conditionalBlock, conditionalBlock.FalseStatements))
            {
                sequenceDiagramBlock = composite.AddBlock("else");
                foreach (var statement in conditionalBlock.FalseStatements)
                {
                    ParseCall(statement, sequenceDiagramBlock);
                }
            }
        }
示例#5
0
        private void ParseTargetNode(SequenceDiagramComposite composite, SDTargetNode targetNode)
        {
            if (!targetNode.CalledType.IsProjectStranger)
            {
                var caller = _sequenceDiagram.Nodes.SingleOrDefault(o => o.TypeIdentifier == targetNode.CallerType.Identifier);
                caller = caller == null?_sequenceDiagram.Nodes.Single(o => o.ID == _sequenceDiagram.StartNodeID) : caller;

                var called = _sequenceDiagram.Nodes.SingleOrDefault(o => o.TypeIdentifier == targetNode.CalledType.Identifier) ?? _sequenceDiagram.AddNode(targetNode.CalledType.Identifier);

                composite.AddConnection(caller.ID, called.ID, targetNode.CalledMethod.Name, targetNode.CalledMethod.Identifier);

                var sdType       = _sdRepository.GetTypeByIdentifier(targetNode.CalledType.Identifier);
                var targetMethod = sdType.Methods.SingleOrDefault(o => o.Identifier == targetNode.CalledMethod.Identifier);
                if (caller.ID != called.ID && targetMethod.ReturnType != null && targetMethod.ReturnType.Type.Name.ToUpper() != "VOID")
                {
                    composite.AddConnection(called.ID, caller.ID, targetMethod.ReturnType.Type.Name, targetNode.CalledMethod.Identifier, true);
                }
            }
        }
示例#6
0
        private void ParseCall(SDNode call, SequenceDiagramComposite composite)
        {
            var block = call as SDBlock;

            if (block != null && NodeNotEmpty(block, block.Statements))
            {
                ParseMethodBlock(composite, block);
            }

            var conditionalBlock = call as SDConditionalBlock;

            if (conditionalBlock != null && NodeNotEmpty(conditionalBlock, conditionalBlock.TrueStatements))
            {
                ParseConditionalMethodBlock(composite, conditionalBlock);
            }

            var targetNode = call as SDTargetNode;

            if (targetNode != null && NodeNotEmpty(targetNode, null))
            {
                ParseTargetNode(composite, targetNode);
            }
        }