Ejemplo n.º 1
0
        public virtual SizeF MeasureItem(IListControl parent, Graphics g, ImageComboItem item)
        {
            TextFormatFlags flags  = GetFlags(parent, item.Text);
            SizeF           sizeF1 = TextRenderer.MeasureText(g, item.Text, parent.Font, parent.ClientSize, flags);
            SizeF           sizeF2 = item.Image != null ? item.Image.Size : SizeF.Empty;

            if (sizeF1.Height < (double)parent.DefaultItemHeight)
            {
                sizeF1.Height = parent.DefaultItemHeight;
            }
            return(new SizeF(Math.Max(sizeF1.Width, sizeF2.Width),
                             Math.Max(Math.Max(sizeF1.Height, sizeF2.Height), parent.DefaultItemHeight)));
        }
Ejemplo n.º 2
0
        public ImageComboItem FindItemByTag(object tag, int startIndex)
        {
            ImageComboItem imageComboItem = null;

            for (int index = startIndex; index < Items.Count; ++index)
            {
                if (Items[index] is ImageComboItem && ((ImageComboItem)Items[index]).Tag == tag)
                {
                    imageComboItem = Items[index] as ImageComboItem;
                    break;
                }
            }
            return(imageComboItem);
        }
Ejemplo n.º 3
0
        public ImageComboItem FindItemByKey(string key, int startIndex)
        {
            ImageComboItem imageComboItem = null;

            for (int index = startIndex; index < Items.Count; ++index)
            {
                if (Items[index] is ImageComboItem && ((ImageComboItem)Items[index]).Key == key)
                {
                    imageComboItem = Items[index] as ImageComboItem;
                    break;
                }
            }
            return(imageComboItem);
        }
Ejemplo n.º 4
0
 protected override void OnMeasureItem(MeasureItemEventArgs e)
 {
     if (e.Index >= 0 && e.Index < Items.Count)
     {
         IListControlRenderer renderer       = GetRenderer();
         ImageComboItem       imageComboItem = GetItem(e.Index);
         if (imageComboItem != null)
         {
             SizeF sizeF = renderer.MeasureItem(this, e.Graphics, imageComboItem);
             e.ItemHeight = ImageList == null
                 ? (int)sizeF.Height + Padding.Vertical
                 : (int)Math.Max(sizeF.Height, ImageList.ImageSize.Height) + Padding.Vertical;
         }
     }
     base.OnMeasureItem(e);
 }
Ejemplo n.º 5
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            IListControlRenderer renderer       = GetRenderer();
            ImageComboItem       imageComboItem = e.Index >= 0
                ? (Items[e.Index] is ImageComboItem
                    ? (ImageComboItem)Items[e.Index]
                    : new ImageComboItem(Items[e.Index].ToString()))
                : new ImageComboItem(Text);
            var e1 = new ListControlDrawItemEventArgs(e, imageComboItem)
            {
                Image  = GetItemImage(imageComboItem),
                Offset = Padding.Left
            };

            renderer.DrawItemBackground(this, e1);
            renderer.DrawItemImage(this, e1);
            renderer.DrawItemText(this, e1);
        }
Ejemplo n.º 6
0
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            IListControlRenderer renderer       = GetRenderer();
            ImageComboItem       imageComboItem = GetItem(e.Index);
            var e1 = new ListControlDrawItemEventArgs(e, imageComboItem)
            {
                Image  = GetItemImage(imageComboItem),
                Offset = Padding.Left
            };

            if (HoverIndex == e.Index)
            {
                e1.State |= DrawItemState.HotLight;
            }
            renderer.DrawItemBackground(this, e1);
            renderer.DrawItemImage(this, e1);
            renderer.DrawItemText(this, e1);
        }
Ejemplo n.º 7
0
 public ListControlDrawItemEventArgs(DrawItemEventArgs e, ImageComboItem item)
     : base(e.Graphics, e.Font, e.Bounds, e.Index, e.State, e.ForeColor, e.BackColor)
 {
     Item  = item;
     State = e.State;
 }
Ejemplo n.º 8
0
 protected virtual Image GetItemImage(ImageComboItem item)
 {
     return(item.GetImage(ImageList));
 }