Esempio n. 1
0
        public bool SwitchPage(AbstractPage.Pages page)
        {
            var target = FindPage(page);

            Dispatcher.UIThread.Post(() =>
            {
                if (target != null)
                {
                    _lastPageCache     = Pager.SelectedItem;
                    Pager.SelectedItem = target;
                    /* Call OnPageShown prematurely */
                    target.OnPageShown();
                    PageSwitched?.Invoke(this, page);
                }
            }, DispatcherPriority.Render);
            return(target != null);
        }
Esempio n. 2
0
        public AbstractPage?FindPage(AbstractPage.Pages page, bool nullAware = false)
        {
            AbstractPage[] matches = PageViewModel.Items.Where(abstractPage => abstractPage.PageType == page).ToArray();
            if (matches.Length < 1)
            {
                if (!nullAware)
                {
                    Log.Error($"Page '{page}' is not assigned");
                }

                return(null);
            }
            if (matches.Length > 1)
            {
                Log.Warning($"Page '{page}' has multiple assignments. Choosing first one.");
            }

            return(matches[0]);
        }
Esempio n. 3
0
        public void RestartApp(AbstractPage.Pages target)
        {
            if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
            {
                MainWindow.Instance.DisableApplicationExit = true;
                MainWindow.Instance.OverrideMinimizeTray   = true;
                MainWindow.Instance.Close();
                MainWindow.Kill();

                ThemeUtils.Reload();

                desktop.MainWindow = MainWindow.Instance;
                desktop.MainWindow.Show();

                MainWindow.Instance.Pager.SwitchPage(target);

                /* Restore crucial information */
                SPPMessageHandler.Instance.DispatchEvent(DeviceMessageCache.Instance.ExtendedStatusUpdate);
                SPPMessageHandler.Instance.DispatchEvent(DeviceMessageCache.Instance.StatusUpdate);
            }
        }
Esempio n. 4
0
 public bool HasPageType(AbstractPage.Pages page)
 {
     return(FindPage(page, nullAware: true) != null);
 }