Пример #1
0
    public static int FindValueInEnumEdgeTypes(string val)
    {
        var values = EdgeTypes.GetValues(typeof(EdgeTypes));

        for (int x = 0; x < values.Length; x++)
        {
            if (values.GetValue(x).ToString().ToLower() == val.ToLower())
            {
                return(x);
            }
        }
        return(-1);
    }
Пример #2
0
    public void SetNextEdgeType()
    {
        // Set caption to next edge type.
        // Cirulates at last element and jumps over index 0
        int index = FindValueInEnumEdgeTypes(label);

        if (index != -1)
        {
            index++;
            index %= EdgeTypes.GetValues(typeof(EdgeTypes)).Length;
            index  = index == 0 ? index + 1 : index;

            EdgeTypes newEdgeType = (EdgeTypes)index;
            label = newEdgeType.ToString().ToLower();
        }
        else
        {
            // If caption could not be found in types set to first
            int firstInEdgeTypes = 1;
            label = ((EdgeTypes)firstInEdgeTypes).ToString().ToLower();
        }
    }