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


C# Grid.GetCellByIndex方法代码示例

本文整理汇总了C#中Grid.GetCellByIndex方法的典型用法代码示例。如果您正苦于以下问题:C# Grid.GetCellByIndex方法的具体用法?C# Grid.GetCellByIndex怎么用?C# Grid.GetCellByIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Grid的用法示例。


在下文中一共展示了Grid.GetCellByIndex方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateAndInitializeFivexFiveGridForBlinkerOscillatorPattern

        private static void CreateAndInitializeFivexFiveGridForBlinkerOscillatorPattern()
        {
            FivexFiveGridForBlinkerOscillatorPattern = new Grid(5, 5);

            for (int rowIndex = 0; rowIndex < 5; rowIndex++)
            {
                for (int colIndex = 0; colIndex < 5; colIndex++)
                {
                    var cell = new Cell { RowIndex = rowIndex, ColIndex = colIndex, IsAlive = false };
                    FivexFiveGridForBlinkerOscillatorPattern.AddCell(cell);
                }
            }

            FivexFiveGridForBlinkerOscillatorPattern.GetCellByIndex(2, 1).IsAlive = true;
            FivexFiveGridForBlinkerOscillatorPattern.GetCellByIndex(2, 2).IsAlive = true;
            FivexFiveGridForBlinkerOscillatorPattern.GetCellByIndex(2, 3).IsAlive = true;
        }
开发者ID:anandkumar2k,项目名称:GOL,代码行数:17,代码来源:TestObjects.cs

示例2: CreateAndInitializeSixxSixGridForToadOscillatorPattern

        private static void CreateAndInitializeSixxSixGridForToadOscillatorPattern()
        {
            SixxSixGridForToadOscillatorPattern = new Grid(6, 6);

            for (int rowIndex = 0; rowIndex < 6; rowIndex++)
            {
                for (int colIndex = 0; colIndex < 6; colIndex++)
                {
                    var cell = new Cell { RowIndex = rowIndex, ColIndex = colIndex, IsAlive = false };
                    SixxSixGridForToadOscillatorPattern.AddCell(cell);
                }
            }

            SixxSixGridForToadOscillatorPattern.GetCellByIndex(2, 2).IsAlive = true;
            SixxSixGridForToadOscillatorPattern.GetCellByIndex(2, 3).IsAlive = true;
            SixxSixGridForToadOscillatorPattern.GetCellByIndex(2, 4).IsAlive = true;
            SixxSixGridForToadOscillatorPattern.GetCellByIndex(3, 1).IsAlive = true;
            SixxSixGridForToadOscillatorPattern.GetCellByIndex(3, 2).IsAlive = true;
            SixxSixGridForToadOscillatorPattern.GetCellByIndex(3, 3).IsAlive = true;
        }
开发者ID:anandkumar2k,项目名称:GOL,代码行数:20,代码来源:TestObjects.cs

示例3: Test_GetCellByIndex_ValidCellIsAdded_ReturnsSameCellAddedUsingAddCell

        public void Test_GetCellByIndex_ValidCellIsAdded_ReturnsSameCellAddedUsingAddCell()
        {
            var grid = new Grid(4, 4);
            var cell = new Cell
            {
                RowIndex = 2,
                ColIndex = 2
            };

            grid.AddCell(cell);

            var returnedCell = grid.GetCellByIndex(2, 2);

            Assert.That(returnedCell, Is.EqualTo(cell),
                        "Cell added using AddCell and cell retrieved using GetCellByIndex should be same");
        }
开发者ID:kulkarp,项目名称:GameOfLife,代码行数:16,代码来源:GridTests.cs

示例4: Test_GetCellByIndex_RowIndexEqualToFour_ThrowsArgumentOutOfRangeException

        public void Test_GetCellByIndex_RowIndexEqualToFour_ThrowsArgumentOutOfRangeException()
        {
            var grid = new Grid(4, 4);
            var cell = new Cell
            {
                RowIndex = 1,
                ColIndex = 1
            };
            grid.AddCell(cell);

            Assert.Throws<ArgumentOutOfRangeException>(() => grid.GetCellByIndex(4,1),
                                                 "ArgumentOutOfRangeException should be thrown");
        }
开发者ID:kulkarp,项目名称:GameOfLife,代码行数:13,代码来源:GridTests.cs

示例5: Test_GetCellByIndex_CellIsNotAddedAtSpecifiedIndex_ReturnsNullCell

        public void Test_GetCellByIndex_CellIsNotAddedAtSpecifiedIndex_ReturnsNullCell()
        {
            var grid = new Grid(4, 4);

            var returnedCell = grid.GetCellByIndex(2,2);

            Assert.That(returnedCell, Is.Null, "Cell retrieved should have been null");
        }
开发者ID:kulkarp,项目名称:GameOfLife,代码行数:8,代码来源:GridTests.cs


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