コード例 #1
0
 protected override void OnNavigatedFrom(NavigationEventArgs e)
 {
     base.OnNavigatedFrom(e);
     if (e.NavigationMode == NavigationMode.Back)
     {
         ViewModelCacheManager.Instance.Pop <AccountContentPageViewModel>();
     }
     else
     {
         Navigation.ContentFrame.BackStack.RemoveAt(Navigation.ContentFrame.BackStack.Count - 1);
         Navigation.ContentFrame.BackStack.Add(new PageStackEntry(typeof(AccountContent), (ViewModel.Account, RootPivot.SelectedIndex), null));
     }
 }
コード例 #2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            recipes                    = (RecipeList)e.Parameter;
            selectedRecipe             = recipes.getSelected();
            detailSection.SelectedItem = detailSection.MenuItems[0];
            contentFrame.Navigate(typeof(DetailPage), selectedRecipe);
            if (isNarrow())
            {
                IList <PageStackEntry> backStack = Frame.BackStack;
                int backStackCount = backStack.Count;
                if (backStackCount > 0)
                {
                    PageStackEntry masterPageEntry = backStack[backStackCount - 1];
                    backStack.RemoveAt(backStackCount - 1);

                    PageStackEntry modifiedEntry = new PageStackEntry(
                        masterPageEntry.SourcePageType,
                        recipes,
                        masterPageEntry.NavigationTransitionInfo
                        );

                    backStack.Add(modifiedEntry);
                }

                // Show back button
                NavigationView currShell = AppShell.currentShell;
                currShell.IsBackButtonVisible = NavigationViewBackButtonVisible.Visible;
                currShell.IsBackEnabled       = true;
            }
        }
コード例 #3
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;
        }
コード例 #4
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            Item             = e.Parameter as Picture;
            this.DataContext = Item;

            var backStack      = App.NavFrame.BackStack;
            var backStackCount = backStack.Count;

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

                // Doctor the navigation parameter for the master page so it
                // will show the correct item in the side-by-side view.
                var modifiedEntry = new PageStackEntry(
                    masterPageEntry.SourcePageType,
                    Item,
                    masterPageEntry.NavigationTransitionInfo
                    );
                backStack.Add(modifiedEntry);
            }
        }
コード例 #5
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            // Parameter is item ID
            Item = ItemViewModel.FromItem(ItemsDataSource.GetItemById((int)e.Parameter));

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

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

                // Doctor the navigation parameter for the master page so it
                // will show the correct item in the side-by-side view.
                var modifiedEntry = new PageStackEntry(
                    masterPageEntry.SourcePageType,
                    Item.ItemId,
                    masterPageEntry.NavigationTransitionInfo
                    );
                backStack.Add(modifiedEntry);
            }

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

            systemNavigationManager.BackRequested += DetailPage_BackRequested;
            systemNavigationManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
        }
コード例 #6
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            this.Note = e.Parameter as Note;

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

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

                // Doctor the navigation parameter for the master page so it
                // will show the correct item in the side-by-side view.
                var modifiedEntry = new PageStackEntry(
                    masterPageEntry.SourcePageType,
                    this.Note.Name,
                    masterPageEntry.NavigationTransitionInfo);

                backStack.Add(modifiedEntry);
            }

            // Register for hardware and software back request from the system
            SystemNavigationManager.GetForCurrentView().BackRequested += DetailPage_BackRequested;
        }
コード例 #7
0
        public void BackStackRemove(PageStackEntry entry)
        {
            var frame = (Frame)Window.Current.Content;

            frame.BackStack.Remove(entry);
            RaiseCanGoBackChanged();
        }
コード例 #8
0
        /// <summary>
        ///  Abhängig von der Quellseite, von der aus man auf diese Seite gelangt, wird eine Party erstellt oder bearbeitet.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // Nimmt die beim Seitenwechsel übergebene Party an (falls vorhanden)
            uebergebeneParty = e.Parameter as Party;

            // Quellseite auslesen
            PageStackEntry vorherigeSeite    = Frame.BackStack.Last();
            Type           vorherigeSeiteTyp = vorherigeSeite?.SourcePageType;

            if (vorherigeSeiteTyp == (typeof(FensterVeranstaltungAnzeigen)))
            {
                // Falls man von der Seite Anzeigen kommt, wird die Party hier zum Bearbeiten freigegeben und die Buttons dementsprechend angepasst.
                ueberarbeiten = true;
                AppBarButtonErstellen.Icon  = new SymbolIcon(Symbol.Edit);
                AppBarButtonErstellen.Label = "Änderungen speichern";

                // Daten der uebergebenen Party anzeigen
                TimeSpan uhrzeit = new TimeSpan(uebergebeneParty.PartyDate.Hour, uebergebeneParty.PartyDate.Minute, uebergebeneParty.PartyDate.Second);

                textBoxErstellenNAME.Text                   = uebergebeneParty.PartyName;
                DatePickerErstellenDATUM.Date               = uebergebeneParty.PartyDate;
                TimePickerErstellenUHRZEIT.Time             = uhrzeit;
                textBoxErstellenORT.Text                    = uebergebeneParty.Location.CityName;
                textBoxErstellenSTRASSE.Text                = uebergebeneParty.Location.StreetName;
                textBoxErstellenHAUSNR.Text                 = uebergebeneParty.Location.HouseNumber;
                textBoxErstellenPLZ.Text                    = uebergebeneParty.Location.ZipCode;
                textBoxErstellenPREIS.Text                  = uebergebeneParty.Price.ToString();
                comboBoxErstellenMUSIKRICHTUNG.SelectedItem = uebergebeneParty.MusicGenre;
                comboBoxErstellenTYP.SelectedItem           = uebergebeneParty.PartyType;
                textBoxErstellenINFOS.Text                  = uebergebeneParty.Description;
            }
        }
コード例 #9
0
ファイル: MainPage.xaml.cs プロジェクト: wjwalcher/lightfun
        private void MainNavView_BackRequested(NavigationView sender, NavigationViewBackRequestedEventArgs args)
        {
            if (ContentFrame.CanGoBack)
            {
                PageStackEntry pse          = ContentFrame.BackStack[ContentFrame.BackStack.Count - 1];
                var            lastPageName = pse.SourcePageType.Name;
                switch (lastPageName)
                {
                case "Dashboard":
                    MainNavView.SelectedItem = MainNavView.MenuItems.ElementAt(0);
                    break;

                case "Scenes":
                    MainNavView.SelectedItem = MainNavView.MenuItems.ElementAt(1);
                    break;

                case "Schedules":
                    MainNavView.SelectedItem = MainNavView.MenuItems.ElementAt(2);
                    break;

                case "Weather":
                    MainNavView.SelectedItem = MainNavView.MenuItems.ElementAt(3);
                    break;
                }
            }
        }
コード例 #10
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            string param = e.Parameter.ToString();

            if (param.StartsWith("tid="))
            {
                ThreadId = Convert.ToInt32(param.Substring("tid=".Length));

                #region 避免在窄视图下拖宽窗口时返回到主页时还是显示旧缓存
                var backStack      = Frame.BackStack;
                var backStackCount = backStack.Count;

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

                    // Doctor the navigation parameter for the master page so it
                    // will show the correct item in the side-by-side view.
                    var modifiedEntry = new PageStackEntry(
                        masterPageEntry.SourcePageType,
                        $"tid={ThreadId}",
                        masterPageEntry.NavigationTransitionInfo
                        );
                    backStack.Add(modifiedEntry);
                }
                #endregion
            }
            else if (param.StartsWith("pid="))
            {
                PostId = Convert.ToInt32(param.Substring("pid=".Length));

                #region 避免在窄视图下拖宽窗口时返回到主页时还是显示旧缓存
                var backStack      = Frame.BackStack;
                var backStackCount = backStack.Count;

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

                    // Doctor the navigation parameter for the master page so it
                    // will show the correct item in the side-by-side view.
                    var modifiedEntry = new PageStackEntry(
                        masterPageEntry.SourcePageType,
                        $"pid={PostId}",
                        masterPageEntry.NavigationTransitionInfo
                        );
                    backStack.Add(modifiedEntry);
                }
                #endregion
            }

            // Register for hardware and software back request from the system
            SystemNavigationManager systemNavigationManager = SystemNavigationManager.GetForCurrentView();
            systemNavigationManager.BackRequested += DetailPage_BackRequested;
            systemNavigationManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
        }
コード例 #11
0
        public void OpenReplyPageByPostId()
        {
            var cts = new CancellationTokenSource();

            RightWrap.DataContext = new ReplyListViewForSpecifiedPostViewModel(cts, PostId, ReplyListView, BeforeLoaded, AfterLoaded, ReplyListViewScrollForSpecifiedPost);

            #region 避免在窄视图下拖宽窗口时返回到主页时还是显示旧缓存
            var backStack      = Frame.BackStack;
            var backStackCount = backStack.Count;

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

                // Doctor the navigation parameter for the master page so it
                // will show the correct item in the side-by-side view.
                var modifiedEntry = new PageStackEntry(
                    masterPageEntry.SourcePageType,
                    $"pid={PostId}",
                    masterPageEntry.NavigationTransitionInfo
                    );
                backStack.Add(modifiedEntry);
            }
            #endregion
        }
コード例 #12
0
        protected override void OnNavigatedFrom(NavigationEventArgs e)
        {
            base.OnNavigatedFrom(e);
            var bundle = this.CreateSaveStateBundle();

            SaveStateBundle(e, bundle);

            var translator = Mvx.Resolve <IMvxWindowsViewModelRequestTranslator>();

            if (e.NavigationMode == NavigationMode.Back)
            {
                var key = translator.RequestTextGetKey(_reqData);
                this.OnViewDestroy(key);
            }
            else
            {
                var backstack = Frame.BackStack;
                if (backstack.Count > 0)
                {
                    var currentEntry = backstack[backstack.Count - 1];
                    var key          = translator.RequestTextGetKey(currentEntry.Parameter.ToString());
                    if (key == 0)
                    {
                        var newParamter = translator.GetRequestTextWithKeyFor(ViewModel);
                        var entry       = new PageStackEntry(currentEntry.SourcePageType, newParamter, currentEntry.NavigationTransitionInfo);
                        backstack.Remove(currentEntry);
                        backstack.Add(entry);
                    }
                }
            }
        }
コード例 #13
0
ファイル: NavigationService.cs プロジェクト: t3ika/Aleat
        /// <summary>
        ///     Navigates back to the previous page
        /// </summary>
        /// <param name="depth">The requested back in back stack</param>
        public async void GoBack(Int32 depth = 1)
        {
            if (depth <= 0)
            {
                return;
            }

            if (EnsureMainFrame() && _mainFrame.CanGoBack)
            {
                await DispatcherHelper.RunAsync(() =>
                {
                    if (depth > 1)
                    {
                        Int32 removeBackStackCount = depth - 1;
                        while (removeBackStackCount >= 1)
                        {
                            PageStackEntry entry = _mainFrame.BackStack.LastOrDefault();
                            if (entry != null)
                            {
                                _mainFrame.BackStack.Remove(entry);
                            }
                            removeBackStackCount--;
                        }
                    }

                    _mainFrame.GoBack();
                });
            }
        }
コード例 #14
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            _contact = (Contact)e.Parameter;

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

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

                var modifiedEntry = new PageStackEntry(
                    masterPageEntry.SourcePageType, _contact,
                    masterPageEntry.NavigationTransitionInfo);
                backStack.Add(modifiedEntry);
            }

            SystemNavigationManager systemNavigationManager =
                SystemNavigationManager.GetForCurrentView();

            systemNavigationManager.BackRequested += DetailPage_BackRequested;

            FirstNameTextBox.Text = _contact.FirstName;
            LastNameTextBox.Text  = _contact.LastName;

            PreviewFirstNameTextBlock.Text = _contact.FirstName;
            PreviewLastNameTextBlock.Text  = _contact.LastName;
        }
コード例 #15
0
        /// <summary>
        /// Search the Backstack from the bottom looking for a duplicate of the current page.
        /// If a duplicate is found, remove that plus everything above. At the end the current page
        /// should sit where the duplicate was.
        ///
        /// For example:
        ///
        /// currentPage  ConversationPage
        /// backStack[2] contactPage
        /// backStack[1] ConversationPage
        /// backStack[0] HomePage
        ///
        /// will be collapsed like this:
        ///
        /// currentPage  ConversationPage
        /// backStack[0] HomePage
        ///
        /// </summary>
        /// <returns>true if a duplicate is found</returns>
        private bool FindAndCollapseDuplicatesInTheBackStack()
        {
            Type currentPageType = this.Frame.CurrentSourcePageType;
            bool foundDuplicate  = false;

            // Check if the current page already exist in the backstack.
            for (int iIfEqualsCurrent = 0; iIfEqualsCurrent < this.Frame.BackStackDepth; iIfEqualsCurrent++)
            {
                PageStackEntry page = this.Frame.BackStack[iIfEqualsCurrent];
                if (page.SourcePageType == currentPageType)
                {
                    // Remove this and all the backstack above.
                    for (int jToRemove = (this.Frame.BackStackDepth - 1); jToRemove >= iIfEqualsCurrent; jToRemove--)
                    {
                        this.Frame.BackStack.RemoveAt(jToRemove);
                    }
                    UpdateBackButton();

                    foundDuplicate = true;
                    break;
                }
            }

            return(foundDuplicate);
        }
コード例 #16
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            System.Diagnostics.Debug.WriteLine("DetailPage.OnNavigatedTo");
            base.OnNavigatedTo(e);

            Item = JopViewModel.Instance.Value.SelectedMasterItem;

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

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

                // Doctor the navigation parameter for the master page so it
                // will show the correct item in the side-by-side view.
                var modifiedEntry = new PageStackEntry(
                    masterPageEntry.SourcePageType,
                    0,
                    masterPageEntry.NavigationTransitionInfo
                    );
                backStack.Add(modifiedEntry);
            }

            SystemNavigationManager systemNavigationManager = SystemNavigationManager.GetForCurrentView();

            systemNavigationManager.BackRequested += DetailPage_BackRequested;
            systemNavigationManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
            JopViewModel.Instance.Value.DirectItemsChanged     += DirectItemsChanged;
        }
コード例 #17
0
        public void NavigateTo(string pageKey, object parameter, bool addToStack = true)
        {
            var lockTaken = false;
            Dictionary <string, Type> dictionary = null;

            try
            {
                Monitor.Enter(dictionary = this.pagesByKey, ref lockTaken);
                if (!this.pagesByKey.ContainsKey(pageKey))
                {
                    throw new ArgumentException(string.Format("No such page: {0}. Did you forget to call NavigationService.Configure?", pageKey), "pageKey");
                }

                if (addToStack && this.currentPage != null)
                {
                    this.historyStack.Push(this.currentPage);
                }

                GetFrame().Navigate(this.pagesByKey[pageKey], parameter);

                this.CurrentPageKey = pageKey;
                this.currentPage    = new PageStackEntry(this.pagesByKey[pageKey], parameter, null);

                Log.Debug(this.historyStack.Reverse().Aggregate("null", (s, entry) => s + " > " + entry.SourcePageType.Name));
            }
            finally
            {
                if (lockTaken && dictionary != null)
                {
                    Monitor.Exit(dictionary);
                }
            }
        }
コード例 #18
0
ファイル: DetailPage.xaml.cs プロジェクト: dengere/WinUap
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (e.Parameter != null)
                Item = ItemViewModel.FromItem(ItemsDataSource.GetItemById((int)e.Parameter));
            else
                throw new InvalidOperationException();

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

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

                // Doctor the navigation parameter for the master page so it
                // will show the correct item in the side-by-side view.
                var modifiedEntry = new PageStackEntry(
                    masterPageEntry.SourcePageType,
                    Item.ItemId,
                    masterPageEntry.NavigationTransitionInfo
                    );
                backStack.Add(modifiedEntry);
            }
            // Register for hardware and software back request from the system
            SystemNavigationManager systemNavigationManager = SystemNavigationManager.GetForCurrentView();
            systemNavigationManager.BackRequested += DetailPage_BackRequested;
            systemNavigationManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
        }
コード例 #19
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            this.Note = e.Parameter as Note;
                    
            var backStack = Frame.BackStack;
            var backStackCount = backStack.Count;

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

                // Doctor the navigation parameter for the master page so it
                // will show the correct item in the side-by-side view.
                var modifiedEntry = new PageStackEntry(
                    masterPageEntry.SourcePageType,
                    this.Note.Name,
                    masterPageEntry.NavigationTransitionInfo);

                backStack.Add(modifiedEntry);
            }

            // Register for hardware and software back request from the system
            SystemNavigationManager.GetForCurrentView().BackRequested += DetailPage_BackRequested;
        }
コード例 #20
0
ファイル: NavJournalHelper.cs プロジェクト: Hazuwall/Pensieve
        /// <summary>
        /// Перейти на страницу и изменить записи в журнале посещений так, как если бы был совершён переход назад
        /// </summary>
        /// <param name="Stack">Стек навигации</param>
        /// <param name="NewParameters">Новые параметры в порядке углубления</param>
        public static void FakeGoBack(this Frame frame, Type sourcePageType, object parameter)
        {
            frame.Navigate(sourcePageType, parameter);
            PageStackEntry entry = frame.BackStack.Last();

            frame.BackStack.Remove(entry);
            frame.ForwardStack.Add(entry);
        }
コード例 #21
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();
        }
コード例 #22
0
        protected override void OnContentChanged(object oldValue, object newValue)
        {
            base.OnContentChanged(oldValue, newValue);

            // Make sure we void CurrentEntry when someone sets Frame.Content = null;
            if (newValue == null)
            {
                CurrentEntry = null;
            }
        }
コード例 #23
0
 protected override void OnNavigatedFrom(NavigationEventArgs e)
 {
     base.OnNavigatedFrom(e);
     if (e.NavigationMode == NavigationMode.New)
     {
         PageStackEntry backStackEntry = new PageStackEntry(typeof(GalleryItemDetails), new GalleryItemDetailsNavigationParameter(ViewModel, GalleryVm.Source.Source), new Windows.UI.Xaml.Media.Animation.EntranceNavigationTransitionInfo());
         Navigation.ContentFrame.BackStack.RemoveAt(Navigation.ContentFrame.BackStack.Count - 1);
         Navigation.ContentFrame.BackStack.Add(backStackEntry);
     }
 }
コード例 #24
0
        /*
         *  When the page is navigated to, check if we're editing an
         *  Existing recipe. If so, load that one. Otherwise, create
         *  a new recipe and use that as the context for this form.
         */
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            recipes = (RecipeList)e.Parameter;
            if (recipes.isEditing())
            {
                recipe = recipes.getSelected();
                for (int i = 0; i < recipe.RecipeIngredients.Count; i++)
                {
                    ingredients.Add(recipe.RecipeIngredients[i]);
                }

                for (int i = 0; i < recipe.RecipeImages.Count; i++)
                {
                    images.Add(recipe.RecipeImages[i]);
                }

                for (int i = 0; i < recipe.RecipeSteps.Count; i++)
                {
                    steps.Add(recipe.RecipeSteps[i]);
                }
            }
            else
            {
                // we're creating a new recipe
                recipe    = new Recipe();
                recipe.ID = RecipeList.recipeIdGenerator.getId();
            }

            if (isNarrow())
            {
                IList <PageStackEntry> backStack = Frame.BackStack;
                int backStackCount = backStack.Count;
                if (backStackCount > 0)
                {
                    PageStackEntry masterPageEntry = backStack[backStackCount - 1];
                    backStack.RemoveAt(backStackCount - 1);

                    PageStackEntry modifiedEntry = new PageStackEntry(
                        typeof(RecipeMasterDetailPage),
                        recipes,
                        masterPageEntry.NavigationTransitionInfo
                        );

                    backStack.Add(modifiedEntry);
                }
            }

            tempImageFolder = await RecipeList.tempFolder.CreateFolderAsync("" + recipe.ID, CreationCollisionOption.ReplaceExisting);

            this.imageFlipView.ItemsSource  = images;
            this.ingredientList.ItemsSource = ingredients;
            this.recipeSteps.ItemsSource    = steps;
        }
コード例 #25
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);
        }
コード例 #26
0
        /// <summary>
        /// Remove a <see cref="PageStackEntry"/> from the Frame's back stack.
        /// </summary>
        /// <param name="entry">The <see cref="PageStackEntry"/> to remove.</param>
        /// <returns>True if item was successfully removed from the back stack; otherwise, false. This method also returns false if item is not found in the back stack.</returns>
        public bool RemoveBackStackEntry(PageStackEntry entry)
        {
            var success = _frame.BackStack.Remove(entry);

            if (success)
            {
                _navigationStateChangedEvent?.Publish(new NavigationStateChangedEventArgs(this, StateChangeType.Remove));
            }

            return(success);
        }
コード例 #27
0
 public static INavigationService AddToBackStackAfter(this INavigationService ns, PageStackEntry entry)
 {
     if (entry != null)
     {
         _backstack_To_add = entry;
         ns.Navigated += Ns_AddToBackStackAfter_OnNavigated;
         ns.NavigationFailed += Ns_AddToBackStackAfter_OnNavigationFailed;
         ns.NavigationStopped += Ns_AddToBackStackAfter_OnNavigationStopped;
     }
     return ns;
 }
コード例 #28
0
        public Task GoBackAsync()
        {
            PageStackEntry stackEntry             = Frame.BackStack.Last();
            Type           backPageType           = stackEntry.SourcePageType;
            KeyValuePair <string, Type> pageEntry = Pages.FirstOrDefault(pair => pair.Value == backPageType);

            _currentPage = pageEntry.Key;

            Frame.GoBack();
            return(Task.CompletedTask);
        }
コード例 #29
0
 private void OnNavigationStopped(PageStackEntry entry, NavigationMode mode)
 {
     NavigationStopped?.Invoke(this, new NavigationEventArgs(
                                   entry.Instance,
                                   mode,
                                   entry.NavigationTransitionInfo,
                                   entry.Parameter,
                                   entry.SourcePageType,
                                   null
                                   ));
 }
コード例 #30
0
        void ReplaceLastBackStackEntryParameter(object parameter)
        {
            var backStack      = Frame.BackStack;
            var backStackCount = backStack.Count;

            if (backStackCount > 0)
            {
                var entry = backStack[backStackCount - 1];
                backStack[backStackCount - 1] = new PageStackEntry(
                    entry.SourcePageType, parameter, entry.NavigationTransitionInfo);
            }
        }
コード例 #31
0
        private bool GetIsAnimated(PageStackEntry entry)
        {
            return(!(entry?.NavigationTransitionInfo is SuppressNavigationTransitionInfo));

            // TODO: Explicitly handle all navigation transitions:
            // - DrillInNavigationTransitionInfo
            // - NavigationTransitionInfo
            // - SlideNavigationTransitionInfo
            // - SuppressNavigationTransitionInfo
            // - EntranceNavigationTransitionInfo
            // - ContinuumNavigationTransitionInfo
            // - CommonNavigationTransitionInfo
        }
コード例 #32
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);


            string videoId = String.Empty;

            Item = e.Parameter as Video;
            if (Item != null && !Item.Id.Equals(String.Empty))
            {
                try
                {
                    //Get The Video Uri and set it as a player source
                    var url = await YouTube.GetVideoUriAsync(Item.Id, YouTubeQuality.Quality480P);

                    player.Source = url.Uri;
                }
                catch (YouTubeUriNotFoundException _e)
                {
                    Debug.WriteLine(_e.Message);
                    MessageDialog message = new MessageDialog("This video is not availible, please select other");
                    await message.ShowAsync();

                    this.Frame.GoBack();
                }
            }

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

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

                // Doctor the navigation parameter for the master page so it
                // will show the correct item in the side-by-side view.
                var modifiedEntry = new PageStackEntry(
                    masterPageEntry.SourcePageType,
                    Item.Id,
                    masterPageEntry.NavigationTransitionInfo
                    );
                backStack.Add(modifiedEntry);
            }

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

            systemNavigationManager.BackRequested += DetailPage_BackRequested;
            systemNavigationManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
        }
コード例 #33
0
        internal static void OnBackRequested(object sender, BackRequestedEventArgs e)
        {
            Frame rootFrame = Window.Current.Content as Frame;
            /* Just to keep in mind how to investicate backstack problems. */
            IList <PageStackEntry> pse = rootFrame.BackStack;

            PageStackEntry[] psea = new PageStackEntry[pse.Count];
            pse.CopyTo(psea, 0);

            if (rootFrame.CanGoBack && e.Handled == false)
            {
                e.Handled = true;
                rootFrame.GoBack();
            }
        }
コード例 #34
0
        /// <summary>
        /// Populates the page with content passed during navigation. Any saved state is also
        /// provided when recreating a page from a prior session.
        /// Resets the state of the view model by passing in the parameters provided by the
        /// caller.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="Common.NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session. The state will be null the first time a page is visited.</param>
        private void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            if (e.NavigationParameter is QueueVoiceCommand)
            {
                // look up destination, set trip.
                QueueVoiceCommand voiceCommand = (QueueVoiceCommand)e.NavigationParameter;
                HubModels.Header = Models.Point.GetModelByNumber(voiceCommand.modelNumber);
                SetControlsPosition(HubModels.Header.ToString());
                SetRandomInput();
                bResult_Click(this, new RoutedEventArgs());

                // artificially populate the page backstack so we have something to
                // go back to to get to the main page.
                PageStackEntry backEntry = new PageStackEntry(typeof(View.MainPage), null, null);
                Frame.BackStack.Add(backEntry);
            }
            else if (e.NavigationParameter is string)
            {
                // We've been URI Activated, possibly by a user clicking on a tile in a Cortana session,
                // we should see an argument like destination=<Location>. 
                // This should handle finding all of the destinations that match, but currently it only
                // finds the first one.
                string arguments = e.NavigationParameter as string;
                if (arguments != null)
                {
                    string[] args = arguments.Split('=');
                    if (args.Length == 2 && args[0].ToLowerInvariant() == "modelnumber")
                    {
                        HubModels.Header = Models.Point.GetModelByNumber(args[1]);
                        SetControlsPosition(HubModels.Header.ToString());
                        SetRandomInput();
                        bResult_Click(this, new RoutedEventArgs());

                        // artificially populate the page backstack so we have something to
                        // go back to to get to the main page.
                        PageStackEntry backEntry = new PageStackEntry(typeof(View.MainPage), null, null);
                        Frame.BackStack.Add(backEntry);
                    }
                }
            }
            else
            {
                Frame.Navigate(typeof(View.MainPage), "");
            }
        }
コード例 #35
0
 /// <summary>
 /// Remove a <see cref="PageStackEntry"/> from the Frame's back stack.
 /// </summary>
 /// <param name="entry">The <see cref="PageStackEntry"/> to remove.</param>
 /// <returns>True if item was successfully removed from the back stack; otherwise, false. This method also returns false if item is not found in the back stack.</returns>
 public bool RemoveBackStackEntry(PageStackEntry entry)
 {
     var success = _frame.BackStack.Remove(entry);
     if (success)
     {
         _navigationStateChangedEvent?.Publish(new NavigationStateChangedEventArgs(this, StateChangeType.Remove));
     }
     
     return success;
 }
コード例 #36
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (ViewModel.CurrentArticle != null)
            {
                if (ViewModel.CurrentArticle.Link?.WithoutScheme() != ArticleWebView.Source?.WithoutScheme())
                {
                    ArticleWebView.Navigate(ViewModel.CurrentArticle.Link);
                }
                else
                {
                    ArticleWebView.Visibility = Visibility.Visible;
                }
            }

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

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

                // Clear the navigation parameter so that navigation back to the
                // MasterDetail page won't reset the current article selection.
                var modifiedEntry = new PageStackEntry(
                    masterPageEntry.SourcePageType,
                    null,
                    masterPageEntry.NavigationTransitionInfo
                    );
                backStack.Add(modifiedEntry);
            }

            // Register for hardware and software back request from the system
            SystemNavigationManager systemNavigationManager = SystemNavigationManager.GetForCurrentView();
            systemNavigationManager.BackRequested += DetailPage_BackRequested;
            systemNavigationManager.AppViewBackButtonVisibility = AppViewBackButtonVisibility.Visible;
            ViewModel.IsInDetailsMode = true;
        }
コード例 #37
0
        /// <summary>
        /// Populates the page with content passed during navigation. Any saved state is also
        /// provided when recreating a page from a prior session.
        /// Resets the state of the view model by passing in the parameters provided by the
        /// caller.
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="Common.NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session. The state will be null the first time a page is visited.</param>
        private void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            defaultViewModel = (TripViewModel)this.DataContext;
            if (e.NavigationParameter is Trip)
            {
                // Activated via selecting a trip in the main page's list of trips.
                DefaultViewModel.ShowTrip((Trip)e.NavigationParameter);
            }
            else if (e.NavigationParameter is TripVoiceCommand)
            {
                // look up destination, set trip.
                TripVoiceCommand voiceCommand = (TripVoiceCommand)e.NavigationParameter;
                DefaultViewModel.LoadTripFromStore(voiceCommand.destination);

                // artificially populate the page backstack so we have something to
                // go back to to get to the main page.
                PageStackEntry backEntry = new PageStackEntry(typeof(View.TripListView), null, null);
                this.Frame.BackStack.Add(backEntry);
            }
            else if(e.NavigationParameter is string)
            {
                // We've been URI Activated, possibly by a user clicking on a tile in a Cortana session,
                // we should see an argument like destination=<Location>. 
                // This should handle finding all of the destinations that match, but currently it only
                // finds the first one.
                string arguments = e.NavigationParameter as string;
                if(arguments != null)
                {
                    string[] args = arguments.Split('=');
                    if (args.Length == 2 && args[0].ToLowerInvariant() == "destination")
                    {
                        DefaultViewModel.LoadTripFromStore(args[1]);

                        // artificially populate the page backstack so we have something to
                        // go back to to get to the main page.
                        PageStackEntry backEntry = new PageStackEntry(typeof(View.TripListView), null, null);
                        this.Frame.BackStack.Add(backEntry);
                    }
                }
            }
            else
            {
                DefaultViewModel.NewTrip();
            }
        }
コード例 #38
0
ファイル: StackEntry.cs プロジェクト: GFlisch/Template10
 public StackEntry(PageStackEntry entry)
 {
     Page = entry.SourcePageType;
     Parameter = entry.Parameter;
     NavigationTransitionInfo = entry.NavigationTransitionInfo;
 }
コード例 #39
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            // Parameter is item ID
            Item = new ItemViewModel(ItemsDataSource.GetItemById((int)e.Parameter));
            //UpdateMap();
            var backStack = Frame.BackStack;
            var backStackCount = backStack.Count;

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

                // Doctor the navigation parameter for the master page so it
                // will show the correct item in the side-by-side view.
                var modifiedEntry = new PageStackEntry(
                    masterPageEntry.SourcePageType,
                    Item.Item.Number,
                    masterPageEntry.NavigationTransitionInfo
                    );
                backStack.Add(modifiedEntry);
            }

            // Register for hardware and software back request from the system
            SystemNavigationManager.GetForCurrentView().BackRequested += DetailPage_BackRequested;
        }