示例#1
0
        public MainViewModel(
            IDataApiClient dataApiClient,
            DataVisualizer dataVisualizer,
            IReadonlyObjectDatabase <UserProfile> userDatabase,
            IReadonlyObjectDatabase <DataSet> dataSetDatabase,
            IReadonlyObjectDatabase <DataProject> dataProjectDatabase,
            IClipboard clipboard,
            IClosable mainWindow)
        {
            this.dataApiClient       = dataApiClient;
            this.userDatabase        = userDatabase;
            this.mainWindow          = mainWindow;
            DataSetMainViewModel     = new DataSetMainViewModel(dataApiClient, dataSetDatabase, dataProjectDatabase, clipboard);
            CollectionsMainViewModel = new CollectionsMainViewModel(dataApiClient, dataVisualizer, userDatabase, clipboard);

            var passwordBoxSpawner = new WpfPasswordBoxSpawner();
            var loginViewSpawner   = new WpfWindowSpawner <LoginViewModel>(vm => new LoginWindow {
                ViewModel = vm
            });
            var changePasswordViewSpawner = new WpfWindowSpawner <ChangePasswordViewModel>(vm => new ChangePasswordWindow {
                ViewModel = vm
            });

            UserSwitchViewModel = new UserSwitchViewModel(
                dataApiClient,
                LoginSuccessful,
                LoginFailed,
                passwordBoxSpawner,
                loginViewSpawner,
                changePasswordViewSpawner);
            OpenUserManagementWindowCommand = new RelayCommand(OpenUserManagementWindow);
            OpenAboutWindowCommand          = new RelayCommand(OpenAboutWindow);
        }
示例#2
0
        public MainViewModel(
            IClosable mainWindow,
            IDataApiClient dataApiClient,
            UploadedFileProcessor uploadedFileProcessor,
            IObjectDatabase <DataSet> dataSetDatabase,
            IObjectDatabase <DataTag> tagDatabase,
            IObjectDatabase <DataProject> projectDatabase,
            IObjectDatabase <DataCollectionProtocol> protocolDatabase,
            IObjectDatabase <DataCollectionProtocolParameter> protocolParameterDatabase)
        {
            this.mainWindow                = mainWindow;
            this.dataApiClient             = dataApiClient;
            this.uploadedFileProcessor     = uploadedFileProcessor;
            this.dataSetDatabase           = dataSetDatabase;
            this.tagDatabase               = tagDatabase;
            this.projectDatabase           = projectDatabase;
            this.protocolDatabase          = protocolDatabase;
            this.protocolParameterDatabase = protocolParameterDatabase;

            var passwordBoxSpawner = new WpfPasswordBoxSpawner();
            var loginViewSpawner   = new WpfWindowSpawner <LoginViewModel>(vm => new LoginWindow {
                ViewModel = vm
            });
            var changePasswordViewSpawner = new WpfWindowSpawner <ChangePasswordViewModel>(vm => new ChangePasswordWindow {
                ViewModel = vm
            });

            UserSwitchViewModel = new UserSwitchViewModel(
                dataApiClient,
                LoginSuccessful,
                LoginFailed,
                passwordBoxSpawner,
                loginViewSpawner,
                changePasswordViewSpawner);
            ProjectAutoCompleteViewModel = new AutoCompleteTextBoxViewModel <DataProject>(
                x => x.Id,
                projectDatabase,
                new DataProjectAutoCompleteMatcher());
            ProjectAutoCompleteViewModel.PropertyChanged += ProjectAutoCompleteViewModel_PropertyChanged;
            DataSetAutoCompleteViewModel = new AutoCompleteTextBoxViewModel <DataSet>(
                x => x.Id,
                dataSetDatabase,
                new DataSetAutoCompleteMatcher(),
                allowNewValue: true,
                objectBuilder: id => new DataSet(id));
            CreateNewProjectCommand          = new RelayCommand(CreateNewProject);
            AddSelectedFilesToDataSetCommand = new AsyncRelayCommand(AddSelectedFilesToDataSet, CanAddSelectedFilesToDataSet);
            SelectAllCommand       = new RelayCommand(SelectAll, CanSelectAll);
            DeselectAllCommand     = new RelayCommand(DeselectAll, CanDeselectAll);
            OpenAboutWindowCommand = new RelayCommand(OpenAboutWindow);
        }
示例#3
0
        public async void LoginSuccessful()
        {
            await CollectionsMainViewModel.Reload();

            UserSwitchViewModel.TriggerOnPropertyChangedEvents();
        }