using Remontor.Setting;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Remontor.Connector
{
    internal class DobleMonFull : IModeMon
    {
        [DllImport("user32.dll")]
        static extern bool MoveWindow(IntPtr Handle, int x, int y, int w, int h, bool repaint);

        private bool Chanded = false;
        public int OldWidth, OldHeight;
        public Point OldPoint;
        public FormWindowState OldState;
        private int over = 0;
        public DobleMonFull()
        {
            OldWidth = SConnector.FormMain.Bounds.Width;
            OldHeight = SConnector.FormMain.Height;
            OldState = SConnector.FormMain.WindowState;
            OldPoint = SConnector.FormMain.Location;
        }
        public override void Resize(Process Proc, Control View)
        {
            if (over == 0)
            {
                over = 1;
            }
            else
            {
                over = 0;
            }
            if (Chanded) return;
            Chanded = true;
            SConnector.FormMain.WindowState = FormWindowState.Normal;
            Chanded = false;
            SConnector.FormMain.Width = SGlobalSetting.settingApp.WidthDoble;
            SConnector.FormMain.Height = SGlobalSetting.settingApp.HeightDoble;
            SConnector.FormMain.Location = new System.Drawing.Point(SGlobalSetting.settingApp.xPosDoble, SGlobalSetting.settingApp.yPosDoble);
            MoveWindow(Proc.MainWindowHandle, View.Bounds.X, View.Bounds.Y + 9, View.Bounds.Width, View.Bounds.Height - 9 + over, true);
        }

        public override IModeMon Change(IModeMon Mode)
        {
           
            if (!(Mode is DobleMonFull))
            {
                Chanded = true; 
                SConnector.FormMain.WindowState = OldState;
                SConnector.FormMain.Width = OldWidth;
                SConnector.FormMain.Height = OldHeight;
                SConnector.FormMain.Location = OldPoint;
                Chanded = false;
            }
            else
            {
                return this;
            }
            return Mode;
        }
    }
}
