Пример #1
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var backStack      = Frame.BackStack;
            var backStackCount = backStack.Count;


            if (backStackCount > 0)
            {
                var masterPageEntry = backStack[backStackCount - 1];
                backStack.RemoveAt(backStackCount - 1);

                try
                {
                    var modifiedEntry = new PageStackEntry(masterPageEntry.SourcePageType, null, masterPageEntry.NavigationTransitionInfo);
                    backStack.Add(modifiedEntry);
                }
                catch // If stuff goes to the shitter, go back to the Garage
                {
                    Debug.WriteLine("CarSummaryPage - Naviagtion to the shits! Go back to garage");
                    this.settingsHelper.UpdateSelectedCarId(-1);
                    Frame.Navigate(typeof(View.GaragePage), new DrillInNavigationTransitionInfo());
                }
            }

            // Register for hardware and software back request from the system
            SystemNavigationManager systemNavigationManager = SystemNavigationManager.GetForCurrentView();

            systemNavigationManager.BackRequested += Page_BackRequested;
            systemNavigationManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;



            // Try to get the CarId. If this has not been filled in (due to an error or going back to the GaragePage) let the user go back to the GaragePage
            try
            {
                this.selectedCarId = settingsHelper.GetSelectedCarId();
                Debug.WriteLine("CarSummaryPage - Navigation - CarId recieved - Car id is: " + this.selectedCarId);
                carManager  = new CarManagerViewModel();
                selectedCar = carManager.GetCarById(selectedCarId);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                // Go back event
                Debug.WriteLine("CarSummaryPage - Navigation - CarId empty -> Go back to GaragePage");
                Frame.Navigate(typeof(View.GaragePage));
            }


            this.tripManager = new TripManagerViewModel(this.selectedCarId);

            // Layout check for a current trip
            this.UpdateButtons();
        }
Пример #2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            var backStack      = Frame.BackStack;
            var backStackCount = backStack.Count;

            if (backStackCount > 0)
            {
                var masterPageEntry = backStack[backStackCount - 1];
                backStack.RemoveAt(backStackCount - 1);

                try
                {
                    var modifiedEntry = new PageStackEntry(masterPageEntry.SourcePageType, null, masterPageEntry.NavigationTransitionInfo);
                    backStack.Add(modifiedEntry);
                }
                catch // If stuff goes to the shitter, go back to the CarSummary
                {
                    Frame.Navigate(typeof(View.CarSummaryPage), new DrillInNavigationTransitionInfo());
                }
            }

            // Register for hardware and software back request from the system
            SystemNavigationManager systemNavigationManager = SystemNavigationManager.GetForCurrentView();

            systemNavigationManager.BackRequested += Page_BackRequested;
            systemNavigationManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;


            // Set selected car for navigation
            try
            {
                this.SelectedCarId = settingsHelper.GetSelectedCarId();
                Debug.WriteLine("TripDetailsPage - Navigation - CarId recieved - Car id is: " + this.SelectedCarId);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                // Go back event
            }

            // TODO --> In Try - Catch zetten?
            TripManager = new TripManagerViewModel(this.SelectedCarId);
            CarManager  = new CarManagerViewModel();


            // Get trip from navigation
            int tripId = (int)e.Parameter;

            this.SelectedTrip         = TripManager.Trips.Where(x => x.TripId == tripId).FirstOrDefault();
            TripManager.SelectedIndex = TripManager.Trips.IndexOf(this.SelectedTrip);

            this.SelectedCar         = CarManager.Cars.Where(x => x.CarId == this.SelectedCarId).FirstOrDefault();
            CarManager.SelectedIndex = CarManager.Cars.IndexOf(this.SelectedCar);
        }