How to: Hide and Show Shapes and Connectors

Every shape and connector has functions that are named Hide and Show, which you can use to toggle visibility on and off as demonstrated in the following procedure.

To hide a shape in a generated designer

  1. Create a domain-specific language that is based on the Minimal Language solution template. For more information, see How to: Create Domain-Specific Language Solutions.

  2. In Solution Explorer, right-click the Dsl project, point to Add, and click New Folder.

  3. Name the folder Custom.

  4. Right-click the Custom folder, point to Add, and click New Item.

  5. In the Add New Item dialog box, in the Templates list, click Code File.

  6. In the Name box, type HideExampleShape.cs, and click Add.

  7. Copy the following code to the HideExampleShape.cs file to create a partial class to override the ExamplShape class's OnMouseDown method.

    Correct the namespace to match that of your solution. You can retrieve the namespace from the file Dsl\GeneratedCode\Diagrams.cs.

    using Microsoft.VisualStudio.Modeling.Diagrams;
    
    // Fix the namespace
    
    namespace Fabrikam.MyLanguage
    {
        public partial class ExampleShape
        {
            public override void OnMouseDown(Microsoft.VisualStudio.Modeling.Diagrams.DiagramMouseEventArgs e)
            {
                base.OnMouseDown(e);
                this.Hide();
            }
        }
    }
    

See Also

Concepts

Writing Changes to the Store

Element Reference for Domain-Specific Languages

Domain-Specific Language Tools Glossary