void HotkeyHandler(object sender, KeyPressedEventArgs e) { var bs = setting.GetBasicSetting(); bs.sysProxyMode = (bs.sysProxyMode % 3) + 1; setting.SaveBasicSetting(bs); Restart(); }
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(); }
void SetProxyMode(Model.Data.Enum.SystemProxyModes proxyMode) { var bs = setting.GetBasicSetting(); bs.sysProxyMode = (int)proxyMode; setting.SaveBasicSetting(bs); serverTracker?.Restart(); }
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); } }