public RenderedSvg RenderHeader()
        {
            RenderedSvg result = new RenderedSvg();

            SvgPaintServer blackPaint = new SvgColourServer(System.Drawing.Color.Black);

            string[] spans    = vm.Heading.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToArray();
            SvgText  text     = new SvgText();
            float    fontSize = 10.0f;

            foreach (var span in spans)
            {
                SvgTextSpan tspan = new SvgTextSpan();
                tspan.Text     = span;
                tspan.FontSize = new SvgUnit(fontSize);
                tspan.Dy.Add(Helpers.dtos(fontSize * 1.2));
                tspan.X.Add(0);
                tspan.Fill = blackPaint;
                text.Children.Add(tspan);
            }
            //text.Transforms.Add(new Svg.Transforms.SvgTranslate(0, (float)(- (fontSize * 1.2) * spans.Length * 0.5)));

            result.RenderedSize = headerView.RenderSize;
            result.SVG          = text;
            return(result);
        }
示例#2
0
        public override RenderedSvg RenderColumn()
        {
            RenderedSvg result = base.RenderColumn();

            SvgGroup group = new SvgGroup();

            for (int i = 0; i < vm.Samples.Length; i++)
            {
                SampleVM sample = vm.Samples[i];
                //sample circle sign
                SvgCircle circle = new SvgCircle();
                circle.CenterX = Helpers.dtos(circleXoffset);
                circle.CenterY = Helpers.dtos(sample.Level);
                circle.Radius  = Helpers.dtos(circleRadius);
                circle.Stroke  = blackPaint;
                group.Children.Add(circle);

                //sample depth label
                SvgText depthText = new SvgText(string.Format("{0:0.##} м", sample.Depth));
                depthText.Transforms.Add(new Svg.Transforms.SvgTranslate(textXoffset, (float)(sample.Level + 2.0 * circleRadius + textFontSize * 0.5)));
                depthText.Fill     = blackPaint;
                depthText.FontSize = Helpers.dtos(textFontSize);
                group.Children.Add(depthText);
                //sample comment
                SvgText commentText = new SvgText(sample.Comment);
                commentText.Transforms.Add(new Svg.Transforms.SvgTranslate(textXoffset, (float)(sample.Level + 2.0 * circleRadius + textFontSize * 1.5)));
                commentText.Fill     = blackPaint;
                commentText.FontSize = Helpers.dtos(textFontSize);
                group.Children.Add(commentText);
            }

            result.SVG = group;

            return(result);
        }
示例#3
0
        public void TestUpdateCoordinatesForCollectionChange()
        {
            SvgText text = new SvgText()
            {
                Text = "Test coordinates",
                X    = { 10 },
                Y    = { 10 },
                Dx   = { 10 },
                Dy   = { 10 },
            };

            text.X = new SvgUnitCollection()
            {
                20
            };
            text.Y = new SvgUnitCollection()
            {
                30
            };
            text.Dx = new SvgUnitCollection()
            {
                40
            };
            text.Dy = new SvgUnitCollection()
            {
                50
            };

            var xml = text.GetXML();

            Assert.IsTrue(xml.Contains("x=\"20\""));
            Assert.IsTrue(xml.Contains("y=\"30\""));
            Assert.IsTrue(xml.Contains("dx=\"40\""));
            Assert.IsTrue(xml.Contains("dy=\"50\""));
        }
示例#4
0
        public void TestWritesCoordinatesForCollectionSet()
        {
            SvgText text = new SvgText();

            text.Text = "Test coordinates";
            text.X    = new SvgUnitCollection {
                20
            };
            text.Y = new SvgUnitCollection {
                30
            };
            text.Dx = new SvgUnitCollection {
                40
            };
            text.Dy = new SvgUnitCollection {
                50
            };

            var xml = text.GetXML();

            Assert.IsTrue(xml.Contains("x=\"20\""));
            Assert.IsTrue(xml.Contains("y=\"30\""));
            Assert.IsTrue(xml.Contains("dx=\"40\""));
            Assert.IsTrue(xml.Contains("dy=\"50\""));
        }
示例#5
0
 public TextDrawable(SvgText svgText, SKRect skOwnerBounds, Drawable?root, Drawable?parent, Attributes ignoreAttributes = Attributes.None)
     : base(svgText, root, parent)
 {
     _svgText         = svgText;
     _skOwnerBounds   = skOwnerBounds;
     IgnoreAttributes = ignoreAttributes;
 }
示例#6
0
        public new void ReadContent(XmlElement xmlElement, SvgReader svgReader)
        {
            base.ReadContent(xmlElement, svgReader);

            _text = null;
            foreach (var node in xmlElement.ChildNodes)
            {
                var childElement = node as XmlElement;
                if (childElement != null)
                {
                    var svgNode = svgReader.CreateSvgNodeFromXml(childElement);
                    svgReader.Read(svgNode, childElement);
                    if (svgNode is SvgText)
                    {
                        _text = svgNode as SvgText;
                    }
                }

                if (_text != null)
                {
                    break;
                }
            }

            if (_text != null)
            {
                ReadText(_text);
            }
            else
            {
                throw new SvgParseException(Resources.Exceptions.CanNotParseSvgVoText);
            }
        }
示例#7
0
        protected virtual void ReadText(SvgText text)
        {
            Text      = text.Text;
            TextColor = text.Fill;

            Underline = text.TextDecoration != null && text.TextDecoration.Contains(_underlineDecoration);
        }
示例#8
0
        protected override void WriteText(SvgText text)
        {
            base.WriteText(text);

            text.X         = 0;
            text.Y         = 0;
            text.Transform = null;
        }
示例#9
0
 public SelectionRectangleHandler(List <SvgRectangle> quads, List <SvgRectangle> selected, SvgTransform rectTransform, SvgText label, SvgRectangle selectionRect, string sessionID)
     : base(selectionRect, sessionID)
 {
     FQuads         = quads;
     FSelectedQuads = selected;
     FRectTransform = rectTransform;
     FLabel         = label;
 }
        private void CloseBlock()
        {
            _openBlocks--;

            var text = new SvgText(_svgRoot, "end", 20 + _openBlocks * 15, _diagramSize.Height);

            text.FontSize = 10;
            _svgRoot.AppendChild(text.XmlElement);

            _diagramSize.Height += 20;
        }
        private void CloseBlock()
        {
            _openBlocks--;

            var text = new SvgText(_svgRoot, "end", 20 + _openBlocks * 15, _diagramSize.Height);

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

            _diagramSize.Height += 20;
        }
示例#12
0
        public bool SetStyleFromSvg(SvgText svg)
        {
            try
            {
                float x = ParseSize(svg.X, Dpi.X);
                float y = ParseSize(svg.Y, Dpi.Y);
                float w = ParseSize(svg.Width, Dpi.X);
                float h = ParseSize(svg.Height, Dpi.Y);
                Text = svg.Value;
                //font
                Stroke = Color.FromNonPremultiplied(svg.Fill.R, svg.Fill.G, svg.Fill.B, svg.Fill.A);
                string family = svg.FontFamily;
                float  size   = ParseSize(svg.FontSize, Dpi.X);
                int    fs     = 0;
                if (svg.FontWeight.IndexOf("bold") >= 0)
                {
                    fs = 1;
                }
                if (svg.FontStyle.IndexOf("italic") >= 0)
                {
                    fs = fs | 2;
                }
                Font = XnaDrawing.defaultFont;
                //new System.Drawing.Font(family,size,(System.Drawing.FontStyle )fs);
                //				y -= font.Size;
                y        -= Font.MeasureString("T").Y;
                Rectangle = new Rectangle((int)x, (int)y, (int)w, (int)h);
                if (svg.TextAnchor.Length > 0)
                {
                    switch (svg.TextAnchor)
                    {
                    case "start":
                        TextAnchor.Alignment = System.Drawing.StringAlignment.Near;
                        break;

                    case "end":
                        TextAnchor.Alignment = System.Drawing.StringAlignment.Far;
                        Rectangle            = new Rectangle((int)(x - w), (int)y, (int)w, (int)h);
                        break;

                    case "middle":
                        TextAnchor.Alignment = System.Drawing.StringAlignment.Center;
                        Rectangle            = new Rectangle((int)(x - w / 2), (int)y, (int)w, (int)h);
                        break;
                    }
                }
                return(true);
            }
            catch
            {
                ErrH.Log("DrawText", "SetStyleFromSvg", "SetStyleFromSvg", ErrH._LogPriority.Info);
                return(false);
            }
        }
示例#13
0
        public RenderedSvg RenderHeader()
        {
            RenderedSvg result = new RenderedSvg();
            SvgText     text   = new SvgText(vm.Heading);

            text.FontSize       = new SvgUnit((float)10);
            text.Fill           = new SvgColourServer(System.Drawing.Color.Black);
            result.RenderedSize = headerView.RenderSize;
            result.SVG          = text;
            return(result);
        }
示例#14
0
 internal static void SvgText2Pdf(SvgText element, XGraphics graphics)
 {
     if (element.Display == "none")
     {
         return;
     }
     if (!string.IsNullOrWhiteSpace(element.Content))
     {
         graphics.DrawString(element.Content, new XFont("黑体", element.FontSize), XBrushes.Black, ConvertHelper.Rectangle2XRect(element.Bounds), XStringFormats.TopLeft);
     }
 }
示例#15
0
        private SvgGroup BuildTileGroup(OutputTile tile, Func <float, float> yCoordinateConverter)
        {
            var tileGroup    = new SvgGroup();
            var mediaBoxRect = new SvgRectangle
            {
                Width       = tile.MediaBox.Width,
                Height      = tile.MediaBox.Height,
                X           = tile.MediaBox.Left,
                Y           = yCoordinateConverter(tile.MediaBox.Top),
                Stroke      = new SvgColourServer(Color.Magenta),
                Fill        = new SvgColourServer(Color.White),
                StrokeWidth = 1.0f
            };

            var cutBoxRect = new SvgRectangle
            {
                Width       = tile.CutBox.Width,
                Height      = tile.CutBox.Height,
                X           = tile.CutBox.Left,
                Y           = yCoordinateConverter(tile.CutBox.Top),
                Stroke      = new SvgColourServer(Color.Black),
                Fill        = new SvgColourServer(Color.White),
                StrokeWidth = 1.0f
            };

            var pageNUmberFontSize = tile.CutBox.Height / 4.0f;
            var pageNumberText     = new SvgText(tile.SourcePage.Number.ToString())
            {
                X          = { tile.CutBox.GetCenter().X - 70.0f },
                Y          = { yCoordinateConverter(tile.CutBox.GetCenter().Y - pageNUmberFontSize / 2.0f) },
                FontSize   = pageNUmberFontSize,
                FontFamily = "Courier New",
                Transforms =
                {
                    new SvgRotate(tile.MediaRotationAngle,
                                  tile.CutBox.GetCenter().X,
                                  yCoordinateConverter(tile.CutBox.GetCenter().Y))
                }
            };
            var sourceFileText = new SvgText(Path.GetFileNameWithoutExtension(tile.SourceFilePath))
            {
                X          = { tile.CutBox.Left + 50.0f },
                Y          = { yCoordinateConverter(tile.CutBox.Bottom + 20) },
                FontSize   = 24,
                FontFamily = "Courier New"
            };

            tileGroup.Children.Add(mediaBoxRect);
            tileGroup.Children.Add(cutBoxRect);
            tileGroup.Children.Add(pageNumberText);
            tileGroup.Children.Add(sourceFileText);

            return(tileGroup);
        }
示例#16
0
        private void AddText(SvgDocument doc, double x, double y, string t)
        {
            SvgText text = doc.AddText();

            text.FontFamily  = "arial";
            text.Text        = t;
            text.X           = x;
            text.Y           = y;
            text.StrokeWidth = 0;
            text.Fill        = "#000000";
            text.FontSize    = 8D;
        }
示例#17
0
        public bool SetStyleFromSvg(SvgText svg)
        {
            try
            {
                float x = ParseSize(svg.X, Dpi.X);
                float y = ParseSize(svg.Y, Dpi.Y);
                float w = ParseSize(svg.Width, Dpi.X);
                float h = ParseSize(svg.Height, Dpi.Y);
                Text = svg.Value;
                //font
                Stroke = svg.Fill;
                string family = svg.FontFamily;
                float  size   = ParseSize(svg.FontSize, Dpi.X);
                int    fs     = 0;
                if (svg.FontWeight.IndexOf("bold") >= 0)
                {
                    fs = 1;
                }
                if (svg.FontStyle.IndexOf("italic") >= 0)
                {
                    fs = fs | 2;
                }
                Font = new Font(family, size, (FontStyle )fs);
                //				y -= font.Size;
                y         -= Font.Height;
                RectangleF = new RectangleF(x, y, w, h);
                if (svg.TextAnchor.Length > 0)
                {
                    switch (svg.TextAnchor)
                    {
                    case "start":
                        TextAnchor.Alignment = StringAlignment.Near;
                        break;

                    case "end":
                        TextAnchor.Alignment = StringAlignment.Far;
                        RectangleF           = new RectangleF(x - w, y, w, h);
                        break;

                    case "middle":
                        TextAnchor.Alignment = StringAlignment.Center;
                        RectangleF           = new RectangleF(x - w / 2, y, w, h);
                        break;
                    }
                }
                return(true);
            }
            catch
            {
                ErrH.Log("DrawText", "SetStyleFromSvg", "SetStyleFromSvg", ErrH._LogPriority.Info);
                return(false);
            }
        }
示例#18
0
        public SvgButtonWidget(string label) : base(label)
        {
            Background.MouseOver += Background_MouseOver;
            Background.MouseOut  += Background_MouseOut;
            Background.MouseDown += Background_MouseDown;

            FLabel          = new SvgText(label);
            FLabel.FontSize = 12;
            FLabel.X        = 2;
            FLabel.Y        = FLabel.FontSize + 2;
            FLabel.CustomAttributes["class"] = "menufont";

            Children.Add(FLabel);
        }
示例#19
0
        public void ChangingCoordinatesInvalidatePathCache()
        {
            SvgText text = new SvgText();

            text.Text = "Test invalidate cache";
            float origX = text.Bounds.X;
            float origY = text.Bounds.Y;

            text.X.Add(100);
            text.Y.Add(100);

            Assert.AreNotEqual(origX, text.Bounds.X);
            Assert.AreNotEqual(origY, text.Bounds.Y);
        }
示例#20
0
        protected virtual void WriteText(SvgText text)
        {
            text.Text = Text;
            text.X    = X;
            text.Y    = Y;
            text.Fill = TextColor;

            text.FontFamily = "Arial";
            text.FontSize   = _font.Size;
            text.FontStyle  = "Regular";

            text.TextDecoration = Underline ? _underlineDecoration : null;
            text.Transform      = new Matrix();
            text.Transform.Translate(StrokeWidth / 2, GetFontHeight());
        }
示例#21
0
        public override SvgElement Draw()
        {
            var container = base.Draw();

            for (var lineNumber = 0; lineNumber < Text.Length; lineNumber++)
            {
                var text = new SvgText(Text[lineNumber]);
                text.Transforms.Add(new SvgTranslate(
                                        LeftMargin,
                                        TopMargin + DebugSvgDrawing.SvgTextHeight * TextSize + DebugSvgDrawing.SvgTextLineSpacing * lineNumber * TextSize));
                text.Children.Add(new SvgTextSpan());
                container.Children.Add(text);
            }

            return(container);
        }
示例#22
0
        public double MeasureWidth(string s, GraphicsContext context, DeviceDescription description)
        {
            var svgContext = _mapper.MapGraphicsContextToSvg(context);
            var text       = new SvgText
            {
                FontFamily = svgContext.Font.Family,
                FontSize   = svgContext.Font.Size,
                FontWeight = svgContext.Font.Weight,
                Text       = s,
                TextAnchor = svgContext.TextAnchor,
                X          = createUnitCollection(0f),
                Y          = createUnitCollection(0f),
            };

            return(text.Bounds.Width);
        }
示例#23
0
文件: SVGDump.cs 项目: rvnbrz/D1
        public void AddCPU(int id, int cores)
        {
            SvgRectangle cpu = new SvgRectangle
            {
                Fill        = new SvgColourServer(_cpus.Count % 2 == 0 ? Color.FromArgb(255, 242, 242, 242) : Color.FromArgb(255, 232, 232, 232)),
                FillOpacity = 1,
                X           = 0,
                Y           = _cycleWidth * _cores.Count,
                Height      = _cycleWidth * cores,
                Width       = _startx
            };
            int offset = _coreoffset.Last();

            _coreoffset.Add(offset + (_cycleWidth * cores));
            SvgText cpuText = new SvgText
            {
                Text = $"CPU{id}",
                X    = new SvgUnitCollection()
                {
                    5
                },
                Y = new SvgUnitCollection()
                {
                    (_cycleWidth * _cores.Count) + ((cores * _cycleWidth) / 2) + 8
                },
                FontSize  = 16,
                FontStyle = SvgFontStyle.Normal
            };

            for (int core = 0; core < cores; core++)
            {
                Color        col        = _cores.Count % 2 == 0 ? Color.FromArgb(255, 255, 255, 255) : Color.FromArgb(255, 242, 242, 242);
                SvgRectangle rectangles = new SvgRectangle
                {
                    Fill        = new SvgColourServer(col),
                    FillOpacity = 1,
                    X           = 0,
                    Y           = _cycleWidth * _cores.Count,
                    Height      = _cycleWidth,
                    Width       = _startx + (_simulationlength * _cycleWidth)
                };

                _cores.Add(rectangles);
            }
            _cpus.Add(cpu);
            _texts.Add(cpuText);
        }
        private static SvgText Text(float x, float y, float rotate, string text)
        {
            var svgText = new SvgText()
            {
                TextAnchor = SvgTextAnchor.Middle,
                Fill       = new SvgColourServer(Color.Black),
                FontSize   = new SvgUnit(16)
            };

            svgText.Nodes.Add(new SvgContentNode()
            {
                Content = text
            });
            svgText.Transforms.Add(new SvgTranslate(x, y));
            svgText.Transforms.Add(new SvgRotate(rotate));
            return(svgText);
        }
        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++;
        }
示例#26
0
        public SessionParameters(string id)
        {
            //selection rect
            SelectionRect             = new SvgRectangle();
            SelectionRect.FillOpacity = 0.1f;
            SelectionRect.Stroke      = new SvgColourServer(Color.Black);
            SelectionRect.StrokeWidth = 1;
            SelectionRect.CustomAttributes["pointer-events"] = "none";

            Label            = new SvgText();
            Label.FontSize   = 12;
            Label.FontFamily = "Lucida Sans Unicode";
            Label.Text       = id;
            Label.X          = -1000;
            Label.CustomAttributes["pointer-events"] = "none";
            Label.Fill = new SvgColourServer(Color.Black);
        }
示例#27
0
        /// <summary>
        /// Gets the SVG text.
        /// </summary>
        /// <param name="text">The text.</param>
        /// <param name="format">The format.</param>
        /// <param name="x">The x.</param>
        /// <param name="y">The y.</param>
        /// <returns></returns>
        public static SvgText GetSvgText(this String text, cursorZoneSpatialSettings format, Int32 x, Int32 y)
        {
            Int32 xStart = x * format.width;
            Int32 yStart = y * format.height;

            Svg.SvgText label = new SvgText(text);


            label.X = new SvgUnit(xStart + (format.width / 2) - ((text.Length * format.spatialUnit) / 2));
            label.Y = new SvgUnit((yStart + (format.height / 2) + (format.spatialUnitHeight)));

            label.Fill = new SvgColourServer(Color.Black);

            //label.Font = new Font("Gulliver");

            return(label);
        }
示例#28
0
        public void TestWritesCoordinatesForCollectionChange()
        {
            SvgText text = new SvgText();

            text.Text = "Test coordinates";
            text.X.Add(20);
            text.Y.Add(30);
            text.Dx.Add(40);
            text.Dy.Add(50);

            var xml = text.GetXML();

            Assert.IsTrue(xml.Contains("x=\"20\""));
            Assert.IsTrue(xml.Contains("y=\"30\""));
            Assert.IsTrue(xml.Contains("dx=\"40\""));
            Assert.IsTrue(xml.Contains("dy=\"50\""));
        }
        private void RenderHeader()
        {
            var accessibility = new SvgText(
                _svgRoot,
                _classDiagram.Accessibility,
                (_diagramSize.Width - _classDiagram.Accessibility.GetWidth(11, Fonts.FontItalic)) / 2,
                ACCESSIBILITY_LABEL_Y);

            accessibility.FontSize = 11;

            SvgElement name;

            if (_classDiagram.IsProjectStranger)
            {
                name = new SvgText(
                    _svgRoot,
                    _classDiagram.Name,
                    (_diagramSize.Width - _classDiagram.Name.GetWidth(14, Fonts.FontLight)) / 2,
                    CLASSLABEL_Y);
                ((SvgText)name).FontSize = 14;
            }
            else
            {
                name = new SvgLink(
                    _svgRoot,
                    _classDiagram.Name,
                    string.Format("{{{{type-link:{0}}}}}", _classDiagram.TypeIdentifier),
                    (_diagramSize.Width - _classDiagram.Name.GetWidth(14, Fonts.FontLight)) / 2,
                    CLASSLABEL_Y);
                ((SvgLink)name).Text.FontSize = 14;
            }

            var path = new SvgPath(
                _svgRoot,
                string.Format("M0.5,{0}L{1},{0}",
                              (CLASSLABEL_Y + 10).ToString("0.00", CultureInfo.InvariantCulture),
                              _diagramSize.Width.ToString("0.00", CultureInfo.InvariantCulture)));

            path.StrokeWidth = 1;
            path.Stroke      = "#979797";

            _svgGraphic.Add(accessibility);
            _svgGraphic.Add(name);
            _svgGraphic.Add(path);
        }
示例#30
-1
        public void TestStyleValue()
        {
            var document = new SvgDocument();
            var text     = new SvgText("Test")
            {
                X                = { 0f },
                Y                = { 20f },
                Fill             = new SvgColourServer(Color.Blue),
                CustomAttributes = { { "style", "test0:test0" } }
            };

            text.AddStyle("test1", "test1", 0);
            document.Children.Add(text);
            document.FlushStyles(true);
            using (var stream = new MemoryStream())
            {
                document.Write(stream);
                stream.Position = 0;

                var xmlDoc = new XmlDocument
                {
                    XmlResolver = new SvgDtdResolver()
                };
                xmlDoc.Load(stream);

                var attribute = xmlDoc.DocumentElement.FirstChild.Attributes["style"];
                Assert.IsNotNull(attribute);

                var styles = attribute.InnerText.Split(';');
                Assert.Contains("test0:test0", styles);
                Assert.Contains("test1:test1", styles);
                Assert.Contains("fill:blue", styles);
            }
        }