Example #1
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;
        }
        void StartFlow(UIControllerFlow controllerFlow, [AllowNull] IConnection conn, ViewWithData data = null)
        {
            Stop();

            if (conn == null)
            {
                return;
            }

            switch (controllerFlow)
            {
            case UIControllerFlow.PullRequests:
                Title = Resources.PullRequestsNavigationItemText;
                break;

            default:
                Title = "GitHub";
                break;
            }

            var uiProvider = ServiceProvider.GetExportedValue <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);
        }
        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);
        }
Example #4
0
 public void Run(IUIController controller)
 {
     controller.Start();
 }