src/Misc/EFTools/EntityDesignPackage/CustomCode/MicrosoftDataEntityDesignCommandSet.cs
/// <summary>
///     The menu item that allows the user to move entity-type-shapes to another diagram.
///     It will do the following:
///     - Copy the selected shapes to clipboard.
///     - Remove the selected shapes from Current Diagram.
///     - Create a new diagram.
///     - Open the newly created diagram.
///     - Paste the shapes to the new diagram
///     - Select the new diagram node in model browser and put the node in rename mode.
///     TODO: MoveToNewDiagram will generate 3 transactions (delete entity-type-shapes, create new diagram, add entity-type-shapes),
///     it would be nice to be able to do all the above in a single transaction.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
The menu item that allows the user to move entity-type-shapes to another diagram.
It will do the following:
Copy the selected shapes to clipboard.
Remove the selected shapes from Current Diagram.
Create a new diagram.
Open the newly created diagram.
Paste the shapes to the new diagram
Select the new diagram node in model browser and put the node in rename mode.
TODO: MoveToNewDiagram will generate 3 transactions (delete entity-type-shapes, create new diagram, add entity-type-shapes),
it would be nice to be able to do all the above in a single transaction.
The menu item that allows the user to move entity - type - shapes to another diagram . It will do the following : Copy the selected shapes to clipboard . Remove the selected shapes from Current Diagram . Create a new diagram . Open the newly created diagram . Paste the shapes to the new diagram Select the new diagram node in model browser and put the node in rename mode . TODO : MoveToNewDiagram will generate 3 transactions ( delete entity - type - shapes create new diagram add entity - type - shapes ) it would be nice to be able to do all the above in a single transaction .
internal void OnMenuMoveToNewDiagram(object sender, EventArgs e)
        {
            var diagram = GetDiagram();
            Debug.Assert(
                diagram != null, "Entity designer diagram should be active and in focus when 'Move to New Diagram' menu item is called.");
            if (diagram != null)
            {
                var areSelectedItemsEntityTypeShape = AreAllSelectedItemsTypeof<EntityTypeShape>();
                Debug.Assert(
                    areSelectedItemsEntityTypeShape,
                    "The selected items must be type of entity type shape when 'Move to New Diagram' menu item is called");
                if (areSelectedItemsEntityTypeShape)
                {
                    OnMenuCut(sender, e);
                    var modelDiagram = CreateDiagramWithDefaultName();
                    Debug.Assert(modelDiagram != null, "Model diagram is null. It should be created by now.");
                    if (modelDiagram != null)
                    {
                        Debug.Assert(DiagramManagerContextItem != null, "Diagram Manager Context item should not be null.");
                        if (DiagramManagerContextItem != null)
                        {
                            DiagramManagerContextItem.DiagramManager.OpenDiagram(modelDiagram.Id.Value, true);
                            Debug.Assert(
                                GetDiagram().DiagramId == modelDiagram.Id.Value,
                                "Expected the active diagram: " + modelDiagram.Name.Value + ", Actual active diagram:" + GetDiagram().Title);
                            OnMenuPaste(sender, e);
                            var frame = ExplorerFrame;
                            Debug.Assert(frame != null, "Explorer frame is null");
                            if (frame != null)
                            {
                                frame.NavigateToElementAndPutInRenameMode(modelDiagram);
                            }
                        }
                    }
                }
            }
        }
internal void OnMenuMoveToNewDiagram ( object sender , EventArgs e ) { var diagram = GetDiagram ( ) ; Debug . Assert ( diagram != null , " " ) ; if ( diagram != null ) { var areSelectedItemsEntityTypeShape = AreAllSelectedItemsTypeof < EntityTypeShape > ( ) ; Debug . Assert ( areSelectedItemsEntityTypeShape , " " ) ; if ( areSelectedItemsEntityTypeShape ) { OnMenuCut ( sender , e ) ; var modelDiagram = CreateDiagramWithDefaultName ( ) ; Debug . Assert ( modelDiagram != null , " " ) ; if ( modelDiagram != null ) { Debug . Assert ( DiagramManagerContextItem != null , " " ) ; if ( DiagramManagerContextItem != null ) { DiagramManagerContextItem . DiagramManager . OpenDiagram ( modelDiagram . Id . Value , true ) ; Debug . Assert ( GetDiagram ( ) . DiagramId == modelDiagram . Id . Value , " " + modelDiagram . Name . Value + " " + GetDiagram ( ) . Title ) ; OnMenuPaste ( sender , e ) ; var frame = ExplorerFrame ; Debug . Assert ( frame != null , " " ) ; if ( frame != null ) { frame . NavigateToElementAndPutInRenameMode ( modelDiagram ) ; } } } } } }
The menu item that allows the user to move entity-type-shapes to another diagram.
The menu item that allows the user to move entity - type - shapes to another diagram .
// Copy the selected items to clipboard and delete the selected items from the diagram // Create a new diagram with default names. // Open the newly created diagram. // Check if the current active diagram is the same as the diagram that we opened in previous step. // Paste the items in the clipboard to the new diagram. // The code below ensures that new diagram node is selected and in rename mode in model browser window. // set the focus to the newly created diagram in model browser. This step must be done as the last step because other operation could cause focus to change.
sender
object
None
e
EventArgs
None