Exemplo n.º 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            ConfigAddForm addForm = new ConfigAddForm();

            addForm.ShowDialog();
            ConfigClass val = addForm.config;

            if (val == null)
            {
                return;
            }
            hotKeys.Add(val.getKeyPairs().GetHashCode(), val);
            addViewItem(val);
            btnApply.Enabled = true;
        }
Exemplo n.º 2
0
        public static void addHotKey(string name, Keys[] keys, ConfigClass.CommandType type, string exe_file, string exe_arg, Keys targetKey, string cmd_line)
        {
            KeyPair tmp_list = new KeyPair(keys);

            if (!hotKeys.ContainsKey(tmp_list.GetHashCode()))
            {
                hotKeys.Add(tmp_list.GetHashCode(), new ConfigClass(name, tmp_list, type, exe_file, exe_arg, targetKey, cmd_line));
            }
        }
Exemplo n.º 3
0
        public static void parseHotKeys()
        {
            hotKeys = new HotKeyDict();
            JArray keys_arr = JArray.Parse(Properties.Settings.Default.HotKeys);

            foreach (JObject obj in keys_arr.Children <JObject>())
            {
                KeyPair key_pairs     = new KeyPair();
                JArray  key_pairs_tmp = (JArray)obj["key_pairs"];
                foreach (int key in key_pairs_tmp)
                {
                    key_pairs.Add((Keys)key);
                }
                ConfigClass.CommandType _type;
                if (!Enum.TryParse(obj["type"].ToString(), out _type))
                {
                    continue;
                }
                hotKeys.Add(key_pairs.GetHashCode(), new ConfigClass(obj["name"].ToString(), key_pairs, _type
                                                                     , obj["exe_file"].ToString(), obj["exe_arg"].ToString(), (Keys)((int)obj["target_key"]), obj["cmd_line"].ToString()));
            }
        }
Exemplo n.º 4
0
 internal static void InitHotkeys() =>
 DefDatabase <KeyBindingDef> .AllDefsListForReading
 .Where(def =>
        def.category.defName.Equals("TogglesHotkeys")).ToList()
 .ForEach(def =>
          HotKeyDict.Add(def.defName, new Hotkey(def)));