Exemplo n.º 1
0
 private void UpdateBackForward()
 {
     CanGoBack    = Browser.GetBrowser().CanGoBack;
     CanGoForward = Browser.GetBrowser().CanGoForward;
     CanGoBackChanged?.Invoke(this, CanGoBack);
     CanGoForwardChanged?.Invoke(this, CanGoForward);
 }
 public NavigationService(Frame frame)
 {
     _frame = new FrameFacade(frame, this);
     _frame.CanGoBackChanged += (s, e) =>
                                CanGoBackChanged?.Invoke(this, EventArgs.Empty);
     _frame.CanGoForwardChanged += (s, e) =>
                                   CanGoForwardChanged?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 3
0
 public FrameFacade(Frame frame, INavigationServiceUwp navigationService)
 {
     _frame             = frame;
     _navigationService = navigationService;
     _frame.RegisterPropertyChangedCallback(Frame.CanGoBackProperty, (s, p)
                                            => CanGoBackChanged?.Invoke(this, EventArgs.Empty));
     _frame.RegisterPropertyChangedCallback(Frame.CanGoForwardProperty, (s, p)
                                            => CanGoForwardChanged?.Invoke(this, EventArgs.Empty));
 }
Exemplo n.º 4
0
 public NavigationService(ILoggerFacade logger, IFrameFacade frameFacade)
 {
     _frameFacade = frameFacade;
     _frameFacade.CanGoBackChanged += (s, e) =>
                                      CanGoBackChanged?.Invoke(this, EventArgs.Empty);
     _frameFacade.CanGoForwardChanged += (s, e) =>
                                         CanGoForwardChanged?.Invoke(this, EventArgs.Empty);
     _logger = logger;
 }
Exemplo n.º 5
0
 private NavigationService(Frame frame)
 {
     _frame = new FrameFacade(frame, this);
     _frame.CanGoBackChanged += (s, e) =>
                                CanGoBackChanged?.Invoke(this, EventArgs.Empty);
     _frame.CanGoForwardChanged += (s, e) =>
                                   CanGoForwardChanged?.Invoke(this, EventArgs.Empty);
     Instances.Add(frame, this);
     _logger = PrismApplicationBase.Current.Container.Resolve <ILoggerFacade>();
 }
Exemplo n.º 6
0
 internal NavigationService(Frame frame, string id)
 {
     _frame = new FrameFacade(frame, this, id);
     _frame.CanGoBackChanged += (s, e) =>
                                CanGoBackChanged?.Invoke(this, EventArgs.Empty);
     _frame.CanGoForwardChanged += (s, e) =>
                                   CanGoForwardChanged?.Invoke(this, EventArgs.Empty);
     Instances.Add(frame, this);
     _logger = ApplicationTemplate.Current.Container.Resolve <ILoggerFacade>();
 }
Exemplo n.º 7
0
        internal FrameFacade(Frame frame, IPlatformNavigationService navigationService)
        {
            _frame = frame;
            _frame.ContentTransitions = new TransitionCollection();
            _frame.ContentTransitions.Add(new NavigationThemeTransition());
            _frame.RegisterPropertyChangedCallback(Frame.CanGoBackProperty, (s, p)
                                                   => CanGoBackChanged?.Invoke(this, EventArgs.Empty));
            _frame.RegisterPropertyChangedCallback(Frame.CanGoForwardProperty, (s, p)
                                                   => CanGoForwardChanged?.Invoke(this, EventArgs.Empty));

            _dispatcher        = frame.Dispatcher;
            _navigationService = navigationService;
        }
Exemplo n.º 8
0
        public FrameFacade(Frame frame, ILoggerFacade logger)
        {
            _frame = frame;
            _frame.ContentTransitions = new TransitionCollection
            {
                new NavigationThemeTransition()
            };
            _frame.RegisterPropertyChangedCallback(Frame.CanGoBackProperty, (s, p)
                                                   => CanGoBackChanged?.Invoke(this, EventArgs.Empty));
            _frame.RegisterPropertyChangedCallback(Frame.CanGoForwardProperty, (s, p)
                                                   => CanGoForwardChanged?.Invoke(this, EventArgs.Empty));

            _dispatcher  = frame.Dispatcher;
            _syncContext = SynchronizationContext.Current;
            _logger      = logger;
        }
Exemplo n.º 9
0
        internal FrameFacade(Frame frame, IPlatformNavigationService navigationService)
        {
            _frame = frame;
            _frame.ContentTransitions = new TransitionCollection
            {
                new NavigationThemeTransition()
            };
            _frame.RegisterPropertyChangedCallback(Frame.CanGoBackProperty, (s, p)
                                                   => CanGoBackChanged?.Invoke(this, EventArgs.Empty));
            _frame.RegisterPropertyChangedCallback(Frame.CanGoForwardProperty, (s, p)
                                                   => CanGoForwardChanged?.Invoke(this, EventArgs.Empty));

            _dispatcher        = frame.Dispatcher;
            _syncContext       = SynchronizationContext.Current;
            _navigationService = navigationService;
            _logger            = PrismApplicationBase.Current.Container.Resolve <ILoggerFacade>();
        }
Exemplo n.º 10
0
        public void Forward()
        {
            var currentEntry = HistoryStack.FirstOrDefault(h => h.Current);

            int currentIndex = HistoryStack.ToList().IndexOf(currentEntry);

            var validNavigationStack = HistoryStack
                                       // Transform to list so we don't affect the original stack
                                       ?.ToList();

            // Find the index of the current address in the valid history items
            int currentIndex_validStack = validNavigationStack.FindIndex(h => h.VisitedAt == currentEntry.VisitedAt);

            var newEntry = validNavigationStack.ElementAtOrDefault(currentIndex_validStack - 1);

            if (newEntry is null)
            {
                // We can't go forward, the UI should reflect that
                CanGoForwardChanged?.Invoke(false);
                // And the code shouldn't try.
                return;
            }

            foreach (var h in HistoryStack)
            {
                h.Current = false;
            }

            // This is the entry we're navigating to, so it should be marked as current
            HistoryStack.First(h => h.VisitedAt == newEntry.VisitedAt).Current = true;

            if (newEntry != null)
            {
                CanGoBackChanged?.Invoke(true);
                // If there is something else at the front of the stack, we can navigate forward to it
                CanGoForwardChanged?.Invoke(currentIndex_validStack - 1 > 0);

                ForwardRequested?.Invoke(newEntry);
            }
        }
Exemplo n.º 11
0
        public void Back()
        {
            var currentEntry = HistoryStack.FirstOrDefault(h => h.Current);
            int currentIndex = HistoryStack.ToList().IndexOf(currentEntry);

            var validNavigationStack = HistoryStack
                                       // Transform to list so we don't affect the original stack
                                       ?.ToList();

            // Find the index of the current address in the valid history items
            int currentIndex_validStack = validNavigationStack.FindLastIndex(h => h.Current);

            var newEntry = validNavigationStack.ElementAtOrDefault(currentIndex_validStack + 1);

            if (newEntry is null)
            {
                // We can't go back, the UI should reflect that
                CanGoBackChanged?.Invoke(false);
                // And the code shouldn't try.
                return;
            }

            foreach (var h in HistoryStack)
            {
                h.Current = false;
            }

            // This is the entry we're navigating to, so it should be marked as current
            HistoryStack.First(h => h.VisitedAt == newEntry.VisitedAt).Current = true;
            int newHistoryItemIndexOnStack = HistoryStack.ToList().FindIndex(h => h.VisitedAt == newEntry.VisitedAt);

            if (validNavigationStack != null)
            {
                CanGoBackChanged?.Invoke(newHistoryItemIndexOnStack + 1 < HistoryStack.Count());
                CanGoForwardChanged?.Invoke(true);

                BackRequested?.Invoke(newEntry);
            }
        }
Exemplo n.º 12
0
        public void Navigate(Uri address)
        {
            // Reset all entries to not current
            foreach (var h in HistoryStack)
            {
                h.Current = false;
            }

            var newNavigationEntry = new NavigationEntry()
            {
                Kind      = NavigationPageType.Web,
                WebUri    = address,
                VisitedAt = DateTime.Now,
                Current   = true
            };

            HistoryStack.Push(newNavigationEntry);

            CanGoBackChanged?.Invoke(true);
            CanGoForwardChanged?.Invoke(false);

            NavigationRequested?.Invoke(newNavigationEntry);
        }
Exemplo n.º 13
0
        public void Navigate(Type pageType, object param)
        {
            // Reset all entries to not current
            foreach (var h in HistoryStack)
            {
                h.Current = false;
            }

            var newNavigationEntry = new NavigationEntry()
            {
                Kind            = NavigationPageType.Native,
                NativePageType  = pageType,
                NativePageParam = param,
                VisitedAt       = DateTime.Now,
                Current         = true
            };

            HistoryStack.Push(newNavigationEntry);

            CanGoBackChanged?.Invoke(true);
            CanGoForwardChanged?.Invoke(false);

            NavigationRequested?.Invoke(newNavigationEntry);
        }
Exemplo n.º 14
0
 protected virtual void OnCanGoForwardChanged(EventArgs e)
 {
     CanGoForwardChanged?.Invoke(this, e);
 }