Esempio n. 1
0
        private void Drawable_Paint(object sender, PaintEventArgs e)
        {
            var g = e.Graphics;

            DrawInfo.SetPixelsPerPoint(g);
            var    rec          = new Rectangle(0, 0, drawable.Width - 1, DrawInfo.TextHeight + _spacing);
            var    overGroup    = false;
            string prevCategory = null;

            _separatorPos = Math.Min(Width - _separatorSafeDistance, Math.Max(_separatorSafeDistance, _separatorPos));
            _selectedCell = null;

            g.Clear(DrawInfo.BackColor);

            if (_cells.Count == 0)
            {
                if (_height != 10)
                {
                    drawable.Height = _height = 10;
                }

                return;
            }

            // Draw separator for not filled rows
            g.FillRectangle(DrawInfo.BorderColor, _separatorPos - 1, 0, 1, Height);

            foreach (var c in _cells)
            {
                rec.Height = c.Height + _spacing;

                // Draw group
                if (prevCategory != c.Category)
                {
                    if (c.Category.Contains("Proc") || Group)
                    {
                        DrawGroup(g, rec, c.Category);
                        prevCategory = c.Category;
                        overGroup   |= rec.Contains(_mouseLocation);
                        rec.Y       += DrawInfo.TextHeight + _spacing;
                    }
                }

                // Draw cell
                var selected = rec.Contains(_mouseLocation);
                if (selected)
                {
                    _selectedCell = c;
                }
                c.Draw(g, rec, _separatorPos, selected);

                // Draw separator for the current row
                g.FillRectangle(DrawInfo.BorderColor, _separatorPos - 1, rec.Y, 1, rec.Height);

                rec.Y += c.Height + _spacing;
            }

            if (_height != rec.Y + 1)
            {
                drawable.Height = _height = rec.Y + 1;
                SetWidth();
            }

            if (overGroup) // TODO: Group collapsing/expanding?
            {
                SetCursor(CursorType.Default);
            }
            else if ((new Rectangle(_separatorPos - _separatorWidth / 2, 0, _separatorWidth, Height)).Contains(_mouseLocation))
            {
                SetCursor(CursorType.VerticalSplit);
            }
            else
            {
                SetCursor(CursorType.Default);
            }
        }