Beispiel #1
0
        protected override void OnPaint(PaintEventArgs e)
        {
            var G = e.Graphics;

            G.TextRenderingHint = TextRenderingHint.ClearTypeGridFit;
            G.SmoothingMode     = SmoothingMode.HighQuality;
            G.PixelOffsetMode   = PixelOffsetMode.HighQuality;
            G.Clear(_BaseColour);
            VSListBoxItem AllItems   = null;
            int           Offset     = Convert.ToInt32(VerticalScrollbar.Value * (VerticalScrollbar.Maximum + (Height - (ItemHeight))));
            int           StartIndex = 0;

            if (Offset == 0)
            {
                StartIndex = 0;
            }
            else
            {
                StartIndex = Convert.ToInt32(Offset / ItemHeight / VerticalScrollbar.Maximum);
            }
            int EndIndex = Math.Min(StartIndex + Convert.ToInt32(Math.Truncate((double)(Height / ItemHeight))), _Items.Count - 1);

            if (!_DontShowInnerScrollbarBorder && !_ShowWholeInnerBorder)
            {
                G.DrawLine(new Pen(_BorderColour, 2F), VerticalScrollbar.Location.X - 1, 0, VerticalScrollbar.Location.X - 1, Height);
            }
            for (int I = StartIndex; I < _Items.Count; I++)
            {
                AllItems = Items[I];
                int Y = ((I * ItemHeight) + 1 - Offset) + Convert.ToInt32((ItemHeight / 2.0) - 8);
                if (_SelectedItems.Contains(AllItems))
                {
                    G.FillRectangle(new SolidBrush(_SelectedItemColour), new Rectangle(0, (I * ItemHeight) + 1 - Offset, Width - 19, ItemHeight - 1));
                }
                else
                {
                    G.FillRectangle(new SolidBrush(_NonSelectedItemColour), new Rectangle(0, (I * ItemHeight) + 1 - Offset, Width - 19, ItemHeight - 1));
                }
                G.DrawLine(new Pen(_BorderColour), 0, ((I * ItemHeight) + 1 - Offset) + ItemHeight - 1, Width - 18, ((I * ItemHeight) + 1 - Offset) + ItemHeight - 1);
                if (G.MeasureString(AllItems.Text, new Font("Segoe UI", 8)).Width > (_SelectedWidth) - 30)
                {
                    G.DrawString(AllItems.Text, new Font("Segoe UI", 8), new SolidBrush(_FontColour), new Rectangle(7, Y, Width - 35, 15));
                    G.DrawString("...", new Font("Segoe UI", 8), new SolidBrush(_FontColour), new Rectangle(Width - 32, Y, 15, 15));
                }
                else
                {
                    G.DrawString(AllItems.Text, new Font("Segoe UI", 8), new SolidBrush(_FontColour), new Rectangle(7, Y, Width - 34, Y + 10));
                }
                G.ResetClip();
            }
            G.DrawRectangle(new Pen(Color.FromArgb(35, 35, 35), 2F), 1, 1, Width - 2, Height - 2);
            G.InterpolationMode = (InterpolationMode)7;
            if (_ShowWholeInnerBorder)
            {
                G.DrawLine(new Pen(_BorderColour, 2F), VerticalScrollbar.Location.X - 1, 0, VerticalScrollbar.Location.X - 1, Height);
            }
        }
Beispiel #2
0
        public void AddItem(string Items)
        {
            VSListBoxItem Item = new VSListBoxItem();

            Item.Text = Items;
            _Items.Add(Item);
            Invalidate();
            InvalidateScroll();
        }
Beispiel #3
0
 public void AddItems(string[] Items)
 {
     foreach (var I in Items)
     {
         VSListBoxItem Item = new VSListBoxItem();
         Item.Text = I;
         _Items.Add(Item);
     }
     Invalidate();
     InvalidateScroll();
 }
Beispiel #4
0
 public void RemoveItem(VSListBoxItem item)
 {
     _Items.Remove(item);
     Invalidate();
     InvalidateScroll();
 }