示例#1
0
        private static void ProcessText(XDocument xdoc)
        {
            System.Collections.Generic.IEnumerable <XElement> attributesToDelete = from ele in xdoc.Descendants()
                                                                                   where ele != null && ele.Attribute("Text") != null
                                                                                   select ele;

            try
            {
                foreach (XAttribute attribute in attributesToDelete.Attributes())
                {
                    XElement parent = attribute.Parent;

                    System.Collections.Generic.IEnumerable <XElement> toDelete = from ele in xdoc.Descendants()
                                                                                 where ele != null && ele.Attribute("Text") != null
                                                                                 select ele;

                    foreach (XAttribute att in toDelete.Attributes())
                    {
                        att.Remove();
                    }

                    parent.SetAttributeValue("TextColor", $"#{LayoutBuilder.GetColor(true).ToHex()}");
                    parent.SetAttributeValue("Text", TextBuilder.GenerateLoremText(attribute.Value));
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
示例#2
0
        private static void TraverseXMl(XElement xdoc)
        {
            foreach (XElement element in xdoc.Descendants())
            {
                if (VisualElementTypes.Any(w => w.Name == element.Name.LocalName))
                {
                    element.SetAttributeValue("BackgroundColor", $"#{LayoutBuilder.GetColor(true).ToHex()}");
                }

                TraverseXMl(element);
            }
        }
示例#3
0
        private static string RandomColor()
        {
            var color = LayoutBuilder.GetColor().ToSKColor().ToString();

            while ((color == Color.White.ToSKColor().ToString() ||
                    color == Color.WhiteSmoke.ToSKColor().ToString() ||
                    color == Color.FloralWhite.ToSKColor().ToString() ||
                    color == Color.NavajoWhite.ToSKColor().ToString() ||
                    color == Color.GhostWhite.ToSKColor().ToString()
                    ))
            {
                return(Color.FromRgb(new Random().Next(255) / 255.0f,
                                     new Random().Next(255) / 255.0f,
                                     new Random().Next(255) / 255.0f).ToSKColor().ToString());
            }

            return(color);
        }