internal WindowTrigger(ActionTriggers triggers, Action <WindowTriggerArgs> action, TWEvent ev, AWnd.Finder finder, TWFlags flags, TWLater later) : base(triggers, action, false) { this.ev = ev; this.finder = finder; this.flags = flags; this.later = later; }
/// <summary> /// Adds a window trigger and its action. /// </summary> /// <param name="winEvent">Trigger event.</param> /// <param name="name">See <see cref="AWnd.Find"/>.</param> /// <param name="cn">See <see cref="AWnd.Find"/>.</param> /// <param name="of">See <see cref="AWnd.Find"/>.</param> /// <param name="also">See <see cref="AWnd.Find"/>.</param> /// <param name="contains">See <see cref="AWnd.Find"/>.</param> /// <param name="flags">Trigger flags.</param> /// <param name="later"> /// Can optionally specify one or more additional events. /// This starts to work when the primary trigger is activated, and works only for that window. /// For example, to be notified when the window is closed or renamed, specify <c>later: TWLater.Destroyed | TWLater.Name</c>. /// When a "later" event occurs, the trigger action is executed. The <see cref="WindowTriggerArgs.Later"/> property then is that event; it is 0 when it is the primary trigger. /// The "later" trigers are not disabled when primary triggers are disabled. /// </param> /// <exception cref="InvalidOperationException">Cannot add triggers after <c>Triggers.Run</c> was called, until it returns.</exception> /// <exception cref="ArgumentException">See <see cref="AWnd.Find"/>.</exception> /// <seealso cref="Last"/> public Action <WindowTriggerArgs> this[TWEvent winEvent, [ParamString(PSFormat.AWildex)] string name = null, [ParamString(PSFormat.AWildex)] string cn = null, [ParamString(PSFormat.AWildex)] WOwner of = default, Func <AWnd, bool> also = null, WContains contains = default, TWFlags flags = 0, TWLater later = 0 ] { set { var f = new AWnd.Finder(name, cn, of, 0, also, contains); this[winEvent, f, flags, later] = value; } }
/// <summary> /// Adds a window trigger and its action. /// </summary> /// <exception cref="InvalidOperationException">Cannot add triggers after <c>Triggers.Run</c> was called, until it returns.</exception> public Action <WindowTriggerArgs> this[TWEvent winEvent, AWnd.Finder f, TWFlags flags = 0, TWLater later = 0] { set { _triggers.ThrowIfRunning_(); if (f.Props.contains.Value is AWinImage.Finder) { AWarning.Write("Window triggers with 'contains image' are unreliable."); } var t = new WindowTrigger(_triggers, value, winEvent, f, flags, later); ref var last = ref _tActive; if (t.IsVisible)