Esempio n. 1
0
        /// <summary>
        /// Loads desktop from xml file. Creates define windows as well.
        /// </summary>
        /// <param name="reader">xml document to load from.</param>
        private void Load(IXmlReader reader)
        {
            IXmlElement root = reader.RootElement;

            if ((null != root) && (root.Name == "desktop"))
            {
                this.desktopSize.Width  = UIUtils.FromString(root.GetAttributeValue("Width", ""), this.desktopSize.Width);
                this.desktopSize.Height = UIUtils.FromString(root.GetAttributeValue("Height", ""), this.desktopSize.Height);
                this.Wallpaper          = root.GetAttributeValue("wallpaper", this.Wallpaper);

                foreach (IXmlElement element in root.Elements)
                {
                    if (element.Name == "window")
                    {
                        String type = element.GetAttributeValue("type", "");

                        if (type.Length > 0)
                        {
                            NewRegisteredWindow(type);
                        }
                        else
                        {
                            NewWindow(CreationFlag.NeedLoading, element.GetAttributeValue("name", ""));
                        }

                        if (null != this.Resized)
                        {
                            this.Resized(this, EventArgs.Empty);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// Loads menu theme settings from xml.
 /// </summary>
 /// <param name="element">xml element to load from.</param>
 internal void LoadMenu(IXmlElement element, ThemeColors colors)
 {
     this.menuHasShadow          = UIUtils.FromString(element.GetAttributeValue("hasShadow", ""), this.menuHasShadow);
     this.colorMenuPopUpBack     = colors.GetColor(element.GetAttributeValue("popUpBackColor", ""), this.colorMenuPopUpBack);
     this.menuHasPopUpBackImage  = UIUtils.FromString(element.GetAttributeValue("hasPopUpBackImage", ""), this.menuHasPopUpBackImage);
     this.menuHasIconPlaceHolder = UIUtils.FromString(element.GetAttributeValue("hasIconPlaceholderImage", ""), this.menuHasIconPlaceHolder);
     this.menuSimple             = UIUtils.FromString(element.GetAttributeValue("hasSimpleMenu", ""), this.menuSimple);
 }
Esempio n. 3
0
        private String GetFontName(String fileName, UIEngine engine)
        {
            using (IXmlReader reader = this.engine.OpenXmlFile(fileName))
            {
                if (null != reader)
                {
                    IXmlElement root     = reader.RootElement;
                    String      fontName = "";

                    if ("font" == root.Name)
                    {
                        fontName = root.GetAttributeValue("name", "");
                    }

                    if ("" == fontName)
                    {
                        return(null);
                    }
                    else
                    {
                        return(fontName);
                    }
                }
                else
                {
                    return(null);
                }
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Loads window theme settings from xml.
 /// </summary>
 /// <param name="element">xml element to load from.</param>
 internal void LoadWindow(IXmlElement element)
 {
     this.windowHasTitleImage      = UIUtils.FromString(element.GetAttributeValue("hasTitleImage", "false"), this.windowHasTitleImage);
     this.windowBorderSize         = UIUtils.FromString(element.GetAttributeValue("windowBorderSize"), this.windowBorderSize);
     this.windowBorderOffset       = UIUtils.FromString(element.GetAttributeValue("windowBorderOffset"), this.windowBorderOffset);
     this.windowSplitImagePosition = UIUtils.FromString(element.GetAttributeValue("windowSplitImagePosition"), this.windowSplitImagePosition);
     this.windowSplitWidth         = UIUtils.FromString(element.GetAttributeValue("windowSplitWidth"), this.windowSplitWidth);
     this.windowTitleHeight        = UIUtils.FromString(element.GetAttributeValue("windowTitleHeight"), this.windowTitleHeight);
     this.windowSplitPosition      = UIUtils.FromString(element.GetAttributeValue("windowSplitPosition"), this.windowSplitPosition);
     this.windowShadowSize         = UIUtils.FromString(element.GetAttributeValue("windowShadowSize"), this.windowShadowSize);
 }
Esempio n. 5
0
File: Theme.cs Progetto: drme/thw-ui
        /// <summary>
        /// Loads theme configuration from xml file.
        /// </summary>
        /// <param name="reader">xml document containing theme configuration.</param>
        private void Load(IXmlReader reader)
        {
            IXmlElement root = reader.RootElement;

            if (null != root)
            {
                this.skinned         = UIUtils.FromString(root.GetAttributeValue("skinned", ""), this.skinned);
                this.defaultFontName = root.GetAttributeValue("defaultfont", this.defaultFontName);

                foreach (IXmlElement element in root.Elements)
                {
                    switch (element.Name)
                    {
                    case "colors":
                        this.Colors.LoadColors(element);
                        break;

                    case "menu":
                        this.Menu.LoadMenu(element, this.Colors);
                        break;

                    case "borders":
                    case "controls":
                        LoadBorders(element);
                        break;

                    case "window":
                        this.Window.LoadWindow(element);
                        break;

                    default:
                        throw new NotSupportedException("Unknown tag: " + element.Name);
                    }
                }
            }
        }
Esempio n. 6
0
 /// <summary>
 /// Loads theme colro values from theme xml file.
 /// </summary>
 /// <param name="element">colors xml element.</param>
 internal void LoadColors(IXmlElement element)
 {
     this.ControlLight.UpdateColor(element.GetAttributeValue("ControlLight", ""), this);
     this.ControlDark.UpdateColor(element.GetAttributeValue("ControlDark", ""), this);
     this.ControlDarkDark.UpdateColor(element.GetAttributeValue("ControlDarkDark", ""), this);
     this.Control.UpdateColor(element.GetAttributeValue("Control", ""), this);
     this.Highlight.UpdateColor(element.GetAttributeValue("Highlight", ""), this);
     this.HighlightBorder.UpdateColor(element.GetAttributeValue("HighlightBorder", ""), this);
     this.TextDark.UpdateColor(element.GetAttributeValue("TextDark", ""), this);
     this.TextLight.UpdateColor(element.GetAttributeValue("TextLight", ""), this);
     this.BackLight.UpdateColor(element.GetAttributeValue("BackLight", ""), this);
     this.BackBorder.UpdateColor(element.GetAttributeValue("BackBorder", ""), this);
     this.BackLightLight.UpdateColor(element.GetAttributeValue("BackLightLight", ""), this);
     this.BorderDark.UpdateColor(element.GetAttributeValue("BorderDark", ""), this);
     this.WindowTitleStart.UpdateColor(element.GetAttributeValue("WindowTitleStart", ""), this);
     this.WindowTitleEnd.UpdateColor(element.GetAttributeValue("WindowTitleEnd", ""), this);
     this.Window.UpdateColor(element.GetAttributeValue("Window", ""), this);
 }
Esempio n. 7
0
 /// <summary>
 /// Loads menu theme settings from xml.
 /// </summary>
 /// <param name="element">xml element to load from.</param>
 internal void LoadMenu(IXmlElement element, ThemeColors colors)
 {
     this.menuHasShadow = UIUtils.FromString(element.GetAttributeValue("hasShadow", ""), this.menuHasShadow);
     this.colorMenuPopUpBack = colors.GetColor(element.GetAttributeValue("popUpBackColor", ""), this.colorMenuPopUpBack);
     this.menuHasPopUpBackImage = UIUtils.FromString(element.GetAttributeValue("hasPopUpBackImage", ""), this.menuHasPopUpBackImage);
     this.menuHasIconPlaceHolder = UIUtils.FromString(element.GetAttributeValue("hasIconPlaceholderImage", ""), this.menuHasIconPlaceHolder);
     this.menuSimple = UIUtils.FromString(element.GetAttributeValue("hasSimpleMenu", ""), this.menuSimple);
 }
Esempio n. 8
0
 /// <summary>
 /// Loads theme colro values from theme xml file.
 /// </summary>
 /// <param name="element">colors xml element.</param>
 internal void LoadColors(IXmlElement element)
 {
     this.ControlLight.UpdateColor(element.GetAttributeValue("ControlLight", ""), this);
     this.ControlDark.UpdateColor(element.GetAttributeValue("ControlDark", ""), this);
     this.ControlDarkDark.UpdateColor(element.GetAttributeValue("ControlDarkDark", ""), this);
     this.Control.UpdateColor(element.GetAttributeValue("Control", ""), this);
     this.Highlight.UpdateColor(element.GetAttributeValue("Highlight", ""), this);
     this.HighlightBorder.UpdateColor(element.GetAttributeValue("HighlightBorder", ""), this);
     this.TextDark.UpdateColor(element.GetAttributeValue("TextDark", ""), this);
     this.TextLight.UpdateColor(element.GetAttributeValue("TextLight", ""), this);
     this.BackLight.UpdateColor(element.GetAttributeValue("BackLight", ""), this);
     this.BackBorder.UpdateColor(element.GetAttributeValue("BackBorder", ""), this);
     this.BackLightLight.UpdateColor(element.GetAttributeValue("BackLightLight", ""), this);
     this.BorderDark.UpdateColor(element.GetAttributeValue("BorderDark", ""), this);
     this.WindowTitleStart.UpdateColor(element.GetAttributeValue("WindowTitleStart", ""), this);
     this.WindowTitleEnd.UpdateColor(element.GetAttributeValue("WindowTitleEnd", ""), this);
     this.Window.UpdateColor(element.GetAttributeValue("Window", ""), this);
 }
Esempio n. 9
0
 internal void LoadAttributes(IXmlElement element)
 {
     base.Name = element.GetAttributeValue("name", base.Name);
     this.text = element.GetAttributeValue("text", this.text);
     this.Icon = element.GetAttributeValue("icon", this.Icon);
 }
Esempio n. 10
0
File: Theme.cs Progetto: drme/thw-ui
        /// <summary>
        /// Loads control settings from xml file.
        /// </summary>
        /// <param name="element">xml file to load from.</param>
        private void LoadControl(IXmlElement element)
        {
            String controlName = element.GetAttributeValue("control", "");

            if (controlName.Length <= 0)
            {
                return;
            }

            ControlSettings controlSettings = new ControlSettings();

            controlSettings.Name              = controlName;
            controlSettings.ColorBack         = this.Colors.GetColor(element.GetAttributeValue("backColor", ""), Colors.Control);
            controlSettings.ColorBorderLight1 = this.Colors.GetColor(element.GetAttributeValue("borderLight1", ""), Colors.ControlLight);
            controlSettings.ColorBorderLight2 = this.Colors.GetColor(element.GetAttributeValue("borderLight2", ""), Colors.Control);
            controlSettings.ColorBorderDark1  = this.Colors.GetColor(element.GetAttributeValue("borderDark1", ""), Colors.ControlDark);
            controlSettings.ColorBorderDark2  = this.Colors.GetColor(element.GetAttributeValue("borderDark2", ""), Colors.ControlDarkDark);
            controlSettings.BordersFilePrefix = element.GetAttributeValue("imagesPrefix", "images/control_");
            controlSettings.Skinned           = UIUtils.FromString(element.GetAttributeValue("skinned", ""), this.skinned);
            controlSettings.BorderWidth       = UIUtils.FromString(element.GetAttributeValue("borderWidth", null), 2);
            controlSettings.BackImage         = element.GetAttributeValue("backImage", "");
            controlSettings.ControlSize       = UIUtils.FromString(element.GetAttributeValue("controlSize", null), controlSettings.ControlSize);

            this.controlsSettings[controlName] = controlSettings;
        }
Esempio n. 11
0
        public BitmapFont(UIEngine engine, String fileName, string fontName, int size, bool bold, bool italic) : base(fontName, size, bold, italic)
        {
            this.engine = engine;

            using (IXmlReader reader = this.engine.OpenXmlFile(fileName))
            {
                if (null != reader)
                {
                    IXmlElement root = reader.RootElement;

                    if ("font" == root.Name)
                    {
                        String name        = root.GetAttributeValue("name", "");
                        String textureName = root.GetAttributeValue("texture", "");
                        int    rowWidth    = int.Parse(root.GetAttributeValue("rowWidth", "0"));
                        int    rowHeight   = int.Parse(root.GetAttributeValue("rowHeight", "0"));
                        float  scaleW      = float.Parse(root.GetAttributeValue("scaleW", "1"));
                        float  scaleH      = float.Parse(root.GetAttributeValue("scaleH", "1"));

                        int[] widths = new int[rowWidth * rowHeight];

                        for (int i = 0; i < widths.Length; i++)
                        {
                            widths[i] = -1;
                        }

                        foreach (IXmlElement child in root.Elements)
                        {
                            if ("letter" == child.Name)
                            {
                                String c    = child.GetAttributeValue("char");
                                String code = child.GetAttributeValue("code");

                                Object cc = null;

                                if ((null != c) && (c.Length == 1))
                                {
                                    cc = c[0];
                                }
                                else if (null != code)
                                {
                                    cc = (char)int.Parse(code);
                                }

                                if ((null != cc) && ((int)(char)cc < widths.Length))
                                {
                                    int width = int.Parse(child.GetAttributeValue("Width", "-1"));

                                    if (width >= 0)
                                    {
                                        widths[(int)(char)cc] = width;
                                    }
                                }
                            }
                        }

                        IImage image = this.engine.CreateImage(textureName);

                        for (int y = 0; y < rowHeight; y++)
                        {
                            for (int x = 0; x < rowWidth; x++)
                            {
                                float w = (int)(image.Width / rowWidth);

                                int w1 = (int)w;

                                if (-1 != widths[y * rowWidth + x])
                                {
                                    w1 = widths[y * rowWidth + x];
                                }

                                float h  = (int)(image.Height / rowHeight);
                                float s1 = (float)(x * w) / (float)image.Width;
                                float s2 = (float)((x + 1) * w) / (float)image.Width;
                                float t1 = (float)(y * h) / (float)image.Height;
                                float t2 = (float)((y + 1) * h) / (float)image.Height;

                                this.letters.Add(new BitmapLetter(image, (int)(w * scaleW), (int)(h * scaleH), s1, t1, s2, t2, w1));
                            }
                        }
                    }

                    this.loaded = true;
                }
            }
        }
Esempio n. 12
0
File: Theme.cs Progetto: drme/thw-ui
        /// <summary>
        /// Loads control settings from xml file.
        /// </summary>
        /// <param name="element">xml file to load from.</param>
        private void LoadControl(IXmlElement element)
        {
            String controlName = element.GetAttributeValue("control", "");

            if (controlName.Length <= 0)
            {
                return;
            }

            ControlSettings controlSettings = new ControlSettings();

            controlSettings.Name = controlName;
            controlSettings.ColorBack = this.Colors.GetColor(element.GetAttributeValue("backColor", ""), Colors.Control);
            controlSettings.ColorBorderLight1 = this.Colors.GetColor(element.GetAttributeValue("borderLight1", ""), Colors.ControlLight);
            controlSettings.ColorBorderLight2 = this.Colors.GetColor(element.GetAttributeValue("borderLight2", ""), Colors.Control);
            controlSettings.ColorBorderDark1 = this.Colors.GetColor(element.GetAttributeValue("borderDark1", ""), Colors.ControlDark);
            controlSettings.ColorBorderDark2 = this.Colors.GetColor(element.GetAttributeValue("borderDark2", ""), Colors.ControlDarkDark);
            controlSettings.BordersFilePrefix = element.GetAttributeValue("imagesPrefix", "images/control_");
            controlSettings.Skinned = UIUtils.FromString(element.GetAttributeValue("skinned", ""), this.skinned);
            controlSettings.BorderWidth = UIUtils.FromString(element.GetAttributeValue("borderWidth", null), 2);
            controlSettings.BackImage = element.GetAttributeValue("backImage", "");
            controlSettings.ControlSize = UIUtils.FromString(element.GetAttributeValue("controlSize", null), controlSettings.ControlSize);

            this.controlsSettings[controlName] = controlSettings;
        }
Esempio n. 13
0
 /// <summary>
 /// Loads window theme settings from xml.
 /// </summary>
 /// <param name="element">xml element to load from.</param>
 internal void LoadWindow(IXmlElement element)
 {
     this.windowHasTitleImage = UIUtils.FromString(element.GetAttributeValue("hasTitleImage", "false"), this.windowHasTitleImage);
     this.windowBorderSize = UIUtils.FromString(element.GetAttributeValue("windowBorderSize"), this.windowBorderSize);
     this.windowBorderOffset = UIUtils.FromString(element.GetAttributeValue("windowBorderOffset"), this.windowBorderOffset);
     this.windowSplitImagePosition = UIUtils.FromString(element.GetAttributeValue("windowSplitImagePosition"), this.windowSplitImagePosition);
     this.windowSplitWidth = UIUtils.FromString(element.GetAttributeValue("windowSplitWidth"), this.windowSplitWidth);
     this.windowTitleHeight = UIUtils.FromString(element.GetAttributeValue("windowTitleHeight"), this.windowTitleHeight);
     this.windowSplitPosition = UIUtils.FromString(element.GetAttributeValue("windowSplitPosition"), this.windowSplitPosition);
     this.windowShadowSize = UIUtils.FromString(element.GetAttributeValue("windowShadowSize"), this.windowShadowSize);
 }