This topic has not yet been rated - Rate this topic

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.

The following procedure demonstrates how to hide a shape.

To hide a shape in a generated designer

  1. Create a domain-specific language based on the Minimal Language solution template. For more information, see Walkthrough: Creating a Domain-Specific Language Solution.

  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();
            }
        }
    

    }

Did you find this helpful?
(1500 characters remaining)

Community Additions

ADD
© 2013 Microsoft. All rights reserved.