/// <summary> /// Executes the paste operation on the given element. /// </summary> /// <param name="modelElement">Element.</param> /// <returns>Validation result, indicating problems during the paste operation.</returns> public static ValidationResult ExecutePaste(ModelElement modelElement) { System.Windows.IDataObject idataObject = System.Windows.Clipboard.GetDataObject(); ValidationResult result = null; using (Transaction transaction = modelElement.Store.TransactionManager.BeginTransaction("Paste")) { result = ModelElementOperations.Merge(modelElement, idataObject); transaction.Commit(); } ModelProtoGroup group = ModelElementOperations.GetModelProtoGroup(idataObject); if (group != null) { if (group.Operation == ModelProtoGroupOperation.Move) { System.Windows.Clipboard.Clear(); ElementsInMoveMode.Clear(); } } return(result); }
/// <summary> /// Helper method of the cut opeation. /// </summary> /// <param name="eventManager">Event manager.</param> /// <param name="idataObject">Data object.</param> public static void ProcessMoveMode(System.Windows.IDataObject idataObject) { bool isInMoveMode = false; if (idataObject != null) { ModelProtoGroup group = ModelElementOperations.GetModelProtoGroup(idataObject); if (group != null) { if (group.Operation == ModelProtoGroupOperation.Move) { isInMoveMode = true; List <System.Guid> guids = new List <System.Guid>(); foreach (ModelProtoElement root in group.ProtoRootElements) { guids.Add(root.ElementId); } foreach (System.Guid id in guids) { if (!ElementsInMoveMode.Contains(id)) { //eventManager.GetEvent<ModelElementCustomEvent<bool>>().Publish(true, ModelElementCustomEventNames.ModelElementMoveModeStatus, id); ElementsInMoveMode.Add(id); } } for (int i = ElementsInMoveMode.Count - 1; i >= 0; i--) { if (!guids.Contains(ElementsInMoveMode[i])) { //eventManager.GetEvent<ModelElementCustomEvent<bool>>().Publish(false, ModelElementCustomEventNames.ModelElementMoveModeStatus, ElementsInMoveMode[i]); ElementsInMoveMode.RemoveAt(i); } } } } } if (!isInMoveMode) { // remove all elements from the current list and notify them to change status //foreach (System.Guid id in ElementsInMoveMode) // eventManager.GetEvent<ModelElementCustomEvent<bool>>().Publish(false, ModelElementCustomEventNames.ModelElementMoveModeStatus, id); } }