Exemplo n.º 1
0
 /// <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;
 }
Exemplo n.º 2
0
 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;
 }
Exemplo n.º 3
0
 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;
 }
Exemplo n.º 4
0
        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));
        }
Exemplo n.º 5
0
 /// <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);
 }
Exemplo n.º 6
0
 public HotKeyEntry(ModKeys modKeys, Keys key, AllowIn allowIn, string description, Action action)
     : this(modKeys, key, allowIn, description, _ => { action(); return(Task.CompletedTask); })
 {
 }
Exemplo n.º 7
0
 public HotKeyEntry(ModKeys modKeys, Keys key, AllowIn allowIn, string description, Func <Task> action)
     : this(modKeys, key, allowIn, description, _ => action())
 {
 }
Exemplo n.º 8
0
 public HotKeyEntry(ModKeys modKeys, string keyName, AllowIn allowIn, string description, Action <HotKeyEntry> action)
     : this(modKeys, keyName, allowIn, description, e => { action(e); return(Task.CompletedTask); })
 {
 }
Exemplo n.º 9
0
 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);
 }
Exemplo n.º 10
0
 public HotKeysContext Add(ModKeys modKeys, Keys key, Action <HotKeyEntry> action, AllowIn allowIn) => this.Add(modKeys, key, action, "", allowIn);
Exemplo n.º 11
0
 public HotKeysContext Add(ModKeys modKeys, Keys key, Func <Task> action, AllowIn allowIn) => this.Add(modKeys, key, action, "", allowIn);
Exemplo n.º 12
0
 public HotKeysContext Add(ModKeys modKeys, string keyName, Action action, AllowIn allowIn) => this.Add(modKeys, keyName, action, "", allowIn);
Exemplo n.º 13
0
 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);
 }
Exemplo n.º 14
0
 public HotKeysContext Add(ModKeys modKeys, string keyName, Func <HotKeyEntry, Task> action, AllowIn allowIn) => this.Add(modKeys, keyName, action, "", allowIn);