コード例 #1
0
 public void ReleaseColor(string groupName)
 {
     if (ColorAssignments.ContainsKey(groupName))
     {
         var count = ColorAssignments[groupName].Count -= 1;
         if (count < 1) ColorAssignments.Remove(groupName);
     }
 }
コード例 #2
0
 public Color RequestColor(string groupName)
 {
     if (ColorAssignments.ContainsKey(groupName)) 
     {
         ColorAssignments[groupName].Count++;
         return ColorAssignments[groupName].AssignedColor;
     }
     var assignedColor = GetNextAvailableColor();
     ColorAssignments.Add(groupName, new ColorGroupDetails() { Count = 1, AssignedColor = assignedColor });
     return assignedColor;
 }
コード例 #3
0
 private Color GetNextAvailableColor()
 {
     var assignedColors = ColorAssignments.Select(a => a.Value.AssignedColor).ToList();
     return Colors.Values.Except(assignedColors).First();
 }