Beispiel #1
0
 void SearchForAvailableProxyServer(
     bool isGlobal,
     List <VgcApis.Models.IControllers.ICoreCtrl> serverList)
 {
     foreach (var serv in serverList)
     {
         if (serv.IsSuitableToBeUsedAsSysProxy(
                 isGlobal, out bool isSocks, out int port))
         {
             UpdateSysProxySetting(
                 serv.GetTitle(),
                 isSocks,
                 port);
             return;
         }
     }
     setting.SendLog(I18N.NoServerCapableOfSysProxy);
 }
Beispiel #2
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);
            }
        }
Beispiel #3
0
        void RegistHotKey()
        {
            ClearHotKey();

            var bs = setting.GetBasicSetting();

            if (!bs.isUseHotkey)
            {
                return;
            }

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

            kbHook             = new KeyboardHook();
            kbHook.KeyPressed += new EventHandler <KeyPressedEventArgs>(HotkeyHandler);
            ModifierKeys modifier = ModifierKeys.Control;

            if (bs.isUseAlt)
            {
                modifier |= ModifierKeys.Alt;
            }
            if (bs.isUseShift)
            {
                modifier |= ModifierKeys.Shift;
            }

            try
            {
                kbHook.RegisterHotKey((uint)modifier, (uint)hotkey);
                return;
            }
            catch { }

            setting.SendLog(I18N.RegistHotkeyFail);
            VgcApis.Libs.UI.MsgBoxAsync(I18N.RegistHotkeyFail);
        }