Beispiel #1
0
    public T ShowDialog <T>(IView owner = null, IViewModel viewModel = null, DialogShowMethod method = DialogShowMethod.AddFront, Action <T> onShown = null) where T : class, IView
    {
        Action <T> newOnShown = dialog =>
        {
            if (onShown != null)
            {
                onShown(dialog);
            }
            OnViewCreated(dialog);
        };
        var result = _dialogManager.ShowDialog(GetViewTypeByView(typeof(T)), owner, viewModel, method, newOnShown);

        return(result);
    }
Beispiel #2
0
    public IView ShowDialog(Type type, ViewType viewType, IView owner = null, IViewModel viewModel = null, DialogShowMethod method = DialogShowMethod.AddFront, Action <IView> onShown = null)
    {
        D.Log(LoggingTags.Events, "Open Dialog: " + type);
        IView dialog = null;

        if (Current == null && method == DialogShowMethod.Queued)
        {
            method = DialogShowMethod.AddFront;
        }

        switch (method)
        {
        case DialogShowMethod.AddFront:
            dialog = CreateDialog(type, owner, viewModel);
            if (Current != null)
            {
                dialog.Next = Current;
            }

            var currentScreen = _screensManager.Current;
            if (currentScreen != null)
            {
                currentScreen.OnBlur();
            }

            break;

        case DialogShowMethod.CloseOthers:
            dialog = CreateDialog(type, owner, viewModel);
            if (Current != null)
            {
                CloseAll();
            }
            break;

        case DialogShowMethod.Queued:
            if (Current != null)
            {
                _dialogQueue.Enqueue(new QueueData
                {
                    mOpenDialogAction = () => ShowDialog(type, viewType, owner, viewModel, DialogShowMethod.AddFront, onShown),
                    mOwnerScreen      = owner
                });
                return(null);
            }
            dialog = CreateDialog(type, owner, viewModel);
            break;
        }

        AfterCreateDialog(viewType, onShown, dialog);

        return(dialog);
    }
Beispiel #3
0
 public ShowDialogMessage(ViewModelBase vmb, Window dialog, DialogShowMethod method, Action<bool?> callback = null)
     : this(dialog, method, callback)
 {
     this.ParentViewModel = vmb;
 }
Beispiel #4
0
    /// <summary>
    ///     Показать диалог с медиатором TDialogClass
    /// </summary>
    /// <typeparam name="T">Медиатор показываемого диалога</typeparam>
    /// <param name="viewType">Тип вьюмодели</param>
    /// <param name="owner">открывающий скрин. Может быть null</param>
    /// <param name="method">Способ отображения диалога</param>
    /// <param name="onShown"> </param>
    /// <returns>Инстанс медиатора диалога</returns>
    public T ShowDialog <T>(ViewType viewType, IView owner = null, IViewModel viewModel = null, DialogShowMethod method = DialogShowMethod.AddFront,
                            Action <T> onShown             = null) where T : class, IView
    {
        Action <IView> onShowAction = null;

        if (onShown != null)
        {
            onShowAction = a => onShown(a as T);
        }
        return(ShowDialog(typeof(T), viewType, owner, viewModel, method, onShowAction) as T);
    }
Beispiel #5
0
 public ShowDialogMessage(Window dialog, DialogShowMethod method, Action<bool?> callback = null)
 {
     this.Dialog = dialog;
     this.ShowMethod = method;
     this.Calllback = callback;
 }