Beispiel #1
0
        protected void DisplayNavigationEntry(INavigationEntry entry)
        {
            if (entry == null)
            {
                // If this entry is null then simply pass null to the deriving class

                DisplayPage(null);
            }
            else
            {
                // Cast to the internal NavigationEntry class so we can access all members
                // TODO : Try to get rid of the need for this cast? (or check that it is of the correct type and provide alternatives for derived classes)

                NavigationEntry internalEntry = (NavigationEntry)entry;

                // If the page and VM have not been created then do so

                if (internalEntry.ViewLifetimeContext == null)
                {
                    CreatePage(internalEntry);
                }

                // Navigate to the relevant page

                DisplayPage(internalEntry.ViewLifetimeContext.View);
            }
        }
Beispiel #2
0
        // *** Private Methods ***

        private void DisplaySearchResults(string queryText, string language)
        {
            // If there are no search results to display then just return

            if (queryText == "")
            {
                return;
            }

            // Navigate to the search page if it is not currently visible

            INavigationEntry currentPage = navigationManager.CurrentPage;

            if (currentPage == null || currentPage.PageName != SearchPageName)
            {
                navigationManager.NavigateTo(SearchPageName);
            }

            // For all page elements that implement ISearchPage then execute the query

            IEnumerable <ISearchPage> searchPages = navigationManager.CurrentPage.GetElements().Where(page => page is ISearchPage).Cast <ISearchPage>();

            foreach (ISearchPage searchPage in searchPages)
            {
                searchPage.PerformQuery(queryText, language);
            }
        }
Beispiel #3
0
        protected void CallNavigatingFrom(INavigationEntry entry, NavigationMode navigationMode)
        {
            if (entry == null)
            {
                return;
            }

            foreach (object element in entry.GetElements())
            {
                if (element is INavigationAware)
                {
                    ((INavigationAware)element).NavigatingFrom(navigationMode);
                }
            }
        }
Beispiel #4
0
        // *** Constructors ***

        public PageNavigationEventArgs(INavigationEntry page, NavigationMode navigationMode)
        {
            // Validate arguments

            if (page == null)
                throw new ArgumentNullException("page");

            if (!Enum.IsDefined(typeof(NavigationMode), navigationMode))
                throw new ArgumentException(ResourceHelper.GetErrorResource("Exception_ArgumentException_SpecifiedEnumIsNotDefined"), "navigationMode");

            // Set properties

            this.page = page;
            this.navigationMode = navigationMode;
        }
Beispiel #5
0
        // *** Methods ***

        public void GoBack()
        {
            // Check that we can go back

            if (!CanGoBack)
            {
                throw new InvalidOperationException(ResourceHelper.GetErrorResource("Exception_InvalidOperation_CannotGoBackWithEmptyBackStack"));
            }

            // Pop the last page from the stack, call NavigationFrom() and dispose any cached items

            INavigationEntry oldNavigationEntry = NavigationStack.Pop();

            CallNavigatingFrom(oldNavigationEntry, NavigationMode.Back);

            if (oldNavigationEntry is NavigationEntry)
            {
                ((NavigationEntry)oldNavigationEntry).DisposeCachedItems();
            }

            // Display the new current page from the navigation stack

            DisplayNavigationEntry(CurrentNavigationEntry);

            // If the value of CanGoBack has changed then raise an event
            // NB: We can assume that the old value was true otherwise an exception is thrown on entry to this method

            if (!CanGoBack)
            {
                OnCanGoBackChanged();
            }

            // Call NavigatingTo()

            CallNavigatedTo(CurrentNavigationEntry, NavigationMode.Back);
        }
Beispiel #6
0
        protected void DisplayNavigationEntry(INavigationEntry entry)
        {
            if (entry == null)
            {
                // If this entry is null then simply pass null to the deriving class

                DisplayPage(null);
            }
            else
            {
                // Cast to the internal NavigationEntry class so we can access all members
                // TODO : Try to get rid of the need for this cast? (or check that it is of the correct type and provide alternatives for derived classes)

                NavigationEntry internalEntry = (NavigationEntry)entry;

                // If the page and VM have not been created then do so

                if (internalEntry.ViewLifetimeContext == null)
                    CreatePage(internalEntry);

                // Navigate to the relevant page

                DisplayPage(internalEntry.ViewLifetimeContext.View);
            }
        }
Beispiel #7
0
        protected void CallNavigatingFrom(INavigationEntry entry, NavigationMode navigationMode)
        {
            if (entry == null)
                return;

            // Fire the NavigatingFrom event

            OnNavigatingFrom(new PageNavigationEventArgs(entry, navigationMode));

            // Call NavigatingFrom on all page elements

            foreach (object element in entry.GetElements())
            {
                if (element is INavigationAware)
                    ((INavigationAware)element).NavigatingFrom(navigationMode);
            }
        }