예제 #1
0
파일: App.cs 프로젝트: chullman/PQLines
        private void StartApp()
        {
            // Bootstrap together our Autofac container, including module registrations
            _runtime = DefaultApplication_Shared.Build().Bootstrap();

            _viewFactory       = _runtime.Container.Resolve <IViewFactory>();
            _VMsICanNavigateTo = _runtime.Container.Resolve <IViewModelsICanNavigateTo>();

            // Deserialise all our JSONs into their respective Models
            _condContent = _runtime.Container.Resolve <IContentProvider <CondContent> >().Fetch();
            _exclContent = _runtime.Container.Resolve <IContentProvider <ExclContent> >().Fetch();
            _madContent  = _runtime.Container.Resolve <IContentProvider <MADContent> >().Fetch();
            _wllContent  = _runtime.Container.Resolve <IContentProvider <WLLContent> >().Fetch();
            _pavContent  = _runtime.Container.Resolve <IContentProvider <PAVContent> >().Fetch();

            // The Home Page View Model, specifically, requires all of the above deserialised contents (just so we generate the text for the 5 buttons on the home page),
            // so we'll collect these into "allContents" for passing into HomePageViewModel
            var allContents = new List <IRootModel>
            {
                _condContent,
                _exclContent,
                _madContent,
                _wllContent,
                _pavContent
            };

            // Map all of our View Models to their respective Views
            _viewFactory.Map <HomePageViewModel, HomePage>();

            _viewFactory.Map <ConductorsViewModel, ConductorsPage>();
            _viewFactory.Map <ConductorViewModel, ConductorPage>();
            _viewFactory.Map <MeasurementsViewModel, MeasurementsPage>();

            _viewFactory.Map <ExclusionZonesViewModel, ExclusionZonesPage>();

            _viewFactory.Map <MADViewModel, MADPage>();
            _viewFactory.Map <CategoriesViewModel, CategoriesPage>();

            _viewFactory.Map <WLLViewModel, WLLPage>();

            _viewFactory.Map <PAVViewModel, PAVPage>();
            _viewFactory.Map <ApprTypesViewModel, ApprTypesPage>();
            _viewFactory.Map <ObserverStatesViewModel, ObserverStatesPage>();

            // Resolve the Home Page View Model from the Autofac container
            _homePageVM = _runtime.Container.ResolveWithParameters <HomePageViewModel>(new Dictionary <string, object>
            {
                { "deserializedContents", allContents }
            });

            // Asycnhronsouly resolve ALL other View Models required for this appliation.
            // In case this takes a while, display a loading activity indicator until this is complete
            Task.Run(() => LoadAppViewModels());

            // Displays the Home Page
            MainPage = _viewFactory.CreateThemedNavPage(_homePageVM);
        }
예제 #2
0
        public MADViewModel(IRootModel deserializedContents, IViewModelNavigator viewModelNavigator,
                            IList <IContentViewModel> viewModelsICanNavigateTo)
        {
            _deserializedContents     = deserializedContents as MADContent;
            _viewModelNavigator       = viewModelNavigator;
            _viewModelsICanNavigateTo = viewModelsICanNavigateTo;

            // Find and grab the relevant "ID" fields from the Models as these will be used for the buttons' text
            if (_deserializedContents != null)
            {
                foreach (var category in _deserializedContents.Categories)
                {
                    _buttonTextsParentIDs.Add(category.ID);
                }
            }
            else
            {
                throw new ArgumentNullException("deserializedContents", String.Format("{0} is referencing null deserialized contents", GetType()));
            }

            Title = "Category";
        }