Наследование: SvgElement
        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);
            }
        }
Пример #2
0
        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;
        }
        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;
        }
        private void DrawUses()
        {
            var leftOffset = _leftMargin + _classDiagramSvgRenderer.CalculateDiagramWidth(_classDiagram);
            var offset = leftOffset;
            for (int i = 0; i < _classDiagram.Uses.Count; i++)
            {
                var diagram = _classDiagramSvgRenderer.RenderDiagram(_classDiagram.Uses[i]);
                var diagramSize = new Size(
                    _classDiagramSvgRenderer.CalculateDiagramWidth(_classDiagram.Uses[i]),
                    _classDiagramSvgRenderer.CalculateDiagramHeight(_classDiagram.Uses[i]));

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

                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"]);

                var pathGraphic = new SvgGraphic(_mainDiagram);

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

                path = new SvgPath(_mainDiagram, string.Format("M{0},{1}L{2},{3}",
                    (positionX + (diagramSize.Width / 2) - 5).ToString("0.00", CultureInfo.InvariantCulture),
                    (positionY - 10).ToString("0.00", CultureInfo.InvariantCulture),
                    (positionX + (diagramSize.Width / 2)).ToString("0.00", CultureInfo.InvariantCulture),
                    positionY.ToString("0.00", CultureInfo.InvariantCulture)));
                path.StrokeWidth = 1;
                path.Stroke = "#979797";
                pathGraphic.Add(path);

                path = new SvgPath(_mainDiagram, string.Format("M{0},{1}L{2},{3}",
                    (positionX + (diagramSize.Width / 2) + 5).ToString("0.00", CultureInfo.InvariantCulture),
                    (positionY - 10).ToString("0.00", CultureInfo.InvariantCulture),
                    (positionX + (diagramSize.Width / 2)).ToString("0.00", CultureInfo.InvariantCulture),
                    positionY.ToString("0.00", CultureInfo.InvariantCulture)));
                path.StrokeWidth = 1;
                path.Stroke = "#979797";
                pathGraphic.Add(path);

                if (i == _classDiagram.Uses.Count - 1)
                {
                    path = new SvgPath(_mainDiagram, string.Format("M{0},{2}L{1},{2}",
                        (positionX + (diagramSize.Width / 2)).ToString("0.00", CultureInfo.InvariantCulture),
                        leftOffset.ToString("0.00", CultureInfo.InvariantCulture),
                        (positionY - 25.5d).ToString("0.00", CultureInfo.InvariantCulture)));
                    path.StrokeWidth = 1;
                    path.Stroke = "#979797";
                    pathGraphic.Add(path);
                }

                _mainDiagram.Add(pathGraphic);
                offset += diagramSize.Width;
            }
        }