Exemple #1
0
        public async Task SaveHotkeyConfig(HotkeyConfig newConfig)
        {
            _config.hotkey = newConfig;
            await SaveConfig(_config);

            ConfigChanged?.Invoke(this, new EventArgs());
        }
Exemple #2
0
 private void TryRegAllHotkeys()
 {
     _modifiedHotkeyConfig = GetConfigFromUI();
     if (this.SwitchProxyModeTextBox.Focused)
     {
         RegHotkeyFromString(_modifiedHotkeyConfig.SwitchProxyMode, "SwitchProxyModeCallback", result => HandleRegResult(_modifiedHotkeyConfig.SwitchProxyMode, SwitchProxyModeLabel, result));
     }
     else if (this.SwitchLoadBalanceTextBox.Focused)
     {
         RegHotkeyFromString(_modifiedHotkeyConfig.SwitchLoadBalance, "SwitchLoadBalanceCallback", result => HandleRegResult(_modifiedHotkeyConfig.SwitchLoadBalance, SwitchLoadBalanceLabel, result));
     }
     else if (this.SwitchAllowLanTextBox.Focused)
     {
         RegHotkeyFromString(_modifiedHotkeyConfig.SwitchAllowLan, "SwitchAllowLanCallback", result => HandleRegResult(_modifiedHotkeyConfig.SwitchAllowLan, SwitchAllowLanLabel, result));
     }
     else if (this.CallClipboardAndQRCodeScanningTextBox.Focused)
     {
         RegHotkeyFromString(_modifiedHotkeyConfig.CallClipboardAndQRCodeScanning, "ClipboardAndQRCodeScanningCallback", result => HandleRegResult(_modifiedHotkeyConfig.CallClipboardAndQRCodeScanning, CallClipboardAndQRCodeScanningLabel, result));
     }
     //RegHotkeyFromString(_modifiedHotkeyConfig.ShowLogs, "ShowLogsCallback", result => HandleRegResult(_modifiedHotkeyConfig.ShowLogs, CallClipboardAndQRCodeScanningLabel, result));
     else if (this.ServerMoveUpTextBox.Focused)
     {
         RegHotkeyFromString(_modifiedHotkeyConfig.ServerMoveUp, "ServerMoveUpCallback", result => HandleRegResult(_modifiedHotkeyConfig.ServerMoveUp, ServerMoveUpLabel, result));
     }
     else if (this.ServerMoveDownTextBox.Focused)
     {
         RegHotkeyFromString(_modifiedHotkeyConfig.ServerMoveDown, "ServerMoveDownCallback", result => HandleRegResult(_modifiedHotkeyConfig.ServerMoveDown, ServerMoveDownLabel, result));
     }
 }
Exemple #3
0
        public static void RegAllHotkeys(HotkeyConfig hotkeyConfig)
        {
            if (hotkeyConfig == null || !hotkeyConfig.regHotkeyAtStartup)
            {
                return;
            }

            // if any of the hotkey reg fail, undo everything
            if (RegHotkeyFromString(hotkeyConfig.stopProxy, "StopProxyCallback") &&
                RegHotkeyFromString(hotkeyConfig.globalProxyMode, "GlobalProxyModeCallback") &&
                RegHotkeyFromString(hotkeyConfig.pacProxyMode, "PACProxyModeCallback") &&
                RegHotkeyFromString(hotkeyConfig.addUserPAC, "AddUserPACCallback")
                )
            {
                // success
            }
            else
            {
                RegHotkeyFromString("", "StopProxyCallback");
                RegHotkeyFromString("", "GlobalProxyModeCallback");
                RegHotkeyFromString("", "PACProxyModeCallback");
                RegHotkeyFromString("", "AddUserPACCallback");
                UI.ShowWarning(UIRes.I18N("HotkeyRegFailed"));
            }
        }
Exemple #4
0
        public void SaveHotkeyConfig(HotkeyConfig newConfig)
        {
            _config.hotkey = newConfig;
            SaveConfig(_config);

            ConfigChanged?.Invoke(this, new EventArgs());
        }
Exemple #5
0
        private void BtnOKAndEnable_Click(object sender, EventArgs e)
        {
            _modifiedHotkeyConfig = GetConfigFromUI();

            // try to register, notify to change settings if failed
            if (!RegisterAllHotkeys(_modifiedHotkeyConfig))
            {
                if (MenuViewController.appbarform != null)
                {
                    MenuViewController.appbarform.RegAppBar(true);
                    MenuViewController.appbarform.Dispose();
                    MenuViewController.appbarform = null;
                    Utils.ReleaseMemory(true);
                }

                //IsRegHotkeys = false;
                MessageBox.Show(I18N.GetString("Register hotkey failed"));
            }
            else
            {
                if (MenuViewController.appbarform == null)
                {
                    MenuViewController.appbarform = new AppBarForm();
                }
                HotKeys._Enabled = true;
            }

            //IsRegHotkeys = true;
            // All check passed, saving
            SaveConfig();
            this.Close();
        }
Exemple #6
0
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="config"></param>
        public void Init(ConfigFile config)
        {
            Config = config;

            Hotkey = new HotkeyConfig();
            Hotkey.Init(Config);

            CustomLockValue   = Config.Bind <int[]>("Cheat", "customLockValue", null, "自定义锁定值");
            includedStoryTyps = Config.Bind <bool[]>("Cheat", "includedStoryTyps", null, "需要直达终点的奇遇的类型");
            PagesPerFastRead  = Config.Bind <int>("Cheat", "PagesPerFastRead", 10, "快速读书每次篇数");


            DayTimeMax               = Config.Bind <bool>("Cheat", "DayTimeMax", false, "行动力锁定");
            ReadBookCheat            = Config.Bind <bool>("Cheat", "ReadBookCheat", false, "快速读书(对残缺篇章有效)");
            PracticeMax              = Config.Bind <bool>("Cheat", "PracticeMax", false, "修习单击全满");
            StoryCheat               = Config.Bind <bool>("Cheat", "StoryCheat", false, "奇遇直接到达目的地");
            InfWeightBearing         = Config.Bind <bool>("Cheat", "InfWeightBearing", false, "无限负重");
            MaxRelationship          = Config.Bind <bool>("Cheat", "MaxRelationship", false, "见面关系全满");
            MaxImpression            = Config.Bind <bool>("Cheat", "MaxImpression", false, "见面印象全满");
            VigilanceCheat           = Config.Bind <bool>("Cheat", "VigilanceCheat", false, "戒心锁定为 0");
            LockGangPartValue        = Config.Bind <bool>("Cheat", "LockGangPartValue", false, "锁定门派支持度");
            LockBasePartValue        = Config.Bind <bool>("Cheat", "LockBasePartValue", false, "锁定地区恩义");
            ChangeCombatRange        = Config.Bind <bool>("Cheat", "ChangeCombatRange", false, "锁定战斗距离");
            ChangeDefalutCombatRange = Config.Bind <bool>("Cheat", "LockCombatRange", false, "默认战斗距离");
            InfAbilityP              = Config.Bind <bool>("Cheat", "InfAbilityP", false, "无限特性点数");
            GetAllQuqu               = Config.Bind <bool>("Cheat", "GetAllQuqu", false, "蛐蛐一网打尽");
            GetQuquNoMiss            = Config.Bind <bool>("Cheat", "GetQuquNoMiss", false, "蛐蛐捕捉不会失手");
            BattleMustWin            = Config.Bind <bool>("Cheat", "BattleMustWin", false, "战斗必胜");
            ManPowerNoLimit          = Config.Bind <bool>("Cheat", "ManPowerNoLimit", false, "人力限制解除");
            InfManPower              = Config.Bind <bool>("Cheat", "InfManPower", false, "无限人力");
            BuildingMaxLevelCheat    = Config.Bind <bool>("Cheat", "BuildingMaxLevelCheat", false, "建筑等级上限修改");
            BuildingLevelPctNoLimit  = Config.Bind <bool>("Cheat", "BuildingLevelPctNoLimit", false, "建筑工作效率限制解除");
            SwitchTheBook            = Config.Bind <bool>("Cheat", "SwitchTheBook", false, "单击切换正逆");


            Config.SaveOnConfigSet = true;

            // 初始化直接到终点的奇遇的ID清单
            if (includedStoryTyps.Value == null || includedStoryTyps.Value.Length != storyTyps.Length)
            {
                includedStoryTyps.Value = new bool[storyTyps.Length];
            }

            // 初始化锁定值
            if (CustomLockValue.Value == null)
            {
                CustomLockValue.Value = new int[lockValueName.Length];
            }
            else if (CustomLockValue.Value.Length < lockValueName.Length)
            {
                var i = new int[lockValueName.Length];
                for (int index = 0; index < CustomLockValue.Value.Length; index++)
                {
                    i[index] = CustomLockValue.Value[index];
                }
                CustomLockValue.Value = i;
            }
        }
 private void LoadConfiguration(HotkeyConfig config)
 {
     SwitchSystemProxyTextBox.Text = config.SwitchSystemProxy;
     SwitchProxyModeTextBox.Text   = config.SwitchSystemProxyMode;
     SwitchAllowLanTextBox.Text    = config.SwitchAllowLan;
     ShowLogsTextBox.Text          = config.ShowLogs;
     ServerMoveUpTextBox.Text      = config.ServerMoveUp;
     ServerMoveDownTextBox.Text    = config.ServerMoveDown;
 }
 public void SaveHotkeyConfig(HotkeyConfig newConfig)
 {
     _config.hotkey = newConfig;
     SaveConfig(_config);
     if (ConfigChanged != null)
     {
         ConfigChanged(this, new EventArgs());
     }
 }
Exemple #9
0
        /// <summary>
        /// 加载配置
        /// </summary>
        /// <param name="config"></param>
        public void Init(ConfigFile config)
        {
            Config       = config;
            ChoiceHotkey = Config.Bind("UI", "UseChoiceHotkey", false, "选项的快捷键");


            Hotkey = new HotkeyConfig();
            Hotkey.Init(Config);
        }
 private void LoadConfiguration(HotkeyConfig config)
 {
     SwitchSystemProxyTextBox.Text = config.SwitchSystemProxy;
     ChangeToPacTextBox.Text       = config.ChangeToPac;
     ChangeToGlobalTextBox.Text    = config.ChangeToGlobal;
     SwitchAllowLanTextBox.Text    = config.SwitchAllowLan;
     ShowLogsTextBox.Text          = config.ShowLogs;
     ServerMoveUpTextBox.Text      = config.ServerMoveUp;
     ServerMoveDownTextBox.Text    = config.ServerMoveDown;
 }
Exemple #11
0
 private bool RegisterAllHotkeys(HotkeyConfig hotkeyConfig)
 {
     return
         (RegHotkeyFromString(hotkeyConfig.SwitchSystemProxy, "SwitchSystemProxyCallback", result => HandleRegResult(hotkeyConfig.SwitchSystemProxy, SwitchSystemProxyLabel, result)) &&
          RegHotkeyFromString(hotkeyConfig.SwitchSystemProxyMode, "SwitchSystemProxyModeCallback", result => HandleRegResult(hotkeyConfig.SwitchSystemProxyMode, SwitchProxyModeLabel, result)) &&
          RegHotkeyFromString(hotkeyConfig.SwitchAllowLan, "SwitchAllowLanCallback", result => HandleRegResult(hotkeyConfig.SwitchAllowLan, SwitchAllowLanLabel, result)) &&
          RegHotkeyFromString(hotkeyConfig.ShowLogs, "ShowLogsCallback", result => HandleRegResult(hotkeyConfig.ShowLogs, ShowLogsLabel, result)) &&
          RegHotkeyFromString(hotkeyConfig.ServerMoveUp, "ServerMoveUpCallback", result => HandleRegResult(hotkeyConfig.ServerMoveUp, ServerMoveUpLabel, result)) &&
          RegHotkeyFromString(hotkeyConfig.ServerMoveDown, "ServerMoveDownCallback", result => HandleRegResult(hotkeyConfig.ServerMoveDown, ServerMoveDownLabel, result)));
 }
Exemple #12
0
 private void SetConfigToUI(HotkeyConfig config)
 {
     SwitchProxyModeTextBox.Text   = config.SwitchProxyMode;
     SwitchLoadBalanceTextBox.Text = config.SwitchLoadBalance;
     SwitchAllowLanTextBox.Text    = config.SwitchAllowLan;
     CallClipboardAndQRCodeScanningTextBox.Text = config.CallClipboardAndQRCodeScanning;
     ServerMoveUpTextBox.Text            = config.ServerMoveUp;
     ServerMoveDownTextBox.Text          = config.ServerMoveDown;
     RegHotkeysAtStartupCheckBox.Checked = config.RegHotkeysAtStartup;
 }
 public void SaveHotkeyConfig(HotkeyConfig newConfig)
 {
     _config.hotkey = newConfig;
     SaveConfig(_config, false);
     //ConfigChanged?.Invoke(this, new EventArgs());
     InvokeConfigChanged(new object[] { new List <string>()
                                        {
                                            "HotkeySettingsForm"
                                        } }, new EventArgs());
 }
Exemple #14
0
 private void SetConfigToUI(HotkeyConfig config)
 {
     SwitchSystemProxyTextBox.Text       = config.SwitchSystemProxy;
     SwitchProxyModeTextBox.Text         = config.SwitchSystemProxyMode;
     SwitchAllowLanTextBox.Text          = config.SwitchAllowLan;
     ShowLogsTextBox.Text                = config.ShowLogs;
     ServerMoveUpTextBox.Text            = config.ServerMoveUp;
     ServerMoveDownTextBox.Text          = config.ServerMoveDown;
     RegHotkeysAtStartupCheckBox.Checked = config.RegHotkeysAtStartup;
 }
        private void Save()
        {
            if (!IsValid().Item1)
            {
                return;
            }

            HotkeyConfig config = GetConfig();

            Form.SaveHotkey(config);
        }
Exemple #16
0
 private void LoadConfiguration(HotkeyConfig config)
 {
     SwitchSystemProxyTextBox.Text     = config.SwitchSystemProxy;
     SwitchSystemProxyModeTextBox.Text = config.SwitchSystemProxyMode;
     SwitchAllowLanTextBox.Text        = config.SwitchAllowLan;
     ShowLogsTextBox.Text                    = config.ShowLogs;
     ServerMoveUpTextBox.Text                = config.ServerMoveUp;
     ServerMoveDownTextBox.Text              = config.ServerMoveDown;
     AddCurrentChromeURLtoPACTextBox.Text    = config.AddCurrentChromeURLtoPAC;
     AddCurrentChromeDomaintoPACTextBox.Text = config.AddCurrentChromeDomaintoPAC;
     ScanQRTextBox.Text = config.ScanQR;
 }
Exemple #17
0
 /// <summary>
 /// Recreate the settings from a config,
 /// storing them in the current instance.
 /// </summary>
 public void ApplySettings(HotkeyConfig config)
 {
     Unload      = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.Unload);
     Load        = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.Load);
     FirePos     = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.FirePosition);
     AttackMove  = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.AttackMove);
     ReverseMove = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.ReverseMove);
     FastMove    = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.FastMove);
     Split       = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.Split);
     VisionTool  = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.VisionTool);
     MenuToggle  = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.MenuToggle);
 }
Exemple #18
0
 private bool RegisterAllHotkeys(HotkeyConfig hotkeyConfig)
 {
     return
         (RegHotkeyFromString(hotkeyConfig.SwitchProxyMode, "SwitchProxyModeCallback", result => HandleRegResult(hotkeyConfig.SwitchProxyMode, SwitchProxyModeLabel, result)) &&
          RegHotkeyFromString(hotkeyConfig.SwitchLoadBalance, "SwitchLoadBalanceCallback", result => HandleRegResult(hotkeyConfig.SwitchLoadBalance, SwitchLoadBalanceLabel, result)) &&
          RegHotkeyFromString(hotkeyConfig.SwitchAllowLan, "SwitchAllowLanCallback", result => HandleRegResult(hotkeyConfig.SwitchAllowLan, SwitchAllowLanLabel, result)) &&
          RegHotkeyFromString(hotkeyConfig.CallClipboardAndQRCodeScanning, "ClipboardAndQRCodeScanningCallback", result => HandleRegResult(hotkeyConfig.CallClipboardAndQRCodeScanning, CallClipboardAndQRCodeScanningLabel, result))
          //&& RegHotkeyFromString(hotkeyConfig.ShowLogs, "ShowLogsCallback", result => HandleRegResult(hotkeyConfig.ShowLogs, CallClipboardAndQRCodeScanningLabel, result))
          && RegHotkeyFromString(hotkeyConfig.ServerMoveUp, "ServerMoveUpCallback", result => HandleRegResult(hotkeyConfig.ServerMoveUp, ServerMoveUpLabel, result)) &&
          RegHotkeyFromString(hotkeyConfig.ServerMoveDown, "ServerMoveDownCallback", result => HandleRegResult(hotkeyConfig.ServerMoveDown, ServerMoveDownLabel, result))
         );
 }
Exemple #19
0
        private void OKButton_Click(object sender, EventArgs e)
        {
            _modifiedHotkeyConfig = GetConfigFromUI();
            // try to register, notify to change settings if failed
            if (!RegisterAllHotkeys(_modifiedHotkeyConfig))
            {
                MessageBox.Show(I18N.GetString("Register hotkey failed"));
            }

            // All check passed, saving
            SaveConfig();
            this.Close();
        }
        protected bool IsPressed(HotkeyConfig hotkey)
        {
            var combination = KeyCombination.Parse(hotkey.Hotkey);

            if (combination.Key != Key.None)
            {
                if (!Keyboard.IsKeyDown(combination.Key))
                {
                    return(false);
                }
            }
            return(Keyboard.Modifiers == combination.ModifierKeys);
        }
        public void Update(HotkeyConfig config)
        {
            FormatText.Text    = config.Format;
            WhitelistText.Text = config.Whitelist;

            ShareBox.Checked            = (config.Share & ShareType.Share) != 0;
            PublicBox.Checked           = (config.Share & ShareType.Public) != 0;
            PublicRegisteredBox.Checked = (config.Share & ShareType.PublicRegistered) != 0;
            FirstViewBox.Checked        = (config.Share & ShareType.FirstView) != 0;
            WhitelistedBox.Checked      = (config.Share & ShareType.Whitelisted) != 0;
            UpdateShareEnables();

            FileProviderBox.SelectedItem = providers.First(p => p.Value == config.Provider).Key;

            Key       = config.Key;
            Modifiers = config.Modifier;
            UpdateButtonText();
        }
Exemple #22
0
        public void ChangeHotkey(HotkeyConfig config)
        {
            Hotkey previous = hotkeys.Where(h => h.HotkeyType == config.Type).SingleOrDefault();

            if (!(previous is null))
            {
                previous.Dispose();
                hotkeys.Remove(previous);
            }
            ConfigHandler.Config.Hotkeys.RemoveAll(c => c.Type == config.Type);

            Hotkey newHotkey = new Hotkey(config.ModifierKeys, config.Key, config.Type);

            newHotkey.Pressed += H_Pressed;
            hotkeys.Add(newHotkey);
            newHotkey.Register();
            ConfigHandler.Config.Hotkeys.Add(config);
            ConfigHandler.Save();
        }
Exemple #23
0
 /// <summary>
 /// Recreate the settings from a config,
 /// storing them in the current instance.
 /// </summary>
 public void ApplySettings(HotkeyConfig config)
 {
     Unload      = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.Unload);
     Load        = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.Load);
     FirePos     = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.FirePosition);
     AttackMove  = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.AttackMove);
     ReverseMove = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.ReverseMove);
     FastMove    = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.FastMove);
     Split       = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.Split);
     VisionTool  = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.VisionTool);
     MenuToggle  = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.MenuToggle);
     Stop        = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.Stop);
     WeaponsOff  = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.WeaponsOff);
     Smoke       = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.Smoke);
     UnitInfo    = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.UnitInfo);
     FlareAttack = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.FlareAttack);
     FlareStop   = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.FlareStop);
     FlareCustom = (KeyCode)System.Enum.Parse(typeof(KeyCode), config.FlareCustom);
 }
        public HotkeyConfig GetConfig()
        {
            ShareType share = ShareType.DontShare;

            if (ShareBox.Checked)
            {
                share |= ShareType.Share;

                if (FirstViewBox.Checked)
                {
                    share |= ShareType.FirstView;
                }

                if (PublicBox.Checked)
                {
                    share |= ShareType.Public;
                }

                if (PublicRegisteredBox.Checked)
                {
                    share |= ShareType.PublicRegistered;
                }

                if (WhitelistedBox.Checked)
                {
                    share |= ShareType.Whitelisted;
                }
            }

            var config = new HotkeyConfig
            {
                Format    = FormatText.Text,
                Whitelist = WhitelistText.Text,
                Share     = share,
                Key       = Key,
                Modifier  = Modifiers,
                Provider  = GetSelectedFileProvider()
            };

            return(config);
        }
Exemple #25
0
 private static void LoadConfiguration(HotkeyConfig config)
 {
     foreach (var pi in config.GetType().GetProperties())
     {
         var pv = pi.GetValue(config, null);
         if (pv is string str)
         {
             var hotkey = Str2HotKey(str);
             if (hotkey != null)
             {
                 var callbackName = pi.Name + "Callback";
                 if (HotkeyCallbacks.GetCallback(callbackName) is HotKeyCallBackHandler callback)
                 {
                     if (IsCallbackExists(callback, out var prevHotKey))
                     {
                         UnRegist(prevHotKey);
                     }
                     var regResult = Regist(hotkey, callback);
                     Logging.Info($"Reg {str} to {pi.Name}{(regResult ? "Successful" : "Fail")}");
                 }
             }
         }
     }
 }
 private void LoadCurrentConfiguration()
 {
     _modifiedConfig = _controller.GetConfigurationCopy().hotkey;
     LoadConfiguration(_modifiedConfig);
 }
Exemple #27
0
 public void SaveHotkey(HotkeyConfig config)
 {
     Hotkeys.Add(config);
 }
Exemple #28
0
 private void RegisterAllButton_Click(object sender, EventArgs e)
 {
     _modifiedHotkeyConfig = GetConfigFromUI();
     RegisterAllHotkeys(_modifiedHotkeyConfig);
 }
Exemple #29
0
 public Hotkeys(HotkeyConfig config)
 {
     ApplySettings(config);
 }
Exemple #30
0
 private void LoadCurrentConfiguration()
 {
     _TempHotkeyConfig = _modifiedHotkeyConfig = _controller.GetCurrentConfiguration().hotkey;
     //GetConfiguration().hotkey;
     SetConfigToUI(_modifiedHotkeyConfig);
 }