protected void NDrawingView1_AsyncClick(object sender, EventArgs e)
        {
            NCallbackMouseEventArgs args = e as NCallbackMouseEventArgs;

            NNodeList            nodes  = NDrawingView1.HitTest(args);
            NNodeList            shapes = nodes.Filter(Nevron.Diagram.Filters.NFilters.Shape2D);
            NExpandCollapseCheck check  = null;
            int length = shapes.Count;

            for (int i = 0; i < length; i++)
            {
                if (shapes[i] is NExpandCollapseCheck)
                {
                    check = shapes[i] as NExpandCollapseCheck;
                    break;
                }
            }
            if (check == null)
            {
                return;
            }

            NExpandableShape shape = check.ParentNode.ParentNode as NExpandableShape;

            shape.Expand(!shape.Expanded);
        }
            /// <summary>
            ///
            /// </summary>
            /// <param name="expandShape"></param>
            public void Expand(bool expandShape)
            {
                // expand or collapse in a single transation
                StartTransaction(expandShape ? "Expand Tree" : "Collapse Tree");

                // mark shape as expanded
                Expanded = expandShape;

                // show/hide the plus or minus
                NExpandCollapseCheck check = GetExpandCollapseCheck();

                NPathPrimitive pathPrimitive;

                pathPrimitive         = check.Primitives.GetChildAt(1) as NPathPrimitive;
                pathPrimitive.Visible = !expandShape;

                pathPrimitive         = check.Primitives.GetChildAt(2) as NPathPrimitive;
                pathPrimitive.Visible = expandShape;

                // show/hide all outgoing shapes
                NNodeList nodes = GetOutgoingShapes();

                for (int i = 0; i < nodes.Count; i++)
                {
                    NShape shape = (nodes[i] as NShape);
                    shape.Visible = expandShape;
                }

                // show/hide all destination shapes
                nodes = GetDestinationShapes();
                for (int i = 0; i < nodes.Count; i++)
                {
                    NShape shape = (nodes[i] as NShape);
                    shape.Visible = expandShape;
                }

                // expand/collapse the destination shapes
                for (int i = 0; i < nodes.Count; i++)
                {
                    NExpandableShape expandableShape = (nodes[i] as NExpandableShape);
                    if (expandableShape != null)
                    {
                        expandableShape.Expand(expandShape);
                    }
                }

                // commit the transaction
                Commit();
            }
            public NExpandableShape()
            {
                // add a rectangle shape as base
                NRectangleShape rect = new NRectangleShape(new NRectangleF(0, 0, 75, 75));

                rect.DestroyShapeElements(ShapeElementsMask.All);
                rect.Protection = new NAbilities(AbilitiesMask.Select | AbilitiesMask.InplaceEdit);
                Shapes.AddChild(rect);

                // add an expand collapse shape
                NExpandCollapseCheck check = new NExpandCollapseCheck();

                check.Bounds            = new NRectangleF(80, 0, 12, 12);
                check.Protection        = new NAbilities(AbilitiesMask.Select | AbilitiesMask.InplaceEdit);
                check.ResizeInAggregate = ResizeInAggregate.RepositionOnly;
                Shapes.AddChild(check);

                // update the model bounds with the rectangle bounds
                UpdateModelBounds(rect.Transform.TransformBounds(rect.ModelBounds));

                // initially it is expanded
                m_bExpanded = true;

                // by default the group has one dynamic port anchored to the rectangle
                CreateShapeElements(ShapeElementsMask.Ports);
                NDynamicPort port = new NDynamicPort(rect.UniqueId, ContentAlignment.MiddleCenter, DynamicPortGlueMode.GlueToContour);

                Ports.AddChild(port);
                Ports.DefaultInwardPortUniqueId = port.UniqueId;

                // by default the group has one rotated bounds port anchored to the rectangle
                CreateShapeElements(ShapeElementsMask.Labels);
                NRotatedBoundsLabel label = new NRotatedBoundsLabel("", rect.UniqueId, new Nevron.Diagram.NMargins(10));

                Labels.AddChild(label);
                Labels.DefaultLabelUniqueId = label.UniqueId;
            }