using System.Windows.Forms;
using System.Drawing;
using FastReport.Utils;
using System.ComponentModel;

namespace FastReport.Controls
{
#if !DEBUG
    [DesignTimeVisible(false)]
#endif
    internal class BandComboBox : ComboBox
    {
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            e.DrawBackground();
            if (e.Index >= 0)
            {
                BandBase c = Items[e.Index] as BandBase;
                Image img = this.GetImage(c == null ? 76 : RegisteredObjects.FindObject(c).ImageIndex);
                string text = "";
                if (c == null)
                    text = Res.Get("Misc,None");
                else
                {
                    text = c.Name;
                    if (c is DataBand)
                        text += ": " + c.GetInfoText();
                    else if (c is DataFooterBand)
                        text += ": " + c.DataBand.GetInfoText();
                    else if (c is GroupFooterBand)
                        text += ": " + (c.Parent as GroupHeaderBand).GetInfoText();
                }

                this.DrawImageAndText(e, img, text);
            }
        }

        public BandComboBox()
        {
            DrawMode = DrawMode.OwnerDrawFixed;
        }
    }
}
