SurDataGrid.cs 24.0 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Drawing.Drawing2D;

namespace Asa.Face
{
    /// <summary>
    /// 数据表格控件
    /// </summary>
    [DefaultProperty("Text")]
    [DefaultEvent("Click")]
    public partial class SurDataGrid : BaseCtl
    {
        private SurHScrollBar hsb = new SurHScrollBar();
        private SurVScrollBar vsb = new SurVScrollBar();
        private bool _scrollBoth = false;

        private List<ColType> _column = new List<ColType>();  //列
        private List<RowType> _row = new List<RowType>();     //行
        private List<List<string>> _content = new List<List<string>>();   //内容文本
        private List<Line> _inside = new List<Line>();        //内部画线
        private List<Rectangle> _insideBack = new List<Rectangle>();
        private List<List<RectangleF>> _insidePlace = new List<List<RectangleF>>();  //内部文本
        private Rectangle[] _headBack;   //标题背景
        
        private float _colStep = 0;
        private int _colHeadHeight = 20;
        private bool _colHeadVisible = true;
        private List<Line> _colHeadLine = new List<Line>();
        private List<RectangleF> _colHeadPlace = new List<RectangleF>();

        private float _rowStep = 0;
        private int _rowHeadWidth = 40;
        private bool _rowHeadVisible = true;
        private List<Line> _rowHeadLine = new List<Line>();
        private List<RectangleF> _rowHeadPlace = new List<RectangleF>();

        private static readonly Pen GRID_PEN = new Pen(Common.BORDER_COLOR, 1);
        private static readonly Font HEADER_FONT = new Font("宋体", 12f, FontStyle.Bold);
        private static readonly Font CONTENT_FONT = new Font("宋体", 9f);
        private static readonly Brush HEAD_BRUSH = new SolidBrush(Color.FromArgb(40, 40, 40));
        //private static readonly Brush ROW_1 = new SolidBrush(Color.FromArgb(10, 10, 10));
        //private static readonly Brush ROW_2 = new SolidBrush(Color.FromArgb(30, 30, 30));


        /// <summary>
        /// 数据表格控件
        /// </summary>
        public SurDataGrid()
        {
            InitializeComponent();
            MouseWheel += SurDataGrid_MouseWheel;

            vsb.Left = Width - BorderWidth - vsb.Width + 1;
            vsb.Top = BorderWidth;
            vsb.Height = Height - BorderWidth - BorderWidth + 1;
            vsb.Anchor = AnchorStyles.Top | AnchorStyles.Right | AnchorStyles.Bottom;
            vsb.Minimum = 0;
            vsb.Maximum = 10;
            vsb.Visible = false;
            vsb.MouseEnter += Vsb_MouseEnter;
            vsb.MouseLeave += Vsb_MouseLeave;
            vsb.ValueChanged += Vsb_ValueChanged;
            Controls.Add(vsb);

            hsb.Left = BorderWidth;
            hsb.Top = Height - BorderWidth - hsb.Height + 1;
            hsb.Width = Width - BorderWidth - BorderWidth;
            hsb.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;
            hsb.Minimum = 0;
            hsb.Maximum = 10;
            hsb.Visible = false;
            hsb.MouseEnter += Hsb_MouseEnter;
            hsb.MouseLeave += Hsb_MouseLeave;
            hsb.ValueChanged += Hsb_ValueChanged;
            Controls.Add(hsb);


        }


        //==========属性==========
        /// <summary>
        /// 列标题单元格的标题文本
        /// </summary>
        [Browsable(false), Category(""), Description("列标题单元格的标题文本")]
        public string[] HeaderText { set; get; }

        /// <summary>
        /// 列标题的高度
        /// </summary>
        [Browsable(true), Category(""), Description("列标题的高度"), DefaultValue(20)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public int ColumnHeadersHeight
        {
            set
            {
                _colHeadHeight = value;
                CalcSize();
                Refresh();
            }
            get => _colHeadHeight;
        }

        /// <summary>
        /// 是否显示列标题
        /// </summary>
        [Browsable(true), Category(""), Description("是否显示列标题"), DefaultValue(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public bool ColumnHeadersVisible
        {
            set
            {
                _colHeadVisible = value;
                CalcSize();
                Refresh();
            }
            get => _colHeadVisible;
        }

        /// <summary>
        /// 行标题的宽度
        /// </summary>
        [Browsable(true), Category(""), Description("行标题的宽度"), DefaultValue(40)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public int RowHeadersWidth
        {
            set
            {
                _rowHeadWidth = value;
                CalcSize();
                Refresh();
            }
            get => _rowHeadWidth;
        }

        /// <summary>
        /// 是否显示行标题
        /// </summary>
        [Browsable(true), Category(""), Description("是否显示行标题"), DefaultValue(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public bool RowHeadersVisible
        {
            set
            {
                _rowHeadVisible = value;
                CalcSize();
                Refresh();
            }
            get => _rowHeadVisible;
        }


        //==========方法==========
        /// <summary>
        /// 添加列
        /// </summary>
        /// <param name="count"></param>
        public void AddColumn(int count)
        {
            if (count < 1) return;
            for (int i = 0; i < count; i++)
            {
                ColType col = new ColType();
                _column.Add(col);
            }
            string[] s = new string[count];
            for (int i = 0; i < _content.Count; i++)
                _content[i].AddRange(s);
            CalcSize();
            Refresh();
        }

        /// <summary>
        /// 添加列
        /// </summary>
        /// <param name="index"></param>
        /// <param name="count"></param>
        public void AddColumn(int index, int count)
        {
            if (count < 1) return;
            if (index < 0 || index >= _column.Count) return;

            for (int i = 0; i < count; i++)
            {
                ColType col = new ColType();
                _column.Insert(index + i, col);
            }
            string[] s = new string[count];
            for (int i = 0; i < _content.Count; i++)
                _content[i].InsertRange(index, s);
            CalcSize();
            Refresh();
        }

        /// <summary>
        /// 添加列
        /// </summary>
        /// <param name="text"></param>
        public void AddColumn(params string[] text)
        {
            if (text == null) return;
            for (int i = 0; i < text.Length; i++)
            {
                ColType col = new ColType(text[i]);
                _column.Add(col);
            }
            string[] s = new string[text.Length];
            for (int i = 0; i < _content.Count; i++)
                _content[i].AddRange(s);
            CalcSize();
            Refresh();
        }

        /// <summary>
        /// 添加列
        /// </summary>
        /// <param name="text"></param>
        /// <param name="width"></param>
        public void AddColumn(string text, int width)
        {
            if (text == null) return;
            ColType col = new ColType(text, width);
            _column.Add(col);
            for (int i = 0; i < _content.Count; i++)
                _content[i].Add("");
            CalcSize();
            Refresh();
        }

        /// <summary>
        /// 添加列
        /// </summary>
        /// <param name="index"></param>
        /// <param name="text"></param>
        public void AddColumn(int index, params string[] text)
        {
            if (text == null) return;
            if (index < 0 || index >= _column.Count) return;

            for (int i = 0; i < text.Length; i++)
            {
                ColType col = new ColType(text[i]);
                _column.Insert(index + i, col);
            }
            string[] s = new string[text.Length];
            for (int i = 0; i < _content.Count; i++)
                _content[i].InsertRange(index, s);
            CalcSize();
            Refresh();
        }

        /// <summary>
        /// 移除列
        /// </summary>
        /// <param name="index"></param>
        public void RemoveColumn(int index)
        {
            if (index >= 0 && index < _column.Count)
            {
                _column.RemoveAt(index);
                for (int i = 0; i < _content.Count; i++)
                    _content[i].RemoveAt(index);
                CalcSize();
                Refresh();
            }
        }

        /// <summary>
        /// 移除列
        /// </summary>
        /// <param name="index"></param>
        /// <param name="count"></param>
        public void RemoveColumn(int index, int count)
        {
            if (index >= 0 && index < _column.Count)
            {
                if (index + count > _column.Count)
                    count = _column.Count - index;
                _column.RemoveRange(index, count);
                for (int i = 0; i < _content.Count; i++)
                    _content[i].RemoveRange(index, count);
                CalcSize();
                Refresh();
            }
        }

        /// <summary>
        /// 添加行
        /// </summary>
        /// <param name="content"></param>
        public void AddRow(params string[] content)
        {
            List<string> item = new List<string>(content);
            if (item.Count > _column.Count)
            {
                for (int i = item.Count; i > _column.Count; i--)
                    item.RemoveAt(i - 1);
            }
            else if (item.Count < _column.Count)
            {
                for (int i = item.Count; i < _column.Count; i++)
                    item.Add("");
            }

            _content.Add(item);
            RowType row = new RowType((_row.Count + 1).ToString());
            _row.Add(row);
            CalcSize();
            Refresh();
        }

        /// <summary>
        /// 添加行
        /// </summary>
        /// <param name="content"></param>
        public void AddRow(string[][] content)
        {
            for (int j = 0; j < content.Length; j++)
            {
                List<string> item = new List<string>(content[j]);
                if (item.Count > _column.Count)
                {
                    for (int i = item.Count; i > _column.Count; i--)
                        item.RemoveAt(i - 1);
                }
                else if (item.Count < _column.Count)
                {
                    for (int i = item.Count; i < _column.Count; i++)
                        item.Add("");
                }

                _content.Add(item);
                RowType row = new RowType((_row.Count + 1).ToString());
                _row.Add(row);
            }




            CalcSize();
            Refresh();
        }

        /// <summary>
        /// 添加行
        /// </summary>
        /// <param name="index"></param>
        /// <param name="content"></param>
        public void AddRow(int index, params string[] content)
        {
            List<string> item = new List<string>(content);
            if (item.Count > _column.Count)
            {
                for (int i = item.Count; i > _column.Count; i--)
                    item.RemoveAt(i - 1);
            }
            else if (item.Count < _column.Count)
            {
                for (int i = item.Count; i < _column.Count; i++)
                    item.Add("");
            }

            _content.Insert(index, item);
            RowType row = new RowType((index + 1).ToString());
            _row.Insert(index, row);
            for (int i = index + 1; i < _row.Count; i++)
                _row[i].Text = (index + 1).ToString();
            CalcSize();
            Refresh();
        }

        /// <summary>
        /// 移除行
        /// </summary>
        /// <param name="index"></param>
        public void RemoveRow(int index)
        {
            _content.RemoveAt(index);
            _row.RemoveAt(index);
            CalcSize();
            Refresh();
        }

        /// <summary>
        /// 移除行
        /// </summary>
        public void RemoveAll()
        {
            _content.Clear();
            _row.Clear();
            CalcSize();
            Refresh();
        }

        //==========私有==========
        /// <summary>
        /// 计算位置大小
        /// </summary>
        protected override void CalcSize()
        {
            base.CalcSize();
            _colHeadLine.Clear();
            _rowHeadLine.Clear();
            _inside.Clear();
            _colHeadPlace.Clear();
            _rowHeadPlace.Clear();
            _insidePlace.Clear();
            _insideBack.Clear();
            _headBack = new Rectangle[2];
            Graphics g = CreateGraphics();
            SizeF sf;

            int y0 = (_colHeadVisible ? _colHeadHeight : 0) + BorderWidth;
            int x0 = (_rowHeadVisible ? _rowHeadWidth : 0) + BorderWidth;
            int showX = Width - x0 - BorderWidth;
            int showY = Height - y0 - BorderWidth;
            int sumX = x0;
            int sumY = y0;

            for (int i = 0; i < _column.Count; i++)
            {
                if (_colHeadVisible)
                {
                    sf = g.MeasureString(_column[i].Text, HEADER_FONT);
                    _colHeadPlace.Add(new RectangleF(sumX + 3, BorderWidth + (_colHeadHeight - sf.Height) / 2f, sf.Width, sf.Height));
                    sumX += _column[i].Width;
                    _colHeadLine.Add(new Line(sumX, BorderWidth, sumX, y0));
                }
                else
                {
                    sumX += _column[i].Width;
                }
            }

            for (int i = 0; i < _row.Count; i++)
            {
                if (_rowHeadVisible)
                {
                    sf = g.MeasureString(_row[i].Text, HEADER_FONT);
                    _rowHeadPlace.Add(new RectangleF(BorderWidth + 3, sumY + (_row[i].Height - sf.Height) / 2f, sf.Width, sf.Height));
                    sumY += _row[i].Height;
                    _rowHeadLine.Add(new Line(BorderWidth, sumY, x0, sumY));
                }
                else
                {
                    sumY += _row[i].Height;
                }
            }

            //滚动条
            if (sumY > Height - BorderWidth)
            {
                vsb.Visible = true;
            }
            else
            {
                vsb.Visible = false;
                vsb.Value = 0;
                hsb.Width = Width - BorderWidth - BorderWidth - 1;
                _scrollBoth = false;
            }
            if (sumX > Width - BorderWidth)
            {
                hsb.Visible = true;
            }
            else
            {
                hsb.Visible = false;
                hsb.Value = 0;
                hsb.Width = Width - BorderWidth - BorderWidth - 1;
                _scrollBoth = false;
            }
            if (vsb.Visible)
            {
                int n = sumY - y0 - showY + (hsb.Visible ? hsb.Height : 0);
                vsb.Maximum = Convert.ToInt32(Math.Ceiling(n / 10f));
                _rowStep = (float)n / vsb.Maximum;
            }
            if (hsb.Visible)
            {
                int m = sumX - x0 - showX + (vsb.Visible ? vsb.Width : 0);
                hsb.Maximum = Convert.ToInt32(Math.Ceiling(m / 10f));
                _colStep = (float)m / hsb.Maximum;
            }
            if (vsb.Visible && hsb.Visible && !_scrollBoth)
            {
                _scrollBoth = true;
                hsb.Width -= vsb.Width;
            }


            if (_colHeadVisible)
            {
                _colHeadLine.Add(new Line(BorderWidth, y0, sumX, y0));
                _headBack[0] = new Rectangle(BorderWidth, BorderWidth, sumX - BorderWidth, _colHeadHeight);
            }
            else
            {
                _headBack[0] = new Rectangle();
            }
            if (_rowHeadVisible)
            {
                _rowHeadLine.Add(new Line(x0, BorderWidth, x0, sumY));
                _headBack[1] = new Rectangle(BorderWidth, BorderWidth, _rowHeadWidth, sumY - BorderWidth);
            }
            else
            {
                _headBack[1] = new Rectangle();
            }

            int x = x0;
            int y = y0;
            for (int i = 0; i < _row.Count; i++)
            {
                _insideBack.Add(new Rectangle(x0, y, sumX - x0, _row[i].Height));
                y += _row[i].Height;
                _inside.Add(new Line(x0, y, sumX, y));
            }
            for (int i = 0; i < _column.Count; i++)
            {
                x += _column[i].Width;
                _inside.Add(new Line(x, y0, x, sumY));
            }

            y = y0;
            for (int i = 0; i < _content.Count; i++)
            {
                x = x0;
                List<RectangleF> item = new List<RectangleF>();
                for (int j = 0; j < _content[i].Count; j++)
                {
                    sf = g.MeasureString(_content[i][j], CONTENT_FONT);
                    //item.Add(new RectangleF(x + 3, y + (_row[i].Height - sf.Height) / 2, sf.Width, sf.Height));
                    item.Add(new RectangleF(x + 3, y + (_row[i].Height - sf.Height) / 2, _column[j].Width, sf.Height));
                    x += _column[j].Width;
                }
                _insidePlace.Add(item);
                y += _row[i].Height;
            }






        }

        private void SurDataGrid_MouseClick(object sender, MouseEventArgs e)
        {

        }

        private void SurDataGrid_MouseDown(object sender, MouseEventArgs e)
        {

        }

        private void SurDataGrid_MouseMove(object sender, MouseEventArgs e)
        {

        }

        private void SurDataGrid_MouseUp(object sender, MouseEventArgs e)
        {

        }

        private void SurDataGrid_Paint(object sender, PaintEventArgs e)
        {
            BufferedGraphicsContext current = BufferedGraphicsManager.Current;
            BufferedGraphics bg = current.Allocate(e.Graphics, e.ClipRectangle);
            Graphics g = bg.Graphics;
            g.SmoothingMode = SmoothingMode.HighQuality;
            g.CompositingQuality = CompositingQuality.HighQuality;
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.Clear(Common.BACK_COLOR);  //背景

            float offsetX = 0, offsetY = 0;
            if (vsb.Visible)
                offsetY = _rowStep * vsb.Value;  //偏移
            if (hsb.Visible)
                offsetX = _colStep * hsb.Value;  //偏移



            //内部背景
            for (int i = 0; i < _insideBack.Count; i++)
            {
                g.FillRectangle((i % 2 == 0 ? Common.ITEM_ROW1_BRUSH : Common.ITEM_ROW2_BRUSH), _insideBack[i].X - offsetX, _insideBack[i].Y - offsetY, _insideBack[i].Width, _insideBack[i].Height);
            }

            //内部画线
            for (int i = 0; i < _inside.Count; i++)
                g.DrawLine(GRID_PEN, _inside[i].Head.X - offsetX, _inside[i].Head.Y - offsetY, _inside[i].End.X - offsetX, _inside[i].End.Y - offsetY);
            StringFormat format = new StringFormat(StringFormatFlags.NoClip);
            for (int i = 0; i < _insidePlace.Count; i++)
            {
                for (int j = 0; j < _insidePlace[i].Count; j++)
                {
                    if (_insidePlace[i][j].X - offsetX > _rowHeadWidth / 2 &&
                        _insidePlace[i][j].Y - offsetY > _colHeadHeight / 2)
                        g.DrawString(_content[i][j], CONTENT_FONT, Common.FORE_BRUSH, new RectangleF(_insidePlace[i][j].X - offsetX, _insidePlace[i][j].Y - offsetY, _insidePlace[i][j].Width, _insidePlace[i][j].Height), format);
                }
            }

            //标题背景
            if (_headBack != null)
            {
                g.FillRectangle(HEAD_BRUSH, _headBack[0]);
                g.FillRectangle(HEAD_BRUSH, _headBack[1]);
            }

            //标题画线
            if (_colHeadVisible)
            {
                for (int i = 0; i < _colHeadLine.Count; i++)
                    g.DrawLine(GRID_PEN, _colHeadLine[i].Head.X - offsetX, _colHeadLine[i].Head.Y, _colHeadLine[i].End.X - offsetX, _colHeadLine[i].End.Y);
                for (int i = 0; i < _colHeadPlace.Count; i++)
                {
                    if (_colHeadPlace[i].X - offsetX > _rowHeadWidth / 2)
                        g.DrawString(_column[i].Text, HEADER_FONT, Common.FORE_BRUSH, _colHeadPlace[i].X - offsetX, _colHeadPlace[i].Y);
                }
            }
            if (_rowHeadVisible)
            {
                for (int i = 0; i < _rowHeadLine.Count; i++)
                    g.DrawLine(GRID_PEN, _rowHeadLine[i].Head.X, _rowHeadLine[i].Head.Y - offsetY, _rowHeadLine[i].End.X, _rowHeadLine[i].End.Y - offsetY);
                for (int i = 0; i < _rowHeadPlace.Count; i++)
                {
                    if (_rowHeadPlace[i].Y - offsetY > _colHeadHeight / 2)
                        g.DrawString(_row[i].Text, HEADER_FONT, Common.FORE_BRUSH, _rowHeadPlace[i].X, _rowHeadPlace[i].Y - offsetY);
                }
            }
            g.FillRectangle(HEAD_BRUSH, BorderWidth, BorderWidth, _rowHeadWidth, _colHeadHeight);

            //控件边框
            if (Inside && Enabled)
            {
                if (BorderWidth > 0)
                    g.DrawRectangle(BorderInsidePen, BorderRect);
            }
            else
            {
                if (BorderWidth > 0)
                    g.DrawRectangle(BorderOutsidePen, BorderRect);
            }

            bg.Render();
            bg.Dispose();
        }

        private void SurDataGrid_MouseWheel(object sender, MouseEventArgs e)
        {
            if (!Enabled) return;
            if (e.Delta > 0)
                vsb.Value--;
            else
                vsb.Value++;
        }

        private void Vsb_MouseLeave(object sender, EventArgs e)
        {
            vsb.Inside = false;
        }

        private void Vsb_MouseEnter(object sender, EventArgs e)
        {
            vsb.Inside = true;
        }

        private void Vsb_ValueChanged(object sender)
        {
            Refresh();
        }

        private void Hsb_MouseLeave(object sender, EventArgs e)
        {
            hsb.Inside = false;
        }

        private void Hsb_MouseEnter(object sender, EventArgs e)
        {
            hsb.Inside = true;
        }

        private void Hsb_ValueChanged(object sender)
        {
            Refresh();
        }





        private class Line
        {
            public Point Head;
            public Point End;

            public Line(int x1, int y1, int x2, int y2)
            {
                Head = new Point(x1, y1);
                End = new Point(x2, y2);
            }
        }

        private class ColType
        {
            /// <summary>
            /// 列标题文本
            /// </summary>
            public string Text = "";
            /// <summary>
            /// 列宽度
            /// </summary>
            public int Width = 80;

            public ColType()
            { }

            public ColType(string text)
            {
                Text = text;
            }

            public ColType(string text, int width)
            {
                Text = text;
                Width = width;
            }
        }

        private class RowType
        {
            /// <summary>
            /// 标题文本
            /// </summary>
            public string Text = "";
            /// <summary>
            /// 高度
            /// </summary>
            public int Height = 25;

            public RowType()
            { }
            
            public RowType(string text)
            {
                Text = text;
            }
        }


    }
}