Exemplo n.º 1
0
        /// <summary>
        /// Use this method to restore session state and navigation history. This method should only be called if Initialize() has already been executed./>
        /// </summary>
        /// <returns>
        /// True if app state was successfully restored.
        /// </returns>
        public static async Task <bool> TryRestoreState()
        {
            try
            {
                StorageFile navFile = await _folder.GetFileAsync(NAV_FILE_NAME);

                StorageFile stateFile = await _folder.GetFileAsync(STATE_FILE_NAME);

                PageStates = await StorageHelper.TryReadAsync <List <Dictionary <string, object> > >(stateFile, _standardKnownTypes);

                int topIndex = PageStates.Count - 1;
                _pageState = PageStates[topIndex];
                PageStates.RemoveAt(topIndex);

                string navHistory = await StorageHelper.TryReadAsync(navFile);

                RootFrame.SetNavigationState(navHistory);

                return(true);
            }
            catch
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        /*********************************************/
        private void ChangePage(PageStates page)
        {
            if (CurrentState == page || ((MainMenuPageState)CurrentState).InTransit)
            {
                return;
            }

            switch (page)
            {
            case PageStates.PAGE_MAIN:
                _nav_points.MoveToNavPoint(0);
                break;

            case PageStates.PAGE_ABOUT:
                _nav_points.MoveToNavPoint(2);
                break;

            case PageStates.PAGE_CONFIG:
            case PageStates.PAGE_CONTROLS:
                _nav_points.MoveToNavPoint(3);
                break;

            default:
                Debug.LogError("Invalid page state requested");
                return;
            }

            ChangeState(page);
        }
        /// <summary>
        /// Call this method to save the navigation history along with session state locally. On failure, the Last Saved date is set to default (of the data type).
        /// </summary>
        /// <returns></returns>
        public static async Task SaveSessionState()
        {
            try
            {
                LastSessionSavedDate = default(DateTimeOffset);
                LastSessionOwner     = null;

                PageStates.Add((_currentPage as IManageable).SaveState());
                StorageFile navFile = await _folder.CreateFileAsync(NAV_FILE_NAME, CreationCollisionOption.ReplaceExisting);

                StorageFile stateFile = await _folder.CreateFileAsync(STATE_FILE_NAME, CreationCollisionOption.ReplaceExisting);

                bool result = true;
                result &= await StorageHelper.TryWriteAsync(navFile, RootFrame.GetNavigationState());

                result &= await StorageHelper.TryWriteAsync(stateFile, PageStates);

                if (result == true)
                {
                    LastSessionSavedDate = DateTimeOffset.UtcNow;
                    LastSessionOwner     = UserManager.CurrentUser.RegNo;
                }
            }
            catch { }
        }
Exemplo n.º 4
0
 private static void RootFrame_Navigated(object sender, NavigationEventArgs e)
 {
     if (_currentType == NavigationType.FreshStart)
     {
         RootFrame.BackStack.Clear();
         PageStates.Clear();
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Manages the page history suitably when the App resumes from a suspended state. Ensure to call this method so that page states are recorded accurately.
 /// </summary>
 /// <remarks>
 /// Ideally, the method call must be placed in the Resuming event handler for the App.
 /// </remarks>
 public static void ResumeState()
 {
     // The current page's state is added to the history when suspending.
     // On resumption, the state is not required as the code continues running from its last point.
     if (PageStates.Count > 0)
     {
         PageStates.RemoveAt(PageStates.Count - 1);
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Navigates to the last visited page in the back stack. This method does nothing if there is no page to go back to.
        /// </summary>
        public static void NavigateBack()
        {
            if (RootFrame.CanGoBack)
            {
                int lastPageIndex = RootFrame.BackStackDepth - 1;
                _pageState = PageStates[lastPageIndex];

                RootFrame.GoBack();
                PageStates.RemoveAt(lastPageIndex);
            }
        }
 private void SetPageState(PageStates state)
 {
     if (state == PageStates.Connecting)
     {
         ConnectingOverlay.Show();
         ApplicationBar.IsVisible = false;
     }
     else
     {
         ConnectingOverlay.Hide();
         ApplicationBar.IsVisible = true;
     }
 }
Exemplo n.º 8
0
 private void SetPageState(PageStates state)
 {
     if (state == PageStates.Connecting)
     {
         ConnectingOverlay.Show();
         ApplicationBar.IsVisible = false;
     }
     else
     {
         ConnectingOverlay.Hide();
         ApplicationBar.IsVisible = true;
     }
 }
Exemplo n.º 9
0
 public static void ShowWarning(
     string message,
     PageStates state = PageStates.Warning,
     Page navPage     = null,
     string pageTitle = "")
 {
     try
     {
         navPage = navPage ?? (Page)GetMainWindow().MainFrame.Content;
         GetMainWindow().MainFrame.Navigate(new WarningPage(navPage, message, state, pageTitle));
     }
     catch { }
 }
Exemplo n.º 10
0
 private void SetPageState(PageStates pageState, string busyMessage = "Connecting...")
 {
     if (pageState == PageStates.Busy)
     {
         PageStateTextBlock.Text  = busyMessage;
         PageStateGrid.Visibility = Windows.UI.Xaml.Visibility.Visible;
         BottomAppBar.Visibility  = Visibility.Collapsed;
     }
     else
     {
         PageStateGrid.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
         BottomAppBar.Visibility  = Visibility.Visible;
     }
 }
Exemplo n.º 11
0
 private void SetPageState(PageStates pageState)
 {
     if (pageState == PageStates.Connecting)
     {
         ConnectionsListView.IsEnabled = false;
         BottomAppBar.Visibility       = Visibility.Collapsed;
         ProgressRing.IsActive         = true;
     }
     else
     {
         ConnectionsListView.IsEnabled = true;
         BottomAppBar.Visibility       = Visibility.Visible;
         ProgressRing.IsActive         = false;
     }
 }
 /// <summary>
 /// Navigates to the desired page, passing a parameter to the next page.
 /// </summary>
 /// <param name="pageType">
 /// The type of page to navigate to.
 /// </param>
 /// <param name="parameter">
 /// The parameter to pass to the page being navigated to.
 /// </param>
 /// <param name="type">
 /// The type of navigation to use.
 /// </param>
 /// <remarks>
 /// This method calls SaveState() on the current page to store page specific state.
 /// </remarks>
 public static void NavigateTo(Type pageType, object parameter, NavigationType type)
 {
     _pageState = null;
     if (type == NavigationType.Default)
     {
         Dictionary <string, object> pageState = (_currentPage as IManageable).SaveState();
         RootFrame.Navigate(pageType, parameter);
         PageStates.Add(pageState);
     }
     else
     {
         RootFrame.Navigate(pageType, parameter);
         RootFrame.BackStack.Clear();
         PageStates.Clear();
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// Navigates to the desired page, passing a parameter to the next page.
        /// </summary>
        /// <param name="pageType">
        /// The type of page to navigate to.
        /// </param>
        /// <param name="parameter">
        /// The parameter to pass to the page being navigated to.
        /// </param>
        /// <param name="type">
        /// The type of navigation to use.
        /// </param>
        /// <remarks>
        /// This method calls SaveState() on the current page to store page specific state.
        /// </remarks>
        public static void NavigateTo(Type pageType, object parameter, NavigationType type)
        {
            _pageState   = null;
            _currentType = type;

            if (type == NavigationType.Default)
            {
                Dictionary <string, object> pageState = (_currentPage as IManageable).SaveState();
                RootFrame.Navigate(pageType, parameter);
                PageStates.Add(pageState);
            }
            else
            {
                ClearPageCache();
                RootFrame.Navigate(pageType, parameter);
                // Clearing of back stack and page states occur in Navigated event handler.
            }
        }
Exemplo n.º 14
0
        private void SetActiveState(PageStates state)
        {
            switch (state)
            {
            case PageStates.IntroPage:
                tabWizard.SelectedTab = tabPageInitial;
                break;

            case PageStates.AdvancedPage:
                tabWizard.SelectedTab = tabPageAdvanced;
                UpdateAdvancedGUI();
                break;

            case PageStates.RegisterBrowsePage:
                tabWizard.SelectedTab = tabPageRegisterBrowse;
                UpdateRegistrationBrowseGUI();
                break;

            case PageStates.RegisterSelectionFb2Page:
                tabWizard.SelectedTab = tabPageRegisterFb2;
                UpdateFb2Gui();
                break;

            case PageStates.RegisterSelectionRarPage:
                tabWizard.SelectedTab = tabPageRegisterRar;
                UpdateRar2Gui();
                break;

            case PageStates.RegisterSelectionZipPage:
                tabWizard.SelectedTab = tabPageRegisterZip;
                UpdateZipGui();
                break;

            case PageStates.UnregisterFinishPage:
                tabWizard.SelectedTab = tabPageUnregisterFinish;
                break;

            case PageStates.RegisterFinishPage:
                tabWizard.SelectedTab = tabPageRegisterFinish;
                UpdateRegistrationFinishGUI();
                break;
            }
            currentPage = state;
        }
Exemplo n.º 15
0
 private void SetActiveState(PageStates state)
 {
     switch (state)
     {
         case PageStates.IntroPage:
             tabWizard.SelectedTab = tabPageInitial;
             break;
         case PageStates.AdvancedPage:
             tabWizard.SelectedTab = tabPageAdvanced;
             UpdateAdvancedGUI();
             break;
         case PageStates.RegisterBrowsePage:
             tabWizard.SelectedTab = tabPageRegisterBrowse;
             UpdateRegistrationBrowseGUI();
             break;
         case PageStates.RegisterSelectionFb2Page:
             tabWizard.SelectedTab = tabPageRegisterFb2;
             UpdateFb2Gui();
             break;
         case PageStates.RegisterSelectionRarPage:
             tabWizard.SelectedTab = tabPageRegisterRar;
             UpdateRar2Gui();
             break;
         case PageStates.RegisterSelectionZipPage:
             tabWizard.SelectedTab = tabPageRegisterZip;
             UpdateZipGui();
             break;
         case PageStates.UnregisterFinishPage:
             tabWizard.SelectedTab = tabPageUnregisterFinish;
             break;
         case PageStates.RegisterFinishPage:
             tabWizard.SelectedTab = tabPageRegisterFinish;
             UpdateRegistrationFinishGUI();
             break;
     }
     currentPage = state;
 }
Exemplo n.º 16
0
 private void SetPageState(PageStates pageState)
 {
     if (pageState == PageStates.Connecting)
     {
         ConnectionsListView.IsEnabled = false;
         BottomAppBar.Visibility = Visibility.Collapsed;
         ProgressRing.IsActive = true;
     }
     else
     {
         ConnectionsListView.IsEnabled = true;
         BottomAppBar.Visibility = Visibility.Visible;
         ProgressRing.IsActive = false;
     }
 }
Exemplo n.º 17
0
        public WarningPage(Page returnPage, string message, PageStates state = PageStates.Warning, string pageTitle = "")
        {
            Message    = message;
            ReturnPage = returnPage;
            PageState  = state;

            var vm = new WarningPageViewModel();

            DataContext = vm;

            var titles = App.LocalizedEnvironment.Translation.EyesGuard.AlertPages.Titles;

            if (PageState == PageStates.Warning)
            {
                vm.Icon  = FontAwesome.WPF.FontAwesomeIcon.Warning;
                vm.Brush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFEEC78A"));
                if (pageTitle?.Length == 0)
                {
                    vm.PageTitle = titles.Attention;
                }
            }
            else if (PageState == PageStates.Success)
            {
                vm.Icon  = FontAwesome.WPF.FontAwesomeIcon.Check;
                vm.Brush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#8ED28A"));
                if (pageTitle?.Length == 0)
                {
                    vm.PageTitle = titles.Successful;
                }
            }
            else if (PageState == PageStates.Error)
            {
                vm.Icon  = FontAwesome.WPF.FontAwesomeIcon.ExclamationCircle;
                vm.Brush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#FFFD9884"));
                if (pageTitle?.Length == 0)
                {
                    vm.PageTitle = titles.Error;
                }
            }
            else if (PageState == PageStates.Info)
            {
                vm.Icon  = FontAwesome.WPF.FontAwesomeIcon.Comment;
                vm.Brush = Brushes.White;
                if (pageTitle?.Length == 0)
                {
                    vm.PageTitle = titles.Info;
                }
            }
            else if (PageState == PageStates.About)
            {
                vm.Icon  = FontAwesome.WPF.FontAwesomeIcon.Rocket;
                vm.Brush = Brushes.White;
                if (pageTitle?.Length == 0)
                {
                    vm.PageTitle = titles.AboutSoftware;
                }
            }
            else if (PageState == PageStates.Donate)
            {
                vm.Icon  = FontAwesome.WPF.FontAwesomeIcon.Heart;
                vm.Brush = new SolidColorBrush((Color)ColorConverter.ConvertFromString("#ff7c7c"));
                if (pageTitle?.Length == 0)
                {
                    vm.PageTitle = titles.Donate;
                }
            }

            if (pageTitle != "")
            {
                vm.PageTitle = pageTitle;
            }

            InitializeComponent();
        }