Example #1
0
        public static object GetMainContext(Frame rootFrame)
        {
            var navigationService = new NavigationService(rootFrame);

            navigationService.Register <FlightReplayViewModel, FlightReplayPage>();
            navigationService.Register <SettingsViewModel, SettingsPage>();

            var fileOpenCommands = new FileOpenCommands();

            var dialogService     = new DialogService();
            var settingsViewModel = new SettingsViewModel(fileOpenCommands, dialogService, new VirtualDashboardRepository(new ResourceDictionary()
            {
                Source = new Uri("ms-appx:///Views/VirtualDashboards.xaml")
            }));

            Task <IFlightAcademyClient> FactoryClient() => FlightAcademyClient.Create(settingsViewModel.Username,
                                                                                      settingsViewModel.Password, new Uri("http://academy.ardrone.com/api3"));


            var flightAcademyPickViewModel = new GalleryPickViewModel(FactoryClient, settingsViewModel, dialogService, navigationService);

            var manualPickViewModel = new ManualPickViewModel(fileOpenCommands, FactoryClient, dialogService, settingsViewModel, navigationService);

            return(new MainViewModel(navigationService, flightAcademyPickViewModel, manualPickViewModel, settingsViewModel, new IFlightSimulationPicker[] { flightAcademyPickViewModel, manualPickViewModel }));
        }
Example #2
0
        static Container()
        {
            var container = new DependencyInjectionContainer();

            container.Configure(x =>
            {
                x.Export <UwpFileSystem>().As <IFileSystem>();
                x.Export <DialogService>().As <IDialogService>();
                x.Export <MediaStore>().As <IMediaStore>();
                x.Export <UwpAccesibleFolders>().As <IAccesibleFolders>();
                x.Export <ViewModelFactory>().As <IViewModelFactory>();
                x.ExportFactory(() => new UwpSettingsStore(typeof(SettingsViewModel).Name,
                                                           typeof(SettingsViewModel), ApplicationData.Current.RoamingSettings)).As <ISettingsStore>();
                x.Export <Navigation>().As <INavigation>().Lifestyle.Singleton();
                x.Export <UwpMediaPlayer>().As <IMediaPlayer>().Lifestyle.Singleton();
                x.Export <VirtualDashboardRepository>().As <IVirtualDashboardRepository>().Lifestyle.Singleton();
                x.Export <SettingsViewModel>().As <ISettings>().As <SettingsViewModel>();

                x.ExportFactory((SettingsViewModel s) => FlightAcademyClient.Create(s.Username, s.Password));
                x.ExportFactory(() => new ResourceDictionary()
                {
                    Source = new Uri("ms-appx:///Views/VirtualDashboards.xaml")
                });

                x.ExcludeTypeFromAutoRegistration(typeof(Simulation));
            });

            Current = container;
        }
Example #3
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            var settingsViewModel = new SettingsViewModel();

            Task <IFlightAcademyClient> FactoryClient() => FlightAcademyClient.Create(settingsViewModel.Username,
                                                                                      settingsViewModel.Password);

            var matcher = new ContentMatcher();

            DataContext = new MainViewModel(FactoryClient, matcher, settingsViewModel);

            base.OnNavigatedTo(e);
        }