Ejemplo n.º 1
0
        public void RequestNavigate(string regionName, string viewName, string stateName)
        {
            if (_isInTransition) return;
            _isInTransition = true;

            if (string.IsNullOrEmpty(regionName))
                throw new ArgumentNullException("regionName");

            if (string.IsNullOrEmpty(viewName))
                throw new ArgumentNullException("viewName");

            INavigationRegion region = EnsureRegion(regionName);
            NavigationDescriptor descriptor = ActivateView(viewName, region);
            ViewState viewState = EnsureState(regionName, viewName, stateName, descriptor);

            OnNavigationStart(_previousDescriptor, descriptor, viewState);

            Presenter.TransitionCompleted -= OnTransitionCompleted;

            if (_previousDescriptor != null && _previousDescriptor.ViewName != descriptor.ViewName)
            {
                _targetDescriptor = descriptor;
                _sourceDescriptor = _previousDescriptor;
                _targetState = viewState;
                Presenter.TransitionCompleted += OnTransitionCompleted;
                Presenter.ApplyTransition(_previousDescriptor.ViewResolver(), descriptor.ViewResolver());
            }
            else
            {
                PostTransition();
            }

            _previousDescriptor = descriptor;
        }
Ejemplo n.º 2
0
 public NavigationItemViewModel(NavigationDescriptor descriptor, string regionName)
 {
     _navigationDescriptor = descriptor;
     RegionName = regionName;
     _navigationService = ServiceLocator.Current.GetInstance<INavigationService>();
     _navigationService.NavigationStart += OnNavigationStart;
 }
Ejemplo n.º 3
0
 private void NotifyStateChanging(NavigationDescriptor descriptor, ViewState state)
 {
     if (descriptor.StateChanging != null)
     {
         descriptor.StateChanging(state);
     }
 }
 public StateNavigationViewModel(ViewState viewState, NavigationDescriptor descriptor, string regionName)
 {
     _viewState = viewState;
     _descriptor = descriptor;
     _regionName = regionName;
     _navigationService = ServiceLocator.Current.GetInstance<INavigationService>();
     _navigationService.NavigationStart += OnNavigationStart;
 }
Ejemplo n.º 5
0
        public void Add(NavigationDescriptor descriptor)
        {
            _navigationViews.Add(descriptor);

            if (!descriptor.DelayLoad)
            {
                _activeNavigationViews.Add(descriptor);
            }
        }
Ejemplo n.º 6
0
        private NavigationDescriptor ActivateView(string viewName, INavigationRegion region)
        {
            NavigationDescriptor descriptor = region.ActiveNavigationViews[viewName];

            if (descriptor == null)
            {
                descriptor = region.Activate(viewName);
            }

            return(descriptor);
        }
Ejemplo n.º 7
0
 private void OnNavigationCompleted(NavigationDescriptor sourceDescriptor, NavigationDescriptor targetDescriptor, ViewState targetState)
 {
     if (NavigationCompleted != null)
     {
         NavigationCompleted(this,
                             new NavigationEventArgs(sourceDescriptor, targetDescriptor)
         {
             TargetState = targetState
         });
     }
 }
Ejemplo n.º 8
0
        public NavigationDescriptor Activate(string viewName)
        {
            NavigationDescriptor descriptor = _navigationViews[viewName];

            if (descriptor == null)
            {
                throw new InvalidOperationException("View missing: " + viewName);
            }

            _activeNavigationViews.Add(descriptor);
            return(descriptor);
        }
Ejemplo n.º 9
0
        private ViewState EnsureState(
            string regionName, string viewName, string stateName, NavigationDescriptor descriptor)
        {
            ViewState viewState = null;

            if (!string.IsNullOrEmpty(stateName))
            {
                if (descriptor.States == null ||
                    (viewState = descriptor.States.SingleOrDefault(x => x.Name == stateName)) == null)
                {
                    throw new InvalidOperationException(
                              string.Format("{0}_{1}_{2} does not exist", regionName, viewName, stateName));
                }
            }

            return(viewState);
        }
Ejemplo n.º 10
0
        public void RequestNavigate(string regionName, string viewName, string stateName)
        {
            if (_isInTransition)
            {
                return;
            }
            _isInTransition = true;

            if (string.IsNullOrEmpty(regionName))
            {
                throw new ArgumentNullException("regionName");
            }

            if (string.IsNullOrEmpty(viewName))
            {
                throw new ArgumentNullException("viewName");
            }

            INavigationRegion    region     = EnsureRegion(regionName);
            NavigationDescriptor descriptor = ActivateView(viewName, region);
            ViewState            viewState  = EnsureState(regionName, viewName, stateName, descriptor);

            OnNavigationStart(_previousDescriptor, descriptor, viewState);

            Presenter.TransitionCompleted -= OnTransitionCompleted;

            if (_previousDescriptor != null && _previousDescriptor.ViewName != descriptor.ViewName)
            {
                _targetDescriptor              = descriptor;
                _sourceDescriptor              = _previousDescriptor;
                _targetState                   = viewState;
                Presenter.TransitionCompleted += OnTransitionCompleted;
                Presenter.ApplyTransition(_previousDescriptor.ViewResolver(), descriptor.ViewResolver());
            }
            else
            {
                PostTransition();
            }

            _previousDescriptor = descriptor;
        }
Ejemplo n.º 11
0
 public NavigationEventArgs(
     NavigationDescriptor sourceDescriptor, NavigationDescriptor targetDescriptor)
 {
     SourceDescriptor = sourceDescriptor;
     TargetDescriptor = targetDescriptor;
 }
Ejemplo n.º 12
0
 public NavigationEventArgs(
     NavigationDescriptor sourceDescriptor, NavigationDescriptor targetDescriptor)
 {
     SourceDescriptor = sourceDescriptor;
     TargetDescriptor = targetDescriptor;
 }
Ejemplo n.º 13
0
 private void OnNavigationStart(NavigationDescriptor sourceDescriptor, NavigationDescriptor targetDescriptor, ViewState targetState)
 {
     if (NavigationStart != null)
         NavigationStart(this,
             new NavigationEventArgs(sourceDescriptor, targetDescriptor) { TargetState = targetState });
 }
Ejemplo n.º 14
0
 private void NotifyStateChanging(NavigationDescriptor descriptor, ViewState state)
 {
     if(descriptor.StateChanging != null)
         descriptor.StateChanging(state);
 }
Ejemplo n.º 15
0
        private ViewState EnsureState(
            string regionName, string viewName, string stateName, NavigationDescriptor descriptor)
        {
            ViewState viewState = null;

            if (!string.IsNullOrEmpty(stateName))
            {
                if (descriptor.States == null ||
                    (viewState = descriptor.States.SingleOrDefault(x => x.Name == stateName)) == null)
                {
                    throw new InvalidOperationException(
                        string.Format("{0}_{1}_{2} does not exist", regionName, viewName, stateName));
                }
            }

            return viewState;
        }