/// <summary> /// Initialize a new instance of the HotKeyEntry class. /// </summary> /// <param name="modKeys">The combination of modifier keys flags.</param> /// <param name="key">The identifier of hotkey.</param> /// <param name="action">The callback action that will be invoked when user enter modKeys + key combination on the browser.</param> /// <param name="description">The description of the meaning of this hot key entry.</param> /// <param name="allowIn">The combination of HTML element flags that will be allowed hotkey works.</param> public HotKeyEntry(ModKeys modKeys, Keys key, AllowIn allowIn, string description, Func <HotKeyEntry, Task> action) { ModKeys = modKeys; Key = key; AllowIn = allowIn; Description = description; Action = action; }
public HotKeyEntry(ModKeys modKeys, Keys key, AllowIn allowIn, string description, Func <HotKeyEntry, Task> action) { this.ModKeys = modKeys; this.Key = key; this.KeyName = key.ToString(); this.Exclude = AllowInToExclude(allowIn); this.Description = description; this.Action = action; }
public HotKeyEntry(ModKeys modKeys, string keyName, AllowIn allowIn, string description, Func <HotKeyEntry, Task> action) { this.ModKeys = modKeys; this.Key = Enum.TryParse <Keys>(keyName, ignoreCase: true, out var v) ? v : (Keys)0; this.KeyName = keyName; this.Exclude = AllowInToExclude(allowIn); this.Description = description; this.Action = action; }
private static Exclude AllowInToExclude(AllowIn allowIn) { var exclude = (!allowIn.HasFlag(AllowIn.Input) && !allowIn.HasFlag(AllowIn.NonTextInput)) ? Exclude.InputText | Exclude.InputNonText : (!allowIn.HasFlag(AllowIn.Input) && allowIn.HasFlag(AllowIn.NonTextInput)) ? Exclude.InputText : Exclude.None; return(exclude | (allowIn.HasFlag(AllowIn.TextArea) ? Exclude.None : Exclude.TextArea)); }
/// <summary> /// Add new hotkey entry to this context. /// </summary> /// <param name="modKeys">The combination of modifier keys flags.</param> /// <param name="key">The identifier of hotkey.</param> /// <param name="action">The callback action that will be invoked when user enter modKeys + key combination on the browser.</param> /// <param name="description">The description of the meaning of this hot key entry.</param> /// <param name="allowIn">The combination of HTML element flags that will be allowed hotkey works.</param> /// <returns>This context.</returns> public HotKeysContext Add(ModKeys modKeys, Keys key, Action action, string description = "", AllowIn allowIn = AllowIn.None) { this.Keys.Add(new HotKeyEntry(modKeys, key, allowIn, description, action)); return(this); }
public HotKeyEntry(ModKeys modKeys, Keys key, AllowIn allowIn, string description, Action action) : this(modKeys, key, allowIn, description, _ => { action(); return(Task.CompletedTask); }) { }
public HotKeyEntry(ModKeys modKeys, Keys key, AllowIn allowIn, string description, Func <Task> action) : this(modKeys, key, allowIn, description, _ => action()) { }
public HotKeyEntry(ModKeys modKeys, string keyName, AllowIn allowIn, string description, Action <HotKeyEntry> action) : this(modKeys, keyName, allowIn, description, e => { action(e); return(Task.CompletedTask); }) { }
public HotKeysContext Add(ModKeys modKeys, Keys key, Action <HotKeyEntry> action, string description, AllowIn allowIn) { this.Keys.Add(this.Register(new HotKeyEntry(modKeys, key, allowIn, description, action))); return(this); }
public HotKeysContext Add(ModKeys modKeys, Keys key, Action <HotKeyEntry> action, AllowIn allowIn) => this.Add(modKeys, key, action, "", allowIn);
public HotKeysContext Add(ModKeys modKeys, Keys key, Func <Task> action, AllowIn allowIn) => this.Add(modKeys, key, action, "", allowIn);
public HotKeysContext Add(ModKeys modKeys, string keyName, Action action, AllowIn allowIn) => this.Add(modKeys, keyName, action, "", allowIn);
public HotKeysContext Add(ModKeys modKeys, string keyName, Func <Task> action, string description, AllowIn allowIn) { this.Keys.Add(this.Register(new HotKeyEntry(modKeys, keyName, allowIn, description, action))); return(this); }
public HotKeysContext Add(ModKeys modKeys, string keyName, Func <HotKeyEntry, Task> action, AllowIn allowIn) => this.Add(modKeys, keyName, action, "", allowIn);