public static KeySet FromString(string keyBindStr) { if (!Regex.IsMatch(keyBindStr, "\\w+=.+")) { return(null); } KeySet keySet = new KeySet(); string[] keySetStrings = keyBindStr.Split('='); if (keySetStrings.Length == 2) { keySet.Name = keySetStrings[0]; string[] strs = keySetStrings[1].Split(','); foreach (string str in strs) { Key key = Key.FromString(str); keySet.Add(key); } } return(keySet); }
public void Load() { _keySets.Clear(); if (Properties == null) { return; } string loadStr = Properties.Load(); if (string.IsNullOrEmpty(loadStr)) { return; } string[] res = loadStr.Split(';'); foreach (string item in res) { IKeySet keySet = KeySet.FromString(item); if (keySet == null) { continue; } var element = getUiElementByNameCallBack.Invoke(keySet.Name); if (element == null) { continue; } keySet.UiElement = element; _keySets.TryAdd(keySet.Name, keySet); } }