public ProtocolParameterViewModel(
            IDataApiClient dataApiClient,

            IReadonlyObjectDatabase <DataCollectionProtocolParameter> protocolParameterDatabase,
            DataCollectionProtocolParameter parameter = null)
        {
            valueViewModelFactory = new ParameterValueViewModelFactory(dataApiClient);

            NameAutoCompleteViewModel = new AutoCompleteTextBoxViewModel <DataCollectionProtocolParameter>(
                x => x.Name,
                protocolParameterDatabase,
                new ProtocolParameterAutoCompleteMatcher(),
                allowNewValue: true,
                objectBuilder: name => new DataCollectionProtocolParameter(name, null, false, DataCollectionProtocolParameterType.Text));
            NameAutoCompleteViewModel.PropertyChanged += NameAutoCompleteViewModel_PropertyChanged;
            var dataTypes = Task.Run(async() => await dataApiClient.ListCollectionNamesAsync(true)).Result;

            DataTypeAutoCompleteViewModel = new AutoCompleteTextBoxViewModel <string>(
                x => x,
                new FixedSetDatabase <string>(dataTypes.ToDictionary(x => x, x => x)),
                new StringAutoCompleteMatcher());
            DataTypeAutoCompleteViewModel.PropertyChanged += DataTypeAutoCompleteViewModel_PropertyChanged;
            ValueViewModel = valueViewModelFactory.Create(SelectedParameterType, DataTypeAutoCompleteViewModel.SelectedObject);
            if (parameter != null)
            {
                NameAutoCompleteViewModel.SelectedObject = Task.Run(() => protocolParameterDatabase.GetFromIdAsync(parameter.Id).Result).Result;
                IsMandatory           = parameter.IsMandatory;
                SelectedParameterType = parameter.Type;
                DataTypeAutoCompleteViewModel.SelectedObject = parameter.DataType;
                DefaultValue = parameter.DefaultValue;
            }
        }
예제 #2
0
 public ProjectSelectionViewModel(IReadonlyObjectDatabase <DataProject> projectDatabase)
 {
     ProjectAutoCompleteViewModel = new AutoCompleteTextBoxViewModel <DataProject>(
         x => x.Id,
         projectDatabase,
         new DataProjectAutoCompleteMatcher());
 }
예제 #3
0
        public DataTypeParameterViewModel(
            string dataType,
            IDataApiClient dataApiClient,

            string value)
        {
            AutoCompleteViewModel = new AutoCompleteTextBoxViewModel <JObject>(
                x => x["Id"].Value <string>(),
                new GenericDatabase(dataApiClient, dataType),
                new GenericIIdAutoCompleteMatcher());
            AutoCompleteViewModel.PropertyChanged += AutoCompleteViewModel_PropertyChanged;
            Value = value;
        }
예제 #4
0
        public CreateProjectViewModel(
            IDataApiClient dataApiClient,

            IObjectDatabase <DataProject> projectDatabase,
            IObjectDatabase <DataCollectionProtocol> protocolDatabase,
            IObjectDatabase <DataCollectionProtocolParameter> protocolParameterDatabase,
            IViewSpawner <CreateProtocolViewModel> createProtocolViewSpawner)
        {
            this.dataApiClient = dataApiClient;

            this.projectDatabase           = projectDatabase;
            this.protocolDatabase          = protocolDatabase;
            this.protocolParameterDatabase = protocolParameterDatabase;
            this.createProtocolViewSpawner = createProtocolViewSpawner;
            ProtocolsAutoCompleteViewModel = new AutoCompleteTextBoxViewModel <DataCollectionProtocol>(
                x => x.Id,
                protocolDatabase,
                new DataCollectionProtocolAutoCompleteMatcher());
            CreateNewProtocolCommand = new RelayCommand(CreateNewProtocol);
            EditProtocolCommand      = new RelayCommand(EditProtocol, () => ProtocolsAutoCompleteViewModel.SelectedObject != null);
            SaveCommand   = new AsyncRelayCommand <IClosable>(Save, CanSave);
            CancelCommand = new RelayCommand <IClosable>(closable => closable.Close(false));
        }