コード例 #1
0
        private void OnNavigatedEvent(object sender, NavigationEventArgs e)
        {
            var eventArgs = new NavigatedEventArgs(e.Uri.ToString(), NavigationMode.Unknown);
            HandleNavigatedEvent(eventArgs);

            _lastNavigationContext = e.ExtraData;
        }
コード例 #2
0
        private void OnActivityStopped(object sender, ActivityEventArgs e)
        {
            _lastActivity = e.Activity;

            var eventArgs = new NavigatedEventArgs(GetNavigationUri(e.Activity), NavigationMode.New);

            RaiseNavigatedAway(eventArgs);
        }
コード例 #3
0
        private void OnNavigatedEvent(object sender, NavigationEventArgs e)
        {
            var eventArgs = new NavigatedEventArgs(e.Uri.ToString(), NavigationMode.Unknown);

            HandleNavigatedEvent(eventArgs);

            _lastNavigationContext = e.ExtraData;
        }
コード例 #4
0
ファイル: NavigationAdapter.cs プロジェクト: yicong/Catel
        /// <summary>
        /// Raises the <see cref="NavigatedAway"/> event.
        /// </summary>
        /// <param name="e">The <see cref="NavigatedEventArgs"/> instance containing the event data.</param>
        protected void RaiseNavigatedAway(NavigatedEventArgs e)
        {
            if (!CanHandleNavigation())
            {
                return;
            }

            Log.Debug("Navigated away from '{0}'", NavigationTargetType);

            NavigatedAway.SafeInvoke(this, e);
        }
コード例 #5
0
ファイル: NavigationAdapter.cs プロジェクト: yicong/Catel
        /// <summary>
        /// Raises the <see cref="NavigatedTo"/> event.
        /// </summary>
        /// <param name="e">The <see cref="NavigatedEventArgs"/> instance containing the event data.</param>
        protected void RaiseNavigatedTo(NavigatedEventArgs e)
        {
            if (!CanHandleNavigation())
            {
                return;
            }

            Log.Debug("Navigated to '{0}'", NavigationTargetType);

            DetermineNavigationContext();

            NavigatedTo.SafeInvoke(this, e);
        }
コード例 #6
0
        private void OnNavigatedEvent(object sender, NavigationEventArgs e)
        {
            var uriString = string.Empty;

            if (e.SourcePageType != null)
            {
                uriString = e.SourcePageType.ToString();
            }

            _lastGlobalNavigationContext = e.Parameter as Dictionary <string, object>;

            var eventArgs = new NavigatedEventArgs(uriString, NavigationMode.Unknown);

            HandleNavigatedEvent(eventArgs);
        }
コード例 #7
0
ファイル: NavigationAdapter.cs プロジェクト: yicong/Catel
        private void InitializeNavigationService(bool isComingFromLoadedEvent)
        {
            if (_navigationServiceInitialized)
            {
                return;
            }

            Initialize();

            _navigationServiceInitialized = true;

            if (isComingFromLoadedEvent)
            {
                var eventArgs = new NavigatedEventArgs(string.Empty, NavigationMode.New);
                RaiseNavigatedTo(eventArgs);
            }
        }
コード例 #8
0
ファイル: NavigationAdapter.cs プロジェクト: yicong/Catel
        private void HandleNavigatedEvent(NavigatedEventArgs e)
        {
            var eventArgs = new NavigatedEventArgs(e.Uri, NavigationMode.Unknown);

            // If this navigation event is not meant for this page, exit
            if (!eventArgs.Uri.IsNavigationForView(NavigationTargetType))
            {
                // We are not navigating *to* this view, but maybe we are navigating away
                RaiseNavigatedAway(eventArgs);
                return;
            }

            if (e.Uri != null && e.Uri.IsNavigationToExternal())
            {
                Log.Debug("Navigating away from the application, ignoring navigation");
                return;
            }

            RaiseNavigatedTo(eventArgs);
        }
コード例 #9
0
        private void OnNavigatedEvent(object sender, NavigationEventArgs e)
        {
            // CTL-906: clear current navication context if (re) navigating to the same view
            if (e.IsNavigationForView(NavigationTargetType))
            {
                _lastNavigationContext = null;
            }

            var sourceDictionary = e.ExtraData as Dictionary <string, object>;

            if (sourceDictionary == null)
            {
                sourceDictionary            = new Dictionary <string, object>();
                sourceDictionary["context"] = e.ExtraData;
            }

            _lastGlobalNavigationContext = sourceDictionary;

            var eventArgs = new NavigatedEventArgs(e.Uri.ToString(), NavigationMode.Unknown);

            HandleNavigatedEvent(eventArgs);
        }
コード例 #10
0
        partial void Initialize()
        {
            var activity    = GetNavigationTarget <Activity>();
            var application = activity.Application;

            if (application == null)
            {
                const string error = "To support navigation events in Android, Catel uses a custom ActivityLifecycleCallbacksListener. This requires an app instance though. Please make sure that the Android app contains an Application class.";
                Log.Error(error);

                throw new NotSupportedException(error);
            }

            _activityLifecycleCallbacksListener = new ActivityLifecycleCallbacksListener(activity);
            _activityLifecycleCallbacksListener.ActivityPaused  += OnActivityPaused;
            _activityLifecycleCallbacksListener.ActivityStopped += OnActivityStopped;

            application.RegisterActivityLifecycleCallbacks(_activityLifecycleCallbacksListener);

            // The first time, the general adapter will take care of this
            if (_isFirstTimeLoaded)
            {
                _isFirstTimeLoaded = false;
            }
            else
            {
                // Note: we don't subscribe to ActivityResumed because that equals the Loaded event. This adapter
                // is also created on the loaded
                _lastActivity = activity;

                var eventArgs = new NavigatedEventArgs(GetNavigationUri(activity), NavigationMode.New);
                RaiseNavigatedTo(eventArgs);
            }

            ContextHelper.CurrentContext = activity;
        }
コード例 #11
0
        private void OnNavigatedEvent(object sender, NavigationEventArgs e)
        {
            var eventArgs = new NavigatedEventArgs(e.Uri.ToString(), NavigationMode.Unknown);

            HandleNavigatedEvent(eventArgs);
        }
コード例 #12
0
        private void OnNavigatedEvent(object sender, NavigationEventArgs e)
        {
            var uriString = string.Empty;
            if (e.SourcePageType != null)
            {
                uriString = e.SourcePageType.ToString();
            }

            var eventArgs = new NavigatedEventArgs(uriString, NavigationMode.Unknown);
            HandleNavigatedEvent(eventArgs);

            _lastGlobalNavigationContext = e.Parameter as Dictionary<string, object>;
        }
コード例 #13
0
        private void OnActivityStopped(object sender, ActivityEventArgs e)
        {
            _lastActivity = e.Activity;

            var eventArgs = new NavigatedEventArgs(GetNavigationUri(e.Activity), NavigationMode.New);
            RaiseNavigatedAway(eventArgs);
        }
コード例 #14
0
        partial void Initialize()
        {
            var activity = GetNavigationTarget<Activity>();
            var application = activity.Application;
            if (application == null)
            {
                const string error = "To support navigation events in Android, Catel uses a custom ActivityLifecycleCallbacksListener. This requires an app instance though. Please make sure that the Android app contains an Application class.";
                Log.Error(error);

                throw new NotSupportedException(error);
            }

            _activityLifecycleCallbacksListener = new ActivityLifecycleCallbacksListener(activity);
            _activityLifecycleCallbacksListener.ActivityPaused += OnActivityPaused;
            _activityLifecycleCallbacksListener.ActivityStopped += OnActivityStopped;

            application.RegisterActivityLifecycleCallbacks(_activityLifecycleCallbacksListener);

            // The first time, the general adapter will take care of this
            if (_isFirstTimeLoaded)
            {
                _isFirstTimeLoaded = false;
            }
            else
            {
                // Note: we don't subscribe to ActivityResumed because that equals the Loaded event. This adapter
                // is also created on the loaded
                _lastActivity = activity;

                var eventArgs = new NavigatedEventArgs(GetNavigationUri(activity), NavigationMode.New);
                RaiseNavigatedTo(eventArgs);
            }

            ContextHelper.CurrentContext = activity;
        }
コード例 #15
0
 /// <summary>
 /// Called when the <c>Navigating</c> event is invoked.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The <see cref="NavigatingCancelEventArgs"/> instance containing the event data.</param>
 /// <remarks>
 /// This method is public due to the fact that weak events are used. Otherwise, the navigation completed events
 /// could not be handled (because we unsubscribed from the RootFrame) when navigating away to prevent memory
 /// leaks.
 /// <para />
 /// Please, do not call this method yourself, otherwise you can seriously ruin your apps.
 /// </remarks>
 public void OnNavigatedEvent(object sender, NavigationEventArgs e)
 {
     var eventArgs = new NavigatedEventArgs(e.Uri.ToString(), NavigationMode.Unknown);
     HandleNavigatedEvent(eventArgs);
 }