示例#1
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);
		}
示例#2
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());
		}