public AutoAttachCharacter( SelectCharacter characterSelecter, SelectProcessViewModel processSelecter, IDialogCoordinator dialogCoordinator, EventMessenger events) : base(events) { _characterSelecter = characterSelecter; _processSelecter = processSelecter; }
public async Task Handle() { // Let user select ffxi process SelectProcessDialog selectionView = new SelectProcessDialog(); SelectProcessViewModel viewModel = new SelectProcessViewModel(selectionView); selectionView.DataContext = viewModel; // Show window and do not continue until user closes it. await _window.ShowMetroDialogAsync(selectionView); await selectionView.WaitUntilUnloadedAsync(); // Get the selected process. Process process = viewModel.SelectedProcess; ChangeCharacter(new SelectCharacterResult { Process = process, IsSelected = viewModel.IsProcessSelected }); }
/// <summary> /// Creates an instance of the given type. /// </summary> /// <param name="requestedType"></param> /// <returns></returns> /// <remarks> /// Every object in the composite root should be instantiates before returning the requested type. /// Otherwise, classes may not work correctly with each other, if they use an indirect way of communicating /// such as through events. /// </remarks> private object CreateInstance(Type requestedType) { MetroWindow metroWindow = Application.Current.MainWindow as MetroWindow; App app = Application.Current as App; LibraryUpdater libraryUpdater = new LibraryUpdater(); DialogCoordinator dialogCoordinator = new DialogCoordinator(); Persister persister = new Persister(); UpdateEliteAPI updateEliteAPI = new UpdateEliteAPI(libraryUpdater, EventMessenger); SelectCharacter selectCharacterRequest = new SelectCharacter(EventMessenger, metroWindow); SelectAbilityRequestHandler selectAbilityRequestHandler = new SelectAbilityRequestHandler(metroWindow); BattlesViewModel battlesViewModel = new BattlesViewModel(); FollowViewModel followViewModel = new FollowViewModel(); IgnoredViewModel ignoredViewModel = new IgnoredViewModel(); LogViewModel logViewModel = new LogViewModel(); ReportViewModel reportViewModel = new ReportViewModel(); SelectProcessViewModel selectProcessViewModel = new SelectProcessViewModel(new SelectProcessDialog()); AutoAttachCharacter onLoadEvents = new AutoAttachCharacter(selectCharacterRequest, selectProcessViewModel, dialogCoordinator, EventMessenger); RestingViewModel restingViewModel = new RestingViewModel(); RoutesViewModel routesViewModel = new RoutesViewModel(); SettingsViewModel settingsViewModel = new SettingsViewModel(); TargetingViewModel targetingViewModel = new TargetingViewModel(); TargetsViewModel targetsViewModel = new TargetsViewModel(); TabViewModels tabViewModels = new TabViewModels(new List <IViewModel>() { reportViewModel, battlesViewModel, targetingViewModel, restingViewModel, routesViewModel, followViewModel, logViewModel, settingsViewModel, }); MainViewModel mainViewModel = new MainViewModel(tabViewModels); MasterViewModel masterViewModel = new MasterViewModel(mainViewModel, EventMessenger); if (requestedType == typeof(EventMessenger)) { return(EventMessenger); } if (requestedType == typeof(App)) { return(app); } if (requestedType == typeof(LibraryUpdater)) { return(libraryUpdater); } if (requestedType == typeof(SelectCharacter)) { return(selectCharacterRequest); } if (requestedType == typeof(SelectAbilityRequestHandler)) { return(selectAbilityRequestHandler); } if (requestedType == typeof(IDialogCoordinator)) { return(dialogCoordinator); } if (requestedType == typeof(IPersister)) { return(persister); } if (requestedType == typeof(UpdateEliteAPI)) { return(updateEliteAPI); } if (requestedType == typeof(AutoAttachCharacter)) { return(onLoadEvents); } if (requestedType == typeof(BattlesViewModel)) { return(battlesViewModel); } if (requestedType == typeof(FollowViewModel)) { return(followViewModel); } if (requestedType == typeof(IgnoredViewModel)) { return(ignoredViewModel); } if (requestedType == typeof(LogViewModel)) { return(logViewModel); } if (requestedType == typeof(ReportViewModel)) { return(reportViewModel); } if (requestedType == typeof(TabViewModels)) { return(tabViewModels); } if (requestedType == typeof(MainViewModel)) { return(mainViewModel); } if (requestedType == typeof(MasterViewModel)) { return(masterViewModel); } if (requestedType == typeof(SelectProcessViewModel)) { return(selectProcessViewModel); } if (requestedType == typeof(RestingViewModel)) { return(restingViewModel); } if (requestedType == typeof(RoutesViewModel)) { return(routesViewModel); } if (requestedType == typeof(SettingsViewModel)) { return(settingsViewModel); } if (requestedType == typeof(TargetingViewModel)) { return(targetingViewModel); } if (requestedType == typeof(TargetsViewModel)) { return(targetsViewModel); } throw new InvalidOperationException($"Could not create instance of requested type {requestedType.Name}"); }