/// <param name="disposing"></param> /// </summary> /// Releases the skin's resources. /// </summary> protected override void Dispose(bool disposing) { if (disposing) { if (content != null) { content.Unload(); content.Dispose(); content = null; } } base.Dispose(disposing); }
/// <returns>Returns the root control of the layout file with all child controls initialized.</returns> /// <param name="asset">Name of the layout XML asset. (Default asset names are file names without extensions.)</param> /// <param name="manager">GUI manager responsible for the controls contained in the layout XML file.</param> /// <summary> /// Reads the specified layout XML file asset. /// </summary> public static Container Load(Manager manager, string asset) { Container win = null; var doc = new LayoutXmlDocument(); var content = new ArchiveManager(manager.Game.Services); try { content.RootDirectory = manager.LayoutDirectory; #if (!XBOX && !XBOX_FAKE) var file = content.RootDirectory + asset; if (File.Exists(file)) { doc.Load(file); } else #endif { doc = content.Load <LayoutXmlDocument>(asset); } if (doc != null && doc["Layout"]["Controls"] != null && doc["Layout"]["Controls"].HasChildNodes) { var node = doc["Layout"]["Controls"].GetElementsByTagName("Control").Item(0); var cls = node.Attributes["Class"].Value; var type = Type.GetType(cls); if (type == null) { cls = "MonoForce.Controls." + cls; type = Type.GetType(cls); } win = (Container)LoadControl(manager, node, type, null); } } finally { content.Dispose(); } return(win); }
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); var folder = GetAddonsFolder(); if (folder == "") { content.UseArchive = true; folder = "Addons\\"; } else { content.UseArchive = false; } var addons = content.GetDirectories(folder); if (addons != null && addons.Length > 0) { for (var i = 0; i < addons.Length; i++) { var d = new DirectoryInfo(GetAddonsFolder() + addons[i]); if (!((d.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden) || content.UseArchive) { LoadSkin(addons[i].Replace("\\", ""), content.UseArchive); } } } }