ElementOperations Class

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

Inheritance Hierarchy

System.Object
  Microsoft.VisualStudio.Modeling.ElementOperations
    Microsoft.VisualStudio.Modeling.Diagrams.DesignSurfaceElementOperations

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

Syntax

'Declaração
Public Class ElementOperations
public class ElementOperations
public ref class ElementOperations
type ElementOperations =  class end
public class ElementOperations

The ElementOperations type exposes the following members.

Constructors

  Name Description
Protected method ElementOperations(IServiceProvider) Initializes a new instance of the ElementOperations class.
Public method ElementOperations(IServiceProvider, Partition) Initializes a new instance of the ElementOperations class.
Public method ElementOperations(IServiceProvider, Store) Obsolete. Initializes a new instance of the ElementOperations class.

Top

Properties

  Name Description
Protected property Partition
Protected property ServiceProvider
Protected property Store

Top

Methods

  Name Description
Protected method AddCustomFormat Adds one or more custom data formats to the specified IDataObject using the specified collection of ModelElements.
Protected method AddElementGroupFormat(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 method AddElementGroupFormat(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 method CanAddCustomFormat Returns a value indicating whether the ModelElement collection can be used to create a custom format.
Protected method CanAddElementGroupFormat Returns a value indicating whether the ModelElement collection can be used to create an ElementGroupPrototype format.
Public method CanCopy(ICollection<ModelElement>) Gets a value indicating whether the collection of ModelElements can be copied to an IDataObject.
Public method CanCopy(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 method CanCopyCore Gets a value indicating whether the collection of ModelElements can be copied to an IDataObject.
Public method CanDelete(ModelElement, array<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 method CanDelete(IEnumerable<ModelElement>, array<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 method CanMerge Returns a value indicating whether the ElementGroupPrototype from the IDataObject can be merged (i.e., pasted or dropped) into the target ModelElement.
Public method CanMergeElementGroupPrototype(ModelElement, ElementGroupPrototype) Returns a value indicating whether MergeElementGroupPrototype can be performed.
Protected method CanMergeElementGroupPrototype(ModelElement, ProtoElementBase, ElementGroupPrototype) Gets a value indicating whether MergeElementGroupPrototype can be performed given the particular hoist and element group prototype.
Public method CanMove Gets a value indicating whether the collection of ModelElements can be moved.
Public method ChooseMergeTarget(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 method ChooseMergeTarget(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 method Copy(IDataObject, ICollection<ModelElement>) Copies the collection of ModelElements to the specified IDataObject in one or more data formats.
Public method Copy(IDataObject, ICollection<ModelElement>, ClosureType) Copies the collection of ModelElements to the specified IDataObject in one or more data formats.
Public method Copy(IDataObject, ICollection<ModelElement>, PointF) Copies the collection of ModelElements to the specified IDataObject in one or more data formats.
Public method Copy(IDataObject, ICollection<ModelElement>, ClosureType, PointF) Copies the collection of ModelElements to the specified IDataObject in one or more data formats.
Protected method CreateElementGroup Creates a ClosureElementGroup
Protected method CreateElementGroupPrototype
Public method Equals Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public methodStatic member GetClipboardDataObject Returns an IDataObject from the Clipboard if it contains our ElementGroupPrototype format, otherwise null.
Public methodStatic member GetElementGroupPrototype Gets the ElementGroupPrototype from the DataObject if it exists.
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Protected methodStatic member GetModelingToolboxItemDisplayName If the IDataObject contains a ModelingToolboxItem, this returns its DisplayName, otherwise null.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public methodStatic member IsElementGroupPrototypeFormatAvailable Returns true if the ElementGroupPrototype clipboard format is available on the clipboard, otherwise false.
Protected method MarkRootElements Mark RootElements in the elementGroup parameter.
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Merge Merges (i.e., pastes or drops) the ElementGroupPrototype from the IDataObject to the target ModelElement.
Public method MergeElementGroup Merges the source ElementGroup with the specified target ModelElement.
Public method MergeElementGroupPrototype Merges the source ElementGroupPrototype with the specified target ModelElement.
Protected method OnElementsReconstituted Called by MergeElementGroupPrototype immediately after the elements from the ElementGroupPrototype have been reconstituted, but before they are connected to the rest of the model.
Protected method OnMerged Called 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 method OnMerging Called by MergeElementGroupPrototype immediately after the target element has been chosen, but before the elements from the ElementGroupPrototype have been reconstituted.
Protected method PropagateElementGroupContextToTransaction Propagates the context present in the element group to the currently active top-level transaction.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)

Top

Events

  Name Description
Public event ElementsReconstituted Called by MergeElementGroupPrototype immediately after the elements from the ElementGroupPrototype have been reconstituted, but before they are connected to the rest of the model.
Public event Merged Called 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 event Merging Called by MergeElementGroupPrototype immediately after the target element has been chosen, but before the elements from the ElementGroupPrototype have been reconstituted.

Top

Remarks

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.

Examples

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
  }

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.VisualStudio.Modeling Namespace