private bool ProcessChanged(EDOUnitVM edoUnit, object newValue, object oldValue) { MenuItemVM newMenuItem = newValue as MenuItemVM; MenuItemVM oldMenuItem = oldValue as MenuItemVM; if (newMenuItem == null) { return(false); } //同じアイテムが選択された場合は以降の処理は行わない(エラーが発生して戻す場合に無限ループになるのを防ぐ) if (newMenuItem == edoUnit.SelectedMenuItem) { return(false); } if (oldMenuItem != null) { if (!oldMenuItem.validate()) { this.Dispatcher.BeginInvoke(new Action(() => { oldMenuItem.IsSelected = true; })); return(false); } } edoUnit.SelectedMenuItem = newMenuItem; edoUnit.SetStatusMessage(newMenuItem.Title, false); return(true); }
public GroupVM(MainWindowVM mainWindowVM, Group group) : base(mainWindowVM, group) { this.groupModel = group; groupForm = new GroupFormVM(this); MenuItemVM categoryGroup = new MenuItemVM(MenuElem.C_GROUP, groupForm); MenuItemVM menuDetail = new MenuItemVM(MenuElem.M_DETAIL, groupForm); categoryGroup.Add(menuDetail); this.MenuItems.Add(categoryGroup); compareConceptSchemeForm = new CompareFormVM(this, groupModel.ConceptSchemeCompareTable); MenuItemVM menuCompareDai = new MenuItemVM(MenuElem.M_COMPARE_DAI, compareConceptSchemeForm); categoryGroup.Add(menuCompareDai); compareConceptForm = new CompareFormVM(this, groupModel.ConceptCompareTable); MenuItemVM menuCompareSho = new MenuItemVM(MenuElem.M_COMPARE_SHO, compareConceptForm); categoryGroup.Add(menuCompareSho); compareVariableForm = new CompareFormVM(this, groupModel.VariableCompareTable); MenuItemVM menuCompareVariable = new MenuItemVM(MenuElem.M_COMPARE_VARIABLE, compareVariableForm); categoryGroup.Add(menuCompareVariable); }
public void SelectMenuItem(MenuItemVM newMenuItem) { //Processing for displaying a menu from the outside when an error occurs foreach (MenuItemVM menuItem in MenuItems) { menuItem.IsSelected = false; } newMenuItem.IsSelected = true; }
public bool ValidateCurrentItem() { MenuItemVM menuItem = this.SelectedMenuItem; if (menuItem == null) { return(true); } return(menuItem.validate()); }
private void treeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs <object> e) { EDOUnitVM edoUnit = DataContext as EDOUnitVM; if (!ProcessChanged(edoUnit, e.NewValue, e.OldValue)) { return; } if (edoUnit is StudyUnitVM) { StudyUnitVM studyUnitVM = (StudyUnitVM)edoUnit; MenuItemVM menuItem = studyUnitVM.SelectedMenuItem; studyUnitVM.Main.IsDataSet = menuItem.IsDataSet; if (menuItem.IsDataSet) { studyUnitVM.Main.IsDataSetSelected = true; } studyUnitVM.Main.IsCategory = menuItem.IsCategory; if (menuItem.IsCategory) { studyUnitVM.Main.IsCategorySelected = true; } studyUnitVM.Main.IsCode = menuItem.IsCode; if (menuItem.IsCode) { studyUnitVM.Main.IsCodeSelected = true; } studyUnitVM.Main.IsQuestionGroup = menuItem.IsQuestionGroup; if (menuItem.IsQuestionGroup) { studyUnitVM.Main.IsQuestionGroupSelected = true; } } else if (edoUnit is GroupVM) { } }
public StudyUnitVM(MainWindowVM mainWindowVM, StudyUnit studyUnit) : base(mainWindowVM, studyUnit) { this.studyUnit = studyUnit; EventFormVM eventFormViewModel = new EventFormVM(this); MenuItemVM categoryEvent = new MenuItemVM(MenuElem.C_EVENT, eventFormViewModel); //1 MenuItemVM menuEvent = new MenuItemVM(MenuElem.M_EVENT, eventFormViewModel); //2 menuEvent.IsSelected = true; categoryEvent.Add(menuEvent); this.MenuItems.Add(categoryEvent); memberForm = new MemberFormVM(this); abstractForm = new AbstractFormVM(this); coverageForm = new CoverageFormVM(this); fundingInfoForm = new FundingInfoFormVM(this); MenuItemVM categoryStudy = new MenuItemVM(MenuElem.C_STUDY, memberForm); //3 MenuItemVM menuStudyMember = new MenuItemVM(MenuElem.M_MEMBER, memberForm); //4 MenuItemVM menuStudyAbstract = new MenuItemVM(MenuElem.M_ABSTRACT, abstractForm); //5 MenuItemVM menuStudyRange = new MenuItemVM(MenuElem.M_COVERAGE, coverageForm); //6 MenuItemVM menuFund = new MenuItemVM(MenuElem.M_FUNDING_INFO, fundingInfoForm); //7 categoryStudy.Add(menuStudyMember); categoryStudy.Add(menuStudyAbstract); categoryStudy.Add(menuStudyRange); categoryStudy.Add(menuFund); this.MenuItems.Add(categoryStudy); samplingForm = new SamplingFormVM(this); MenuItemVM categoryScheme = new MenuItemVM(MenuElem.C_SAMPLING, samplingForm); //8 MenuItemVM menuScheme = new MenuItemVM(MenuElem.M_SAMPLING, samplingForm); //9 categoryScheme.Add(menuScheme); this.MenuItems.Add(categoryScheme); conceptForm = new ConceptFormVM(this); categoryForm = new CategoryFormVM(this); codeForm = new CodeFormVM(this); questionForm = new QuestionFormVM(this); //QuestionFormはconcept、category、codeよりあとに生成する必要あり questionGroupForm = new QuestionGroupFormVM(this); // QuestionGroupFormは、SequenceFormより先に生成する必要あり sequenceForm = new SequenceFormVM(this); MenuItemVM categoryQuestion = new MenuItemVM(MenuElem.C_QUESTION, conceptForm); //10 MenuItemVM menuConcept = new MenuItemVM(MenuElem.M_CONCEPT, conceptForm); //11 MenuItemVM menuQuestion = new MenuItemVM(MenuElem.M_QUESTION, questionForm); //12 MenuItemVM menuCategory = new MenuItemVM(MenuElem.M_CATEGORY, categoryForm); //13 MenuItemVM menuCode = new MenuItemVM(MenuElem.M_CODE, codeForm); //14 MenuItemVM menuSequence = new MenuItemVM(MenuElem.M_SEQUENCE, sequenceForm); //15 MenuItemVM menuQuestionGroup = new MenuItemVM(MenuElem.M_QUESTION_GROUP, questionGroupForm); categoryQuestion.Add(menuConcept); categoryQuestion.Add(menuQuestion); categoryQuestion.Add(menuCategory); categoryQuestion.Add(menuCode); categoryQuestion.Add(menuSequence); categoryQuestion.Add(menuQuestionGroup); this.MenuItems.Add(categoryQuestion); variableForm = new VariableFormVM(this); MenuItemVM categoryVariable = new MenuItemVM(MenuElem.C_VARIABLE, variableForm); //16 MenuItemVM menuVariable = new MenuItemVM(MenuElem.M_VARIABLE, variableForm); //17 categoryVariable.Add(menuVariable); this.MenuItems.Add(categoryVariable); dataSetForm = new DataSetFormVM(this); dataFileForm = new DataFileFormVM(this); bookForm = new BookFormVM(this); MenuItemVM categoryData = new MenuItemVM(MenuElem.C_DATA, dataSetForm); //18 MenuItemVM menuDataRelation = new MenuItemVM(MenuElem.M_DATA_SET, dataSetForm); //19 MenuItemVM menuPhysicalStructure = new MenuItemVM(MenuElem.M_DATA_FILE, dataFileForm); //20 MenuItemVM menuBooks = new MenuItemVM(MenuElem.M_BOOKS, bookForm); categoryData.Add(menuDataRelation); categoryData.Add(menuPhysicalStructure); categoryData.Add(menuBooks); this.MenuItems.Add(categoryData); this.SelectedMenuItem = categoryEvent; OnRemoveBooks(); }
public StudyUnitVM(MainWindowVM mainWindowVM, StudyUnit studyUnit) : base(mainWindowVM, studyUnit) { this.studyUnit = studyUnit; EventFormVM eventFormViewModel = new EventFormVM(this); MenuItemVM categoryEvent = new MenuItemVM(MenuElem.C_EVENT, eventFormViewModel); //1 MenuItemVM menuEvent = new MenuItemVM(MenuElem.M_EVENT, eventFormViewModel); //2 menuEvent.IsSelected = true; categoryEvent.Add(menuEvent); this.MenuItems.Add(categoryEvent); memberForm = new MemberFormVM(this); abstractForm = new AbstractFormVM(this); coverageForm = new CoverageFormVM(this); fundingInfoForm = new FundingInfoFormVM(this); MenuItemVM categoryStudy = new MenuItemVM(MenuElem.C_STUDY, memberForm); //3 MenuItemVM menuStudyMember = new MenuItemVM(MenuElem.M_MEMBER, memberForm); //4 MenuItemVM menuStudyAbstract = new MenuItemVM(MenuElem.M_ABSTRACT, abstractForm); //5 MenuItemVM menuStudyRange = new MenuItemVM(MenuElem.M_COVERAGE, coverageForm); //6 MenuItemVM menuFund = new MenuItemVM(MenuElem.M_FUNDING_INFO, fundingInfoForm); //7 categoryStudy.Add(menuStudyMember); categoryStudy.Add(menuStudyAbstract); categoryStudy.Add(menuStudyRange); categoryStudy.Add(menuFund); this.MenuItems.Add(categoryStudy); samplingForm = new SamplingFormVM(this); MenuItemVM categoryScheme = new MenuItemVM(MenuElem.C_SAMPLING, samplingForm); //8 MenuItemVM menuScheme = new MenuItemVM(MenuElem.M_SAMPLING, samplingForm); //9 categoryScheme.Add(menuScheme); this.MenuItems.Add(categoryScheme); conceptForm = new ConceptFormVM(this); categoryForm = new CategoryFormVM(this); codeForm = new CodeFormVM(this); questionForm = new QuestionFormVM(this); //QuestionForm needs to be genarated after concept, category and code questionGroupForm = new QuestionGroupFormVM(this); // QuestionGroupForm needs to be genarated before SequenceForm sequenceForm = new SequenceFormVM(this); MenuItemVM categoryQuestion = new MenuItemVM(MenuElem.C_QUESTION, conceptForm); //10 MenuItemVM menuConcept = new MenuItemVM(MenuElem.M_CONCEPT, conceptForm); //11 MenuItemVM menuQuestion = new MenuItemVM(MenuElem.M_QUESTION, questionForm); //12 MenuItemVM menuCategory = new MenuItemVM(MenuElem.M_CATEGORY, categoryForm); //13 MenuItemVM menuCode = new MenuItemVM(MenuElem.M_CODE, codeForm); //14 MenuItemVM menuSequence = new MenuItemVM(MenuElem.M_SEQUENCE, sequenceForm); //15 MenuItemVM menuQuestionGroup = new MenuItemVM(MenuElem.M_QUESTION_GROUP, questionGroupForm); categoryQuestion.Add(menuConcept); categoryQuestion.Add(menuQuestion); categoryQuestion.Add(menuCategory); categoryQuestion.Add(menuCode); categoryQuestion.Add(menuSequence); categoryQuestion.Add(menuQuestionGroup); this.MenuItems.Add(categoryQuestion); variableForm = new VariableFormVM(this); MenuItemVM categoryVariable = new MenuItemVM(MenuElem.C_VARIABLE, variableForm); //16 MenuItemVM menuVariable = new MenuItemVM(MenuElem.M_VARIABLE, variableForm); //17 categoryVariable.Add(menuVariable); this.MenuItems.Add(categoryVariable); dataSetForm = new DataSetFormVM(this); dataFileForm = new DataFileFormVM(this); bookForm = new BookFormVM(this); statisticsForm = new StatisticsFormVM(this); MenuItemVM categoryData = new MenuItemVM(MenuElem.C_DATA, dataSetForm); //18 MenuItemVM menuDataRelation = new MenuItemVM(MenuElem.M_DATA_SET, dataSetForm); //19 MenuItemVM menuPhysicalStructure = new MenuItemVM(MenuElem.M_DATA_FILE, dataFileForm); //20 MenuItemVM menuBooks = new MenuItemVM(MenuElem.M_BOOKS, bookForm); MenuItemVM menuAggregate = new MenuItemVM(MenuElem.M_STATISTICS, statisticsForm); categoryData.Add(menuDataRelation); categoryData.Add(menuPhysicalStructure); categoryData.Add(menuBooks); categoryData.Add(menuAggregate); this.MenuItems.Add(categoryData); this.SelectedMenuItem = categoryEvent; OnRemoveBooks(); }
public void Add(MenuItemVM childMenuItem) { this.MenuItems.Add(childMenuItem); }
public void ShowMenuItem(EDOUnitVM edoUnit, MenuItemVM menuItem) { SelectedItem = edoUnit; Window window = Application.Current.MainWindow; //こうしないと現在表示中のStudyUnit以外でエラーが発生したときに指定メニューが表示されない。 window.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => { edoUnit.SelectMenuItem(menuItem); })); }
public ErrorInfoVM(WriteError errorInfo, MenuItemVM menuItem) { this.errorInfo = errorInfo; this.menuItem = menuItem; }
public void SelectMenuItem(MenuItemVM newMenuItem) { //エラー発生時に外部からメニューを表示するための処理 foreach (MenuItemVM menuItem in MenuItems) { menuItem.IsSelected = false; } newMenuItem.IsSelected = true; }