private void control_DragDrop(object sender, DragEventArgs e) { SetMousePosition(e); IInstancingContext instancingContext = AdaptedControl.ContextAs <IInstancingContext>(); if (instancingContext != null && instancingContext.CanInsert(e.Data)) { try { m_isDropping = true; string name = "Drag and Drop".Localize(); ITransactionContext transactionContext = AdaptedControl.ContextAs <ITransactionContext>(); transactionContext.DoTransaction( delegate { instancingContext.Insert(e.Data); if (m_statusService != null) { m_statusService.ShowStatus(name); } }, name); AdaptedControl.Focus(); } finally { m_isDropping = false; } } }
/// <summary> /// Paste's the clipboard into the active context</summary> public void Paste() { IInstancingContext instancingContext = m_contextRegistry.GetActiveContext <IInstancingContext>(); if (instancingContext != null && instancingContext.CanInsert(Clipboard)) { ITransactionContext transactionContext = instancingContext.As <ITransactionContext>(); transactionContext.DoTransaction( delegate { instancingContext.Insert(Clipboard); }, CommandInfo.EditPaste.MenuText); OnPasted(EventArgs.Empty); } }
/// <summary> /// Perform the actual insertion</summary> /// <param name="context">Must implement IHierarchicalInsertionContext and/or /// IInstancingContext to succeed</param> /// <param name="parent">Optional. Parent object to which the new child is added. Can be null /// if the context supports it.</param> /// <param name="child">New child object to be inserted into the specified parent</param> private static void DoInsert(object context, object parent, object child) { IHierarchicalInsertionContext hierarchicalInsertionContext = context.As <IHierarchicalInsertionContext>(); if (hierarchicalInsertionContext != null) { hierarchicalInsertionContext.Insert(parent, child); } else { IInstancingContext instancingContext = context.As <IInstancingContext>(); if (instancingContext != null) { instancingContext.Insert(child); } } }
private void listView_DragDrop(object sender, DragEventArgs e) { IInstancingContext context = m_eventSequenceContext; if (context.CanInsert(e.Data)) { ITransactionContext transactionContext = context as ITransactionContext; transactionContext.DoTransaction(delegate { context.Insert(e.Data); }, "Drag and Drop".Localize()); if (m_statusService != null) { m_statusService.ShowStatus("Drag and Drop".Localize()); } } }
private void resourcesListView_DragDrop(object sender, DragEventArgs e) { if (m_event != null) { IInstancingContext context = m_event.Cast <IInstancingContext>(); if (context.CanInsert(e.Data)) { ITransactionContext transactionContext = context as ITransactionContext; TransactionContexts.DoTransaction(transactionContext, delegate { context.Insert(e.Data); }, Localizer.Localize("Drag and Drop")); if (m_statusService != null) { m_statusService.ShowStatus(Localizer.Localize("Drag and Drop")); } } } }