예제 #1
0
        /**
         *  Updates navigation history whenever the user navigates.
         *
         *  @param  WrapperViewModel navObj : Navigation object representing the current navigation
         *                                    point.
         *
         *  @return Void
         */
        private void AddToHistory(WrapperViewModel navObj)
        {
            if (NavigationHistory.Count >= MaxHistoryObjects)
            {
                NavigationHistory.RemoveAt(0);
            }

            NavigationHistory.Add(navObj);
        }
예제 #2
0
 /**
  *  Links a navigation handler and instance of the service to the corenavigationviewmodel.
  *  Inheriting classes will now be registerd with a window
  *
  *  @param  INavigationProvider navigationHandler
  *  @param  WrapperViewModel defaultNavigation
  *  @param forceDefaultNavigation
  *  @return void
  */
 public void Startup(INavigationProvider navigationHandler, WrapperViewModel defaultNavigation = null,
                     bool forceDefaultNavigation = false)
 {
     service.RegisterProvider(navigationHandler);
     Handler = navigationHandler;
     if (defaultNavigation != null)
     {
         service.SetDefaultNavigation(defaultNavigation, forceDefaultNavigation);
     }
 }
예제 #3
0
        /**
         *  Sets default navigation based on parameters.  Can force setting if the provider
         *  is empty.
         *
         *  @param  WrapperViewModel navigationObject : The navigation object to be set as default
         *  @param  bool forceIfProviderEmpty : A bool value indicating if the default navigation
         *                                      should be forced.  False by default.
         *  @return Void
         */
        public void SetDefaultNavigation(WrapperViewModel navigationObject, bool forceIfProviderEmpty = false)
        {
            DefaultNavigation = navigationObject;

            if (forceIfProviderEmpty)
            {
                if (Provider != null)
                {
                    Provider.Current = navigationObject;
                }
            }
        }
예제 #4
0
        /**
         *  Navigates to a view specified by the parameter
         *
         *  @param  WrapperViewModel navObject : An object representing the view to be navigated to
         *
         *  @return Void
         */
        public void Navigate(WrapperViewModel navObject)
        {
            if (Provider == null)
            {
                throw new NullReferenceException("The navigation service does not have a registered 'INavigationProvider'");
            }

            var args = new NavigationEventArgs(navObject, Provider.Current);

            OnBeforeNavigate(this, args);

            if (Provider.Current != null && Provider.Current != navObject)
            {
                AddToHistory(Provider.Current);
            }

            Provider.Current = navObject;

            OnAfterNavigate(this, args);
        }
예제 #5
0
 /**
  *  Navigates to the specified navigation object
  *
  *  @param  WrapperViewModel navigationObject : Navigation object representing
  *                                              the place to navigate to.
  *
  *  @return Void
  */
 protected virtual void Navigate(WrapperViewModel navigationObject)
 {
     service.Navigate(navigationObject);
 }
예제 #6
0
 /// <summary>
 /// Constructor with ViewModels that indicate where navigation will go and where it came from
 /// </summary>
 public NavigationEventArgs(WrapperViewModel navigatingTo, WrapperViewModel navigatingFrom = null)
 {
     ViewModelTo   = navigatingTo;
     ViewModelFrom = navigatingFrom;
 }