src/Misc/EFTools/EntityDesign/UI/Views/Explorer/EntityDesignExplorerFrame.cs
// <summary>
//     Entity Designer drag and drop support.
//     Given an ExplorerEFElement constructs clipboard data-object containing collection of entity-types.
//     Type:
//     ExplorerEntitySet   -> collection of all entity-types in the entity set.
//     AssociationSet      -> Participating entity-type in the associationset's association.
// </summary>
Entity Designer drag and drop support.
Given an ExplorerEFElement constructs clipboard data-object containing collection of entity-types.
Type:
ExplorerEntitySet   -> collection of all entity-types in the entity set.
AssociationSet      -> Participating entity-type in the associationset's association.
Entity Designer drag and drop support . Given an ExplorerEFElement constructs clipboard data - object containing collection of entity - types . Type : ExplorerEntitySet - > collection of all entity - types in the entity set . AssociationSet - > Participating entity - type in the associationset ' s association .
protected override DataObject GetClipboardObjectForExplorerItem(ExplorerEFElement explorerEFElement)
        {
            DataObject dataObject = null;
            Debug.Assert(explorerEFElement != null && explorerEFElement.ModelItem != null, "explorerEFElement parameter is null");
            if (explorerEFElement != null
                && explorerEFElement.ModelItem != null)
            {
                var entityTypes = new List<EntityType>();
                var associations = new List<Association>();
                if (explorerEFElement.ModelItem.GetParentOfType(typeof(StorageEntityModel)) == null)
                {
                    var entityType = explorerEFElement.ModelItem as ConceptualEntityType;
                    var association = explorerEFElement.ModelItem as Association;
                    var associationSet = explorerEFElement.ModelItem as AssociationSet;
                    var entitySet = explorerEFElement.ModelItem as EntitySet;
                    if (associationSet != null
                        && associationSet.Association.Status == BindingStatus.Known)
                    {
                        association = associationSet.Association.Target;
                    }
                    if (entityType != null)
                    {
                        entityTypes.Add(entityType);
                    }
                    else if (association != null)
                    {
                        foreach (var associationEnd in association.AssociationEnds())
                        {
                            if (associationEnd.Type.Status == BindingStatus.Known)
                            {
                                entityTypes.Add(associationEnd.Type.Target);
                            }
                        }
                        associations.Add(association);
                    }
                    else if (entitySet != null)
                    {
                        entityTypes.AddRange(entitySet.GetEntityTypesInTheSet());
                    }
                }
                if (entityTypes.Count == 0
                    && associations.Count == 0)
                {
                    dataObject = new DataObject(typeof(object).Name, new object());
                }
                else
                {
                    dataObject = new DataObject(
                        typeof(EntitiesClipboardFormat).Name,
                        new EntitiesClipboardFormat(entityTypes, associations, new Dictionary<EntityType, EntityType>()));
                }
            }
            return dataObject;
        }
protected override DataObject GetClipboardObjectForExplorerItem ( ExplorerEFElement explorerEFElement ) { DataObject dataObject = null ; Debug . Assert ( explorerEFElement != null && explorerEFElement . ModelItem != null , " " ) ; if ( explorerEFElement != null && explorerEFElement . ModelItem != null ) { var entityTypes = new List < EntityType > ( ) ; var associations = new List < Association > ( ) ; if ( explorerEFElement . ModelItem . GetParentOfType ( typeof ( StorageEntityModel ) ) == null ) { var entityType = explorerEFElement . ModelItem as ConceptualEntityType ; var association = explorerEFElement . ModelItem as Association ; var associationSet = explorerEFElement . ModelItem as AssociationSet ; var entitySet = explorerEFElement . ModelItem as EntitySet ; if ( associationSet != null && associationSet . Association . Status == BindingStatus . Known ) { association = associationSet . Association . Target ; } if ( entityType != null ) { entityTypes . Add ( entityType ) ; } else if ( association != null ) { foreach ( var associationEnd in association . AssociationEnds ( ) ) { if ( associationEnd . Type . Status == BindingStatus . Known ) { entityTypes . Add ( associationEnd . Type . Target ) ; } } associations . Add ( association ) ; } else if ( entitySet != null ) { entityTypes . AddRange ( entitySet . GetEntityTypesInTheSet ( ) ) ; } } if ( entityTypes . Count == 0 && associations . Count == 0 ) { dataObject = new DataObject ( typeof ( object ) . Name , new object ( ) ) ; } else { dataObject = new DataObject ( typeof ( EntitiesClipboardFormat ) . Name , new EntitiesClipboardFormat ( entityTypes , associations , new Dictionary < EntityType , EntityType > ( ) ) ) ; } } return dataObject ; }
Entity Designer drag and drop support.
Entity Designer drag and drop support .
// Check if the type is a storage type, we don't support drag and drop support for any storage type // When the user is trying to drag an associationset, we want to treat as if the user drag the association in the set. // if entitytypes and association collections are both empty, that means drag and drop support are not supported for the ExplorerEFElement type. // Return an instance of dataobject that contains an empty object. This is so that we can display the appropriate "stop" icon in the diagram.
explorerEFElement
ExplorerEFElement