コード例 #1
0
        void StartFlow(UIControllerFlow controllerFlow)
        {
            var notifications = ServiceProvider.TryGetService <INotificationDispatcher>();
            var teServices    = ServiceProvider.TryGetService <ITeamExplorerServices>();

            notifications.AddListener(teServices);

            ServiceProvider.GitServiceProvider = TEServiceProvider;
            var uiProvider = ServiceProvider.TryGetService <IUIProvider>();
            var controller = uiProvider.Configure(controllerFlow, SectionConnection);

            controller.ListenToCompletionState()
            .Subscribe(success =>
            {
                if (success)
                {
                    if (controllerFlow == UIControllerFlow.Clone)
                    {
                        isCloning = true;
                    }
                    else if (controllerFlow == UIControllerFlow.Create)
                    {
                        isCreating = true;
                    }
                }
            });
            uiProvider.RunInDialog(controller);

            notifications.RemoveListener();
        }
コード例 #2
0
        void StartFlow(UIControllerFlow controllerFlow)
        {
            var notifications = ServiceProvider.GetExportedValue <INotificationDispatcher>();
            var teServices    = ServiceProvider.GetExportedValue <ITeamExplorerServices>();

            notifications.AddListener(teServices);

            var uiProvider = ServiceProvider.GetExportedValue <IUIProvider>();

            uiProvider.GitServiceProvider = ServiceProvider;
            uiProvider.SetupUI(controllerFlow, SectionConnection);
            uiProvider.ListenToCompletionState()
            .Subscribe(success =>
            {
                if (success)
                {
                    if (controllerFlow == UIControllerFlow.Clone)
                    {
                        isCloning = true;
                    }
                    else if (controllerFlow == UIControllerFlow.Create)
                    {
                        isCreating = true;
                    }
                }
            });
            uiProvider.RunUI();

            notifications.RemoveListener();
        }
コード例 #3
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);
        }
コード例 #4
0
ファイル: UIProvider.cs プロジェクト: nsb1271/UWPapplication
        public IUIController Run(UIControllerFlow flow)
        {
            var controller = Configure(flow);

            controller.Start();
            return(controller);
        }
コード例 #5
0
ファイル: UIProvider.cs プロジェクト: nsb1271/UWPapplication
        public IUIController Configure(UIControllerFlow flow, IConnection connection = null, ViewWithData data = null)
        {
            var controller = new UIController(serviceProvider);

            disposables.Add(controller);
            var listener = controller.Configure(flow, connection, data).Publish().RefCount();

            listener.Subscribe(_ => { }, () =>
            {
                StopUI(controller);
            });

            // 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
            listener
            .Where(c => c.Flow == UIControllerFlow.Authentication)
            .ObserveOn(RxApp.TaskpoolScheduler)
            .Subscribe(c =>
            {
                // nothing to do, we already have a dialog
                if (windowController != null)
                {
                    return;
                }
                RunModalDialogForAuthentication(c.Flow, listener, c).Forget();
            });

            return(controller);
        }
コード例 #6
0
        void LoadView(UIControllerFlow flow, IConnection connection = null, ViewWithData data = null, UIViewType type = UIViewType.None)
        {
            // if we're loading a single view or a different flow, we need to stop the current controller
            var restart = flow == UIControllerFlow.None || uiController?.SelectedFlow != flow;

            if (restart)
            {
                Stop();
            }

            // if there's no selected flow, then just load a view directly
            if (flow == UIControllerFlow.None)
            {
                var factory = ServiceProvider.GetExportedValue <IUIFactory>();
                var c       = factory.CreateViewAndViewModel(type);
                c.View.DataContext = c.ViewModel;
                Control            = c.View;
            }
            // it's a new flow!
            else if (restart)
            {
                StartFlow(flow, connection, data);
            }
            // navigate to a requested view within the currently running uiController
            else
            {
                uiController.Jump(data ?? navStack[currentNavItem]);
            }
        }
コード例 #7
0
 void StartFlow(UIControllerFlow controllerFlow)
 {
     var uiProvider = ServiceProvider.GetExportedValue<IUIProvider>();
     var ret = uiProvider.SetupUI(controllerFlow, null);
     ret.Subscribe(c => { }, () => CheckLogin().Forget());
     uiProvider.RunUI();
 }
コード例 #8
0
        void StartFlow(UIControllerFlow controllerFlow)
        {
            var uiProvider = ServiceProvider.GetExportedValue <IUIProvider>();

            uiProvider.GitServiceProvider = ServiceProvider;
            uiProvider.RunUI(controllerFlow, SectionConnection);
        }
コード例 #9
0
        void StartFlow(UIControllerFlow controllerFlow)
        {
            var uiProvider = ServiceProvider.GetExportedValue <IUIProvider>();
            var ret        = uiProvider.SetupUI(controllerFlow, null);

            ret.Subscribe(c => { }, () => CheckLogin().Forget());
            uiProvider.RunUI();
        }
コード例 #10
0
        UIViewType Go(Trigger trigger, UIControllerFlow flow)
        {
            var m = machines[flow];

            Debug.WriteLine("Firing {0} from {1} for flow {2} ({3})", trigger, m.State, flow, GetHashCode());
            m.Fire(trigger);
            return(m.State);
        }
コード例 #11
0
        void StartFlow(UIControllerFlow controllerFlow)
        {
            var uiProvider = ServiceProvider.GetService <IUIProvider>();
            var controller = uiProvider.Configure(controllerFlow);

            controller.TransitionSignal.Subscribe(c => { }, () => CheckLogin().Forget());
            uiProvider.RunInDialog(controller);
        }
コード例 #12
0
        public IObservable <LoadData> SelectFlow(UIControllerFlow choice)
        {
            mainFlow = choice;

            transition = new Subject <LoadData>();
            transition.Subscribe(_ => {}, _ => Fire(Trigger.Next));

            return(transition);
        }
コード例 #13
0
        void ShutdownFlow(UIControllerFlow flow)
        {
            var list = GetObjectsForFlow(flow);

            foreach (var i in list.Values)
            {
                i.ClearHandlers();
            }
        }
コード例 #14
0
        public IObservable <UserControl> SelectFlow(UIControllerFlow choice)
        {
            currentFlow = choice;

            transition = new Subject <UserControl>();
            transition.Subscribe(_ => { }, _ => Fire(Trigger.Next));

            return(transition);
        }
コード例 #15
0
        void DisposeFlow(UIControllerFlow flow)
        {
            var list = GetObjectsForFlow(flow);

            foreach (var i in list.Values)
            {
                i.Dispose();
            }
            list.Clear();
        }
コード例 #16
0
        /// <summary>
        /// Returns the view/viewmodel pair for a given flow
        /// </summary>
        Dictionary <UIViewType, IUIPair> GetObjectsForFlow(UIControllerFlow flow)
        {
            Dictionary <UIViewType, IUIPair> list;

            if (!uiObjects.TryGetValue(flow, out list))
            {
                list = new Dictionary <UIViewType, IUIPair>();
                uiObjects.Add(flow, list);
            }
            return(list);
        }
コード例 #17
0
        void ShowDialog(UIControllerFlow flow)
        {
            var ui                    = App.ServiceProvider.GetService <IUIProvider>();
            var controller            = ui.Configure(flow);
            var userControlObservable = controller.TransitionSignal;
            var x = new WindowController(userControlObservable);

            userControlObservable.Subscribe(_ => { }, _ => x.Close());
            x.Show();
            ui.RunInDialog(controller);
        }
コード例 #18
0
ファイル: MenuBase.cs プロジェクト: github/VisualStudio
 protected void StartFlow(UIControllerFlow controllerFlow)
 {
     IConnection connection = null;
     if (controllerFlow != UIControllerFlow.Authentication)
     {
         var activeRepo = GetActiveRepo();
         connection = ServiceProvider.TryGetService<IConnectionManager>()?.Connections
             .FirstOrDefault(c => activeRepo?.CloneUrl?.RepositoryName != null && c.HostAddress.Equals(HostAddress.Create(activeRepo.CloneUrl)));
     }
     ServiceProvider.RunUI(controllerFlow, connection);
 }
コード例 #19
0
        void DisposeView(UIControllerFlow flow, UIViewType type)
        {
            var     list   = GetObjectsForFlow(flow);
            IUIPair uipair = null;

            if (list.TryGetValue(type, out uipair))
            {
                list.Remove(type);
                uipair.Dispose();
            }
        }
コード例 #20
0
        protected void StartFlow(UIControllerFlow controllerFlow)
        {
            IConnection connection = null;

            if (controllerFlow != UIControllerFlow.Authentication)
            {
                var activeRepo = GetActiveRepo();
                connection = ServiceProvider.TryGetService <IConnectionManager>()?.Connections
                             .FirstOrDefault(c => activeRepo?.CloneUrl?.RepositoryName != null && c.HostAddress.Equals(HostAddress.Create(activeRepo.CloneUrl)));
            }
            ServiceProvider.TryGetService <IUIProvider>().RunInDialog(controllerFlow, connection);
        }
コード例 #21
0
ファイル: UIProvider.cs プロジェクト: nsb1271/UWPapplication
        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;
        }
コード例 #22
0
 public void RunUI(UIControllerFlow controllerFlow, [AllowNull] IConnection connection)
 {
     SetupUI(controllerFlow, connection);
     try
     {
         windowController.ShowModal();
     }
     catch (Exception ex)
     {
         log.Error("WindowController ShowModal failed for {0}. {1}", controllerFlow, ex);
     }
 }
コード例 #23
0
        void ShowDialog(UIControllerFlow flow)
        {
            var ui = App.ServiceProvider.GetService<IUIProvider>();

            var factory = ui.GetService<IExportFactoryProvider>();
            var d = factory.UIControllerFactory.CreateExport();
            var userControlObservable = d.Value.SelectFlow(flow);
            var x = new WindowController(userControlObservable);
            userControlObservable.Subscribe(_ => { }, _ => x.Close());
            x.Show();
            d.Value.Start(null);
        }
コード例 #24
0
        public IObservable <LoadData> Configure(UIControllerFlow choice,
                                                IConnection conn        = null,
                                                ViewWithData parameters = null)
        {
            connection      = conn;
            selectedFlow    = choice;
            requestedTarget = parameters;

            transition = new Subject <LoadData>();
            transition.Subscribe(_ => {}, _ => Fire(Trigger.Next));

            return(transition);
        }
コード例 #25
0
        void ShowDialog(UIControllerFlow flow)
        {
            var ui = App.ServiceProvider.GetExportedValue <IUIProvider>();

            var factory = ui.GetService <IExportFactoryProvider>();
            var d       = factory.UIControllerFactory.CreateExport();
            var userControlObservable = d.Value.SelectFlow(flow);
            var x = new WindowController(userControlObservable);

            userControlObservable.Subscribe(_ => { }, _ => x.Close());
            x.Show();
            d.Value.Start(null);
        }
コード例 #26
0
        void ConfigureSingleViewLogic(UIControllerFlow flow, UIViewType type)
        {
            var logic = new StateMachineType(UIViewType.None);

            logic.Configure(UIViewType.None)
            .Permit(Trigger.Next, type)
            .Permit(Trigger.Finish, UIViewType.End);
            logic.Configure(type)
            .Permit(Trigger.Next, UIViewType.End)
            .Permit(Trigger.Cancel, UIViewType.End)
            .Permit(Trigger.Finish, UIViewType.End);
            logic.Configure(UIViewType.End)
            .Permit(Trigger.Next, UIViewType.None);
            machines.Add(flow, logic);
        }
コード例 #27
0
        void StartFlow(UIControllerFlow controllerFlow)
        {
            var uiProvider = ServiceProvider.GetExportedValue <IUIProvider>();
            var ret        = uiProvider.SetupUI(controllerFlow, null);

            ret.Subscribe((c) => { }, async() =>
            {
                loggedIn = await connectionManager.IsLoggedIn(hosts);
                if (loggedIn)
                {
                    ShowPublish();
                }
            });
            uiProvider.RunUI();
        }
コード例 #28
0
        public void RunUI(UIControllerFlow controllerFlow, [AllowNull] IConnection connection)
        {
            if (!Initialized)
            {
                log.Error("ExportProvider is not initialized, cannot run UI for {0}.", controllerFlow);
                return;
            }

            SetupUI(controllerFlow, connection);
            try
            {
                windowController.ShowModal();
            }
            catch (Exception ex)
            {
                log.Error("WindowController ShowModal failed for {0}. {1}", controllerFlow, ex);
            }
        }
コード例 #29
0
        void StartFlow(UIControllerFlow controllerFlow)
        {
            var uiProvider = ServiceProvider.GetExportedValue <IUIProvider>();

            uiProvider.GitServiceProvider = ServiceProvider;
            var ret = uiProvider.SetupUI(controllerFlow, SectionConnection);

            ret.Subscribe(c =>
            {
                if (c.IsViewType(UIViewType.Clone))
                {
                    isCloning = true;
                }
                else if (c.IsViewType(UIViewType.Create))
                {
                    isCreating = true;
                }
            });
            uiProvider.RunUI();
        }
コード例 #30
0
        void StartFlow(UIControllerFlow controllerFlow)
        {
            var notifications = ServiceProvider.GetExportedValue <INotificationDispatcher>();
            var teServices    = ServiceProvider.GetExportedValue <ITeamExplorerServices>();

            notifications.AddListener(teServices);

            var uiProvider = ServiceProvider.GetExportedValue <IUIProvider>();

            uiProvider.GitServiceProvider = ServiceProvider;
            uiProvider.SetupUI(controllerFlow, null);
            uiProvider.ListenToCompletionState()
            .Subscribe(success =>
            {
                Refresh();
            });
            uiProvider.RunUI();

            notifications.RemoveListener();
        }
コード例 #31
0
ファイル: MenuBase.cs プロジェクト: wallivy/VisualStudio
        protected void StartFlow(UIControllerFlow controllerFlow)
        {
            var uiProvider = ServiceProvider.GetExportedValue <IUIProvider>();

            Debug.Assert(uiProvider != null, "MenuBase:StartFlow:No UIProvider available.");
            if (uiProvider == null)
            {
                return;
            }

            IConnection connection = null;

            if (controllerFlow != UIControllerFlow.Authentication)
            {
                var activeRepo = GetActiveRepo();
                connection = ServiceProvider.GetExportedValue <IConnectionManager>()?.Connections
                             .FirstOrDefault(c => activeRepo?.CloneUrl?.RepositoryName != null && c.HostAddress.Equals(HostAddress.Create(activeRepo.CloneUrl)));
            }
            uiProvider.RunUI(controllerFlow, connection);
        }
コード例 #32
0
        void StartFlow(UIControllerFlow controllerFlow)
        {
            var notifications = ServiceProvider.TryGetService <INotificationDispatcher>();
            var teServices    = ServiceProvider.TryGetService <ITeamExplorerServices>();

            notifications.AddListener(teServices);

            ServiceProvider.GitServiceProvider = TEServiceProvider;
            var uiProvider = ServiceProvider.TryGetService <IUIProvider>();
            var controller = uiProvider.Configure(controllerFlow);

            controller.ListenToCompletionState()
            .Subscribe(success =>
            {
                Refresh();
            });
            uiProvider.RunInDialog(controller);

            notifications.RemoveListener();
        }
コード例 #33
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);
        }
コード例 #34
0
 void StartFlow(UIControllerFlow controllerFlow)
 {
     var uiProvider = ServiceProvider.GetExportedValue<IUIProvider>();
     uiProvider.GitServiceProvider = ServiceProvider;
     var ret = uiProvider.SetupUI(controllerFlow, SectionConnection);
     ret.Subscribe(c =>
     {
         if (c.IsViewType(UIViewType.Clone))
             isCloning = true;
         else if (c.IsViewType(UIViewType.Create))
             isCreating = true;
     });
     uiProvider.RunUI();
 }
コード例 #35
0
        public IObservable<UserControl> SelectFlow(UIControllerFlow choice)
        {
            currentFlow = choice;

            transition = new Subject<UserControl>();
            transition.Subscribe(_ => { }, _ => Fire(Trigger.Next));
        
            return transition;
        }
コード例 #36
0
        void LoadView(UIControllerFlow flow, IConnection connection = null, ViewWithData data = null, UIViewType type = UIViewType.None)
        {
            // if we're loading a single view or a different flow, we need to stop the current controller
            var restart = flow == UIControllerFlow.None || uiController?.SelectedFlow != flow;

            if (restart)
                Stop();

            // if there's no selected flow, then just load a view directly
            if (flow == UIControllerFlow.None)
            {
                var factory = ServiceProvider.GetExportedValue<IUIFactory>();
                var c = factory.CreateViewAndViewModel(type);
                c.View.DataContext = c.ViewModel;
                Control = c.View;
            }
            // it's a new flow!
            else if (restart)
            {
                StartFlow(flow, connection, data);
            }
            // navigate to a requested view within the currently running uiController
            else
            {
                uiController.Jump(data ?? navStack[currentNavItem]);
            }
        }
コード例 #37
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);
        }
コード例 #38
0
        void StartFlow(UIControllerFlow controllerFlow)
        {
            var notifications = ServiceProvider.GetExportedValue<INotificationDispatcher>();
            var teServices = ServiceProvider.GetExportedValue<ITeamExplorerServices>();
            notifications.AddListener(teServices);

            var uiProvider = ServiceProvider.GetExportedValue<IUIProvider>();
            uiProvider.GitServiceProvider = ServiceProvider;
            var ret = uiProvider.SetupUI(controllerFlow, SectionConnection);
            ret.Subscribe(_ => {}, () =>
            {
                if (controllerFlow == UIControllerFlow.Clone)
                    isCloning = true;
                else if (controllerFlow == UIControllerFlow.Create)
                    isCreating = true;
            });
            uiProvider.RunUI();

            notifications.RemoveListener();
        }
コード例 #39
0
 void StartFlow(UIControllerFlow controllerFlow)
 {
     var uiProvider = ServiceProvider.GetExportedValue<IUIProvider>();
     uiProvider.GitServiceProvider = ServiceProvider;
     uiProvider.RunUI(controllerFlow, SectionConnection);
 }
コード例 #40
0
ファイル: IUIController.cs プロジェクト: github/VisualStudio
 public ViewWithData(UIControllerFlow flow)
 {
     ActiveFlow = flow;
     MainFlow = flow;
 }
コード例 #41
0
 void StartFlow(UIControllerFlow controllerFlow)
 {
     var uiProvider = ServiceProvider.GetExportedValue<IUIProvider>();
     uiProvider.RunUI(controllerFlow, null);
 }
コード例 #42
0
 void StartFlow(UIControllerFlow controllerFlow)
 {
     var uiProvider = ServiceProvider.GetService<IUIProvider>();
     var ret = uiProvider.SetupUI(controllerFlow, null);
     ret.Subscribe((c) => { }, async () =>
     {
         loggedIn = await connectionManager.IsLoggedIn(hosts);
         if (loggedIn)
             ShowPublish();
     });
     uiProvider.RunUI();
 }