private BookRelationVM CreateRelation(BookRelation relationModel) { ObservableCollection <ITitleProvider> objects = StudyUnit.RelatedMetaData(relationModel.BookRelationType); string typeName = BookRelationItem.GetLabel(relationModel.BookRelationType); ITitleProvider obj = SelectMetaDataWindowVM.Find(objects, relationModel.MetadataId); string metaDataName = null; if (obj != null) { metaDataName = obj.Title; } BookRelationVM relation = new BookRelationVM(relationModel) { Parent = this, TypeName = typeName, MetaDataName = metaDataName }; return(relation); }
private BookRelationVM SelectRelation(BookRelation selectedRelationModel) { BookRelationType type = BookRelationType.Abstract; string metaDataId = null; if (selectedRelationModel != null) { type = selectedRelationModel.BookRelationType; metaDataId = selectedRelationModel.MetadataId; } SelectMetaDataWindowVM vm = new SelectMetaDataWindowVM(type, metaDataId) { Parent = this }; vm.Init(); SelectMetaDataWindow window = new SelectMetaDataWindow(vm); window.Owner = Window; BookRelationVM relation = null; if (window.ShowDialog() == true) { BookRelation relationModel = new BookRelation(); relationModel.BookRelationType = vm.BookRelationType; ITitleProvider selectedObject = vm.SelectedObject as ITitleProvider; if (selectedObject != null) { relationModel.MetadataId = selectedObject.Id; } relation = FindExistRelation(relationModel); if (relation == null) { relation = CreateRelation(relationModel); } } return(relation); }
private BookRelationVM SelectRelation(BookRelation selectedRelationModel) { BookRelationType type = BookRelationType.Abstract; string metaDataId = null; if (selectedRelationModel != null) { type = selectedRelationModel.BookRelationType; metaDataId = selectedRelationModel.MetadataId; } SelectMetaDataWindowVM vm = new SelectMetaDataWindowVM(type, metaDataId) { Parent = this }; vm.Init(); SelectMetaDataWindow window = new SelectMetaDataWindow(vm); window.Owner = Window; BookRelationVM relation = null; if (window.ShowDialog() == true) { BookRelation relationModel = new BookRelation(); relationModel.BookRelationType = vm.BookRelationType; ITitleProvider selectedObject = vm.SelectedObject as ITitleProvider; if (selectedObject != null) { relationModel.MetadataId = selectedObject.Id; } relation = FindExistRelation(relationModel); if (relation == null) { relation = CreateRelation(relationModel); } } return relation; }
public SelectMetaDataWindow(SelectMetaDataWindowVM viewModel) { InitializeComponent(); this.viewModel = viewModel; DataContext = viewModel; }
public SelectMetaDataWindow(SelectMetaDataWindowVM viewModel) { InitializeComponent(); this.viewModel = viewModel; DataContext = viewModel; }