Esempio n. 1
0
        private static void WriteNode(XmlWriter xmlWriter, NodeBase nodeBase, IRenderer renderer, string fontSize, bool useColors, string noTextPlaceholder)
        {
            var color = "#000";

            if (useColors)
            {
                var themeColor = renderer.FindColor(nodeBase);

                color = ColorsVectorHelper.ConvertToRGBString(themeColor.Darker);
            }

            xmlWriter.WriteStartElement("span");
            xmlWriter.WriteAttributeString("style", FormattableString.Invariant($"color:{color}; font-size:{fontSize};"));

            xmlWriter.WriteValue(!string.IsNullOrWhiteSpace(nodeBase.Text) ? nodeBase.Text : noTextPlaceholder);

            xmlWriter.WriteEndElement();
        }
Esempio n. 2
0
        public static void WriteContent(Document document, XDocument xMapStyles, IRenderer renderer)
        {
            var styles = new XElement(Namespaces.Styles("styles"));

            foreach (var node in document.Nodes)
            {
                var color = renderer.FindColor(node);

                if (color == null)
                {
                    continue;
                }

                var colorString = ColorsVectorHelper.ConvertToRGBString(color.Normal);

                var properties = new XElement(Namespaces.Styles("topic-properties"));

                if (node is RootNode || node.Parent is RootNode)
                {
                    properties.Add(new XAttribute(Namespaces.SVG("fill"), colorString));
                }
                else
                {
                    properties.Add(new XAttribute("border-line-color", colorString));
                    properties.Add(new XAttribute("line-color", colorString));
                }

                styles.Add(
                    new XElement(Namespaces.Styles("style"),
                                 new XAttribute("id", "s" + node.Id),
                                 new XAttribute("type", "topic"),
                                 properties));
            }

            xMapStyles.Add(
                new XElement(Namespaces.Styles("xmap-styles"),
                             new XAttribute("version", "2.0"),
                             new XAttribute(XNamespace.Xmlns + "svg", Namespaces.SVGNamespace),
                             styles));
        }
Esempio n. 3
0
        public void Convert_ColorToInt_CorrectResult2()
        {
            int actual = ColorsVectorHelper.ConvertToInt(new Vector3(0, 0, 1));

            Assert.Equal(0x0000FF, actual);
        }
Esempio n. 4
0
        public void Convert_ColorToInt_CorrectResult1()
        {
            int actual = ColorsVectorHelper.ConvertToInt(new Vector3(1, 0, 0));

            Assert.Equal(0xFF0000, actual);
        }
Esempio n. 5
0
        public void Convert_ColorToString_CorrectResult2()
        {
            string actual = ColorsVectorHelper.ConvertToRGBString(0x0000FF);

            Assert.Equal("#0000FF", actual);
        }
Esempio n. 6
0
        public void Convert_ColorToString_CorrectResult1()
        {
            string actual = ColorsVectorHelper.ConvertToRGBString(0xFF0000);

            Assert.Equal("#FF0000", actual);
        }