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> /// Returns whether the active context can paste from the clipboard</summary> /// <returns>True iff the active context can paste from the clipboard</returns> public bool CanPaste() { IInstancingContext instancingContext = m_contextRegistry.GetActiveContext <IInstancingContext>(); return (instancingContext != null && instancingContext.CanInsert(Clipboard)); }
private void control_DragOver(object sender, DragEventArgs e) { SetMousePosition(e); e.Effect = DragDropEffects.None; IInstancingContext instancingContext = AdaptedControl.ContextAs <IInstancingContext>(); if (instancingContext != null && instancingContext.CanInsert(e.Data)) { OnDragOver(e); } }
/// <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); } }
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()); } } }
/// <summary> /// Indicates if the specified child can be inserted into the specified parent object</summary> /// <param name="context">Must implement IHierarchicalInsertionContext and/or /// IInstancingContext to succeed</param> /// <param name="parent">Optional. Parent object we want to insert into. Can be null if the /// context supports it.</param> /// <param name="child">Child object to be inserted into the specified parent</param> /// <returns>True iff the child can be inserted into the parent (or the context supports /// parent-less insertion)</returns> /// <remarks>The context must implement IHierarchicalInsertionContext and/or IInstancingContext /// to allow insertion. If the context implements both, IHierarchicalInsertionContext is preferred and /// any insertion logic in the IInstancingContext implementation is ignored!</remarks> public static bool CanInsert(object context, object parent, object child) { IHierarchicalInsertionContext hierarchicalInsertionContext = context.As <IHierarchicalInsertionContext>(); if (hierarchicalInsertionContext != null) { return(hierarchicalInsertionContext.CanInsert(parent, child)); } else { IInstancingContext instancingContext = context.As <IInstancingContext>(); if (instancingContext != null) { return(instancingContext.CanInsert(child)); } } return(false); }
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")); } } } }