当前位置: 首页>>代码示例>>C#>>正文


C# TableLayoutPanel.CreateGraphics方法代码示例

本文整理汇总了C#中System.Windows.Forms.TableLayoutPanel.CreateGraphics方法的典型用法代码示例。如果您正苦于以下问题:C# TableLayoutPanel.CreateGraphics方法的具体用法?C# TableLayoutPanel.CreateGraphics怎么用?C# TableLayoutPanel.CreateGraphics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.TableLayoutPanel的用法示例。


在下文中一共展示了TableLayoutPanel.CreateGraphics方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitTableLayout

        // khởi tạo lưới khung
        public void InitTableLayout()
        {
            if (_tablelayout != null)
            {
                this.splitContainer2.Panel1.Controls.Remove(_tablelayout);
            }
            if (_mapController == null)
            {
                return;
            }
            else if (_mapController.TilesMap == null)
            {
                return;
            }
            int columns = this._mapController.TilesMap.Columns;
            int rows = this._mapController.TilesMap.Rows;
                _tablelayout = new TableLayoutPanel();

            _tablelayout.ColumnCount = columns;
            // khởi tạo ma trận index
            // khởi tạo cột
            Size tilesize = MainForm.Settings.TileSize;
            float columnsize = 100.0f / columns;
            for (int i = 0; i < columns; i++)
            {
                var columnstyle = new ColumnStyle(SizeType.Absolute, tilesize.Width - 1);
                _tablelayout.ColumnStyles.Add(columnstyle);
            }
            // khởi tạo dòng
            _tablelayout.RowCount = rows;
            float rowsize = 100.0f / rows;
            for (int i = 0; i < rows; i++)
            {
                var rowstyle = new RowStyle(SizeType.Absolute, tilesize.Height - 1);
                _tablelayout.RowStyles.Add(rowstyle);
            }

            _tablelayout.BackColor = Color.FromArgb(205, 205, 205);
            _tablelayout.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single;
            _tablelayout.Margin = new System.Windows.Forms.Padding(5);
            _tablelayout.Name = "map";

            _tablelayout.AutoSize = true;
            _tablelayout.Paint += _tablelayout_Paint;
            _tablelayout.MouseClick += TablelayoutMouseClick;
            this.splitContainer2.Panel1.Controls.Add(_tablelayout);
            this.splitContainer2.SplitterDistance = (int)(this.splitContainer2.Size.Height * 0.75);

            _tablelayout.MouseDown += TablelayoutMouseDown;
            _tablelayout.MouseUp += TablelayoutMouseUp;

            // Khởi tạo graphics.
            _graphics = _tablelayout.CreateGraphics();
            var context = BufferedGraphicsManager.Current;
            context.MaximumBuffer = _tablelayout.Size + new Size(1, 1);
            _buffergraphics = context.Allocate(_tablelayout.CreateGraphics(), new Rectangle(Point.Empty, _tablelayout.Size));

            this._mapController.Graphics = _buffergraphics.Graphics;
        }
开发者ID:7ung,项目名称:NMGAME,代码行数:60,代码来源:MainForm.cs


注:本文中的System.Windows.Forms.TableLayoutPanel.CreateGraphics方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。