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(); }
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(); }
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); }
public IUIController Run(UIControllerFlow flow) { var controller = Configure(flow); controller.Start(); return(controller); }
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); }
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]); } }
void StartFlow(UIControllerFlow controllerFlow) { var uiProvider = ServiceProvider.GetExportedValue<IUIProvider>(); var ret = uiProvider.SetupUI(controllerFlow, null); ret.Subscribe(c => { }, () => CheckLogin().Forget()); uiProvider.RunUI(); }
void StartFlow(UIControllerFlow controllerFlow) { var uiProvider = ServiceProvider.GetExportedValue <IUIProvider>(); uiProvider.GitServiceProvider = ServiceProvider; uiProvider.RunUI(controllerFlow, SectionConnection); }
void StartFlow(UIControllerFlow controllerFlow) { var uiProvider = ServiceProvider.GetExportedValue <IUIProvider>(); var ret = uiProvider.SetupUI(controllerFlow, null); ret.Subscribe(c => { }, () => CheckLogin().Forget()); uiProvider.RunUI(); }
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); }
void StartFlow(UIControllerFlow controllerFlow) { var uiProvider = ServiceProvider.GetService <IUIProvider>(); var controller = uiProvider.Configure(controllerFlow); controller.TransitionSignal.Subscribe(c => { }, () => CheckLogin().Forget()); uiProvider.RunInDialog(controller); }
public IObservable <LoadData> SelectFlow(UIControllerFlow choice) { mainFlow = choice; transition = new Subject <LoadData>(); transition.Subscribe(_ => {}, _ => Fire(Trigger.Next)); return(transition); }
void ShutdownFlow(UIControllerFlow flow) { var list = GetObjectsForFlow(flow); foreach (var i in list.Values) { i.ClearHandlers(); } }
public IObservable <UserControl> SelectFlow(UIControllerFlow choice) { currentFlow = choice; transition = new Subject <UserControl>(); transition.Subscribe(_ => { }, _ => Fire(Trigger.Next)); return(transition); }
void DisposeFlow(UIControllerFlow flow) { var list = GetObjectsForFlow(flow); foreach (var i in list.Values) { i.Dispose(); } list.Clear(); }
/// <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); }
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); }
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); }
void DisposeView(UIControllerFlow flow, UIViewType type) { var list = GetObjectsForFlow(flow); IUIPair uipair = null; if (list.TryGetValue(type, out uipair)) { list.Remove(type); uipair.Dispose(); } }
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); }
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; }
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); } }
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); }
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); }
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); }
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); }
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(); }
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); } }
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(); }
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(); }
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); }
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(); }
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); }
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(); }
public IObservable<UserControl> SelectFlow(UIControllerFlow choice) { currentFlow = choice; transition = new Subject<UserControl>(); transition.Subscribe(_ => { }, _ => Fire(Trigger.Next)); return transition; }
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]); } }
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); }
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(); }
void StartFlow(UIControllerFlow controllerFlow) { var uiProvider = ServiceProvider.GetExportedValue<IUIProvider>(); uiProvider.GitServiceProvider = ServiceProvider; uiProvider.RunUI(controllerFlow, SectionConnection); }
public ViewWithData(UIControllerFlow flow) { ActiveFlow = flow; MainFlow = flow; }
void StartFlow(UIControllerFlow controllerFlow) { var uiProvider = ServiceProvider.GetExportedValue<IUIProvider>(); uiProvider.RunUI(controllerFlow, null); }
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(); }