Beispiel #1
0
        public static async Task <bool> SwitchMainPageAsync(NavigableViewModel viewModel, bool isNavPage = false, params object[] prepareData)
        {
            if (!await viewModel.OnPrepareViewAsync(prepareData))
            {
                throw new Exception($"Failed OnInitializeView, viewModel: {viewModel.GetType().FullName}");
            }

            if (Application.Current.MainPage is MasterDetailPage masterPage)
            {
                if (isNavPage)
                {
                    masterPage.Detail = new MaterialNavigationPage(viewModel.CoupledPage);
                }
                else
                {
                    masterPage.Detail = viewModel.CoupledPage;
                }
            }
            else
            {
                if (isNavPage)
                {
                    Application.Current.MainPage = new MaterialNavigationPage(viewModel.CoupledPage);
                }
                else
                {
                    Application.Current.MainPage = viewModel.CoupledPage;
                }
            }

            return(true);
        }
Beispiel #2
0
    public void NavigateTo(Type key, object parameter = null)
    {
        CurrentViewModel?.OnNavigatingTo(parameter);
        CurrentViewModel = _registeredViewModels[key].Invoke();
        Uri uri = _registeredViews[key];

        ((MainWindow)Application.Current.MainWindow).Frame.Source      = uri;
        ((MainWindow)Application.Current.MainWindow).Frame.DataContext = CurrentViewModel;
        CurrentViewModel.OnNavigatedTo(parameter);
    }
 public async Task NavigateToPageAsync(NavigableViewModel navigationPage, NavigationData.NavigationData navigationData)
 {
     if (navigationPage is LoginViewModel)
     {
         await NavigateToLoginPageAsync(navigationData);
     }
     else
     {
         await NavigateToMainPageAsync(navigationData);
     }
 }
Beispiel #4
0
        public static async Task <bool> PushNavPageAsync(NavigableViewModel viewModel, params object[] prepareData)
        {
            if (!await viewModel.OnPrepareViewAsync(prepareData))
            {
                throw new Exception($"Failed OnInitializeView, viewModel: {viewModel.GetType().FullName}");
            }

            await Application.Current.MainPage.Navigation.PushAsync(viewModel.CoupledPage, false);

            await Task.Delay(1500);

            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// Since a <see cref="GalaSoft.MvvmLight.Command.RelayCommand"/> does not accept keyboard shortcuts,
        /// we have to manually invoke the commands on a keyboard event.
        /// </summary>
        private void OnKeyDown(object sender, KeyEventArgs e)
        {
            KeyboardDevice keyboardDevice = e.KeyboardDevice;

            if (keyboardDevice.IsKeyDown(Key.LeftCtrl) || keyboardDevice.IsKeyDown(Key.RightCtrl))
            {
                // Use CTRL+Numbers (starting at 1) to navigate to the respective tabs.

                NavigationPageEnum?navigationTarget = null;

                switch (e.Key)
                {
                case Key.D1:
                case Key.NumPad1:
                    navigationTarget = NavigationPageEnum.Home;
                    break;

                case Key.D2:
                case Key.NumPad2:
                    navigationTarget = NavigationPageEnum.Srs;
                    break;

                case Key.D3:
                case Key.NumPad3:
                    navigationTarget = NavigationPageEnum.Kanji;
                    break;

                case Key.D4:
                case Key.NumPad4:
                    navigationTarget = NavigationPageEnum.Vocab;
                    break;

                case Key.D5:
                case Key.NumPad5:
                    navigationTarget = NavigationPageEnum.Settings;
                    break;
                }

                if (navigationTarget.HasValue)
                {
                    NavigableViewModel navModel = (NavigableViewModel)HomePage.DataContext;
                    navModel.NavigateCommand.Execute(navigationTarget.Value);
                    e.Handled = true;
                }
            }
        }
        /// <summary>
        /// Since a <see cref="GalaSoft.MvvmLight.Command.RelayCommand"/> does not accept keyboard shortcuts,
        /// we have to manually invoke the commands on a keyboard event.
        /// </summary>
        private void OnKeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyModifiers.HasFlag(KeyModifiers.Control))
            {
                // Use CTRL+Numbers (starting at 1) to navigate to the respective tabs.

                NavigationPageEnum?navigationTarget = null;

                switch (e.Key)
                {
                case Key.D1:
                case Key.NumPad1:
                    navigationTarget = NavigationPageEnum.Home;
                    break;

                case Key.D2:
                case Key.NumPad2:
                    navigationTarget = NavigationPageEnum.Srs;
                    break;

                case Key.D3:
                case Key.NumPad3:
                    navigationTarget = NavigationPageEnum.Kanji;
                    break;

                case Key.D4:
                case Key.NumPad4:
                    navigationTarget = NavigationPageEnum.Vocab;
                    break;

                case Key.D5:
                case Key.NumPad5:
                    navigationTarget = NavigationPageEnum.Settings;
                    break;
                }

                if (navigationTarget.HasValue)
                {
                    NavigableViewModel navModel = (NavigableViewModel)this.Find <HomePage>("HomePage").DataContext;
                    navModel.NavigateCommand.Execute(navigationTarget.Value);
                    e.Handled = true;
                }
            }
        }
Beispiel #7
0
		protected void Navigate(NavigableViewModel navigable)
		{
			((INavigableViewModel)this).Navigate(navigable);
		}
Beispiel #8
0
		void INavigableViewModel.Navigate(NavigableViewModel navigable)
		{
			Content = navigable;
		}
Beispiel #9
0
 protected void Navigate(NavigableViewModel navigable)
 {
     navigableViewModel.Navigate(navigable);
 }
Beispiel #10
0
 protected void Navigate(NavigableViewModel navigable)
 {
     ((INavigableViewModel)this).Navigate(navigable);
 }
Beispiel #11
0
 void INavigableViewModel.Navigate(NavigableViewModel navigable)
 {
     Content = navigable;
 }