Smrf.NodeXL.Visualization.Wpf.NodeXLControl.SetGroupVertexAttributes C# (CSharp) Method

SetGroupVertexAttributes() protected method

protected SetGroupVertexAttributes ( GroupInfo oCollapsedGroup, IVertex oCollapsedGroupVertex, ICollection oVerticesToCollapse ) : void
oCollapsedGroup Smrf.NodeXL.Core.GroupInfo
oCollapsedGroupVertex IVertex
oVerticesToCollapse ICollection
return void
    SetGroupVertexAttributes
    (
        GroupInfo oCollapsedGroup,
        IVertex oCollapsedGroupVertex,
        ICollection<IVertex> oVerticesToCollapse
    )
    {
        Debug.Assert(oCollapsedGroup != null);
        Debug.Assert(oCollapsedGroupVertex != null);
        Debug.Assert(oVerticesToCollapse != null);
        Debug.Assert(oVerticesToCollapse.Count > 0);
        AssertValid();

        // If the group has no collapsed location, arbitrarily use the location
        // of the first vertex in the group.

        oCollapsedGroupVertex.Location = 
            oCollapsedGroup.CollapsedLocation ??
            oVerticesToCollapse.First().Location;

        Boolean bAllVerticesSelected = true;
        Boolean bAllVerticesHidden = true;

        foreach (IVertex oVertex in oVerticesToCollapse)
        {
            if ( !VertexOrEdgeIsSelected(oVertex) )
            {
                bAllVerticesSelected = false;
            }

            if (VertexDrawer.GetVisibility(oVertex) !=
                VisibilityKeyValue.Hidden)
            {
                bAllVerticesHidden = false;
            }
        }

        // If all of the group's vertices are selected or hidden, select or
        // hide the collapsed group vertex.

        if (bAllVerticesSelected)
        {
            MarkVertexOrEdgeAsSelected(oCollapsedGroupVertex, true);
            m_oSelectedVertices.Add(oCollapsedGroupVertex);
        }

        if (bAllVerticesHidden)
        {
            oCollapsedGroupVertex.SetValue(ReservedMetadataKeys.Visibility,
                VisibilityKeyValue.Hidden);
        }

        // Store the group information on the collapsed group vertex.  This
        // gets used by VertexDrawer when the collapsed group vertex is drawn.

        oCollapsedGroupVertex.SetValue(
            ReservedMetadataKeys.CollapsedGroupInfo, oCollapsedGroup);

        // In case a sort order has been specified for the graph's vertices,
        // arbitrarily put the group vertex at the top of the sort order.
        //
        // This is only to avoid an exception that SortableLayoutBase throws
        // when it encounters a vertex that is missing the
        // SortableLayoutAndZOrder key.

        oCollapsedGroupVertex.SetValue(
            ReservedMetadataKeys.SortableLayoutAndZOrder, Single.MaxValue);
    }
NodeXLControl