本文整理汇总了C#中Canvas.SetBorder方法的典型用法代码示例。如果您正苦于以下问题:C# Canvas.SetBorder方法的具体用法?C# Canvas.SetBorder怎么用?C# Canvas.SetBorder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Canvas
的用法示例。
在下文中一共展示了Canvas.SetBorder方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Decorate
public void Decorate(Canvas embroidery, Canvas pattern, Settings settings)
{
int squareWidth = embroidery.Width / settings.CellsCount;
if (embroidery.Height < pattern.Height * squareWidth)
throw new WrongResolutionException("Resolution.Height has to be higher");
for (int squareY = 0; squareY <= embroidery.Height - squareWidth; squareY += squareWidth)
for (int squareX = 0; squareX <= embroidery.Width - squareWidth; squareX += squareWidth)
{
embroidery.SetBorder(squareX, squareY, squareWidth, squareWidth, Color.Black, Aligns.Right, settings.GridType);
embroidery.SetBorder(squareX, squareY, squareWidth, squareWidth, Color.Black, Aligns.Buttom, settings.GridType);
}
/*
* LONGER THAN SIMPLE FOR
var loopsHeight = Enumerable.Range(0, embroidery.Height - squareWidth + 1).Where(i => i % squareWidth == 0);
var loopsWidth = Enumerable.Range(0, embroidery.Width - squareWidth + 1).Where(i => i % squareWidth == 0);
Parallel.ForEach(loopsHeight, squareY =>
{
Parallel.ForEach(loopsWidth, squareX =>
{
embroidery.SetBorder(squareX, squareY, squareWidth, squareWidth, Color.Black, Aligns.Right, settings.GridType);
embroidery.SetBorder(squareX, squareY, squareWidth, squareWidth, Color.Black, Aligns.Buttom, settings.GridType);
});
});
*/
}
示例2: Test_Canvas_SetBorderTop
public void Test_Canvas_SetBorderTop()
{
Canvas canvas = new Canvas(4, 3);
Canvas expectedCanvas = new Canvas(4, 3);
expectedCanvas.SetColor(0, 0, Color.Black);
expectedCanvas.SetColor(1, 0, Color.Black);
expectedCanvas.SetColor(2, 0, Color.Black);
expectedCanvas.SetColor(3, 0, Color.Black);
canvas.SetBorder(0, 0, 4, 3, Color.Black, Aligns.Top, GridType.SolidLine);
Assert.IsTrue(canvas.Width == expectedCanvas.Width && canvas.Height == expectedCanvas.Height);
for (int y = 0; y < canvas.Height; y++)
for (int x = 0; x < canvas.Width; x++)
{
Color actualColor = canvas.GetColor(x, y);
Color expectedColor = expectedCanvas.GetColor(x, y);
Assert.IsTrue(actualColor == expectedColor);
}
}
示例3: Test_Canvas_SetBorderPointsLeft
public void Test_Canvas_SetBorderPointsLeft()
{
Canvas canvas = new Canvas(4, 4);
Canvas expectedCanvas = new Canvas(4, 4);
expectedCanvas.SetColor(0, 0, Color.Black);
expectedCanvas.SetColor(0, 3, Color.Black);
canvas.SetBorder(0, 0, 4, 4, Color.Black, Aligns.Left, GridType.Points);
Assert.IsTrue(canvas.Width == expectedCanvas.Width && canvas.Height == expectedCanvas.Height);
for (int y = 0; y < canvas.Height; y++)
for (int x = 0; x < canvas.Width; x++)
{
Color actualColor = canvas.GetColor(x, y);
Color expectedColor = expectedCanvas.GetColor(x, y);
Assert.IsTrue(actualColor == expectedColor);
}
}