Exemple #1
0
        private void cbAlpha_SelectedIndexChanged(object sender, EventArgs e)
        {
            // update the alpha color
            MyComboBoxItem cb = cbAlpha.SelectedItem as MyComboBoxItem;

            if (cb != null)
            {
                String c = cb.Value.ToString();
                img2LZW.UpdateAlpha(c);
            }
        }
 protected override void OnDrawItem(DrawItemEventArgs e)
 {
     base.OnDrawItem(e);
     e.DrawBackground();
     if (e.Index >= 0)
     {
         MyComboBoxItem item  = (MyComboBoxItem)this.Items[e.Index];
         Brush          brush = new SolidBrush(item.BackColor);
         e.Graphics.FillRectangle(brush, e.Bounds);
         Brush fontBrush = item.BackColor.GetBrightness() > 0.5f ? Brushes.Black : Brushes.White;
         e.Graphics.DrawString(item.Text, this.Font, fontBrush, e.Bounds.X, e.Bounds.Y);
     }
 }