Пример #1
0
        public void SwitchToUser()
        {
            var mock = new MockLoginModel();
            var sm   = new StartViewModel(mock);

            sm.SwitchedToThis();

            ViewModelID to = ViewModelID.Start;

            sm.ViewChanged += id => { to = id; };
            sm.SelectedUser = sm.SavedUsers[0];
            Assert.AreEqual(ViewModelID.User, to);
        }
Пример #2
0
        public void SwitchToLogin()
        {
            var mock = new MockLoginModel();
            var sm   = new StartViewModel(mock);

            sm.SwitchedToThis();

            ViewModelID to = ViewModelID.Start;

            sm.ViewChanged += id => { to = id; };
            Assert.True(sm.NewLoginButton_Click.CanExecute());
            sm.NewLoginButton_Click.Execute();

            Assert.AreEqual(ViewModelID.Login, to);
        }
Пример #3
0
        private void ChangeViewModel(ViewModelID vmName)
        {
            ViewModelBase newVM = _pageViewModels.FirstOrDefault(vm => vm.ID == vmName);

            CurrentPageViewModel = newVM ?? throw new NotImplementedException($"No ViewModel with name {vmName} exists.");
            if (newVM.ID == ViewModelID.Login || newVM.ID == ViewModelID.Start)
            {
                _clientSyncRunning = false; // sync threads are stopped on startup and after logout
            }
            else if (newVM.ID == ViewModelID.User)
            {
                _clientSyncRunning = true;
            }

            if (App.Current.Dispatcher.CheckAccess())  // setup needs to be run from the UI thread
            {
                newVM.SwitchedToThis();
            }
            else
            {
                App.Current.Dispatcher.Invoke(newVM.SwitchedToThis);
            }
        }
Пример #4
0
 protected void RaiseViewChanged(ViewModelID type)
 {
     ViewChanged?.Invoke(type);
 }