private void OnDialogStateChanged(object sender, DialogState e) { if (sender is IDialog dialog) { switch (e) { case DialogState.Active: if (ActiveDialogs.Contains(dialog)) { return; } MinimizedDialogs.RemoveIfExists(dialog); ActiveDialogs.Add(dialog); break; case DialogState.Minimized: if (MinimizedDialogs.Contains(dialog)) { return; } ActiveDialogs.RemoveIfExists(dialog); MinimizedDialogs.Add(dialog); break; default: throw new ArgumentOutOfRangeException(nameof(e), e, null); } DialogStateChanged?.Invoke(this, dialog); } }
public void CloseAllDialogs(bool clearQueue = false) { ActiveDialogs.ForEach(d => d.Close()); if (clearQueue) { _queue.Clear(); } }
private void ContainerClosed(object sender, EventArgs e) { if (sender is IDialog dialog) { MinimizedDialogs.RemoveIfExists(dialog); ActiveDialogs.RemoveIfExists(dialog); DialogClosed?.Invoke(this, dialog); } }
protected override void BeforeOpen(bool skipAnimation) { base.BeforeOpen(skipAnimation); ActiveDialogs.Push(this); Canvas.overrideSorting = true; Canvas.sortingOrder = ActiveDialogs.Count; }
// close/submit dialogs when the scene changes/gets deselected // TODO Timeout component (as in graphic settings) - executes an action when the timer expires (also updates a UI element) // TODO scene changed event /// <summary> /// OnBlurred callback. Activate it only on the dialog /// </summary> protected virtual void OnBlurred() { if (!IsOpened || ActiveDialogs.Peek() != this) { return; } switch (deselectAction) { case DeselectAction.None: break; case DeselectAction.Submit: Submit(); break; case DeselectAction.Cancel: Cancel(); break; default: goto case DeselectAction.None; } }
/// <inheritdoc /> public IEnumerable <IDialog> GetActiveDialogs() { return(ActiveDialogs.ToList()); }
protected override void AfterClose() { ActiveDialogs.Pop(); Canvas.overrideSorting = false; }