/// <summary> /// Constuctor. /// </summary> /// <param name="viewModelStore">The store this view model belongs to.</param> /// <param name="modelTreeView">Diagram tree view.</param> public DiagramViewModel(ViewModelStore viewModelStore, ModelContextViewModel modelContextVM, DiagramView diagramView) : base(viewModelStore) { this.diagramView = diagramView; this.modelContextVM = modelContextVM; this.contextMenuOperations = new Collection<MenuItemViewModel>(); this.selectedVMS = new Collection<object>(); this.rootNodeVMs = new ObservableCollection<DiagramClassViewModel>(); this.rootNodeVMsRO = new ReadOnlyObservableCollection<DiagramClassViewModel>(this.rootNodeVMs); if (diagramView != null) { foreach (DiagramClassView view in diagramView.DiagramClassViews) AddDiagramClassView(view); // subscribe this.EventManager.GetEvent<ModelElementLinkAddedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(DiagramViewHasDiagramClassViews.DomainClassId), true, this.diagramView.Id, new Action<ElementAddedEventArgs>(OnDiagramClassViewAdded)); this.EventManager.GetEvent<ModelElementLinkDeletedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(DiagramViewHasDiagramClassViews.DomainClassId), true, this.diagramView.Id, new Action<ElementDeletedEventArgs>(OnDiagramClassViewRemoved)); } addNewDiagramClassCommand = new DelegateCommand(AddNewDiagramClassCommand_Executed); addNewDiagramClassFromTemplateCommand = new DelegateCommand(AddNewDiagramClassFromTemplateCommand_Executed); addNewShapeClassCommand = new DelegateCommand(AddNewShapeClassCommand_Executed); addNewMappingRelationshipShapeClassCommand = new DelegateCommand(AddNewMappingRelationshipShapeClassCommand_Executed); addNewRelationshipShapeClassCommand = new DelegateCommand(AddNewRelationshipShapeClassCommand_Executed); addNewDomainPropertyCommand = new DelegateCommand(AddNewDomainPropertyCommand_Executed); unparentCommand = new DelegateCommand(UnparentCommand_Executed); reparentCommand = new DelegateCommand(ReparentCommand_Executed); moveUpCommand = new DelegateCommand(MoveUpCommand_Executed); moveDownCommand = new DelegateCommand(MoveDownCommand_Executed); deleteCommand = new DelegateCommand(DeleteCommand_Executed, DeleteCommand_CanExecute); viewPropertiesCommand = new DelegateCommand(ViewPropertiesCommand_Executed); addIncludedDDCCommand = new DelegateCommand(AddIncludedDDCCommand_Executed); addImportedDCCommand = new DelegateCommand(AddImportedDCCommand_Executed); showTemplateHelperCommand = new DelegateCommand(ShowTemplateHelperCommand_Executed); addNewDomainClassSEDCommand = new DelegateCommand(AddNewDomainClassSEDCommand_Executed); addNewDomainRLForRLShape = new DelegateCommand(AddNewDomainRLForRLShape_Executed); UpdateOperations(); this.EventManager.GetEvent<SelectionChangedEvent>().Subscribe(new Action<SelectionChangedEventArgs>(OnSelectionChanged)); }
/// <summary> /// Constuctor. /// </summary> /// <param name="viewModelStore">The store this view model belongs to.</param> /// <param name="modelTreeView">Domain model tree view.</param> public ModelTreeViewModel(ViewModelStore viewModelStore, ModelContextViewModel modelContextVM, DomainModelTreeView modelTreeView) : base(viewModelStore) { this.rootNodeVMs = new ObservableCollection<RootNodeViewModel>(); this.rootNodeVMsRO = new ReadOnlyObservableCollection<RootNodeViewModel>(rootNodeVMs); this.modelContextVM = modelContextVM; this.modelTreeView = modelTreeView; this.selectedVMS = new Collection<object>(); this.contextMenuOperations = new Collection<MenuItemViewModel>(); addNewDomainPropertyCommand = new DelegateCommand(AddNewDomainPropertyCommand_Executed); addNewDomainClassCommand = new DelegateCommand(AddNewDomainClassCommand_Executed); addNewEmbeddingRSCommand = new DelegateCommand(AddNewEmbeddingRSCommand_Executed); addNewEmbeddingRSToExistantCommand = new DelegateCommand(AddNewEmbeddingRSToExistantCommand_Executed); addNewReferenceRSCommand = new DelegateCommand(AddNewReferenceRSCommand_Executed); addNewReferenceRSToRSCommand = new DelegateCommand(AddNewReferenceRSToRSCommand_Executed); addNewInheritanceRSCommand = new DelegateCommand(AddNewInheritanceRSCommand_Executed); addNewDerivedElementCommand = new DelegateCommand(AddNewDerivedElementCommand_Executed); deleteCommand = new DelegateCommand(DeleteCommand_Executed, DeleteCommand_CanExecute); showTemplateHelperCommand = new DelegateCommand(ShowTemplateHelperCommand_Executed); /* copyCommand = new DelegateCommand(CopyCommand_Executed, CopyCommand_CanExecute); pasteCommand = new DelegateCommand(PasteCommand_Executed, PasteCommand_CanExecute); */ bringTreeHereCommand = new DelegateCommand(BringTreeHereCommand_Executed); splitTreeCommand = new DelegateCommand(SplitTreeCommand_Executed); moveUpCommand = new DelegateCommand(MoveUpCommand_Executed); moveDownCommand = new DelegateCommand(MoveDownCommand_Executed); viewPropertiesCommand = new DelegateCommand(ViewPropertiesCommand_Executed); addMappingToNewRelShapeClassCommand = new DelegateCommand(AddMappingToNewRelShapeClassCommand_Executed); addMappingToExtRelShapeClassCommand = new DelegateCommand(AddMappingToExtRelShapeClassCommand_Executed); addMappingToNewShapeClassCommand = new DelegateCommand(AddMappingToNewShapeClassCommand_Executed); addMappingToExtShapeClassCommand = new DelegateCommand(AddMappingToExtShapeClassCommand_Executed); addMappingToNewMappingShapeClassCommand = new DelegateCommand(AddMappingToNewMappingShapeClassCommand_Executed); addMappingToExtMappingShapeClassCommand = new DelegateCommand(AddMappingToExtMappingShapeClassCommand_Executed); UpdateOperations(); foreach (RootNode n in modelTreeView.RootNodes) this.AddRootNode(n); this.EventManager.GetEvent<SelectionChangedEvent>().Subscribe(new Action<SelectionChangedEventArgs>(OnSelectionChanged)); Subscribe(); }