ElementOperations Class

Provides common operations that act upon a collection of model elements.

Namespace:  Microsoft.VisualStudio.Modeling
Assembly:  Microsoft.VisualStudio.Modeling.Sdk.12.0 (in Microsoft.VisualStudio.Modeling.Sdk.12.0.dll)

public class ElementOperations

The ElementOperations type exposes the following members.

  NameDescription
Protected methodElementOperations(IServiceProvider)Initializes a new instance of the ElementOperations class.
Public methodElementOperations(IServiceProvider, Partition)Initializes a new instance of the ElementOperations class.
Public methodElementOperations(IServiceProvider, Store) Obsolete. Initializes a new instance of the ElementOperations class.
Top

  NameDescription
Protected methodAddCustomFormatAdds one or more custom data formats to the specified IDataObject using the specified collection of ModelElements.
Protected methodAddElementGroupFormat(IDataObject, ICollection<ModelElement>, ClosureType)Adds the ElementGroupPrototype format to the specified IDataObject using the specified collection of ModelElements. This method calls the following 3 overridable methods(in order) a. CreateElementGroup b. MarkRootElements c. CreateElementGroupPrototype It then stashes the created ElementGroupPrototype in the data parameter.
Protected methodAddElementGroupFormat(IDataObject, ICollection<ModelElement>, ClosureType, Boolean)Adds the ElementGroupPrototype format to the specified IDataObject using the specified collection of ModelElements. Can be called from derived classes to force demand load of element links in order to create the collection of model elements.
Protected methodCanAddCustomFormatReturns a value indicating whether the ModelElement collection can be used to create a custom format.
Protected methodCanAddElementGroupFormatReturns a value indicating whether the ModelElement collection can be used to create an ElementGroupPrototype format.
Public methodCanCopy(ICollection<ModelElement>)Gets a value indicating whether the collection of ModelElements can be copied to an IDataObject.
Public methodCanCopy(ICollection<ModelElement>, ClosureType)Gets a value indicating whether the collection of ModelElements can be copied to an IDataObject. Calls CanCopyCore to do the work.
Protected methodCanCopyCoreGets a value indicating whether the collection of ModelElements can be copied to an IDataObject.
Public methodCanDelete(ModelElement, Guid[])Query whether a specified element can be deleted, taking into account any IMS locks applicable to any of the elements in the delete closure of the element.
Public methodCanDelete(IEnumerable<ModelElement>, Guid[])Query whether a specified set of elements can be deleted, taking into account any IMS locks applicable to any of the elements in the complete delete closure of the elements.
Public methodCanMergeReturns a value indicating whether the ElementGroupPrototype from the IDataObject can be merged (i.e., pasted or dropped) into the target ModelElement.
Public methodCanMergeElementGroupPrototype(ModelElement, ElementGroupPrototype)Returns a value indicating whether MergeElementGroupPrototype can be performed.
Protected methodCanMergeElementGroupPrototype(ModelElement, ProtoElementBase, ElementGroupPrototype)Gets a value indicating whether MergeElementGroupPrototype can be performed given the particular hoist and element group prototype.
Public methodCanMoveGets a value indicating whether the collection of ModelElements can be moved.
Public methodChooseMergeTarget(ModelElement, ElementGroup)Gets the target element for the merge, given the proposed targetElement. By default, this method will give the target element the chance to change the intended target.
Public methodChooseMergeTarget(ModelElement, ElementGroupPrototype)Gets the target element for the merge, given the proposed targetElement. This gives the ElementOperations the chance to change the intended target for the merge. By default, this method will give the target element the chance to change the intended target.
Public methodCopy(IDataObject, ICollection<ModelElement>)Copies the collection of ModelElements to the specified IDataObject in one or more data formats.
Public methodCopy(IDataObject, ICollection<ModelElement>, ClosureType)Copies the collection of ModelElements to the specified IDataObject in one or more data formats.
Public methodCopy(IDataObject, ICollection<ModelElement>, PointF)Copies the collection of ModelElements to the specified IDataObject in one or more data formats.
Public methodCopy(IDataObject, ICollection<ModelElement>, ClosureType, PointF)Copies the collection of ModelElements to the specified IDataObject in one or more data formats.
Protected methodCreateElementGroupCreates a ClosureElementGroup
Protected methodCreateElementGroupPrototype
Public methodEqualsDetermines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodStatic memberGetClipboardDataObjectReturns an IDataObject from the Clipboard if it contains our ElementGroupPrototype format, otherwise null.
Public methodStatic memberGetElementGroupPrototypeGets the ElementGroupPrototype from the DataObject if it exists.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Protected methodStatic memberGetModelingToolboxItemDisplayNameIf the IDataObject contains a ModelingToolboxItem, this returns its DisplayName, otherwise null.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodStatic memberIsElementGroupPrototypeFormatAvailableReturns true if the ElementGroupPrototype clipboard format is available on the clipboard, otherwise false.
Protected methodMarkRootElementsMark RootElements in the elementGroup parameter.
Protected methodMemberwiseCloneCreates a shallow copy of the current Object. (Inherited from Object.)
Public methodMergeMerges (i.e., pastes or drops) the ElementGroupPrototype from the IDataObject to the target ModelElement.
Public methodMergeElementGroupMerges the source ElementGroup with the specified target ModelElement.
Public methodMergeElementGroupPrototypeMerges the source ElementGroupPrototype with the specified target ModelElement.
Protected methodOnElementsReconstitutedCalled by MergeElementGroupPrototype immediately after the elements from the ElementGroupPrototype have been reconstituted, but before they are connected to the rest of the model.
Protected methodOnMergedCalled by MergeElementGroupPrototype immediately before the local transaction is committed. The rules are queued during the local transaction and fired when the transaction commits. The local transaction wraps reconstituting and connecting elements.
Protected methodOnMergingCalled by MergeElementGroupPrototype immediately after the target element has been chosen, but before the elements from the ElementGroupPrototype have been reconstituted.
Protected methodPropagateElementGroupContextToTransactionPropagates the context present in the element group to the currently active top-level transaction.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Public eventElementsReconstitutedCalled by MergeElementGroupPrototype immediately after the elements from the ElementGroupPrototype have been reconstituted, but before they are connected to the rest of the model.
Public eventMergedCalled by MergeElementGroupPrototype immediately before the local transaction is committed. The rules are queued during the local transaction and fired when the transaction commits. The local transaction wraps reconstituting and connecting elements.
Public eventMergingCalled by MergeElementGroupPrototype immediately after the target element has been chosen, but before the elements from the ElementGroupPrototype have been reconstituted.
Top

Derive from this class to create custom data formats for copy and paste operations. In your diagram class, override ElementOperations to return an instance of your ElementOperations subclass. You should return the same instance at every call.

For more information, see How to: Program Copy and Paste Behavior - redirect.

using Microsoft.VisualStudio.Modeling;
using Microsoft.VisualStudio.Modeling.Diagrams;
using Microsoft.VisualStudio.Modeling.Diagrams.ExtensionEnablement;

  public partial class MyDslDiagram
  {
    public override DesignSurfaceElementOperations ElementOperations
    {
      get
      {
        if (this.elementOperations == null)
        {
          this.elementOperations = new MyElementOperations(this.Store as IServiceProvider, this);
        }
        return this.elementOperations;
      }
    }
    private MyElementOperations elementOperations = null;
  }

  public class MyElementOperations : DesignSurfaceElementOperations
  {
    public MyElementOperations(IServiceProvider serviceProvider, MyDslDiagram diagram)
      : base(serviceProvider, diagram)
    { }
    // Overridden methods follow
  }

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft