예제 #1
0
        public async Task <TU> ShowDialog <TU>(Func <IDialog <TU>, Window> window)
        {
            return(await await Fusion.Application.MainThread.InvokeAsync(() =>
            {
                var childWindow = new WindowsDialog <TU>();

                var model = window(childWindow);

                if (model.Style == WindowStyle.Sheet)
                {
                    var content = model.Size.HasValue
                                                        ? model.Content.WithSize(model.Size.Value.NotNone().Transpose())
                                                        : model.Content;

                    childWindow._modalDialogs = _modalDialogs;
                    childWindow._parent = _parent;
                    childWindow._onClose = () =>
                                           _modalDialogs.OnNext(_modalDialogs.Value.Remove(content));

                    _modalDialogs.OnNext(_modalDialogs.Value.Add(content));
                }
                else
                {
                    var modalDialogs = new BehaviorSubject <IImmutableList <IControl> >(ImmutableList <IControl> .Empty);

                    var wnd = WindowImplementation.Initialize(OverlayModalDialogs(model, modalDialogs));

                    childWindow._modalDialogs = modalDialogs;
                    childWindow._parent = wnd;
                    childWindow._onClose = () =>
                    {
                        Fusion.Application.MainThread.Schedule(wnd.Close);
                    };

                    wnd.Show();
                }

                return childWindow._result.FirstAsync();
            }));
        }
예제 #2
0
        public void CreateSingletonWindow(IObservable <bool> isVisible, Func <IDialog <object>, Window> window)
        {
            Fusion.Application.MainThread.Schedule(() =>
            {
                var modalDialogs = new BehaviorSubject <IImmutableList <IControl> >(ImmutableList <IControl> .Empty);

                var childWindow = new WindowsDialog <object>();

                var model = OverlayModalDialogs(window(childWindow), modalDialogs);

                var wnd = WindowImplementation.Initialize(model);

                childWindow._modalDialogs = modalDialogs;
                childWindow._parent       = wnd;
                childWindow._onClose      = () =>
                                            Fusion.Application.MainThread.Schedule(wnd.Hide);

                wnd.Closing += (s, a) =>
                {
                    a.Cancel = true;
                    wnd.Hide();
                };

                isVisible.Subscribe(vis =>
                                    Fusion.Application.MainThread.Schedule(() =>
                {
                    if (vis)
                    {
                        wnd.Show();
                    }
                    if (!vis)
                    {
                        wnd.Hide();
                    }
                }));
            });
        }