internal MouseTrigger(ActionTriggers triggers, Action <MouseTriggerArgs> action, KMod mod, KMod modAny, TMFlags flags, TMScreen screen, string paramsString) : base(triggers, action, true) { const KMod csaw = KMod.Ctrl | KMod.Shift | KMod.Alt | KMod.Win; modMask = ~modAny & csaw; modMasked = mod & modMask; this.flags = flags; this.screenIndex = screen; _paramsString = paramsString; }
MouseTrigger _Add(Action <MouseTriggerArgs> f, ESubtype subtype, string modKeys, TMFlags flags, byte data, TMScreen screen, string sData) { _triggers.ThrowIfRunning_(); bool noMod = modKeys.NE(); string ps; using (new Util.StringBuilder_(out var b)) { b.Append(subtype.ToString()).Append(' ').Append(sData); b.Append(" + ").Append(noMod ? "none" : (modKeys == "?" ? "any" : modKeys)); if (flags != 0) { b.Append(" (").Append(flags.ToString()).Append(')'); } if (subtype == ESubtype.Edge || subtype == ESubtype.Move) { if (screen == 0) { b.Append(", primary screen"); } else if (screen > 0) { b.Append(", non-primary screen ").Append((int)screen); } else if (screen == TMScreen.Any) { b.Append(", any screen"); } else if (screen == TMScreen.OfActiveWindow) { b.Append(", screen of the active window"); } else { throw new ArgumentException(); } } ps = b.ToString(); //AOutput.Write(ps); } KMod mod = 0, modAny = 0; if (noMod) { if (flags.HasAny(subtype == ESubtype.Click ? TMFlags.LeftMod | TMFlags.RightMod : TMFlags.LeftMod | TMFlags.RightMod | TMFlags.ButtonModUp)) { throw new ArgumentException("Invalid flags."); } } else { if (!AKeys.More.ParseHotkeyTriggerString_(modKeys, out mod, out modAny, out _, true)) { throw new ArgumentException("Invalid modKeys string."); } } var t = new MouseTrigger(_triggers, f, mod, modAny, flags, screen, ps); t.DictAdd(_d, _DictKey(subtype, data)); _lastAdded = t; UsedHookEvents_ |= HooksThread.UsedEvents.Mouse; //just sets the hook switch (subtype) { case ESubtype.Click: UsedHookEvents_ |= HooksThread.UsedEvents.MouseClick; break; case ESubtype.Wheel: UsedHookEvents_ |= HooksThread.UsedEvents.MouseWheel; break; default: UsedHookEvents_ |= HooksThread.UsedEvents.MouseEdgeMove; break; } return(t); }
/// <summary> /// Adds a mouse move trigger. /// </summary> /// <param name="move"></param> /// <param name="modKeys">See <see cref="this[TMClick, string, TMFlags]"/>.</param> /// <param name="flags"></param> /// <param name="screen">See <see cref="this[TMEdge, string, TMFlags, TMScreen]"/>.</param> /// <exception cref="ArgumentException">Invalid modKeys string or flags.</exception> /// <exception cref="InvalidOperationException">Cannot add triggers after <c>Triggers.Run</c> was called, until it returns.</exception> /// <example> See <see cref="ActionTriggers"/>.</example> public Action <MouseTriggerArgs> this[TMMove move, string modKeys = null, TMFlags flags = 0, TMScreen screen = 0] { set { var t = _Add(value, ESubtype.Move, modKeys, flags, (byte)move, screen, move.ToString()); } }
/// <summary> /// Adds a mouse wheel trigger. /// </summary> /// <param name="direction"></param> /// <param name="modKeys">See <see cref="this[TMClick, string, TMFlags]"/>.</param> /// <param name="flags"></param> /// <exception cref="ArgumentException">Invalid modKeys string or flags.</exception> /// <exception cref="InvalidOperationException">Cannot add triggers after <c>Triggers.Run</c> was called, until it returns.</exception> /// <example> See <see cref="ActionTriggers"/>.</example> public Action <MouseTriggerArgs> this[TMWheel direction, string modKeys = null, TMFlags flags = 0] { set { var t = _Add(value, ESubtype.Wheel, modKeys, flags, (byte)direction, 0, direction.ToString()); } }
/// <summary> /// Adds a mouse click trigger. /// </summary> /// <param name="button"></param> /// <param name="modKeys"> /// Modifier keys, like with the <see cref="AKeys.Key"/> function. /// Examples: "Ctrl", "Ctrl+Shift+Alt+Win". /// To ignore modifiers: "?". Then the trigger works with any combination of modifiers. /// To ignore a modifier: "Ctrl?". Then the trigger works with or without the modifier. More examples: "Ctrl?+Shift?", "Ctrl+Shift?". /// </param> /// <param name="flags"></param> /// <exception cref="ArgumentException">Invalid modKeys string or flags.</exception> /// <exception cref="InvalidOperationException">Cannot add triggers after <c>Triggers.Run</c> was called, until it returns.</exception> /// <example> See <see cref="ActionTriggers"/>.</example> public Action <MouseTriggerArgs> this[TMClick button, string modKeys = null, TMFlags flags = 0] { set { var t = _Add(value, ESubtype.Click, modKeys, flags, (byte)button, 0, button.ToString()); } }
internal MouseTrigger(ActionTriggers triggers, Action <MouseTriggerArgs> action, TMKind kind, byte data, KMod mod, KMod modAny, TMFlags flags, TMScreen screenIndex, string paramsString, (string, int) source) : base(triggers, action, true, source)