Beispiel #1
0
 public static void FullscreenOff()
 {
     if (fullscreen)
     {
         try
         {
             windowPosition.FullscreenPosition = WindowPosition.Serialize(Form1.thisForm);
             fullscreen = false;
             if (dxDevice != null)
             {
                 dxDevice.RestoreDisplayMode();
             }
             WindowPosition.Deserialize(Form1.thisForm, Global.windowPosition.MainFormPosition, true);
             if (Form1.thisForm.formOptions != null)
             {
                 WindowPosition.Deserialize(Form1.thisForm.formOptions, Global.windowPosition.OptionsFormPosition, true);
             }
             if (FormMonitor.isCreated())
             {
                 WindowPosition.Deserialize(FormMonitor.instance, Global.windowPosition.MonitorFormPosition, true);
             }
             Form1.thisForm.TopMost = Global.isTopMost();
             PInvokeFunc.SetWindowPos(gameWindow, IntPtr.Zero, oldGameLocation.X, oldGameLocation.Y, 0, 0, 21);
         }
         catch (Exception)
         {
         }
     }
 }
Beispiel #2
0
        public void UpdatePos()
        {
            int border = (Form1.thisForm.Width - Form1.thisForm.ClientSize.Width) / 2;

            PInvokeFunc.SetWindowPos(Handle, Form1.thisForm.Handle, Form1.thisForm.Left + border, Form1.thisForm.Top + (Form1.thisForm.Height - border - Form1.thisForm.ClientSize.Height), Form1.thisForm.ClientSize.Width, Form1.thisForm.ClientSize.Height, 16);
            WindowState = Form1.thisForm.WindowState;
        }
Beispiel #3
0
        public static void FullscreenOn()
        {
            if (gameWindow == IntPtr.Zero)
            {
                IntPtr[] possibleWindows = GetPossibleWindows();
                if (possibleWindows.Length == 0)
                {
                    return;
                }
                else if (possibleWindows.Length == 1)
                {
                    gameWindow = possibleWindows[0];
                }
                else
                {
                    FormSelectApp.instance.UpdateWindowsList(possibleWindows);
                    if (FormSelectApp.instance.ShowDialog() == DialogResult.OK)
                    {
                        gameWindow = FormSelectApp.instance.GetSelectedWindow();
                        if (gameWindow == IntPtr.Zero)
                        {
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                }
            }
            Rectangle rect  = PInvokeFunc.GetWindowRect(gameWindow);
            int       w     = rect.Width;
            int       h     = rect.Height;
            int       fullX = -1;
            int       fullY = -1;

            int[,] sizes = { {  640, 480 }, {  800,  600 }, { 1024,  768 }, { 1152,  720 }, { 1152, 864 }, { 1280, 720 },
                             { 1280, 768 }, { 1280,  800 }, { 1280,  960 }, { 1280, 1024 }, { 1360, 768 }, { 1440, 900 },
                             { 1600, 900 }, { 1600, 1024 }, { 1600, 1200 } };
            int minD = int.MaxValue;

            for (int i = 0; i <= sizes.GetUpperBound(0); ++i)
            {
                int dx = w - sizes[i, 0];
                int dy = h - sizes[i, 1];
                int d  = dx * dx + dy * dy;
                if (d <= minD)
                {
                    minD  = d;
                    fullX = sizes[i, 0];
                    fullY = sizes[i, 1];
                }
            }

            Global.windowPosition.MainFormPosition = WindowPosition.Serialize(Form1.thisForm);
            if (Form1.thisForm.formOptions != null)
            {
                Global.windowPosition.OptionsFormPosition = WindowPosition.Serialize(Form1.thisForm.formOptions);
            }
            if (FormMonitor.isCreated())
            {
                Global.windowPosition.MonitorFormPosition = WindowPosition.Serialize(FormMonitor.instance);
            }
            oldGameLocation = new Point(rect.Left, rect.Top);
            fullscreen      = true;
            try
            {
                if (dxDevice == null)
                {
                    dxDevice = new Device();
                }
                dxDevice.SetDisplayMode(fullX, fullY, 32, 0, true);
                int border = (rect.Width - fullX) / 2;
                PInvokeFunc.SetWindowPos(gameWindow, IntPtr.Zero, -border, fullY - rect.Height + border, 0, 0, 5);
                WindowPosition.Deserialize(Form1.thisForm, Global.windowPosition.FullscreenPosition);
                if (Form1.thisForm.Width > fullX)
                {
                    Form1.thisForm.Width = fullX;
                }
                if (Form1.thisForm.Height > fullY)
                {
                    Form1.thisForm.Height = fullY;
                }
                if (Form1.thisForm.Left + Form1.thisForm.Width > fullX)
                {
                    Form1.thisForm.Left = fullX - Form1.thisForm.Width;
                }
                if (Form1.thisForm.Top + Form1.thisForm.Height > fullY)
                {
                    Form1.thisForm.Top = fullY - Form1.thisForm.Height;
                }
                Form1.thisForm.TopMost = true;
            }
            catch (Exception)
            {
                FullscreenOff();
            }
        }
Beispiel #4
0
 public void _Show()
 {
     PInvokeFunc.ShowWindow(this.Handle, PInvokeFunc.SW_SHOWNOACTIVATE);
     PInvokeFunc.SetWindowPos(this.Handle, new IntPtr(-1), 0, 0, 0, 0, 19);
 }