ARKBreedingStats.ParentComboBox.comboBoxParents_DrawItem C# (CSharp) Method

comboBoxParents_DrawItem() private method

private comboBoxParents_DrawItem ( object sender, DrawItemEventArgs e ) : void
sender object
e System.Windows.Forms.DrawItemEventArgs
return void
        private void comboBoxParents_DrawItem(object sender, DrawItemEventArgs e)
        {
            // index of item in parentListSimilarity
            int i = e.Index - 1;
            if (i < -1)
            {
                return;
            }

            ComboBox cb = (ComboBox)sender;

            // Draw the background of the ComboBox control for each item.
            e.DrawBackground();
            // Define the default color of the brush as black.
            Brush myBrush = Brushes.Black;

            // colors of similarity
            Brush[] brushes = new Brush[] { Brushes.Black, Brushes.DarkRed, Brushes.DarkOrange, Brushes.Green, Brushes.Green, Brushes.Green, Brushes.Green, Brushes.Green };

            if (i == -1)
            {
                myBrush = Brushes.DarkGray; // no parent selected
            }
            else if (i >= 0 && parentsSimilarity != null && parentsSimilarity.Count > i)
            {
                // Determine the color of the brush to draw each item based on the similarity of the wildlevels
                myBrush = brushes[parentsSimilarity[i]];
            }

            string text = cb.Items[e.Index].ToString();
            // Draw the current item text
            e.Graphics.DrawString(text, e.Font, myBrush, e.Bounds, StringFormat.GenericDefault);

            // show tooltip (for too long names)
            if ((e.State & DrawItemState.Selected) == DrawItemState.Selected && cb.DroppedDown)
            { tt.Show(text, cb, e.Bounds.Right, e.Bounds.Bottom); }
        }