Exemplo n.º 1
0
        private void DrawBaseTypes()
        {
            var offset = _leftMargin;

            for (int i = 0; i < _classDiagram.BaseTypes.Count; i++)
            {
                var diagram     = _classDiagramSvgRenderer.RenderDiagram(_classDiagram.BaseTypes[i]);
                var diagramSize = new Size(
                    _classDiagramSvgRenderer.CalculateDiagramWidth(_classDiagram.BaseTypes[i]),
                    _classDiagramSvgRenderer.CalculateDiagramHeight(_classDiagram.BaseTypes[i]));

                var positionX = (i * 50) + offset;
                var positionY = 0;

                var translate = diagram.CreateAttribute("transform");
                translate.Value = string.Format("translate({0}, {1})", positionX.ToString("0.00", CultureInfo.InvariantCulture), positionY.ToString("0.00", CultureInfo.InvariantCulture));
                diagram["svg"]["g"].Attributes.Append(translate);

                _mainDiagram.ImportAdd((SvgElement)diagram["svg"]["g"]);

                offset += diagramSize.Width;

                var pathGraphic = new SvgGraphic(_mainDiagram);

                //line
                if (i == 0)
                {
                    var path = new SvgPath(_mainDiagram, string.Format("M{0},{1}L{0},{2}",
                                                                       (positionX + 50).ToString("0.00", CultureInfo.InvariantCulture),
                                                                       (positionY + diagramSize.Height).ToString("0.00", CultureInfo.InvariantCulture),
                                                                       _topMargin.ToString("0.00", CultureInfo.InvariantCulture)));
                    path.StrokeWidth = 1;
                    path.Stroke      = "#979797";
                    pathGraphic.Add(path);
                }

                //arrow
                var startX = positionX + 50;
                var startY = diagramSize.Height;

                var points = string.Format("{0},{1} {2},{3} {4},{3}",
                                           startX.ToString("0.00", CultureInfo.InvariantCulture),
                                           startY.ToString("0.00", CultureInfo.InvariantCulture),
                                           (startX - 5).ToString("0.00", CultureInfo.InvariantCulture),
                                           (startY + 10).ToString("0.00", CultureInfo.InvariantCulture),
                                           (startX + 5).ToString("0.00", CultureInfo.InvariantCulture));
                var arrow = new SvgPolygon(_mainDiagram, points);
                arrow.Stroke = "#979797";
                arrow.Fill   = "#FFFFFF";

                pathGraphic.Add(arrow);

                _mainDiagram.Add(pathGraphic);
            }
        }
        public SvgRoot RenderDiagram(SequenceDiagram sequenceDiagram)
        {
            _nodeMiddlePoints = new Dictionary <Guid, double>();
            _diagramSize      = new Size(0.5, 80.5);
            _svgRoot          = new SvgRoot();
            _svgGraphic       = new SvgGraphic(_svgRoot);
            _svgRoot.Add(_svgGraphic);

            DrawAllNodes(sequenceDiagram);
            DrawAllDiagramElements(sequenceDiagram);
            DrawVerticalLines(sequenceDiagram);

            _svgRoot.Height = _diagramSize.Height;
            _svgRoot.Width  = _diagramSize.Width;

            return(_svgRoot);
        }
        public SvgRoot RenderDiagram(ClassDiagram classDiagram)
        {
            _classDiagram = classDiagram;
            _diagramSize  = new Size(CalculateDiagramWidth(classDiagram), CalculateDiagramHeight(classDiagram));

            _svgRoot = new SvgRoot()
            {
                Width = _diagramSize.Width, Height = _diagramSize.Height
            };
            _svgGraphic = new SvgGraphic(_svgRoot);
            _svgRoot.Add(_svgGraphic);

            RenderFrame();
            RenderHeader();
            RenderAllRowSections();

            return(_svgRoot);
        }