コード例 #1
0
ファイル: ImageListBox.cs プロジェクト: windygu/AW-master
        /// <summary>
        /// Overrides parent OnDrawItem method to perform custom painting
        /// </summary>
        /// <param name="pe"></param>
        protected override void OnDrawItem(System.Windows.Forms.DrawItemEventArgs pe)
        {
            pe.DrawBackground();
            pe.DrawFocusRectangle();
            Rectangle bounds = pe.Bounds;

            // Check whether the index is valid
            if (pe.Index >= 0 && pe.Index < base.Items.Count)
            {
                ImageListBoxItem item = (ImageListBoxItem)base.Items[pe.Index];
                int iOffset           = 0;
                // If the image list is present and the image index is set, draw the image
                if (this.imageList != null)
                {
                    if (item.ImageIndex != -1 && item.ImageIndex < this.imageList.Images.Count)
                    {
                        this.imageList.Draw(pe.Graphics, bounds.Left, bounds.Top, item.ImageIndex);
                    }
                    iOffset += this.imageList.ImageSize.Width;
                }
                // Draw item text
                pe.Graphics.DrawString(item.Text, pe.Font, new SolidBrush(pe.ForeColor),
                                       bounds.Left + iOffset, bounds.Top);
            }
            base.OnDrawItem(pe);
        }
コード例 #2
0
ファイル: ImageListBox.cs プロジェクト: windygu/AW-master
 private int DoInsertItem(int index, ImageListBoxItem item)
 {
     item.imageList = this.imageList;
     item.itemIndex = index;
     base.Items.Insert(index, item);
     return(index);
 }
コード例 #3
0
ファイル: ImageListBox.cs プロジェクト: windygu/AW-master
 private void DoSetElement(int index, ImageListBoxItem value)
 {
     base.Items[index] = value;
 }
コード例 #4
0
ファイル: ImageListBox.cs プロジェクト: windygu/AW-master
 public int Add(ImageListBoxItem item)
 {
     return(owner.DoInsertItem(this.Count, item));
 }
コード例 #5
0
ファイル: ImageListBox.cs プロジェクト: windygu/AW-master
 public void Insert(int index, ImageListBoxItem item)
 {
     owner.DoInsertItem(index, item);
 }
コード例 #6
0
ファイル: ImageListBox.cs プロジェクト: windygu/AW-master
 public void Remove(ImageListBoxItem item)
 {
     throw new NotSupportedException();
 }