Inheritance: DialogWindow, IDisposable
Ejemplo n.º 1
0
        public IObservable <LoadData> SetupUI(UIControllerFlow controllerFlow, [AllowNull] IConnection connection)
        {
            StopUI();

            var factory = TryGetService(typeof(IExportFactoryProvider)) as IExportFactoryProvider;

            currentUIFlow = factory.UIControllerFactory.CreateExport();
            var disposable = currentUIFlow;
            var ui         = currentUIFlow.Value;
            var creation   = ui.SelectFlow(controllerFlow);

            windowController = new UI.WindowController(creation);
            windowController.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            windowController.Closed += StopUIFlowWhenWindowIsClosedByUser;
            creation.Subscribe(c => {}, () =>
            {
                windowController.Closed -= StopUIFlowWhenWindowIsClosedByUser;
                windowController.Close();
                if (currentUIFlow != disposable)
                {
                    StopUI(disposable);
                }
                else
                {
                    StopUI();
                }
            });
            ui.Start(connection);
            return(creation);
        }
Ejemplo n.º 2
0
        async Task RunModalDialogForAuthentication(UIControllerFlow flow, IObservable <LoadData> listener, LoadData initiaLoadData)
        {
            await ThreadingHelper.SwitchToMainThreadAsync();

            windowController = new WindowController(listener,
                                                    (v, f) => f == flow,
                                                    (v, f) => f != flow);
            windowController.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            windowController.Load(initiaLoadData.View);
            windowController.ShowModal();
            windowController = null;
        }
Ejemplo n.º 3
0
        public void RunInDialog(IUIController controller)
        {
            var listener = controller.TransitionSignal;

            windowController = new UI.WindowController(listener);
            windowController.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            EventHandler stopUIAction = (s, e) =>
            {
                StopUI(controller);
            };

            windowController.Closed += stopUIAction;
            listener.Subscribe(_ => { }, () =>
            {
                windowController.Closed -= stopUIAction;
                windowController.Close();
                StopUI(controller);
            });

            controller.Start();
            windowController.ShowModal();
            windowController = null;
        }
Ejemplo n.º 4
0
        public IObservable <LoadData> SetupUI(UIControllerFlow controllerFlow, [AllowNull] IConnection connection)
        {
            if (!Initialized)
            {
                log.Error("ExportProvider is not initialized, cannot setup UI.");
                return(Observable.Empty <LoadData>());
            }

            StopUI();

            var factory = GetService <IExportFactoryProvider>();

            currentUIFlow = factory.UIControllerFactory.CreateExport();
            var disposable = currentUIFlow;
            var ui         = currentUIFlow.Value;
            var creation   = ui.SelectFlow(controllerFlow);

            windowController = new UI.WindowController(creation);
            windowController.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            windowController.Closed += StopUIFlowWhenWindowIsClosedByUser;
            creation.Subscribe(c => {}, () =>
            {
                windowController.Closed -= StopUIFlowWhenWindowIsClosedByUser;
                windowController.Close();
                if (currentUIFlow != disposable)
                {
                    StopUI(disposable);
                }
                else
                {
                    StopUI();
                }
            });
            ui.Start(connection);
            return(creation);
        }
Ejemplo n.º 5
0
        void StartFlow(UIControllerFlow controllerFlow, [AllowNull]IConnection conn, ViewWithData data = null)
        {
            Stop();

            if (conn == null)
                return;

            var uiProvider = ServiceProvider.GetService<IUIProvider>();
            var factory = uiProvider.GetService<IExportFactoryProvider>();
            var uiflow = factory.UIControllerFactory.CreateExport();
            disposables.Add(uiflow);
            uiController = uiflow.Value;
            var creation = uiController.SelectFlow(controllerFlow).Publish().RefCount();

            // if the flow is authentication, we need to show the login dialog. and we can't
            // block the main thread on the subscriber, it'll block other handlers, so we're doing
            // this on a separate thread and posting the dialog to the main thread
            creation
                .Where(c => uiController.CurrentFlow == UIControllerFlow.Authentication)
                .ObserveOn(RxApp.TaskpoolScheduler)
                .Subscribe(c =>
                {
                    // nothing to do, we already have a dialog
                    if (windowController != null)
                        return;
                    syncContext.Post(_ =>
                    {
                        windowController = new WindowController(creation,
                            __ => uiController.CurrentFlow == UIControllerFlow.Authentication,
                            ___ => uiController.CurrentFlow != UIControllerFlow.Authentication);
                        windowController.WindowStartupLocation = WindowStartupLocation.CenterOwner;
                        windowController.Load(c.View);
                        windowController.ShowModal();
                        windowController = null;
                    }, null);
                });

            creation
                .Where(c => uiController.CurrentFlow != UIControllerFlow.Authentication)
                .Subscribe(c =>
                {
                    if (!navigatingViaArrows)
                    {
                        if (c.Direction == LoadDirection.Forward)
                            GoForward(c.Data);
                        else if (c.Direction == LoadDirection.Back)
                            GoBack();
                    }
                    UpdateToolbar();

                    Control = c.View;
                });

            if (data != null)
                uiController.Jump(data);
            uiController.Start(conn);
        }