public Settings(Main mF, Config cG, Overlay oF)
        {
            InitializeComponent();
            panel_cursorPanel.Paint += new PaintEventHandler(CursorPreviewPaint);
            mainForm    = mF;
            config      = cG;
            overlayForm = oF;

            // Overlay tab setup
            if (config.disableOverlay)
            {
                checkBox_disableOverlay.Checked = true;
            }
            if (config.allScreens)
            {
                checkBox_allScreens.Checked = true;
            }
            if (config.manualOverlayOverride)
            {
                checkBox_manualOverlayOverride.Checked = true;
            }
            else
            {
                textBox_overlayPositionX.Enabled = false;
                textBox_overlayPositionY.Enabled = false;
                textBox_overlaySizeX.Enabled     = false;
                textBox_overlaySizeY.Enabled     = false;
            }
            Rectangle ob = config.overrideBounds;

            textBox_overlayPositionX.Text = ob.Location.X.ToString();
            textBox_overlayPositionY.Text = ob.Location.Y.ToString();
            textBox_overlaySizeX.Text     = ob.Width.ToString();
            textBox_overlaySizeY.Text     = ob.Height.ToString();

            // Cursor tab
            if (config.disableCatchUp)
            {
                checkBox_disableCatchUp.Checked = true;
            }
            if (config.snapToCursor)
            {
                checkBox_snapToCursor.Checked = true;
            }
            switch (overlayForm.cursorType)
            {
            case Overlay.CursorType.Bullseye:
                radioButton_bullseye.Checked = true;
                break;

            case Overlay.CursorType.Circle:
                radioButton_circle.Checked = true;
                break;

            case Overlay.CursorType.Crosshair:
                radioButton_crosshair.Checked = true;
                break;

            case Overlay.CursorType.Cursor:
                radioButton_cursor.Checked = true;
                break;

            case Overlay.CursorType.TinyCursor:
                radioButton_tinyCursor.Checked = true;
                break;

            case Overlay.CursorType.Pen:
                radioButton_pen.Checked = true;
                break;
            }
            button_mainColor.BackColor = overlayForm.cursorColor;
            button_fillColor.BackColor = overlayForm.cursorFillColor;

            // Tablet tab
            if (config.disableAutoDetection)
            {
                checkBox_disableAutoDetection.Checked = true;
            }
            if (mainForm.smoothingOn)
            {
                checkBox_disableAutoDetection.Enabled = false;
            }
            int t = config.tolerance;

            textBox_tolerance.Text = t.ToString();
            if (config.tabletOffsetOverride)
            {
                checkBox_tabletOffsetOverride.Checked = true;
            }
            else
            {
                textBox_tabletOffsetX.Enabled = false;
                textBox_tabletOffsetY.Enabled = false;
            }
            Point co = config.tabletOffset;

            textBox_tabletOffsetX.Text = co.X.ToString();
            textBox_tabletOffsetY.Text = co.Y.ToString();

            // Hotkey tab
            KeysConverter c = new KeysConverter();
            string        mod;

            string[] ms;
            Keys     k;

            Hotkey.KeyModifiers m;
            k = (Keys)c.ConvertFromString(config.hotkeys[0]);
            if (k.ToString() != "None")
            {
                m   = Hotkey.GetModifiers(k, out k);
                mod = "";
                ms  = m.ToString().Split(new[] { ", " }, StringSplitOptions.None);
                foreach (string mm in ms)
                {
                    mod += mm + "+";
                }
                textBox_hotkeySmoothOnOff.Text = mod + k;
            }
            k = (Keys)c.ConvertFromString(config.hotkeys[1]);
            if (k.ToString() != "None")
            {
                m   = Hotkey.GetModifiers(k, out k);
                mod = "";
                ms  = m.ToString().Split(new[] { ", " }, StringSplitOptions.None);
                foreach (string mm in ms)
                {
                    mod += mm + "+";
                }
                textBox_hotkeyOverlayOnOff.Text = mod + k;
            }
            k = (Keys)c.ConvertFromString(config.hotkeys[2]);
            if (k.ToString() != "None")
            {
                m   = Hotkey.GetModifiers(k, out k);
                mod = "";
                ms  = m.ToString().Split(new[] { ", " }, StringSplitOptions.None);
                foreach (string mm in ms)
                {
                    mod += mm + "+";
                }
                textBox_hotkeyToggleDisplay.Text = mod + k;
            }
            k = (Keys)c.ConvertFromString(config.hotkeys[3]);
            if (k.ToString() != "None")
            {
                m   = Hotkey.GetModifiers(k, out k);
                mod = "";
                ms  = m.ToString().Split(new[] { ", " }, StringSplitOptions.None);
                foreach (string mm in ms)
                {
                    mod += mm + "+";
                }
                textBox_hotkeyTabletMode.Text = mod + k;
            }
            k = (Keys)c.ConvertFromString(config.hotkeys[4]);
            if (k.ToString() != "None")
            {
                m   = Hotkey.GetModifiers(k, out k);
                mod = "";
                ms  = m.ToString().Split(new[] { ", " }, StringSplitOptions.None);
                foreach (string mm in ms)
                {
                    mod += mm + "+";
                }
                textBox_hotkeyStrengthUp.Text = mod + k;
            }
            k = (Keys)c.ConvertFromString(config.hotkeys[5]);
            if (k.ToString() != "None")
            {
                m   = Hotkey.GetModifiers(k, out k);
                mod = "";
                ms  = m.ToString().Split(new[] { ", " }, StringSplitOptions.None);
                foreach (string mm in ms)
                {
                    mod += mm + "+";
                }
                textBox_hotkeyStrengthDown.Text = mod + k;
            }
        }
        public void LoadConfig(bool def = false)
        {
            if (def)
            {
                tabletOffset           = new Point(0, 0);
                overrideBounds         = new Rectangle(0, 0, 0, 0);
                smoothingStrength      = 30;
                smoothingInterpolation = 4;
                overlayScreen          = 0;
                tolerance             = 300;
                manualInterpolation   = false;
                stayOnTop             = false;
                disableOverlay        = false;
                allScreens            = false;
                manualOverlayOverride = false;
                disableCatchUp        = false;
                snapToCursor          = false;
                smoothOnDraw          = false;
                tabletOffsetOverride  = false;
                disableAutoDetection  = false;
                hotkeys[0]            = "None";
                hotkeys[1]            = "None";
                hotkeys[2]            = "None";
                hotkeys[3]            = "None";
                hotkeys[4]            = "None";
                hotkeys[5]            = "None";

                // Main window resetting
                mainForm.checkBox_smoothOnDraw.Checked           = true;
                mainForm.checkBox_stayOnTop.Checked              = true;
                mainForm.checkBox_tabletMode.Checked             = false;
                mainForm.checkBox_tabletMode.Enabled             = false;
                mainForm.checkBox_manualInterpolation.Checked    = false;
                mainForm.trackBar_smoothingInterpolation.Enabled = false;
                mainForm.textBox_smoothingInterpolation.Enabled  = false;
                mainForm.textBox_smoothingInterpolation.Text     = smoothingInterpolation.ToString();
                mainForm.textBox_smoothingStrength.Text          = smoothingStrength.ToString();
                mainForm.checkBox_smoothOnDraw.Checked           = false;
                mainForm.TopMost = false;

                // Cursor and overlay resetting
                overlayForm.cursorColor     = Color.FromArgb(128, 128, 128);
                overlayForm.cursorFillColor = Color.FromArgb(255, 255, 254);
                overlayForm.cursorType      = Overlay.CursorType.Bullseye;
                overlayForm.Show();
                overlayForm.Bounds = Screen.PrimaryScreen.Bounds;
                mainForm.button_colorDialog.BackColor = overlayForm.cursorColor;

                // Hotkey resetting
                for (int i = 0; i < mainForm.hotKeyHandling.Count(); i++)
                {
                    try {
                        mainForm.hotKeyHandling[i].Dispose();
                    }
                    catch {
                        // Nothing to dispose!
                    }
                }
            }
            else
            {
                try {
                    Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                    // Main window loading
                    smoothingStrength      = int.Parse(config.AppSettings.Settings["Strength"].Value);
                    smoothingInterpolation = int.Parse(config.AppSettings.Settings["Interpolation"].Value);
                    manualInterpolation    = bool.Parse(config.AppSettings.Settings["Manual Interpolation"].Value);
                    smoothOnDraw           = bool.Parse(config.AppSettings.Settings["Smooth On Draw"].Value);
                    stayOnTop            = bool.Parse(config.AppSettings.Settings["Stay On Top"].Value);
                    disableAutoDetection = bool.Parse(config.AppSettings.Settings["Disable Auto Detection"].Value);
                    mainForm.tabletMode  = bool.Parse(config.AppSettings.Settings["Tablet Mode"].Value);
                    mainForm.checkBox_tabletMode.Enabled   = disableAutoDetection;
                    mainForm.checkBox_tabletMode.Checked   = mainForm.tabletMode;
                    mainForm.checkBox_smoothOnDraw.Checked = smoothOnDraw;
                    if (manualInterpolation)
                    {
                        mainForm.checkBox_manualInterpolation.Checked    = true;
                        mainForm.trackBar_smoothingInterpolation.Enabled = true;
                        mainForm.textBox_smoothingInterpolation.Enabled  = true;
                    }
                    mainForm.textBox_smoothingInterpolation.Text = smoothingInterpolation.ToString();
                    mainForm.textBox_smoothingStrength.Text      = smoothingStrength.ToString();
                    if (stayOnTop)
                    {
                        mainForm.checkBox_stayOnTop.Checked = true;
                        mainForm.TopMost    = true;
                        overlayForm.TopMost = true;
                    }

                    // Cursor and overlay loading
                    overlayForm.cursorType      = (Overlay.CursorType)Enum.Parse(typeof(Overlay.CursorType), config.AppSettings.Settings["Cursor Graphic"].Value);
                    overlayForm.cursorColor     = ColorTranslator.FromHtml(config.AppSettings.Settings["Main Color"].Value);
                    overlayForm.cursorFillColor = ColorTranslator.FromHtml(config.AppSettings.Settings["Fill Color"].Value);
                    overlayScreen         = int.Parse(config.AppSettings.Settings["Overlay Screen"].Value);
                    disableOverlay        = bool.Parse(config.AppSettings.Settings["Disable Overlay"].Value);
                    allScreens            = bool.Parse(config.AppSettings.Settings["All Screens"].Value);
                    manualOverlayOverride = bool.Parse(config.AppSettings.Settings["Manual Overlay Override"].Value);
                    RectangleConverter r = new RectangleConverter();
                    overrideBounds = (Rectangle)r.ConvertFromString(config.AppSettings.Settings["Override Bounds"].Value);
                    if (disableOverlay)
                    {
                        overlayForm.Hide();
                    }
                    overlayForm.Bounds = Screen.AllScreens[overlayScreen].Bounds;
                    if (allScreens)
                    {
                        overlayForm.Bounds = new Rectangle(0, 0, SystemInformation.VirtualScreen.Width, SystemInformation.VirtualScreen.Height);
                    }
                    if (manualOverlayOverride)
                    {
                        overlayForm.Bounds = overrideBounds;
                    }
                    mainForm.button_colorDialog.BackColor = overlayForm.cursorColor;

                    // ...and everything else
                    disableCatchUp       = bool.Parse(config.AppSettings.Settings["Disable Catch Up"].Value);
                    snapToCursor         = bool.Parse(config.AppSettings.Settings["Snap To Cursor"].Value);
                    tolerance            = int.Parse(config.AppSettings.Settings["Tolerance"].Value);
                    tabletOffsetOverride = bool.Parse(config.AppSettings.Settings["Tablet Offset Override"].Value);
                    PointConverter p = new PointConverter();
                    tabletOffset = (Point)p.ConvertFromString(config.AppSettings.Settings["Tablet Offset"].Value);
                    KeysConverter       c = new KeysConverter();
                    Keys                k;
                    Hotkey.KeyModifiers m;
                    hotkeys[0] = config.AppSettings.Settings["Hotkey 1"].Value;
                    if (hotkeys[0] != "None")
                    {
                        k = (Keys)c.ConvertFromString(config.AppSettings.Settings["Hotkey 1"].Value);
                        m = Hotkey.GetModifiers(k, out k);
                        if (k != Keys.None)
                        {
                            mainForm.RegisterHotkey(mainForm.Handle, 0, m, k);
                        }
                    }
                    hotkeys[1] = config.AppSettings.Settings["Hotkey 2"].Value;
                    if (hotkeys[1] != "None")
                    {
                        k = (Keys)c.ConvertFromString(config.AppSettings.Settings["Hotkey 2"].Value);
                        m = Hotkey.GetModifiers(k, out k);
                        if (k != Keys.None)
                        {
                            mainForm.RegisterHotkey(mainForm.Handle, 1, m, k);
                        }
                    }
                    hotkeys[2] = config.AppSettings.Settings["Hotkey 3"].Value;
                    if (hotkeys[2] != "None")
                    {
                        k = (Keys)c.ConvertFromString(config.AppSettings.Settings["Hotkey 3"].Value);
                        m = Hotkey.GetModifiers(k, out k);
                        if (k != Keys.None)
                        {
                            mainForm.RegisterHotkey(mainForm.Handle, 2, m, k);
                        }
                    }
                    hotkeys[3] = config.AppSettings.Settings["Hotkey 4"].Value;
                    if (hotkeys[3] != "None")
                    {
                        k = (Keys)c.ConvertFromString(config.AppSettings.Settings["Hotkey 4"].Value);
                        m = Hotkey.GetModifiers(k, out k);
                        if (k != Keys.None)
                        {
                            mainForm.RegisterHotkey(mainForm.Handle, 3, m, k);
                        }
                    }
                    hotkeys[4] = config.AppSettings.Settings["Hotkey 5"].Value;
                    if (hotkeys[4] != "None")
                    {
                        k = (Keys)c.ConvertFromString(config.AppSettings.Settings["Hotkey 5"].Value);
                        m = Hotkey.GetModifiers(k, out k);
                        if (k != Keys.None)
                        {
                            mainForm.RegisterHotkey(mainForm.Handle, 4, m, k);
                        }
                    }
                    hotkeys[5] = config.AppSettings.Settings["Hotkey 6"].Value;
                    if (hotkeys[5] != "None")
                    {
                        k = (Keys)c.ConvertFromString(config.AppSettings.Settings["Hotkey 6"].Value);
                        m = Hotkey.GetModifiers(k, out k);
                        if (k != Keys.None)
                        {
                            mainForm.RegisterHotkey(mainForm.Handle, 5, m, k);
                        }
                    }
                }
                catch {
                    // Quietly fail loading bad configs or no configs
                }
            }
        }