Esempio n. 1
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;
        }
Esempio n. 2
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);
                }
            }
        }