Beispiel #1
0
		public Skin(Manager manager, string name)
			: base(manager) {
			this.name = name;
			content = new ArchiveManager(Manager.Game.Services, GetArchiveLocation(name + Manager.SkinExtension));
			content.RootDirectory = GetFolder();
			doc = new SkinXmlDocument();
			controls = new SkinList<SkinControl>();
			fonts = new SkinList<SkinFont>();
			images = new SkinList<SkinImage>();
			cursors = new SkinList<SkinCursor>();
			attributes = new SkinList<SkinAttribute>();

			LoadSkin(null, content.UseArchive);

			string folder = GetAddonsFolder();
			if (folder == "") {
				content.UseArchive = true;
				folder = "Addons\\";
			} else {
				content.UseArchive = false;
			}

			string[] addons = content.GetDirectories(folder);

			if (addons != null && addons.Length > 0) {
				for (int i = 0; i < addons.Length; i++) {
					DirectoryInfo d = new DirectoryInfo(GetAddonsFolder() + addons[i]);
					if (!((d.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) || content.UseArchive) {
						LoadSkin(addons[i].Replace("\\", ""), content.UseArchive);
					}
				}
			}
		}
Beispiel #2
0
        public Skin(Manager manager, string name)
            : base(manager)
        {
            this.name             = name;
            content               = new ArchiveManager(Manager.Game.Services, GetArchiveLocation(name + Manager.SkinExtension));
            content.RootDirectory = GetFolder();
            doc        = new SkinXmlDocument();
            controls   = new SkinList <SkinControl>();
            fonts      = new SkinList <SkinFont>();
            images     = new SkinList <SkinImage>();
            cursors    = new SkinList <SkinCursor>();
            attributes = new SkinList <SkinAttribute>();

            LoadSkin(null, content.UseArchive);

            string folder = GetAddonsFolder();

            if (folder == "")
            {
                content.UseArchive = true;
                folder             = "Addons\\";
            }
            else
            {
                content.UseArchive = false;
            }

            string[] addons = content.GetDirectories(folder);

            if (addons != null && addons.Length > 0)
            {
                for (int i = 0; i < addons.Length; i++)
                {
                    DirectoryInfo d = new DirectoryInfo(GetAddonsFolder() + addons[i]);
                    if (!((d.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) || content.UseArchive)
                    {
                        LoadSkin(addons[i].Replace("\\", ""), content.UseArchive);
                    }
                }
            }
        }
Beispiel #3
0
		private void LoadSkin(string addon, bool archive) {
			try {
				bool isaddon = addon != null && addon != "";
				string file = GetFolder();
				if (isaddon) {
					file = GetAddonsFolder() + addon + "\\";
				}
				file += "Skin";

				file = archive ? file : Path.GetFullPath(file);
				doc = content.Load<SkinXmlDocument>(file);

				XmlElement e = doc["Skin"];
				if (e != null) {
					string xname = ReadAttribute(e, "Name", null, true);
					if (!isaddon) {
						if (name.ToLower() != xname.ToLower()) {
							throw new Exception("Skin name defined in the skin file doesn't match requested skin.");
						} else {
							name = xname;
						}
					} else {
						if (addon.ToLower() != xname.ToLower()) {
							throw new Exception("Skin name defined in the skin file doesn't match addon name.");
						}
					}

					Version xversion = null;
					try {
						xversion = new Version(ReadAttribute(e, "Version", "0.0.0.0", false));
					} catch (Exception x) {
						throw new Exception("Unable to resolve skin file version. " + x.Message);
					}

					if (xversion != Manager._SkinVersion) {
						throw new Exception("This version of Window Library Controls can only read skin files in version of " + Manager._SkinVersion.ToString() + ".");
					} else if (!isaddon) {
						version = xversion;
					}

					if (!isaddon) {
						XmlElement ei = e["Info"];
						if (ei != null) {
							if (ei["Name"] != null)
								info.Name = ei["Name"].InnerText;
							if (ei["Description"] != null)
								info.Description = ei["Description"].InnerText;
							if (ei["Author"] != null)
								info.Author = ei["Author"].InnerText;
							if (ei["Version"] != null)
								info.Version = ei["Version"].InnerText;
						}
					}

					LoadImages(addon, archive);
					LoadFonts(addon, archive);
					LoadCursors(addon, archive);
					LoadSkinAttributes();
					LoadControls();
				}
			} catch (Exception x) {
				throw new Exception("Unable to load skin file. " + x.Message);
			}
		}
Beispiel #4
0
        private void LoadSkin(string addon, bool archive)
        {
            try {
                bool   isaddon = addon != null && addon != "";
                string file    = GetFolder();
                if (isaddon)
                {
                    file = GetAddonsFolder() + addon + "\\";
                }
                file += "Skin";

                file = archive ? file : Path.GetFullPath(file);
                doc  = content.Load <SkinXmlDocument>(file);

                XmlElement e = doc["Skin"];
                if (e != null)
                {
                    string xname = ReadAttribute(e, "Name", null, true);
                    if (!isaddon)
                    {
                        if (name.ToLower() != xname.ToLower())
                        {
                            throw new Exception("Skin name defined in the skin file doesn't match requested skin.");
                        }
                        else
                        {
                            name = xname;
                        }
                    }
                    else
                    {
                        if (addon.ToLower() != xname.ToLower())
                        {
                            throw new Exception("Skin name defined in the skin file doesn't match addon name.");
                        }
                    }

                    Version xversion = null;
                    try {
                        xversion = new Version(ReadAttribute(e, "Version", "0.0.0.0", false));
                    } catch (Exception x) {
                        throw new Exception("Unable to resolve skin file version. " + x.Message);
                    }

                    if (xversion != Manager._SkinVersion)
                    {
                        throw new Exception("This version of Window Library Controls can only read skin files in version of " + Manager._SkinVersion.ToString() + ".");
                    }
                    else if (!isaddon)
                    {
                        version = xversion;
                    }

                    if (!isaddon)
                    {
                        XmlElement ei = e["Info"];
                        if (ei != null)
                        {
                            if (ei["Name"] != null)
                            {
                                info.Name = ei["Name"].InnerText;
                            }
                            if (ei["Description"] != null)
                            {
                                info.Description = ei["Description"].InnerText;
                            }
                            if (ei["Author"] != null)
                            {
                                info.Author = ei["Author"].InnerText;
                            }
                            if (ei["Version"] != null)
                            {
                                info.Version = ei["Version"].InnerText;
                            }
                        }
                    }

                    LoadImages(addon, archive);
                    LoadFonts(addon, archive);
                    LoadCursors(addon, archive);
                    LoadSkinAttributes();
                    LoadControls();
                }
            } catch (Exception x) {
                throw new Exception("Unable to load skin file. " + x.Message);
            }
        }