/// <summary> /// Copy command executed. /// </summary> public virtual void OnCopyCommandExecuted() { if (!this.IsDomainModel) { using (new WaitCursor()) { try { Collection <ModelElement> modelElements = new Collection <ModelElement>(); modelElements.Add(this.Element); CopyAndPasteOperations.ExecuteCopy(modelElements); } catch (System.Exception ex) { this.GlobalServiceProvider.Resolve <IMessageBoxService>().ShowError("Copying to clipboard failed: " + ex.Message); } } } }
/// <summary> /// Copy command executed. /// </summary> private void CopyCommand_Executed() { Collection <ModelElement> modelElements = new Collection <ModelElement>(); if (this.SelectedItem is ModelTreeViewModel) { foreach (BaseModelElementViewModel vm in this.ModelTreeViewModel.SelectedItems) { if (vm.GetHostedElement() == null) { continue; } modelElements.Add(vm.GetHostedElement()); } } else if (this.SelectedItem is DiagramViewModel) { foreach (BaseModelElementViewModel vm in this.DiagramViewModel.SelectedItems) { if (vm.GetHostedElement() == null) { continue; } modelElements.Add(vm.GetHostedElement()); } } using (new WaitCursor()) { try { CopyAndPasteOperations.ExecuteCopy(modelElements); } catch (System.Exception ex) { this.GlobalServiceProvider.Resolve <IMessageBoxService>().ShowError("Copying to clipboard failed: " + ex.Message); } } }
/// <summary> /// Copy command executed. /// </summary> private void CopyReferenceTreeCommand_Executed() { Collection <ModelElement> modelElements = new Collection <ModelElement>(); if (this.SelectedItem is ModelTreeViewModel) { foreach (BaseModelElementViewModel vm in this.ModelTreeViewModel.SelectedItems) { if (vm.GetHostedElement() == null) { continue; } if (!(vm.GetHostedElement() is DomainClass)) { continue; } modelElements.Add(vm.GetHostedElement()); } } if (modelElements.Count != 1) { return; } using (new WaitCursor()) { try { CopyAndPasteOperations.Operation = CopyAndPasteOperation.CopyReferenceTree; CopyAndPasteOperations.ExecuteCopy(modelElements); CopyAndPasteOperations.Operation = CopyAndPasteOperation.Default; } catch (System.Exception ex) { this.GlobalServiceProvider.Resolve <IMessageBoxService>().ShowError("Copying to clipboard failed: " + ex.Message); } } }