コード例 #1
0
        private ThemeImage GetImage(ThemeImage[] Images, int Width, int Height)
        {
            ThemeImage Best = null;
            double     BestSqrError = double.MaxValue;
            double     SqrError, d;

            foreach (ThemeImage Img in Images)
            {
                d        = Img.Width - Width;
                SqrError = d * d;

                d         = Img.Height - Height;
                SqrError += d * d;

                if (Best == null || SqrError < BestSqrError)
                {
                    Best         = Img;
                    BestSqrError = SqrError;
                }
            }

            return(Best);
        }
コード例 #2
0
        /// <summary>
        /// Contains properties for a theme.
        /// </summary>
        /// <param name="Xml">XML Definition</param>
        internal ThemeDefinition(XmlDocument Xml)
        {
            this.id = XML.Attribute(Xml.DocumentElement, "id");

            foreach (XmlNode N in Xml.DocumentElement.ChildNodes)
            {
                if (N is XmlElement E)
                {
                    switch (E.LocalName)
                    {
                    case "Presentation":
                        foreach (XmlNode N2 in E.ChildNodes)
                        {
                            if (N2 is XmlElement E2)
                            {
                                switch (E2.LocalName)
                                {
                                case "Title":
                                    this.title = E2.InnerText;
                                    break;

                                case "Thumbnail":
                                    this.thumbnail = this.ParseThemeImage(E2);
                                    break;
                                }
                            }
                        }
                        break;

                    case "BasicProperties":
                        foreach (XmlNode N2 in E.ChildNodes)
                        {
                            if (N2 is XmlElement E2)
                            {
                                switch (E2.LocalName)
                                {
                                case "CSSX":
                                    this.cssx = this.GetResourceName(E2.InnerText);
                                    break;

                                case "TextColor":
                                    if (Color.TryParse(E2.InnerText, out SKColor cl))
                                    {
                                        this.textColor = cl;
                                    }
                                    break;

                                case "BackgroundColor":
                                    if (Color.TryParse(E2.InnerText, out cl))
                                    {
                                        this.backgroundColor = cl;
                                    }
                                    break;

                                case "HeaderColor":
                                    if (Color.TryParse(E2.InnerText, out cl))
                                    {
                                        this.headerColor = cl;
                                    }
                                    break;

                                case "HeaderTextColor":
                                    if (Color.TryParse(E2.InnerText, out cl))
                                    {
                                        this.headerTextColor = cl;
                                    }
                                    break;

                                case "ButtonColor":
                                    if (Color.TryParse(E2.InnerText, out cl))
                                    {
                                        this.buttonColor = cl;
                                    }
                                    break;

                                case "ButtonTextColor":
                                    if (Color.TryParse(E2.InnerText, out cl))
                                    {
                                        this.buttonTextColor = cl;
                                    }
                                    break;

                                case "MenuTextColor":
                                    if (Color.TryParse(E2.InnerText, out cl))
                                    {
                                        this.menuTextColor = cl;
                                    }
                                    break;

                                case "EditColor":
                                    if (Color.TryParse(E2.InnerText, out cl))
                                    {
                                        this.editColor = cl;
                                    }
                                    break;

                                case "LinkColorUnvisited":
                                    if (Color.TryParse(E2.InnerText, out cl))
                                    {
                                        this.linkColorUnvisited = cl;
                                    }
                                    break;

                                case "LinkColorVisited":
                                    if (Color.TryParse(E2.InnerText, out cl))
                                    {
                                        this.linkColorVisited = cl;
                                    }
                                    break;

                                case "LinkColorHot":
                                    if (Color.TryParse(E2.InnerText, out cl))
                                    {
                                        this.linkColorHot = cl;
                                    }
                                    break;

                                case "FontFamily":
                                    this.fontFamily = E2.InnerText;
                                    break;
                                }
                            }
                        }
                        break;

                    case "CustomProperties":
                        foreach (XmlNode N2 in E.ChildNodes)
                        {
                            if (N2 is XmlElement E2 && E2.LocalName == "Property")
                            {
                                string Name  = XML.Attribute(E2, "name");
                                string Value = XML.Attribute(E2, "value");

                                this.customProperties[Name] = Value;
                            }
                        }
                        break;

                    case "BackgroundImages":
                        List <ThemeImage> Images = new List <ThemeImage>();

                        foreach (XmlNode N2 in E.ChildNodes)
                        {
                            if (N2 is XmlElement E2 && E2.LocalName == "BackgroundImage")
                            {
                                Images.Add(this.ParseThemeImage(E2));
                            }
                        }

                        this.backgroundImages = Images.ToArray();
                        break;

                    case "BannerImages":
                        Images = new List <ThemeImage>();

                        foreach (XmlNode N2 in E.ChildNodes)
                        {
                            if (N2 is XmlElement E2 && E2.LocalName == "BannerImage")
                            {
                                Images.Add(this.ParseThemeImage(E2));
                            }
                        }

                        this.bannerImages = Images.ToArray();
                        break;
                    }
                }
            }
        }