本文整理匯總了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();
}