예제 #1
0
        protected override void OnPaint(PaintEventArgs aPArgs)
        {
            _updateScroll();

            Graphics lGraphics = aPArgs.Graphics;

            lGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
            int lY   = _HeaderHeight - _Offset;
            int lTop = 0;

            Pen   lPen       = new Pen(Color.Black, 2);
            Brush lBrush     = new SolidBrush(this.BackColor);
            Brush lEvenRow   = new SolidBrush(Graph.ColorTools.SetAlpha(80, Color.White));
            Brush lTextBrush = new SolidBrush(Color.Black);

            lGraphics.FillRectangle(lBrush, 0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height);

            if (_items != null && _items.Count > 0)
            {
                for (int i = 0; i < _items.Count; i++)
                {
                    if (i == _highlighted)
                    {
                        lGraphics.FillRectangle(lEvenRow, 0, lY, this.ClientRectangle.Width, _rowHeight);
                    }

                    CPasswdEditorItem iItem = _items[i];

                    if (_imgList != null)
                    {
                        Image img = iItem.IconIndex < _imgList.Images.Count ? _imgList.Images[iItem.IconIndex] : _imgList.Images[0];

                        lTop = (_rowHeight - img.Height) / 2;
                        lGraphics.DrawImage(img, 32, lY + lTop);
                    }

                    lTop = (_rowHeight - (int)(lGraphics.MeasureString(iItem.Service, this.Font).Height)) / 2;

                    lGraphics.DrawString(
                        iItem.Service,
                        this.Font,
                        lTextBrush,
                        32 + _imgList.ImageSize.Width + 8,
                        lY + lTop
                        );

                    lY += _rowHeight;
                }
                lBrush = new SolidBrush(this.BackColor);

                lGraphics.FillRectangle(lBrush, 0, 0, ClientRectangle.Width, _HeaderHeight);
                lGraphics.DrawLine(lPen, 0, _HeaderHeight, this.ClientRectangle.Width, _HeaderHeight);
            }
            else
            {
                lGraphics.DrawString(_noItemMsg, this.Font, lTextBrush, 32, 48);
            }
        }
예제 #2
0
 public void Remove(CPasswdEditorItem aItem)
 {
     if (_items.IndexOf(aItem) > -1)
     {
         aItem.Parent = null;
         _refreshEditor();
     }
     if (Change != null)
     {
         Change(this, null);
     }
 }
예제 #3
0
 public void Add(CPasswdEditorItem aItem)
 {
     if (_items.IndexOf(aItem) < 0)
     {
         _items.Add(aItem);
         aItem.Parent = this;
         _refreshEditor();
     }
     if (Change != null)
     {
         Change(this, null);
     }
 }