Ejemplo n.º 1
0
        void HotkeyHandler(object sender, KeyPressedEventArgs e)
        {
            var bs = setting.GetBasicSetting();

            bs.sysProxyMode = (bs.sysProxyMode % 3) + 1;
            setting.SaveBasicSetting(bs);
            Restart();
        }
Ejemplo n.º 2
0
        void UpdateSysProxySetting(string servTitle, bool isSocks, int port)
        {
            setting.SendLog(I18N.SysProxyChangeTo + " " + servTitle);
            if (!IsProxySettingChanged(isSocks, port))
            {
                setting.SendLog(I18N.SystemProxySettingRemain);
                return;
            }

            var bs = setting.GetBasicSetting();

            bs.proxyPort = VgcApis.Libs.Utils.Clamp(port, 0, 65536);
            if (bs.sysProxyMode == (int)Model.Data.Enum.SystemProxyModes.Global)
            {
                Lib.Sys.ProxySetter.SetGlobalProxy(port);
            }
            else
            {
                bs.pacProtocol =
                    (int)(isSocks ?
                          Model.Data.Enum.PacProtocols.SOCKS :
                          Model.Data.Enum.PacProtocols.HTTP);
                Lib.Sys.ProxySetter.SetPacProxy(pacServer.GetPacUrl());
            }

            setting.SaveBasicSetting(bs);
            setting.SendLog(I18N.SystemProxySettingUpdated);
            InvokeOnSysProxyChange();
        }
Ejemplo n.º 3
0
        void SetProxyMode(Model.Data.Enum.SystemProxyModes proxyMode)
        {
            var bs = setting.GetBasicSetting();

            bs.sysProxyMode = (int)proxyMode;
            setting.SaveBasicSetting(bs);
            serverTracker?.Restart();
        }
Ejemplo n.º 4
0
        public void UpdateHotkey()
        {
            ClearHotKey();

            var bs = setting.GetBasicSetting();

            if (!bs.isUseHotkey)
            {
                return;
            }

            if (!Enum.TryParse(bs.hotkeyStr, out Keys hotkey))
            {
                setting.SendLog(I18N.ParseKeyCodeFail);
                VgcApis.Misc.UI.MsgBoxAsync(I18N.ParseKeyCodeFail);
                return;
            }

            Action handler = () =>
            {
                bs.sysProxyMode = (bs.sysProxyMode % 3) + 1;
                setting.SaveBasicSetting(bs);
                Restart();
            };

            hotKeyHandle = notifier.RegisterHotKey(handler, bs.hotkeyStr, bs.isUseAlt, true, bs.isUseShift);

            if (string.IsNullOrEmpty(hotKeyHandle))
            {
                setting.SendLog(I18N.RegistHotkeyFail);
                VgcApis.Misc.UI.MsgBoxAsync(I18N.RegistHotkeyFail);
            }
            else
            {
                setting.SendLog(I18N.RegHotKeySuccess);
            }
        }