/// <summary> /// Set connection /// </summary> /// <param name="c">Key code</param> /// <param name="newconnection">Connection</param> public void SetConnect(int c, Connect newconnection) { if (_connect.ContainsKey(c)) { throw new Exception("Key " + string.Join(",", KeyCodeHelper.SplitKeys(c)) + " is duplicated."); } _connect.Add(c, newconnection); }
public List <CKeyBinding> ListBindings() { List <CKeyBinding> list = new List <CKeyBinding>(bindingsCount); for (int i = 0, j = 0; i < bindings.Length && j < bindingsCount; ++i) { String cmd = bindings[i]; if (cmd != null) { KeyCode code = (KeyCode)i; String name = KeyCodeHelper.ToString(code); list.Add(new CKeyBinding(name, cmd)); ++j; } } return(list); }
public override void Execute() { if (ArgsCount() != 1) { Print("usage: " + name + " <key>"); return; } String codeValue = StrArg(0).ToUpper(); KeyCode code = KeyCodeHelper.FromString(codeValue); if (code == KeyCode.None) { Print("Invalid key '" + codeValue + "'"); return; } CKeyBindings bindings = GetRootController().GetKeyBindings(); bindings.Unbind(code); }
/// <summary> /// Return string representation /// </summary> /// <param name="automaton"></param> /// <returns></returns> public static string Dump() { StringBuilder builder = new StringBuilder(); foreach (var instance in _instances) { builder.Append("{ "); builder.Append(instance.Key); builder.Append(" : {"); foreach (var connect in instance.Value.GetConnect()) { builder.Append(" { "); builder.AppendFormat(" ch : {0},", string.Join(",", KeyCodeHelper.SplitKeys(connect.Key))); builder.AppendFormat(" to : {0},", connect.Value.Automaton.ID); builder.AppendFormat(" st : {0} ", connect.Value.Character); builder.Append("} "); } builder.Append("} "); builder.Append("}"); builder.AppendLine(); } return(builder.ToString()); }