Exemplo n.º 1
0
        public void CreateSingletonWindow(IObservable <bool> isVisible, Func <IDialog <object>, Window> window)
        {
            Fusion.Application.MainThread.Schedule(() =>
            {
                var childWindow = new MacDialog <object>();

                var handle = WindowImplementation.Create(window(childWindow), Optional.None());
                handle.ReleasedWhenClosed = false;

                var close            = new Subject <bool>();
                childWindow._parent  = handle;
                childWindow._onClose = () => close.OnNext(false);

                isVisible.Merge(close).Subscribe(vis =>
                                                 Fusion.Application.MainThread.Schedule(() =>
                {
                    if (vis)
                    {
                        handle.MakeKeyAndOrderFront(handle);
                    }
                    else
                    {
                        handle.OrderOut(handle);
                    }
                }));
            });
        }
Exemplo n.º 2
0
        public static void ShowDocumentWindow(ObservableNSDocument document, Func <IDialog <object>, Window> window)
        {
            Fusion.Application.MainThread.Schedule(() =>
            {
                var childWindow = new MacDialog <object>();

                var handle = WindowImplementation.Create(window(childWindow), Optional.Some(document));

                childWindow._parent  = handle;
                childWindow._onClose = () =>
                                       Fusion.Application.MainThread.Schedule(document.Close);

                document.AddWindowController(new DocumentWindowController(handle));
            });
        }
Exemplo n.º 3
0
        public async Task <TU> ShowDialog <TU>(Func <IDialog <TU>, Window> window)
        {
            return(await await Fusion.Application.MainThread.InvokeAsync(() =>
            {
                var childWindow = new MacDialog <TU>();

                var model = window(childWindow);
                var handle = WindowImplementation.Create(model, Optional.None());

                childWindow._parent = handle;
                childWindow._onClose = () =>
                                       Fusion.Application.MainThread.Schedule(() =>
                {
                    if (model.Style == WindowStyle.Sheet)
                    {
                        NSApplication.SharedApplication.EndSheet(handle);
                        handle.OrderOut(handle);
                    }
                    else
                    {
                        handle.Close();
                    }
                });

                if (model.Style == WindowStyle.Sheet)
                {
                    NSApplication.SharedApplication.BeginSheet(handle, _parent.Value);
                }
                else
                {
                    handle.MakeKeyAndOrderFront(handle);
                }

                return childWindow._result.FirstAsync();
            }));
        }