本文整理汇总了C#中System.Windows.Forms.GroupBox.CreateGraphics方法的典型用法代码示例。如果您正苦于以下问题:C# GroupBox.CreateGraphics方法的具体用法?C# GroupBox.CreateGraphics怎么用?C# GroupBox.CreateGraphics使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.GroupBox
的用法示例。
在下文中一共展示了GroupBox.CreateGraphics方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawMaze
public void DrawMaze(GroupBox canvas)
{
Pen myPen = new System.Drawing.Pen(Color.Red);
SolidBrush mBrush = new SolidBrush(Color.LawnGreen);
Graphics fGraphics = canvas.CreateGraphics();
fGraphics.Clear(Color.Gray);
Random rand = new Random();
startPosition = new Point(rand.Next(0, width), rand.Next(0, height));
finalDestination = new Point(rand.Next(0, width), rand.Next(0, height));
int size = 20;
for (int i = 0; i < width; i++)
{
for (int j = 0; j < height; j++)
{
MazeCell currCell = maze[i][j];
if (currCell.North == null)
fGraphics.DrawLine(myPen, i * size, j * size, (i + 1) * size, j * size);
if (currCell.South == null)
fGraphics.DrawLine(myPen, i * size, (j + 1) * size, (i + 1) * size, (j + 1) * size);
if (currCell.East == null)
fGraphics.DrawLine(myPen, (i + 1) * size, j * size, (i + 1) * size, (j + 1) * size);
if (currCell.West == null)
fGraphics.DrawLine(myPen, i * size, j * size, i * size, (j + 1) * size);
}
}
//drawing startin and ending point
fGraphics.FillRectangle(mBrush, startPosition.X * size + size / 2, startPosition.Y * size + size / 2, size / 2, size / 2);
mBrush.Color = Color.SteelBlue;
fGraphics.FillRectangle(mBrush, finalDestination.X * size + size / 2, finalDestination.Y * size + size / 2, size / 2, size / 2);
myPen.Dispose();
fGraphics.Dispose();
mBrush.Dispose();
}