/// <summary> /// Constuctor. /// </summary> /// <param name="viewModelStore">The store this view model belongs to.</param> public MainSurfaceViewModel(ViewModelStore viewModelStore) : base(viewModelStore) { this.rootNodeVMs = new ObservableCollection<ModelContextViewModel>(); this.rootNodeVMsRO = new ReadOnlyObservableCollection<ModelContextViewModel>(this.rootNodeVMs); if (this.ModelData.MetaModel != null) { foreach (BaseModelContext mc in this.ModelData.MetaModel.ModelContexts) AddModelContext(mc); // subscribe this.EventManager.GetEvent<ModelElementLinkAddedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(MetaModelHasModelContexts.DomainClassId), true, this.ModelData.MetaModel.Id, new Action<ElementAddedEventArgs>(OnModelContextAdded)); this.EventManager.GetEvent<ModelElementLinkDeletedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(MetaModelHasModelContexts.DomainClassId), true, this.ModelData.MetaModel.Id, new Action<ElementDeletedEventArgs>(OnModelContextRemoved)); if (this.ModelContextVMs.Count > 0) this.selectedItem = this.ModelContextVMs[0]; } this.EventManager.GetEvent<SelectionChangedEvent>().Subscribe(new Action<SelectionChangedEventArgs>(OnSelectionChanged)); }
/// <summary> /// Constuctor. /// </summary> /// <param name="viewModelStore">The store this view model belongs to.</param> public MainSurfaceViewModel(ViewModelStore viewModelStore) : base(viewModelStore) { this.rootNodeVMs = new ObservableCollection <ModelContextViewModel>(); this.rootNodeVMsRO = new ReadOnlyObservableCollection <ModelContextViewModel>(this.rootNodeVMs); if (this.ModelData.MetaModel != null) { foreach (BaseModelContext mc in this.ModelData.MetaModel.ModelContexts) { AddModelContext(mc); } // subscribe this.EventManager.GetEvent <ModelElementLinkAddedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(MetaModelHasModelContexts.DomainClassId), true, this.ModelData.MetaModel.Id, new Action <ElementAddedEventArgs>(OnModelContextAdded)); this.EventManager.GetEvent <ModelElementLinkDeletedEvent>().Subscribe(this.Store.DomainDataDirectory.GetDomainRelationship(MetaModelHasModelContexts.DomainClassId), true, this.ModelData.MetaModel.Id, new Action <ElementDeletedEventArgs>(OnModelContextRemoved)); if (this.ModelContextVMs.Count > 0) { this.selectedItem = this.ModelContextVMs[0]; } } this.EventManager.GetEvent <SelectionChangedEvent>().Subscribe(new Action <SelectionChangedEventArgs>(OnSelectionChanged)); }
/// <summary> /// Deletes a new ModelContext view model for the given ModelContext. /// </summary> /// <param name="element">ModelContext.</param> public void DeleteModelContext(LibraryModelContext element) { if (this.externMCReference != null) { if (this.externMCReference.ModelContext == element) { this.externMCReference.Dispose(); this.externMCReference = null; } } OnPropertyChanged("ExternModelContextReference"); }
/// <summary> /// Adds a new ModelContext view model for the given ModelContext. /// </summary> /// <param name="element">ModelContext.</param> public void AddModelContext(LibraryModelContext element) { if (this.externMCReference != null) { if (this.externMCReference.ModelContext == element) { return; } } this.externMCReference = new ModelContextViewModel(this.ViewModelStore, element, true); OnPropertyChanged("ExternModelContextReference"); }
/// <summary> /// Adds a new model context view model for the given node. /// </summary> /// <param name="m">ModelContext.</param> public void AddModelContext(BaseModelContext m) { // verify that node hasnt been added yet foreach (ModelContextViewModel viewModel in this.rootNodeVMs) { if (viewModel.ModelContext.Id == m.Id) { return; } } ModelContextViewModel vm = new ModelContextViewModel(this.ViewModelStore, m); vm.Index = this.rootNodeVMs.Count + 1; this.rootNodeVMs.Add(vm); }
/// <summary> /// Adds a new model context view model for the given node. /// </summary> /// <param name="m">ModelContext.</param> public void AddModelContext(BaseModelContext m) { // verify that node hasnt been added yet foreach (ModelContextViewModel viewModel in this.rootNodeVMs) if (viewModel.ModelContext.Id == m.Id) return; ModelContextViewModel vm = new ModelContextViewModel(this.ViewModelStore, m); vm.Index = this.rootNodeVMs.Count +1; this.rootNodeVMs.Add(vm); }
/// <summary> /// Deletes a new ModelContext view model for the given ModelContext. /// </summary> /// <param name="element">ModelContext.</param> public void DeleteModelContext(LibraryModelContext element) { if( this.externMCReference != null ) if( this.externMCReference.ModelContext == element ) { this.externMCReference.Dispose(); this.externMCReference = null; } OnPropertyChanged("ExternModelContextReference"); }
/// <summary> /// Adds a new ModelContext view model for the given ModelContext. /// </summary> /// <param name="element">ModelContext.</param> public void AddModelContext(LibraryModelContext element) { if( this.externMCReference != null ) if( this.externMCReference.ModelContext == element ) return; this.externMCReference = new ModelContextViewModel(this.ViewModelStore, element, true); OnPropertyChanged("ExternModelContextReference"); }