Exemplo n.º 1
0
 public WindowsGameForm()
 {
     base.SuspendLayout();
     base.AutoScaleDimensions = new SizeF(6f, 13f);
     base.AutoScaleMode       = AutoScaleMode.Font;
     base.CausesValidation    = false;
     base.ClientSize          = new Size(0x124, 0x10a);
     base.Name               = "GameForm";
     this.Text               = "GameForm";
     base.ResizeBegin       += new EventHandler(this.Form_ResizeBegin);
     base.ClientSizeChanged += new EventHandler(this.Form_ClientSizeChanged);
     base.Resize            += new EventHandler(this.Form_Resize);
     base.LocationChanged   += new EventHandler(this.Form_LocationChanged);
     base.ResizeEnd         += new EventHandler(this.Form_ResizeEnd);
     base.MouseEnter        += new EventHandler(this.Form_MouseEnter);
     base.MouseLeave        += new EventHandler(this.Form_MouseLeave);
     base.ResumeLayout(false);
     try
     {
         this.freezeOurEvents   = true;
         this.resizeWindowState = base.WindowState;
         this.screen            = WindowsGameWindow.ScreenFromHandle(base.Handle);
         base.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, false);
         base.ClientSize = new Size(GameWindow.DefaultClientWidth, GameWindow.DefaultClientHeight);
         this.UpdateBorderStyle();
     }
     finally
     {
         this.freezeOurEvents = false;
     }
 }
Exemplo n.º 2
0
 public WindowsGameHost(Game game)
 {
     this.game = game;
     this.LockThreadToProcessor();
     this.gameWindow                = new WindowsGameWindow();
     Mouse.WindowHandle             = this.gameWindow.Handle;
     this.gameWindow.IsMouseVisible = game.IsMouseVisible;
     this.gameWindow.Activated     += new EventHandler(this.GameWindowActivated);
     this.gameWindow.Deactivated   += new EventHandler(this.GameWindowDeactivated);
     this.gameWindow.Suspend       += new EventHandler(this.GameWindowSuspend);
     this.gameWindow.Resume        += new EventHandler(this.GameWindowResume);
 }
Exemplo n.º 3
0
        public Game()
        {
            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();

            _view      = new WindowsGameWindow();
            _view.Game = this;

            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime   = new GameTime();
        }
Exemplo n.º 4
0
        public WindowsGamePlatform(Game game)
            : base(game)
        {
            _view       = new WindowsGameWindow();
            _view.Game  = game;
            this.Window = _view;

            // Setup our OpenALSoundController to handle our SoundBuffer pools
            soundControllerInstance = OpenALSoundController.GetInstance;

            //Initialize cursor visibility based on default value
            OnIsMouseVisibleChanged();
        }
Exemplo n.º 5
0
        internal void EndScreenDeviceChange(string screenDeviceName, int clientWidth, int clientHeight)
        {
            if (!this.deviceChangeWillBeFullScreen.HasValue)
            {
                throw new InvalidOperationException(Microsoft.Xna.Framework.Resources.MustCallBeginDeviceChange);
            }
            bool flag = false;

            if (this.deviceChangeWillBeFullScreen.Value)
            {
                Screen screen = WindowsGameWindow.ScreenFromDeviceName(screenDeviceName);
                System.Drawing.Rectangle bounds = Screen.GetBounds(new System.Drawing.Point(screen.Bounds.X, screen.Bounds.Y));
                if (!this.isFullScreenMaximized)
                {
                    flag                 = true;
                    base.TopMost         = true;
                    base.FormBorderStyle = FormBorderStyle.None;
                    base.WindowState     = FormWindowState.Normal;
                    base.BringToFront();
                }
                base.Location              = new System.Drawing.Point(bounds.X, bounds.Y);
                base.ClientSize            = new Size(bounds.Width, bounds.Height);
                this.isFullScreenMaximized = true;
            }
            else
            {
                if (this.isFullScreenMaximized)
                {
                    flag = true;
                    base.BringToFront();
                }
                this.ResizeWindow(screenDeviceName, clientWidth, clientHeight, this.centerScreen);
            }
            if (this.deviceChangeChangedVisible)
            {
                base.Visible = this.oldVisible;
            }
            if (flag && (this.oldClientSize != base.ClientSize))
            {
                this.OnUserResized(true);
            }
            this.deviceChangeWillBeFullScreen = null;
        }
Exemplo n.º 6
0
 private bool IsWindowOnAdapter(IntPtr windowHandle, GraphicsAdapter adapter)
 {
     return(WindowsGameWindow.ScreenFromAdapter(adapter) == WindowsGameWindow.ScreenFromHandle(windowHandle));
 }
Exemplo n.º 7
0
        public Game()
        {
            _instance = this;

            // Initialize collections
            _services = new GameServiceContainer();
            _gameComponentCollection = new GameComponentCollection();

            _view = new WindowsGameWindow();
            _view.Game = this;

            // Initialize GameTime
            _updateGameTime = new GameTime();
            _drawGameTime = new GameTime();
        }
Exemplo n.º 8
0
        //F**K YOU MICROSOFT

        /*protected override bool ProcessDialogKey(Keys keyData)
         * {
         *  //Keys keys = keyData & Keys.KeyCode;
         *  //Keys keys2 = keyData & Keys.Alt;
         *  return (keyData == Keys.Alt) || base.ProcessDialogKey(keyData);
         * }*/

        private void ResizeWindow(string screenDeviceName, int clientWidth, int clientHeight, bool center)
        {
            int    x;
            int    y;
            Screen screen = WindowsGameWindow.ScreenFromDeviceName(screenDeviceName);

            System.Drawing.Rectangle bounds = Screen.GetBounds(new System.Drawing.Point(screen.Bounds.X, screen.Bounds.Y));
            if (screenDeviceName != WindowsGameWindow.DeviceNameFromScreen(this.DeviceScreen))
            {
                x = bounds.X;
                y = bounds.Y;
            }
            else
            {
                x = this.screen.Bounds.X;
                y = this.screen.Bounds.Y;
            }
            if (this.isFullScreenMaximized)
            {
                Size size = this.SizeFromClientSize(new Size(clientWidth, clientHeight));
                if (this.savedWindowState == FormWindowState.Maximized)
                {
                    int num3 = (this.savedRestoreBounds.X - this.screen.Bounds.X) + x;
                    int num4 = (this.savedRestoreBounds.Y - this.screen.Bounds.Y) + y;
                    this.SetBoundsCore(num3, num4, this.savedRestoreBounds.Width, this.savedRestoreBounds.Height, BoundsSpecified.All);
                }
                else if (center)
                {
                    int num5 = (x + (bounds.Width / 2)) - (size.Width / 2);
                    int num6 = (y + (bounds.Height / 2)) - (size.Height / 2);
                    this.SetBoundsCore(num5, num6, size.Width, size.Height, BoundsSpecified.All);
                }
                else
                {
                    int num7 = (this.savedBounds.X - this.screen.Bounds.X) + x;
                    int num8 = (this.savedBounds.Y - this.screen.Bounds.Y) + y;
                    this.SetBoundsCore(num7, num8, size.Width, size.Height, BoundsSpecified.All);
                }
                base.WindowState           = this.savedWindowState;
                this.isFullScreenMaximized = false;
            }
            else if (base.WindowState == FormWindowState.Normal)
            {
                int num9;
                int num10;
                if (center)
                {
                    Size size2 = this.SizeFromClientSize(new Size(clientWidth, clientHeight));
                    num9  = (x + (bounds.Width / 2)) - (size2.Width / 2);
                    num10 = (y + (bounds.Height / 2)) - (size2.Height / 2);
                }
                else
                {
                    num9  = (x + base.Bounds.X) - this.screen.Bounds.X;
                    num10 = (y + base.Bounds.Y) - this.screen.Bounds.Y;
                }
                if ((num9 != base.Location.X) || (num10 != base.Location.Y))
                {
                    base.Location = new System.Drawing.Point(num9, num10);
                }
                if ((base.ClientSize.Width != clientWidth) || (base.ClientSize.Height != clientHeight))
                {
                    base.ClientSize = new Size(clientWidth, clientHeight);
                }
            }
        }
Exemplo n.º 9
0
		public WindowsGamePlatform(Game game)
            : base(game)
        {
            _view = new WindowsGameWindow();
            _view.Game = game;
            this.Window = _view;
			
			// Setup our OpenALSoundController to handle our SoundBuffer pools
			soundControllerInstance = OpenALSoundController.GetInstance;

            //Initialize cursor visibility based on default value
            OnIsMouseVisibleChanged();
        }