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


C# Canvas.SetBorder方法代码示例

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

                 });
             */
        }
开发者ID:nsvova,项目名称:Embroidery-NS-Vova,代码行数:32,代码来源:GridDecorator.cs

示例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);
                }
        }
开发者ID:nsvova,项目名称:Embroidery-NS-Vova,代码行数:22,代码来源:UnitCanvas.cs

示例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);
                }
        }
开发者ID:nsvova,项目名称:Embroidery-NS-Vova,代码行数:20,代码来源:UnitCanvas.cs


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