public static void ExportQuestionnaire(EDOConfig config, StudyUnitVM studyUnit) { ControlConstructSchemeVM controlConstructScheme = null; if (studyUnit.ControlConstructSchemes.Count > 1) { SelectObjectWindowVM <ControlConstructSchemeVM> vm = new SelectObjectWindowVM <ControlConstructSchemeVM>(studyUnit.ControlConstructSchemes); SelectObjectWindow window = new SelectObjectWindow(vm); controlConstructScheme = SelectObjectWindow.Select(Resources.SelectOrder, vm) as ControlConstructSchemeVM; //Select Sequence } else if (studyUnit.ControlConstructSchemes.Count == 1) { controlConstructScheme = studyUnit.ControlConstructSchemes[0]; } if (controlConstructScheme == null) { return; } string path = IOUtils.QuerySavePathName(Resources.ExportQuestionnair + ": " + controlConstructScheme.Title, null, QUESTIONNAIRE_FILTER, true); if (string.IsNullOrEmpty(path)) { return; } try { QuestionnaireWriter writer = new QuestionnaireWriter(config, controlConstructScheme); writer.Write(path); } catch (Exception ex) { EDOUtils.ShowUnexpectedError(ex); } }
public void InitTitle() { if (string.IsNullOrEmpty(studyUnit.Abstract.Title)) { studyUnit.Abstract.Title = EDOUtils.OrderTitle(this); } }
public static bool ImportSpssAll(StudyUnitVM studyUnit, MainWindowVM mainWindow) { string path = IOUtils.QueryOpenPathName(SPSS_FILTER); if (string.IsNullOrEmpty(path)) { return(false); } try { SpssReader reader = new SpssReader(); if (!reader.ImportVariables(path, studyUnit)) { return(false); } StudyUnit studyUnitModel = studyUnit.StudyUnitModel; mainWindow.RecreateViewModels(); RawData rawData = reader.LoadRawData(path); if (rawData == null) { return(false); } StudyUnitVM newStudyUnit = mainWindow.GetStudyUnit(studyUnitModel); List <StatisticsInfo> statisticsInfos = StatisticsUtils.CreateStatisticsInfos(rawData, newStudyUnit); studyUnitModel.StatisticsInfos = statisticsInfos; mainWindow.RecreateViewModels(); return(true); } catch (Exception ex) { EDOUtils.ShowUnexpectedError(ex); } return(false); }
public static void ExportSetupSyntax(StudyUnitVM studyUnit) { DataFileVM dataFile = null; if (studyUnit.DataFiles.Count > 1) { SelectObjectWindowVM <DataFileVM> vm = new SelectObjectWindowVM <DataFileVM>(studyUnit.DataFiles); SelectObjectWindow window = new SelectObjectWindow(vm); dataFile = SelectObjectWindow.Select(Resources.SelectDataFile, vm) as DataFileVM; //Select Data File } else if (studyUnit.DataFiles.Count == 1) { dataFile = studyUnit.DataFiles[0]; } if (dataFile == null) { return; } string path = IOUtils.QuerySavePathName(Resources.ExportSetupSyntax, null, SETUPSYNTAX_FILTER, true); //Export Setup Syntax if (string.IsNullOrEmpty(path)) { return; } try { SetupSyntaxWriter writer = new SetupSyntaxWriter(studyUnit, dataFile); writer.Write(path); } catch (Exception ex) { EDOUtils.ShowUnexpectedError(ex); } }
public void InitTitle() { if (string.IsNullOrEmpty(conceptScheme.Title)) { conceptScheme.Title = EDOUtils.OrderTitle(this); } }
protected override void Reload(VMState state) { if (state != null) { SelectedBookItem = EDOUtils.FindOrFirst(books, state.State1); } }
public void InitTitle() { if (string.IsNullOrEmpty(sampling.Title)) { sampling.Title = EDOUtils.OrderTitle(this); } }
public void InitTitle() { if (string.IsNullOrEmpty(fundingInfo.Title)) { fundingInfo.Title = EDOUtils.OrderTitle(this); } }
public SamplingFormVM(StudyUnitVM studyUnit) : base(studyUnit) { samplings = new ObservableCollection <SamplingVM>(); //change how to name the title //*Find the unique title like unsed //*The title such as Concept and Amount can be changed manually, //Cannot do here HashSet <string> titles = Sampling.CollectTitles(studyUnit.SamplingModels); foreach (Sampling samplingModel in studyUnit.SamplingModels) { int uniqIndex = EDOUtils.UniqOrderNo(titles, samplingModel.Title, PREFIX); SamplingVM sampling = new SamplingVM(samplingModel) { Parent = this, OrderNo = uniqIndex, OrderPrefix = PREFIX }; sampling.Init(); samplings.Add(sampling); titles.Add(sampling.Title); //Add in title set. } modelSyncher = new ModelSyncher <SamplingVM, Sampling>(this, samplings, studyUnit.SamplingModels); }
public CreateBranchWindowVM(ControlConstructSchemeVM controlConstructScheme, IfThenElse ifThenElse) { this.controlConstructScheme = controlConstructScheme; questionConstructs = new ObservableCollection <QuestionConstructVM>(); questionConstructs.AddRange(controlConstructScheme.QuestionConstructs); thenConstructs = new ObservableCollection <ConstructVM>(); thenConstructs.AddRange(controlConstructScheme.ThenConstructs); if (ifThenElse == null) { //In the case of TargetQuestionConstruct = controlConstructScheme.SelectedConstruct as QuestionConstructVM; branches = new ObservableCollection <BranchVM>(); //Add IF ~ THEN BranchVM ifBranch = new BranchVM(BranchVM.TYPE_IF_CODE) { Parent = this, No = 1, }; ifBranch.Init(); branches.Add(ifBranch); } else { // Inthe case of edit TargetQuestionConstruct = EDOUtils.Find(controlConstructScheme.QuestionConstructs, ifThenElse.IfCondition.QuestionId); branches = SequenceUtils.CreateBranches(ifThenElse, this); } }
public void UpdateTemplate() { if (VM == null) { return; } responsePane.ContentTemplate = EDOUtils.SelectTemplate(VM.SelectedVariable); }
public static void MergeMember(this StudyUnit curStudyUnit, StudyUnit newStudyUnit) { curStudyUnit.Members.AddRange(newStudyUnit.Members); foreach (Organization organization in newStudyUnit.Organizations) { List <string> existNames = Organization.GetOrganizationNames(curStudyUnit.Organizations); organization.OrganizationName = EDOUtils.UniqueLabel(existNames, organization.OrganizationName); curStudyUnit.Organizations.Add(organization); } }
public void AddConceptScheme() { ConceptSchemeVM conceptScheme = new ConceptSchemeVM(); conceptScheme.OrderNo = EDOUtils.GetMaxOrderNo <ConceptSchemeVM>(conceptSchemes) + 1; conceptScheme.OrderPrefix = PREFIX; conceptScheme.InitTitle(); conceptSchemes.Add(conceptScheme); SelectedConceptScheme = conceptScheme; Memorize(); }
protected override void Reload(VMState state) { if (state != null) { SelectedCodeScheme = EDOUtils.Find(codeSchemes, state.State1); } if (SelectedCodeScheme == null) { SelectedCodeScheme = EDOUtils.GetFirst(codeSchemes); } }
protected override void Reload(VMState state) { if (state != null) { selectedSamplingItem = EDOUtils.Find(Samplings, state.State1); } if (selectedSamplingItem == null) { selectedSamplingItem = Samplings.FirstOrNull(); } }
protected override void Reload(VMState state) { if (state != null) { SelectedVariableItem = EDOUtils.Find(variables, state.State1); } if (SelectedVariableItem == null || !Variables.Contains(SelectedVariable)) { SelectedVariableItem = EDOUtils.GetFirst <VariableVM>(variables); } }
protected override void Reload(VMState state) { if (state != null) { SelectedItem = EDOUtils.Find(fundingInfos, state.State1); } if (SelectedItem == null) { SelectedItem = fundingInfos.FirstOrNull(); } }
protected override void Reload(VMState state) { if (state != null) { SelectedDataFile = EDOUtils.Find(dataFiles, state.State1); } if (SelectedDataFile == null) { SelectedDataFile = EDOUtils.GetFirst(dataFiles); } }
protected override void Reload(VMState state) { if (state != null) { SelectedControlConstructScheme = EDOUtils.Find(ControlConstructSchemes, state.State1); } if (SelectedControlConstructScheme == null) { SelectedControlConstructScheme = ControlConstructSchemes.FirstOrNull(); } }
public void AddControlConstructScheme() { ControlConstructSchemeVM scheme = new ControlConstructSchemeVM(); scheme.OrderNo = EDOUtils.GetMaxOrderNo <ControlConstructSchemeVM>(controlConstructSchemes) + 1; scheme.OrderPrefix = PREFIX; scheme.Init(); controlConstructSchemes.Add(scheme); SelectedControlConstructScheme = scheme; Memorize(); }
public QuestionGroupVM(QuestionGroup questionGroup, ObservableCollection <QuestionVM> allQuestions) { this.questionGroup = questionGroup; this.questions = new ObservableCollection <QuestionVM>(); foreach (string questionId in questionGroup.QuestionIds) { QuestionVM question = EDOUtils.Find(allQuestions, questionId); if (question != null) //Don't modify Parent because VM which is not under control is diverted { questions.Add(question); } } }
public static void Parse(string str, SamplingNumber samplingNumber) { string[] tokens = GetFirstToken(str); samplingNumber.ResponseRate = tokens[0]; string[] restTokens = EDOUtils.ParseCSV(tokens[1]); if (restTokens == null || restTokens.Length < 3) { return; } samplingNumber.SampleSize = restTokens[0]; samplingNumber.NumberOfResponses = restTokens[1]; samplingNumber.Description = restTokens[2]; }
public void RemoveOrganization() { List <MemberVM> usedMembers = MemberVM.FindByOrganizationName(members, SelectedOrganization.OrganizationName); if (usedMembers.Count > 0) { string msg = EDOUtils.CannotDeleteError(Resources.Member, usedMembers, param => param.FullName); MessageBox.Show(msg); return; } organizations.Remove(SelectedOrganization); SelectedOrganizationItem = null; }
public static bool ImportData(StudyUnitVM studyUnit) { string path = IOUtils.QueryOpenPathName(Resources.DataFilter); if (string.IsNullOrEmpty(path)) { return(false); } bool result = false; try { Mouse.OverrideCursor = Cursors.Wait; string extension = Path.GetExtension(path); RawData rawData = null; if (extension == ".sav") { SpssReader reader = new SpssReader(); rawData = reader.LoadRawData(path); } else if (extension == ".xlsx") { ExcelReader reader = new ExcelReader(); rawData = reader.LoadRawData(path); } else if (extension == ".csv") { CsvReader reader = new CsvReader(); rawData = reader.LoadRawData(path); } if (rawData != null) { List <StatisticsInfo> statisticsInfos = StatisticsUtils.CreateStatisticsInfos(rawData, studyUnit); studyUnit.StudyUnitModel.StatisticsInfos = statisticsInfos; result = true; } } catch (Exception ex) { EDOUtils.ShowUnexpectedError(ex); } finally { Mouse.OverrideCursor = null; } return(result); }
public void AddFundingInfo() { int count = fundingInfos.Count + 1; FundingInfoVM fundingInfo = new FundingInfoVM() { Parent = this, OrderNo = EDOUtils.GetMaxOrderNo <FundingInfoVM>(fundingInfos) + 1, OrderPrefix = PREFIX }; fundingInfo.InitTitle(); fundingInfos.Add(fundingInfo); SelectedItem = fundingInfo; Memorize(); }
public void AddSampling() { HashSet <string> titles = Sampling.CollectTitles(StudyUnit.SamplingModels); int uniqIndex = EDOUtils.UniqOrderNo(titles, null, PREFIX); SamplingVM sampling = new SamplingVM(); sampling.Parent = this; sampling.OrderNo = uniqIndex; sampling.OrderPrefix = PREFIX; sampling.Init(); samplings.Add(sampling); SelectedSamplingItem = sampling; Memorize(); }
private static BranchVM CreateIfBranch(IfThenElse ifThenElse, CreateBranchWindowVM window) { BranchVM branch = new BranchVM(BranchVM.TYPE_IF_CODE) { Parent = window }; branch.Init(); branch.CondGroups.Clear(); IfCondition ifCondition = ifThenElse.IfCondition; CreateCondGroups(ifCondition.Code, branch, window.QuestionConstructs); branch.ThenConstruct = EDOUtils.Find(window.ThenConstructs, ifThenElse.ThenConstructId); return(branch); }
private static BranchVM CreateElseBranch(IfThenElse ifThenElse, CreateBranchWindowVM window) { if (ifThenElse.ElseConstructId == null) { return(null); } BranchVM branch = new BranchVM(BranchVM.TYPE_ELSE_CODE) { Parent = window }; branch.Init(); branch.CondGroups.Clear(); branch.ThenConstruct = EDOUtils.Find(window.ThenConstructs, ifThenElse.ElseConstructId); return(branch); }
protected override void Reload(VMState state) { CreateVariableInfos(); CreateStatisticsInfos(); if (state != null) { if (state.State1 != null) { SelectedVariableInfoItem = EDOUtils.Find(variableInfos, (string)state.State1); } } if (SelectedVariableInfoItem == null) { SelectedVariableInfoItem = EDOUtils.FindOrFirst(variableInfos, selectedVariableId); // keep selectedIndex when page changes } }
private static bool SaveGroup(GroupVM group, List <string> studyUnitPathNames, bool queryPathName) { if (!QuerySavePathName(group, GROUP_FILTER, queryPathName)) { return(false); } string baseDir = Path.GetDirectoryName(group.PathName) + Path.DirectorySeparatorChar; group.GroupModel.StudyUnitRelPathNames.Clear(); foreach (string absPath in studyUnitPathNames) { string relPath = EDOUtils.AbsToRel(absPath, baseDir); group.GroupModel.StudyUnitRelPathNames.Add(relPath); } EDOSerializer.DoSave <Group>(group.GroupModel); return(true); }