Ejemplo n.º 1
0
        private void page_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
        {
            var evnt = NavigationEvent.FromCancelEventArgs(sender as PhoneApplicationPage, e);

            if (evnt.FromUri == null)
            {
                evnt.FromUri = currentPageUri;
            }
            MessageTopicProvider <NavigationEvent> .Instance.Send(NavigationEvent.BackKeyPress, evnt);

            e.Cancel = evnt.Cancel;
        }
Ejemplo n.º 2
0
        internal static NavigationEvent FromNavigationEventArgs(System.Windows.Navigation.NavigationService navigationService, NavigationEventArgs e)
        {
            var evnt = new NavigationEvent()
            {
                IsCancelable          = false,
                IsNavigationInitiator = e.IsNavigationInitiator,
                NavigationMode        = (AdysTech.FeatherLite.Navigation.NavigationMode)e.NavigationMode,
                FromUri           = navigationService.BackStack.Any() ? UriWithoutQUeryParam(navigationService.BackStack.FirstOrDefault().Source) : null,
                ToUri             = UriWithoutQUeryParam(e.Uri),
                NavigationContext = new NavigationContext(e.Uri)
            };

            return(evnt);
        }
Ejemplo n.º 3
0
        internal static NavigationEvent FromCancelEventArgs(Microsoft.Phone.Controls.PhoneApplicationPage phoneApplicationPage, System.ComponentModel.CancelEventArgs e)
        {
            var evnt = new NavigationEvent()
            {
                IsCancelable          = true,
                IsNavigationInitiator = true,
                NavigationMode        = NavigationMode.Back,
                FromUri           = null,
                ToUri             = null,
                NavigationContext = null
            };

            return(evnt);
        }
Ejemplo n.º 4
0
        internal static NavigationEvent FromNavigatingCancelEventArgs(System.Windows.Navigation.NavigationService navigationService, NavigatingCancelEventArgs e)
        {
            var evnt = new NavigationEvent()
            {
                IsCancelable          = e.IsCancelable,
                IsNavigationInitiator = e.IsNavigationInitiator,
                FromUri           = UriWithoutQUeryParam(navigationService.CurrentSource),
                NavigationMode    = (AdysTech.FeatherLite.Navigation.NavigationMode)e.NavigationMode,
                Cancel            = e.Cancel,
                ToUri             = UriWithoutQUeryParam(e.Uri),
                NavigationContext = new NavigationContext(e.Uri)
            };

            return(evnt);
        }
Ejemplo n.º 5
0
        private bool HookupEvents()
        {
            if (_mainFrame != null)
            {
                // Could be null if the app runs inside a design tool
                _mainFrame.Navigating += (s, e) =>
                {
                    //No need to propagate event when its already cancelled.
                    if (e.Cancel)
                    {
                        return;
                    }
                    var service = s as System.Windows.Navigation.NavigationService;
                    var evnt    = NavigationEvent.FromNavigatingCancelEventArgs(service, e);
                    lastPageUri = evnt.FromUri;
                    MessageTopicProvider <NavigationEvent> .Instance.Send(NavigationEvent.Navigating, evnt);

                    e.Cancel = evnt.Cancel;
                };
                _mainFrame.Navigated += (s, e) =>
                {
                    var evnt = NavigationEvent.FromNavigationEventArgs(s as System.Windows.Navigation.NavigationService, e);
                    if (evnt.FromUri == null)
                    {
                        evnt.FromUri = lastPageUri;
                    }
                    currentPageUri = evnt.ToUri;
                    var page = e.Content as PhoneApplicationPage;
                    if (page != null)
                    {
                        if (lastPage != null && lastPage != page)
                        {
                            lastPage.BackKeyPress -= page_BackKeyPress;
                        }
                        lastPage           = page;
                        page.BackKeyPress += page_BackKeyPress;
                    }
                    MessageTopicProvider <NavigationEvent> .Instance.Send(NavigationEvent.Navigated, evnt);
                };

                return(true);
            }

            return(false);
        }