/// <summary>Called when initializing.</summary>
        protected override async Task OnInitializeAsync(CancellationToken cancellationToken)
        {
            await base.OnInitializeAsync(cancellationToken);

            Items.Add(_viewModelFactory.Create <FirstTabViewModel>());
            Items.Add(_viewModelFactory.Create <SecondTabViewModel>());
        }
예제 #2
0
 public SnapshotSectionViewModel(IViewModelFactory viewModelFactory)
 {
     _availableLaps        = new List <LapSummaryDto>();
     ReplayViewModel       = viewModelFactory.Create <IReplayViewModel>();
     PedalSectionViewModel = viewModelFactory.Create <IPedalSectionViewModel>();
     CarWheelsViewModel    = new CarWheelsViewModel();
 }
예제 #3
0
        public async Task <ActionResult> Index(SearchPage currentPage, string q)
        {
            if (string.IsNullOrEmpty(q))
            {
                return(View("~/Features/Search/SearchPage.cshtml", _viewModelFactory.Create(currentPage)));
            }
            var searchResult = _searchEngine.Query().MultiMatch(q, new List <MatchField <ISearch> >()
            {
                new MatchField <ISearch>()
                {
                    field = x => x.Title
                },
                new MatchField <ISearch>()
                {
                    field = x => x.Overview
                }
            }).GetSearchHits <ISearch>();

            var result = new SearchResultData()
            {
                Query          = q,
                SearcheResults = searchResult.Select(x => x.Document).ToList()
            };
            var viewModel = await _viewModelFactory.Create(currentPage, result);

            return(View("~/Features/Search/SearchPageResult.cshtml", viewModel));
        }
        public IAggregatedChartViewModel CreateAggregatedChartViewModel()
        {
            IReadOnlyCollection <LapTelemetryDto> loadedLaps = _loadedLapsCache.LoadedLaps;
            string title = $"{ChartName} - Laps: {string.Join(", ", loadedLaps.Select(x => x.LapSummary.CustomDisplayName))}";

            int maxGear = loadedLaps.SelectMany(x => x.TimedTelemetrySnapshots).Where(x => !string.IsNullOrWhiteSpace(x.PlayerData.CarInfo.CurrentGear) && x.PlayerData.CarInfo.CurrentGear != "R" && x.PlayerData.CarInfo.CurrentGear != "N").Max(x => int.Parse(x.PlayerData.CarInfo.CurrentGear));

            CompositeAggregatedChartsViewModel viewModel = new CompositeAggregatedChartsViewModel()
            {
                Title = title
            };

            HistogramChartViewModel mainViewModel = _viewModelFactory.Create <HistogramChartViewModel>();

            mainViewModel.FromModel(CreateHistogramAllGears(loadedLaps, _rpmHistogramDataExtractor.DefaultBandSize));

            viewModel.MainAggregatedChartViewModel = mainViewModel;

            for (int i = 1; i <= maxGear; i++)
            {
                Histogram histogram = CreateHistogram(loadedLaps, i, _rpmHistogramDataExtractor.DefaultBandSize);
                if (histogram == null)
                {
                    continue;
                }
                HistogramChartViewModel child = _viewModelFactory.Create <HistogramChartViewModel>();
                child.FromModel(histogram);
                viewModel.AddChildAggregatedChildViewModel(child);
            }

            return(viewModel);
        }
        private void SetAvailableSessions(IOpenWindowViewModel openWindowViewModel, IReadOnlyCollection <SessionInfoDto> recentSessionInfos, IReadOnlyCollection <SessionInfoDto> archivedSessionInfoDtos, Func <SessionInfoDto, Task> openByDoubleClickCommand)
        {
            openWindowViewModel.ArchiveSessionsInfos = archivedSessionInfoDtos.OrderByDescending(x => x.SessionRunDateTime).Select(x =>
            {
                IOpenWindowSessionInformationViewModel newViewModel = _viewModelFactory.Create <IOpenWindowSessionInformationViewModel>();
                newViewModel.FromModel(x);
                newViewModel.IsArchiveIconVisible     = false;
                newViewModel.SelectThisSessionCommand = new AsyncCommand(() => openByDoubleClickCommand(x));
                newViewModel.OpenSessionFolderCommand = new AsyncCommand(() => OpenSessionFolder(x));
                newViewModel.DeleteSessionCommand     = new RelayCommand(() => DeleteSession(x, openWindowViewModel));
                return(newViewModel);
            }).ToList();

            openWindowViewModel.RecentSessionsInfos = recentSessionInfos.OrderByDescending(x => x.SessionRunDateTime).Select(x =>
            {
                IOpenWindowSessionInformationViewModel newViewModel = _viewModelFactory.Create <IOpenWindowSessionInformationViewModel>();
                newViewModel.FromModel(x);
                newViewModel.ArchiveCommand           = new AsyncCommand(() => ArchiveSession(openWindowViewModel, x));
                newViewModel.SelectThisSessionCommand = new AsyncCommand(() => openByDoubleClickCommand(x));
                newViewModel.OpenSessionFolderCommand = new AsyncCommand(() => OpenSessionFolder(x));
                newViewModel.DeleteSessionCommand     = new RelayCommand(() => DeleteSession(x, openWindowViewModel));
                newViewModel.IsArchiveIconVisible     = archivedSessionInfoDtos.FirstOrDefault(y => x.Id == y.Id) == null;
                return(newViewModel);
            }).ToList();
        }
예제 #6
0
        public async Task <IActionResult> GetGameAsync(string key)
        {
            if (string.IsNullOrWhiteSpace(key))
            {
                return(NotFound());
            }

            var gameDto = await _gameService.GetByKeyAsync(key);

            var viewModel = await _displayGameViewModelFactory.CreateAsync(gameDto);

            await _gameService.IncrementVisitsCountAsync(key);

            if (!viewModel.Images.Any())
            {
                var defaultImage = _gameImageViewModelFactory.Create(key);
                viewModel.Images.Add(defaultImage);
            }

            await _gameService.IncrementVisitsCountAsync(key);

            _logger.LogDebug($"The game with key {key} was read from database");

            return(View("Details", viewModel));
        }
예제 #7
0
 public TrackOverviewViewModel(IViewModelFactory viewModelFactory)
 {
     TrackGeometryViewModel = viewModelFactory.Create <TrackGeometryViewModel>();
     OverallRecord          = viewModelFactory.Create <RecordEntryViewModel>();
     CarRecord   = viewModelFactory.Create <RecordEntryViewModel>();
     ClassRecord = viewModelFactory.Create <RecordEntryViewModel>();
 }
예제 #8
0
        public ActionResult AddUser()
        {
            var user      = new User();
            var viewModel = viewModelFactory.Create <UserViewModel>();

            viewModel.User = user;
            return(View(viewModel));
        }
예제 #9
0
        public async Task <ActionResult> Index(CheckOutPage currentPage)
        {
            var checkoutModel = await CreateModel(new CheckOutInputModel(), string.Empty);

            var viewModel = await _viewModelFactory.Create(currentPage, checkoutModel);

            return(View("~/Features/CheckOut/CheckOutPage.cshtml", viewModel));
        }
예제 #10
0
 public ChampionshipCreationViewModel(IViewModelFactory viewModelFactory)
 {
     CalendarDefinitionViewModel = viewModelFactory.Create <CalendarDefinitionViewModel>();
     SessionsDefinitionViewModel = viewModelFactory.Create <SessionsDefinitionViewModel>();
     AiNamesCanChange            = true;
     ChampionshipTitle           = "Custom Championship";
     CalendarDefinitionViewModel.CalendarViewModel.CalendarEntries.CollectionChanged += CalendarEntriesOnCollectionChanged;
 }
 public async Task StartControllerAsync()
 {
     RatingApplicationViewModel           = _viewModelFactory.Create <IRatingApplicationViewModel>();
     RatingApplicationViewModel.IsVisible = _displaySettingsViewModel.RatingSettingsViewModel.IsEnabled;
     _raceObserverController.RatingApplicationViewModel = RatingApplicationViewModel;
     _displaySettingsViewModel.RatingSettingsViewModel.PropertyChanged += RatingSettingsViewModelOnPropertyChanged;
     BindCommands();
     await _raceObserverController.StartControllerAsync();
 }
예제 #12
0
 public MainWindowViewModel(IViewModelFactory viewModelFactory)
 {
     _viewModelFactory        = viewModelFactory;
     _leftPanelGraphs         = new List <IGraphViewModel>();
     _rightPanelGraphs        = new List <IGraphViewModel>();
     LapSelectionViewModel    = viewModelFactory.Create <ILapSelectionViewModel>();
     SnapshotSectionViewModel = viewModelFactory.Create <ISnapshotSectionViewModel>();
     MapViewViewModel         = viewModelFactory.Create <IMapViewViewModel>();
 }
예제 #13
0
        public Task Show <TViewModel>() where TViewModel : ReactiveObject
        {
            var v = (UserControl)Activator.CreateInstance(typeof(TViewModel).Assembly.FullName,
                                                          typeof(TViewModel).FullName.Replace("ViewModel", "View")).Unwrap();
            var vm = _factory.Create <TViewModel>();

            v.DataContext = vm;
            return(DialogHost.Show(v));
        }
        private void InitializeViewModels()
        {
            _pluginsSettingsWindowViewModel = _viewModelFactory.Create <IPluginsSettingsWindowViewModel>();
            IPluginsConfigurationViewModel pluginsConfigurationViewModel = _viewModelFactory.Create <IPluginsConfigurationViewModel>();

            pluginsConfigurationViewModel.FromModel(_pluginConfigurationRepository.LoadOrCreateDefault());
            _pluginsSettingsWindowViewModel.SaveCommand  = new RelayCommand(SaveAndClose);
            _pluginsSettingsWindowViewModel.CloseCommand = new RelayCommand(Close);
            _pluginsSettingsWindowViewModel.PluginsConfigurationViewModel = pluginsConfigurationViewModel;
        }
        public void ShowWindow <T>()
        {
            var window = new Window
            {
                Content     = LocateViewFor <T>(),
                DataContext = _viewModelFactory.Create <T>(),
            };

            window.Show();
        }
예제 #16
0
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            var controller = filterContext.Controller as BaseController;

            if (controller != null)
            {
                controller.Context = _viewModelFactory.Create <SharedContext>();
            }

            base.OnActionExecuting(filterContext);
        }
 public RatingApplicationViewModel(IViewModelFactory viewModelFactory)
 {
     SimulatorRating           = viewModelFactory.Create <IRatingViewModel>();
     ClassRating               = viewModelFactory.Create <IRatingViewModel>();
     DifficultyRating          = viewModelFactory.Create <IRatingViewModel>();
     SelectableClasses         = new ObservableCollection <string>();
     AiLevels                  = new ObservableCollection <int>();
     UseSuggestedDifficulty    = true;
     IsEnabled                 = true;
     IsRateRaceCheckboxChecked = true;
 }
 public OpenWindowController(IMainWindowViewModel mainWindowViewModel, ITelemetryLoadController telemetryLoadController, IViewModelFactory viewModelFactory, ITelemetryViewsSynchronization telemetryViewsSynchronization)
 {
     _loadedSessions                = new List <SessionInfoDto>();
     _mainWindowViewModel           = mainWindowViewModel;
     _telemetryLoadController       = telemetryLoadController;
     _viewModelFactory              = viewModelFactory;
     _telemetryViewsSynchronization = telemetryViewsSynchronization;
     _openWindowViewModel           = viewModelFactory.Create <IOpenWindowViewModel>();
     _addWindowViewModel            = viewModelFactory.Create <IOpenWindowViewModel>();
     _mainWindowViewModel.LapSelectionViewModel.OpenWindowViewModel = _openWindowViewModel;
     _mainWindowViewModel.LapSelectionViewModel.AddWindowViewModel  = _addWindowViewModel;
     BindCommands();
 }
예제 #19
0
        public MainWindowViewModel(
            IViewModelFactory viewModelFactory,
            IRepository repository)
        {
            _viewModelFactory = viewModelFactory;
            _repository       = repository;

            _repository.Load().Wait(); // TODO: Load async

            Content = _viewModelFactory.Create <HomeViewModel>();

            ShowView = ReactiveCommand.Create <Type>(p => Content = _viewModelFactory.Create(p));
            Exit     = ReactiveCommand.Create(() => { Application.Current.Shutdown(); });
        }
        private IAggregatedChartSelectorViewModel CreateAggregatedChartSelectionViewModel()
        {
            IAggregatedChartSelectorViewModel viewModel = _viewModelFactory.Create <IAggregatedChartSelectorViewModel>();

            viewModel.HistogramChartNames         = _aggregatedChartProviders.Where(x => x.Kind == AggregatedChartKind.Histogram).Select(x => x.ChartName).OrderBy(x => x).ToList();
            viewModel.ScatterPlotChartNames       = _aggregatedChartProviders.Where(x => x.Kind == AggregatedChartKind.ScatterPlot).Select(x => x.ChartName).OrderBy(x => x).ToList();
            viewModel.CancelAndCloseWindowCommand = new RelayCommand(CancelAndCloseSelectionWindow);
            viewModel.OpenSelectedChartCommand    = new RelayCommand(OpenSelectedChart);

            IAggregatedChartSettingsViewModel aggregatedChartSettingsViewModel = _viewModelFactory.Create <IAggregatedChartSettingsViewModel>();

            aggregatedChartSettingsViewModel.FromModel(_settingsController.TelemetrySettings.AggregatedChartSettings);
            viewModel.AggregatedChartSettingsViewModel = aggregatedChartSettingsViewModel;
            return(viewModel);
        }
        public void OpenChampionshipCreationDialog(Action <ChampionshipDto> newChampionshipCallback, Action cancellationCallback)
        {
            _newChampionshipCallback       = newChampionshipCallback;
            _cancellationCallback          = cancellationCallback;
            _championshipCreationViewModel = _viewModelFactory.Create <ChampionshipCreationViewModel>();
            _championshipCreationViewModel.IsSimulatorSelectionEnabled = true;
            _championshipCreationViewModel.AvailableSimulators         = SimulatorRatingControllerFactory.SupportedSimulators;
            _championshipCreationViewModel.ConfirmSimulatorCommand     = new RelayCommand(ConfirmSimulatorSelection);
            _championshipCreationViewModel.CalendarDefinitionViewModel.CalendarViewModel.SelectPredefinedCalendarCommand = new RelayCommand(SelectPredefinedCalendar);
            _championshipCreationViewModel.CalendarDefinitionViewModel.CalendarViewModel.RandomCalendarCommand           = new RelayCommand(CreateRandomCalendar);
            _championshipCreationViewModel.OkCommand     = new RelayCommand(CreateNewChampionship);
            _championshipCreationViewModel.CancelCommand = new RelayCommand(CancelChampionshipCreation);

            _dialogWindow = _windowService.OpenWindow(_championshipCreationViewModel, "New Championship", WindowState.Maximized, SizeToContent.Manual, WindowStartupLocation.CenterOwner, DialogWindowClosed);
        }
예제 #22
0
        /// <summary>
        /// If the ViewModel, identified by the combination of the event arguments, not already exists in the ViewModels list,
        /// then a new Viewmodel (NavigationViewModel or DetailViewModel) is created from the event arguments,
        /// and LoadAsync function of the created ViewModel is called
        /// and ViewModel is added tio ViewModels list
        /// and SelectedViewModel is set to ViewModel.
        /// </summary>
        /// <param name="eventOpenViewModelArgs">Id and Name of the ViewModel</param>
        private async void OnEventOpenNavigationOrDetailViewModel(EventOpenNavigationOrDetailViewModelArgs eventOpenViewModelArgs)
        {
            IsBusy = true;

            var viewModel = ViewModels.SingleOrDefault(dvm
                                                       => dvm.Id == eventOpenViewModelArgs.Id &&
                                                       dvm.Name == eventOpenViewModelArgs.ViewModelName);

            //ViewModel does not exist in ViewModels
            //-> create, call ViewModels LoadAsync function and add ViewModel to ViewModels
            if (viewModel == null)
            {
                viewModel = _viewModelFactory.Create(eventOpenViewModelArgs.ViewModelName);
                bool loadAsyncSucessful = await viewModel.LoadAsync(eventOpenViewModelArgs.Id);

                //bool loadAsyncSucessful = await Task.Run(() => viewModel.LoadAsync(eventOpenViewModelArgs.Id));

                if (loadAsyncSucessful)
                {
                    ViewModels.Add(viewModel);


                    //Set the focus to the selected ViewModel
                    SelectedViewModel = viewModel;

                    //Hide the MainNavigationView:
                    IsMainNavigationViewShown = false;
                }
                else
                {
                    _messageDialogService.ShowInfoDialog("Entry could not be loaded as it might have been deleted. Displayed Entries are refreshed.", "Information");
                }
            }
            IsBusy = false;
        }
예제 #23
0
        protected EditViewModel(IViewModelFactory viewModelFactory, ICompositeValidator <TViewModel> validators)
        {
            _viewModelFactory = viewModelFactory;
            _validators       = validators;

            /*
             *
             * _validateCommand = ReactiveCommand.CreateFromTask<TViewModel, IEnumerable<ValidationResult>>(ValidateViewModel);
             *
             * _validateCommand
             *  .Subscribe(results =>
             *      Error = results.FirstOrDefault(r => !r.IsValid)?.Errors?.Select(e => e.ErrorMessage).FirstOrDefault())
             *  .DisposeWith(Disposables);
             *
             * this.WhenAnyValue(x => x.ToCreate)
             *  .Throttle(TimeSpan.FromMilliseconds(500))
             *  .InvokeCommand(_validateCommand)
             *  .DisposeWith(Disposables);
             *
             * var canExecute = this.WhenAnyValue(x => x.Error, err => err.IsMissing());
             */

            ConfirmCommand = new PlappCommand(ConfirmAsync);
            CancelCommand  = new PlappCommand(CancelAsync);

            ToCreate = _viewModelFactory.Create <TViewModel>();
        }
예제 #24
0
        public static TViewModel Get <TViewModel>(
            [NotNull] IViewModelStore store,
            [NotNull] string key,
            [NotNull] IViewModelFactory factory,
            [CanBeNull] IBundle state,
            out bool created)
            where TViewModel : class, IViewModel, IStateOwner
        {
            if (store == null)
            {
                throw new ArgumentNullException(nameof(store));
            }
            if (string.IsNullOrWhiteSpace(key))
            {
                throw new ArgumentException("Value cannot be null or whitespace.", nameof(key));
            }
            if (factory == null)
            {
                throw new ArgumentNullException(nameof(factory));
            }

            var viewModel = store.Get <TViewModel>(key);

            created = false;

            if (viewModel == null)
            {
                viewModel = factory.Create <TViewModel>(state);
                store.Add(key, viewModel);
                created = true;
            }

            return(viewModel);
        }
 public SettingsWindowController(IMainWindowViewModel mainWindowViewModel, IViewModelFactory viewModelFactory, ITelemetrySettingsRepository telemetrySettingsRepository)
 {
     _telemetrySettingsRepository = telemetrySettingsRepository;
     _settingsWindowViewModel     = viewModelFactory.Create <ISettingsWindowViewModel>();
     mainWindowViewModel.LapSelectionViewModel.SettingsWindowViewModel = _settingsWindowViewModel;
     BindCommands();
 }
예제 #26
0
        public void ShowWelcomeScreen(SimulatorDataSet dataSet, ChampionshipDto championship)
        {
            var eventStartingViewModel = _viewModelFactory.Create <EventStartingViewModel>();

            EventDto   currentEvent   = championship.GetCurrentOrLastEvent();
            SessionDto currentSession = currentEvent.Sessions[championship.CurrentSessionIndex];

            eventStartingViewModel.EventTitleViewModel.FromModel((championship, currentEvent, currentSession));

            eventStartingViewModel.Screens.Add(CreateTrackOverviewViewModel(dataSet, championship));
            eventStartingViewModel.Screens.Add(CreateStandingOverviewViewModel(championship));

            Window window = _windowService.OpenWindow(eventStartingViewModel, "Event Starting", WindowState.Maximized, SizeToContent.Manual, WindowStartupLocation.CenterOwner);

            eventStartingViewModel.CloseCommand = new RelayCommand(() => CloseWindow(window));
        }
        protected override void ApplyModel(SessionResultDto model)
        {
            int  totalGap       = 0;
            int  previousPoints = 0;
            bool isFirst        = true;

            foreach (DriverSessionResultDto driverSessionResultDto in model.DriverSessionResult.OrderBy(x => x.AfterEventPosition))
            {
                var newDriverNewStanding = _viewModelFactory.Create <DriverNewStandingViewModel>();

                if (!isFirst)
                {
                    int gap = driverSessionResultDto.TotalPoints - previousPoints;
                    totalGap = gap + totalGap;
                    newDriverNewStanding.GapToPrevious = gap;
                    newDriverNewStanding.GapToLeader   = totalGap;
                }

                previousPoints = driverSessionResultDto.TotalPoints;
                isFirst        = false;

                newDriverNewStanding.FromModel(driverSessionResultDto);
                DriversNewStandings.Add(newDriverNewStanding);
            }
        }
예제 #28
0
        private void AddLaps(IReadOnlyCollection <LapSummaryDto> lapsSummary)
        {
            foreach (LapSummaryDto lapSummaryDto in lapsSummary)
            {
                ILapSummaryViewModel newViewModel = _viewModelFactory.Create <ILapSummaryViewModel>();
                newViewModel.FromModel(lapSummaryDto);
                newViewModel.LapColor = _colorPaletteProvider.GetNext();
                _lapSelectionViewModel.AddLapSummaryViewModel(newViewModel);
                _allAvailableLaps.Add(lapSummaryDto);
            }

            LapSummaryDto bestLap = _allAvailableLaps.Where(x => x.LapTime != TimeSpan.Zero).OrderBy(x => x.LapTime).FirstOrDefault();

            if (bestLap != null)
            {
                _lapSelectionViewModel.BestLap = $"{bestLap?.CustomDisplayName} - {bestLap.LapTime.FormatToDefault()}";
            }

            LapSummaryDto bestSector1Lap = _allAvailableLaps.Where(x => x.Sector1Time > TimeSpan.Zero).OrderBy(x => x.Sector1Time).FirstOrDefault();

            _lapSelectionViewModel.BestSector1 = bestSector1Lap?.Sector1Time > TimeSpan.Zero ? $"{bestSector1Lap.CustomDisplayName} - {bestSector1Lap.Sector1Time.FormatToDefault()}" : string.Empty;

            LapSummaryDto bestSector2Lap = _allAvailableLaps.Where(x => x.Sector2Time > TimeSpan.Zero).OrderBy(x => x.Sector1Time).FirstOrDefault();

            _lapSelectionViewModel.BestSector2 = bestSector2Lap?.Sector2Time > TimeSpan.Zero ? $"{bestSector2Lap.CustomDisplayName} - {bestSector2Lap.Sector2Time.FormatToDefault()}" : string.Empty;

            LapSummaryDto bestSector3Lap = _allAvailableLaps.Where(x => x.Sector3Time > TimeSpan.Zero).OrderBy(x => x.Sector1Time).FirstOrDefault();

            _lapSelectionViewModel.BestSector3 = bestSector3Lap?.Sector3Time > TimeSpan.Zero ? $"{bestSector3Lap.CustomDisplayName} - {bestSector3Lap.Sector3Time.FormatToDefault()}" : string.Empty;
        }
        /// <summary>
        /// Gets or creates a window and opens/activates it immediately after.
        /// </summary>
        /// <typeparam name="TView">The type of the <see cref="Window" /> (view).</typeparam>
        /// <typeparam name="TViewModel">The type of the associated <see cref="ViewModel" /> DataContext.</typeparam>
        /// <param name="dialog">if set to <c>true</c> the <see cref="Window" /> will be opened as a dialog.</param>
        /// <param name="ensureSingleInstance">if set to <c>true</c> only one instance of the specified <see cref="Window" /> can ever exist at once.</param>
        /// <returns>The opened window's viewmodel.</returns>
        public TViewModel OpenWindow <TView, TViewModel>(bool dialog, bool ensureSingleInstance) where TView : Window where TViewModel : ViewModel
        {
            // When opening views that only exist one at a time,
            // it's important not to recreate the viewmodel every time,
            // as that would override any changes made.
            // Therefore, check if the view already has a data context that isn't null.

            TView view = Create <TView>(ensureSingleInstance);

            if (view.DataContext is null)
            {
                view.DataContext = viewModelFactory.Create <TViewModel>();
            }

            if (dialog)
            {
                view.ShowDialog();
            }
            else
            {
                view.Show();
                view.Activate();
            }

            return(view.DataContext as TViewModel);
        }
예제 #30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ViewStackServiceFixture"/> class.
 /// </summary>
 public ViewStackServiceFixture()
 {
     _view = Substitute.For <IView>();
     _view.PushPage(Arg.Any <IViewModel>(), Arg.Any <string>(), Arg.Any <bool>(), Arg.Any <bool>()).Returns(Observable.Return(Unit.Default));
     _viewModelFactory = Substitute.For <IViewModelFactory>();
     _viewModelFactory.Create <NavigableViewModelMock>(Arg.Any <string>()).Returns(new NavigableViewModelMock());
 }
 public DefaultExceptionHandler(
     IWindowManagerEx windowManager, 
     IViewModelFactory screenFactory,
     IAppCommands appCommands, 
     IEventAggregator eventAggregator,
     IShellViewModel shell)
     : base(screenFactory.Create<IExceptionViewModel>())
 {
     _windowManager = windowManager;
     _appCommands = appCommands;
     _eventAggregator = eventAggregator;
     _shell = shell;
 }
예제 #32
0
        public ListViewModel(IStore store, IViewModelFactory factory)
        {
            _store = store;
            _factory = factory;

            var customers = _store.LoadAllCustomers();
            foreach (var customer in customers)
                Console.WriteLine("Customer: {0}", customer.Name);

            var detailed = customers.First();
            Console.WriteLine("Going to display the details of {0}", detailed.Name);

            var viewModel = _factory.Create<IDetailViewModel, ShowCustomerDetails>(new ShowCustomerDetails(detailed.Id));
        }
예제 #33
0
        public ListViewModel(IStore store, IViewModelFactory factory)
        {
            _store = store;
              _factory = factory;

              var customers = _store.LoadAllCustomers();
              foreach (var customer in customers)
              {
            Console.WriteLine("Customer: {0}", customer.Name);
              }

              var detailed = customers.First();
              Console.WriteLine("Going to display the details of {0}", detailed.Name);

              _factory.Create<DetailViewModel>(new { customerId = detailed.Id });
        }
예제 #34
0
        public MainVM(IViewModelFactory viewModelFactory)
        {
            _viewModelFactory = viewModelFactory;

            OpenListCommand = new DelegateCommandModel(
                x => true,
                x =>
                {
                    EmployeeList = viewModelFactory.Create<EmployeeListVM>();
                    EmployeeList.Load();
                    EmployeeList.SelectedEmployeeChanged += SelectedEmployeeChanged; // unsubscribe in real solution...
                });

            DeleteItemsCommand = new DelegateCommandModel(
                x => EmployeeList != null,
                x => EmployeeList.DeleteSelected());
        }
 public MainWindow(IViewModelFactory viewModelFactory)
 {
     InitializeComponent();
     Content = viewModelFactory.Create<MainVM>();
 }