예제 #1
0
 public void RemoveItem(ImageListItem imageListItem)
 {
     this.Items.Remove(imageListItem);
 }
예제 #2
0
 public void AddItem(ImageListItem imageListItem)
 {
     this.Items.Add(imageListItem);
 }
예제 #3
0
 public void RemoveItem(ImageListItem imageListItem)
 {
     this.Items.Remove(imageListItem);
 }
예제 #4
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            if (this.DesignMode)
            {
                base.OnDrawItem(e);
                return;
            }

            // draw background & focus rect
            e.DrawBackground();
            e.DrawFocusRectangle();

            // check if it is an item from the Items collection
            if (e.Index < 0)
            {
                // not an item, draw the text (indented)
                e.Graphics.DrawString(
                    this.Text,
                    e.Font,
                    new SolidBrush(e.ForeColor),
                    e.Bounds.Left + mp_ImageSize.Width,
                    e.Bounds.Top);
            }

            else
            {
                // check if item is an ImageComboItem
                if (this.Items[e.Index].GetType() == typeof(ImageListItem))
                {
                    // get item to draw
                    ImageListItem item = (ImageListItem)this.Items[e.Index];

                    // get forecolor & font
                    Color forecolor = (item.ForeColor != Color.FromKnownColor(KnownColor.Transparent)) ? item.ForeColor : e.ForeColor;
                    Font  font      = item.Bold ? new Font(e.Font, FontStyle.Bold) : e.Font;


                    // draw the item...
                    if (item.Image != null)
                    {
                        #region If has image...
                        //Resize image if necessary...
                        if (
                            item.Image.Width != mp_ImageSize.Width ||
                            item.Image.Height != mp_ImageSize.Height
                            )
                        {
                            ResizeImage(item.Image, mp_ImageSize.Width, mp_ImageSize.Height);
                        }

                        //Draw image
                        e.Graphics.DrawImage(
                            item.Image,
                            e.Bounds.Left,
                            e.Bounds.Top);

                        //Draw text
                        e.Graphics.DrawString(
                            item.Text,
                            font,
                            new SolidBrush(forecolor),
                            e.Bounds.Left + mp_ImageSize.Width,
                            e.Bounds.Top);
                        #endregion
                    }
                    else
                    {
                        #region If doesn'h has image
                        // draw text (indented)
                        e.Graphics.DrawString(
                            item.Text,
                            font,
                            new SolidBrush(forecolor),
                            e.Bounds.Left + mp_ImageSize.Width,
                            e.Bounds.Top);
                        #endregion
                    }
                }
                else
                {
                    // it is not an ImageComboItem, draw it
                    e.Graphics.DrawString(this.Items[e.Index].ToString(), e.Font, new SolidBrush(e.ForeColor), e.Bounds.Left + mp_ImageSize.Width, e.Bounds.Top);
                }
            }

            base.OnDrawItem(e);
        }
예제 #5
0
 public void AddItem(ImageListItem imageListItem)
 {
     this.Items.Add(imageListItem);
 }