示例#1
0
文件: Skin.cs 项目: GodLesZ/svn-dump
		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);
					}
				}
			}
		}
示例#2
0
文件: Skin.cs 项目: GodLesZ/svn-dump
		protected override void Dispose(bool disposing) {
			if (disposing) {
				if (content != null) {
					content.Unload();
					content.Dispose();
					content = null;
				}
			}

			base.Dispose(disposing);
		}
示例#3
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (content != null)
                {
                    content.Unload();
                    content.Dispose();
                    content = null;
                }
            }

            base.Dispose(disposing);
        }
示例#4
0
        public static Container Load(Manager manager, string asset)
        {
            Container         win     = null;
            LayoutXmlDocument doc     = new LayoutXmlDocument();
            ArchiveManager    content = new ArchiveManager(manager.Game.Services);

            try {
                content.RootDirectory = manager.LayoutDirectory;

#if (!XBOX && !XBOX_FAKE)
                string 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)
                {
                    XmlNode node = doc["Layout"]["Controls"].GetElementsByTagName("Control").Item(0);
                    string  cls  = node.Attributes["Class"].Value;
                    Type    type = Type.GetType(cls);

                    if (type == null)
                    {
                        cls  = "GodLesZ.Library.Xna.WindowLibrary.Controls." + cls;
                        type = Type.GetType(cls);
                    }

                    win = (Container)LoadControl(manager, node, type, null);
                }
            } finally {
                content.Dispose();
            }

            return(win);
        }
示例#5
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);
                    }
                }
            }
        }
示例#6
0
		public static Container Load(Manager manager, string asset) {
			Container win = null;
			LayoutXmlDocument doc = new LayoutXmlDocument();
			ArchiveManager content = new ArchiveManager(manager.Game.Services);

			try {
				content.RootDirectory = manager.LayoutDirectory;

#if (!XBOX && !XBOX_FAKE)

				string 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) {
					XmlNode node = doc["Layout"]["Controls"].GetElementsByTagName("Control").Item(0);
					string cls = node.Attributes["Class"].Value;
					Type type = Type.GetType(cls);

					if (type == null) {
						cls = "GodLesZ.Library.Xna.WindowLibrary.Controls." + cls;
						type = Type.GetType(cls);
					}

					win = (Container)LoadControl(manager, node, type, null);
				}

			} finally {
				content.Dispose();
			}

			return win;
		}
示例#7
0
		protected override void Dispose(bool disposing) {
			if (disposing) {
				this.disposing = true;

				// Recursively disposing all controls added to the manager and its child controls.
				if (controls != null) {
					int c = controls.Count;
					for (int i = 0; i < c; i++) {
						if (controls.Count > 0)
							controls[0].Dispose();
					}
				}

				// Disposing all components added to manager.
				if (components != null) {
					int c = components.Count;
					for (int i = 0; i < c; i++) {
						if (components.Count > 0)
							components[0].Dispose();
					}
				}

				if (content != null) {
					content.Unload();
					content.Dispose();
					content = null;
				}

				if (renderer != null) {
					renderer.Dispose();
					renderer = null;
				}
				if (input != null) {
					input.Dispose();
					input = null;
				}
			}
			base.Dispose(disposing);
		}
示例#8
0
		/// <summary>
		/// Initializes a new instance of the Manager class.
		/// </summary>
		/// <param name="game">
		/// The Game class.
		/// </param>
		/// <param name="graphics">
		/// The GraphicsDeviceManager class provided by the Game class.
		/// </param>
		/// <param name="skin">
		/// The name of the skin being loaded at the start.
		/// </param>
		public Manager(Game game, GraphicsDeviceManager graphics, string skin)
			: base(game) {
			disposing = false;

			AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(HandleUnhadledExceptions);

#if (!XBOX && !XBOX_FAKE)
			menuDelay = SystemInformation.MenuShowDelay;
			doubleClickTime = SystemInformation.DoubleClickTime;
#endif

#if (!XBOX && !XBOX_FAKE)
			window = (Form)Form.FromHandle(Game.Window.Handle);
			window.FormClosing += new FormClosingEventHandler(Window_FormClosing);
#endif

			content = new ArchiveManager(Game.Services);
			input = new InputSystem(this, new InputOffset(0, 0, 1f, 1f));
			components = new List<Component>();
			controls = new ControlsList();
			orderList = new ControlsList();

			this.graphics = graphics;
			graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(PrepareGraphicsDevice);

			skinName = skin;

#if (XBOX_FAKE)
			game.Window.Title += " (XBOX_FAKE)";
#endif

			states.Buttons = new Control[32];
			states.Click = -1;
			states.Over = null;

			input.MouseDown += new MouseEventHandler(MouseDownProcess);
			input.MouseUp += new MouseEventHandler(MouseUpProcess);
			input.MousePress += new MouseEventHandler(MousePressProcess);
			input.MouseMove += new MouseEventHandler(MouseMoveProcess);

			input.GamePadDown += new GamePadEventHandler(GamePadDownProcess);
			input.GamePadUp += new GamePadEventHandler(GamePadUpProcess);
			input.GamePadPress += new GamePadEventHandler(GamePadPressProcess);

			input.KeyDown += new KeyEventHandler(KeyDownProcess);
			input.KeyUp += new KeyEventHandler(KeyUpProcess);
			input.KeyPress += new KeyEventHandler(KeyPressProcess);

			keyboardLayouts.Add(new KeyboardLayout());
			keyboardLayouts.Add(new CzechKeyboardLayout());
			keyboardLayouts.Add(new GermanKeyboardLayout());
		}