本文整理汇总了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;
}