Smrf.NodeXL.Visualization.Wpf.VertexAndEdgeDrawerBase.GetAlpha C# (CSharp) Method

GetAlpha() protected method

protected GetAlpha ( IMetadataProvider oVertexOrEdge, VisibilityKeyValue eVisibility, Byte btDefaultAlpha ) : Byte
oVertexOrEdge IMetadataProvider
eVisibility VisibilityKeyValue
btDefaultAlpha Byte
return Byte
    GetAlpha
    (
        IMetadataProvider oVertexOrEdge,
        VisibilityKeyValue eVisibility,
        Byte btDefaultAlpha
    )
    {
        Debug.Assert(oVertexOrEdge != null);
        AssertValid();

        if (eVisibility == VisibilityKeyValue.Filtered)
        {
            // The vertex or edge is filtered.

            return (m_btFilteredAlpha);
        }

        // Check for a per-vertex or per-edge alpha.

        Object oPerAlphaAsObject;

        if ( oVertexOrEdge.TryGetValue(ReservedMetadataKeys.PerAlpha,
            typeof(Single), out oPerAlphaAsObject) )
        {
            Single fPerAlpha = (Single)oPerAlphaAsObject;

            if (fPerAlpha < 0F || fPerAlpha > 255F)
            {
                Debug.Assert(oVertexOrEdge is IIdentityProvider);

                throw new FormatException( String.Format(

                    "{0}: The {1} with the ID {2} has an out-of-range"
                    + " {3} value.  Valid values are between 0 and 255."
                    ,
                    this.ClassName,
                    (oVertexOrEdge is IVertex) ? "vertex" : "edge",
                    ( (IIdentityProvider)oVertexOrEdge ).ID,
                    "ReservedMetadataKeys.PerAlpha"
                    ) );
            }

            return ( (Byte)fPerAlpha );
        }

        return (btDefaultAlpha);
    }