예제 #1
0
        public static ColorCollectionFile CreateFromXml(string colorXml)
        {
            using (var reader = XmlReader.Create(new StringReader(colorXml)))
            {
                while (reader.Read())
                {
                    if (!reader.IsStartElement())
                    {
                        continue;
                    }
                    if (reader.IsStartElement("xml"))
                    {
                        continue;
                    }
                    if (reader.IsStartElement("ColorCollection"))
                    {
                        break;
                    }
                }

                var nameKey        = reader.GetAttribute("NameKey") ?? "empty";
                var descriptionKey = reader.GetAttribute("DescriptionKey") ?? "empty";
                var innterHexagonBlendIntensity = Convert.ToSingle(reader.GetAttribute("InnerHexagonBlendIntensity") ?? "0", NumberFormatInfo.InvariantInfo);
                var outerHexagonBlendIntensity  = Convert.ToSingle(reader.GetAttribute("OuterHexagonBlendIntensity") ?? "0", NumberFormatInfo.InvariantInfo);
                List <ColorEntry> colorEntries  = new List <ColorEntry>();
                while (reader.Read())
                {
                    if (reader.IsStartElement("Color"))
                    {
                        var colorKey    = reader.GetAttribute("ColorKey");
                        var colorString = reader.GetAttribute("Value");
                        var color       = ParseColor(colorString);
                        var colorEntry  = new ColorEntry(colorKey, color);
                        colorEntries.Add(colorEntry);
                    }
                }
                var colorCollectionFile = new ColorCollectionFile(nameKey, descriptionKey, innterHexagonBlendIntensity, outerHexagonBlendIntensity, colorEntries);
                return(colorCollectionFile);
            }
        }
예제 #2
0
 public void ChangeColorCollectionFile(ColorCollectionFile colorCollectionFile)
 {
     ColorCollectionFile = colorCollectionFile;
 }
예제 #3
0
 public ColorCollection(ColorCollectionFile colorCollectionFile)
 {
     ColorCollectionFile = colorCollectionFile;
 }