Beispiel #1
0
        public MenuBarViewModel(ScreenSwitcher switcher)
        {
            this.switcher = switcher;

            AuthorityController.LoggedIn += (s, e) =>
            {
                CurrentUser = AuthorityController.CurrentUser;

                OpenSyncCommand.IsVisible     = AuthorityController.CurrentUserCanOpen(Screen.Sync);
                OpenDoctorsCommand.IsVisible  = AuthorityController.CurrentUserCanOpen(Screen.Doctors);
                OpenPatientsCommand.IsVisible = AuthorityController.CurrentUserCanOpen(Screen.Patients);
                OpenWordsCommand.IsVisible    = AuthorityController.CurrentUserCanOpen(Screen.Words);
                OpenVocsCommand.IsVisible     = AuthorityController.CurrentUserCanOpen(Screen.Vocabularies);
                OpenCriteriaCommand.IsVisible = AuthorityController.CurrentUserCanOpen(Screen.Criteria);
#if DEBUG
                OpenSyncCommand.IsVisible = true;
                OpenVocsCommand.IsVisible = true;
#endif
            };

            AuthorityController.LoggedOut += (s, e) =>
            {
                CurrentUser = AuthorityController.CurrentUser;
            };

            switcher.PropertyChanged += (s, e) =>
            {
                if (e.PropertyName == "CurrentView")
                {
                    Visible = switcher.WithMenuBar;
                }
            };
        }
Beispiel #2
0
        public MainWindowViewModel(bool demoMode = false)
        {
            if (demoMode)
            {
                titlePrefix = "Демо :: ";
            }

            switcher = new ScreenSwitcher(AuthorityController);

            _screens       = new ObservableCollection <ScreenBaseViewModel>();
            Screens        = new ReadOnlyObservableCollection <ScreenBaseViewModel>(_screens);
            Tools          = new ObservableCollection <ToolViewModel>();
            OverlayService = new OverlayServiceViewModel();
            MenuBar        = new MenuBarViewModel(switcher);
            ADLayout       = new AvalonDockLayoutViewModel(ReloadContentOnStartUp);

            //DoPanesChangedLogging();

            ADLayout.LayoutLoading += (s, e) =>
            {
                // сначала открываем первый экран, чтобы поставить его в панель во время десериализации лейаута
                switcher.OpenScreen(Screen.Login, replace: true);
            };

            Subscribe();
        }