/// <summary> /// Handle the drop of a <see cref="ElementDefinition"/> /// </summary> /// <param name="dropInfo">The <see cref="IDropInfo"/> containing the payload</param> /// <param name="elementDefinition">The <see cref="ElementDefinition"/></param> private async Task Drop(IDropInfo dropInfo, ElementDefinition elementDefinition) { try { if (elementDefinition.Iid == Guid.Empty) { logger.Debug("Copying an Element Definition that has been created as template - iid is the empty guid"); dropInfo.Effects = DragDropEffects.Copy; var iteration = (Iteration)this.Thing.Container; await ElementDefinitionService.CreateElementDefinitionFromTemplate(this.Session, iteration, elementDefinition); return; } if (elementDefinition.TopContainer == this.Thing.TopContainer) { await this.ThingCreator.CreateElementUsage(this.Thing, elementDefinition, this.currentDomain, this.Session); } else { // copy the payload to this iteration var copyCreator = new CopyCreator(this.Session, this.dialogNavigationService); await copyCreator.Copy(elementDefinition, (Iteration)this.Thing.Container, dropInfo.KeyStates); } } catch (Exception ex) { logger.Error(ex.Message); this.ErrorMsg = ex.Message; } }
/// <summary> /// Performs the drop operation /// </summary> /// <param name="dropInfo"> /// Information about the drop operation. /// </param> public async Task Drop(IDropInfo dropInfo) { var droptarget = dropInfo.TargetItem as IDropTarget; if (droptarget != null) { try { this.IsBusy = true; await droptarget.Drop(dropInfo); } catch (Exception ex) { this.Feedback = ex.Message; } finally { this.IsBusy = false; } return; } var elementDefinition = dropInfo.Payload as ElementDefinition; if (elementDefinition != null) { if (elementDefinition.Iid == Guid.Empty) { logger.Debug("Copying an Element Definition that has been created as template - iid is the empty guid"); dropInfo.Effects = DragDropEffects.Copy; try { this.IsBusy = true; await ElementDefinitionService.CreateElementDefinitionFromTemplate(this.Session, this.Thing, elementDefinition); } catch (Exception e) { logger.Error(e.Message); this.Feedback = e.Message; } finally { this.IsBusy = false; } } else { // copy the payload to this iteration try { this.IsBusy = true; var copyCreator = new CopyCreator(this.Session, this.DialogNavigationService); await copyCreator.Copy(elementDefinition, this.Thing, dropInfo.KeyStates); } catch (Exception e) { logger.Error(e.Message); this.Feedback = e.Message; } finally { this.IsBusy = false; } } } }