コード例 #1
0
        protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs e)
        {
            base.OnDrawItem(e);

            e.DrawBackground();
            e.DrawFocusRectangle();

            if (e.Index < 0)
            {
                return;
            }

            if (!(this.Items[e.Index] is ImageComboItem))
            {
                e.Graphics.DrawString(Items[e.Index].ToString(), e.Font, new SolidBrush(e.ForeColor), e.Bounds.Left, e.Bounds.Top);
                return;
            }

            ImageComboItem CurrItem = this.Items[e.Index] as ImageComboItem;
            SizeF          fontSize = e.Graphics.MeasureString(CurrItem.Text, CurrItem.Font);
            SolidBrush     brush    = new SolidBrush(CurrItem.ForeColor);
            int            imageX   = e.Bounds.Left;

            if (CurrItem.Text != string.Empty && CurrItem.TextAlign == EImageComboItemTextAlign.Left)
            {
                e.Graphics.DrawString(CurrItem.Text, CurrItem.Font, brush, e.Bounds.Left, e.Bounds.Top + (mImageList.ImageSize.Height / 2) - fontSize.Height / 2);
            }

            if (mImageList != null && CurrItem.ImageIndex != -1)
            {
                if (CurrItem.TextAlign == EImageComboItemTextAlign.Left)
                {
                    imageX += (int)fontSize.Width + 7;
                }

                if (mImagePlace > imageX)
                {
                    imageX = mImagePlace;
                }
                ImageList.Draw(e.Graphics, imageX, e.Bounds.Top, CurrItem.ImageIndex);
            }

            if (CurrItem.Text != string.Empty && CurrItem.TextAlign == EImageComboItemTextAlign.Right)
            {
                imageX += ImageList.ImageSize.Width + 7;
                e.Graphics.DrawString(CurrItem.Text, CurrItem.Font, brush, imageX, e.Bounds.Top + (mImageList.ImageSize.Height / 2) - fontSize.Height / 2);
            }
        }
コード例 #2
0
        public LapiImageComboBox()
            : base()
        {
            if (Lapis == null)
            {
                Lapis = new LapiCollection();
                BuildLapiList();
            }

            // empty_slot
            Items.Add(new ImageComboItem("", Font, System.Drawing.Color.Black, 0, EImageComboItemTextAlign.Right));
            // fill Combolist with Lapi Images
            foreach (Lapi lapi in Lapis)
            {
                ImageComboItem i = new ImageComboItem("", Font, System.Drawing.Color.Black, lapi.ToImageIndex() + 1, EImageComboItemTextAlign.Right);
                i.Tag = lapi;
                Items.Add(i);
            }
        }
コード例 #3
0
        public LapiComboBox()
            : base()
        {
            if (Lapis == null)
            {
                Lapis = new LapiCollection();
                BuildLapiList();
            }

            //Items.Add( new ImageComboItem( "freier Sockel", Font, System.Drawing.Color.Black, 0, EImageComboItemTextAlign.Right ) );
            // fill Combolist with Lapis
            foreach (Lapi lapi in Lapis)
            {
                ImageComboItem i = new ImageComboItem(lapi.ToName(), Font, System.Drawing.Color.Black, lapi.ToImageIndex() + 1, EImageComboItemTextAlign.Right);
                i.Tag = lapi;
                Items.Add(i);
            }

            SelectedIndexChanged += new EventHandler(LapiComboBox_SelectedIndexChanged);
        }