<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Input;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Regions;
using Poseidon.BackOffice.Common;
using Poseidon.BackOffice.Core.Contracts;

namespace Poseidon.BackOffice.Core.ViewModels
{
    public class NavigationViewModel : INavigationViewModel
    {
        readonly IRegionManager _regionManager;
        readonly List<Uri> _backStack = new List<Uri>();
        readonly List<Uri> _forwardStack = new List<Uri>();

        Uri _startPage;
        Uri StartPage { get { return _startPage ?? new Uri("ModulesView", UriKind.Relative); } }
        Uri _currentPage;
        Uri CurrentPage { get { return _currentPage ?? StartPage; } set { _currentPage = value; } }

        public NavigationViewModel(IRegionManager regionManager)
        {
            _regionManager = regionManager;

            var modules = _regionManager.Regions[Regions.TagModulesRegion];
            modules.NavigationService.Navigated += OnNavigated;
            
            //_navigationJournal = navigationJournal;
            
            //_navigationJournal = navigationJournal;
            OnBackCommand = new DelegateCommand(OnBack, CanGoBack);
            OnForwardCommand = new DelegateCommand(OnForward, CanGoForward);
        }

        void OnNavigated(object sender, RegionNavigationEventArgs e)
        {
            if (e.Uri != StartPage)
            {
                _backStack.Add(CurrentPage);
                CurrentPage = e.Uri;
            }
            else
                CurrentPage = null;
            ((DelegateCommand)OnBackCommand).RaiseCanExecuteChanged();
            ((DelegateCommand)OnForwardCommand).RaiseCanExecuteChanged();
        }

        #region Commands

        public ICommand OnForwardCommand { get; private set; }

        void OnForward()
        {
            if (!_forwardStack.Any()) return;
            var uri = _forwardStack.Take(1).FirstOrDefault();
            _forwardStack.RemoveAt(0);
            _regionManager.RequestNavigate(Regions.TagModulesRegion, uri);
        }

        bool CanGoForward()
        {<commit_msg>Clear the forward stack when navigating to another page<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Input;
using Microsoft.Practices.Prism.Commands;
using Microsoft.Practices.Prism.Regions;
using Poseidon.BackOffice.Common;
using Poseidon.BackOffice.Core.Contracts;

namespace Poseidon.BackOffice.Core.ViewModels
{
    public class NavigationViewModel : INavigationViewModel
    {
        readonly IRegionManager _regionManager;
        readonly List<Uri> _backStack = new List<Uri>();
        readonly List<Uri> _forwardStack = new List<Uri>();

        Uri _startPage;
        Uri StartPage { get { return _startPage ?? new Uri("ModulesView", UriKind.Relative); } }
        Uri _currentPage;
        Uri CurrentPage { get { return _currentPage ?? StartPage; } set { _currentPage = value; } }

        public NavigationViewModel(IRegionManager regionManager)
        {
            _regionManager = regionManager;

            var modules = _regionManager.Regions[Regions.TagModulesRegion];
            modules.NavigationService.Navigated += OnNavigated;
            
            //_navigationJournal = navigationJournal;
            
            //_navigationJournal = navigationJournal;
            OnBackCommand = new DelegateCommand(OnBack, CanGoBack);
            OnForwardCommand = new DelegateCommand(OnForward, CanGoForward);
        }

        void OnNavigated(object sender, RegionNavigationEventArgs e)
        {
            if (e.Uri != StartPage)
            {
                _backStack.Add(CurrentPage);
                _forwardStack.Clear();
                CurrentPage = e.Uri;
            }
            else
            {
                CurrentPage = null;
            }
            ((DelegateCommand)OnBackCommand).RaiseCanExecuteChanged();
            ((DelegateCommand)OnForwardCommand).RaiseCanExecuteChanged();
        }

        #region Commands

        public ICommand OnForwardCommand { get; private set; }

        void OnForward()
        {
            if (!_forwardStack.Any()) return;
            var uri = _forwardStack.Take(1).FirstOrDefault();
            _forwardStack.RemoveAt(0);
            _regionManager.RequestNavigate(Regions.TagModulesRegion, uri);
        }

        bool CanGoForward()
        {
{'fraction_non_alphanumeric': 0.08420583648919581, 'fraction_numerical': 0.0008910670527957229, 'mean_word_length': 2.328391401037806, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3866980', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1134, 'n_words': 239}