本文整理汇总了C#中Grid.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# Grid.Clear方法的具体用法?C# Grid.Clear怎么用?C# Grid.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grid
的用法示例。
在下文中一共展示了Grid.Clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GridView_IsSolid
public void GridView_IsSolid()
{
Map m = new Map(256, 256);
m.AddLayer(new Layer("test"));
m.ZoomAll();
Grid g = new Grid(256, 256);
m.Render(g);
GridView v1 = g.View(0, 0, 256, 256);
Assert.IsTrue(v1.IsSolid());
m.Clear();
g.Clear();
Mapnik.RegisterDatasource(Path.Combine(Mapnik.Paths["InputPlugins"], "shape.input"));
m.Load(@".\data\test.xml");
m.ZoomAll();
m.Render(g);
GridView v2 = g.View(0, 0, 256, 256);
Assert.IsFalse(v2.IsSolid());
}
示例2: Basics
[Test] public void Basics()
{
Grid<int> grid = new Grid<int>(2, 2);
grid[0, 0] = 0;
grid[1, 0] = 1;
grid[0, 1] = 2;
grid[1, 1] = 3;
Assert.AreEqual(4, grid.Capacity);
Assert.AreEqual(2, grid.Width);
Assert.AreEqual(2, grid.Height);
CollectionAssert.AreEqual(new[] {
0, 1,
2, 3 }, grid);
Assert.IsTrue(grid.Contains(3));
Assert.AreEqual(new Point2(1, 1), grid.IndexOf(3));
Assert.IsTrue(grid.Remove(3));
Assert.IsFalse(grid.Remove(3));
Assert.IsFalse(grid.Contains(3));
Assert.AreEqual(new Point2(-1, -1), grid.IndexOf(3));
CollectionAssert.AreEqual(new[] {
0, 1,
2, 0 }, grid);
grid.Resize(4, 4, Alignment.Center);
Assert.AreEqual(16, grid.Capacity);
Assert.AreEqual(4, grid.Width);
Assert.AreEqual(4, grid.Height);
CollectionAssert.AreEqual(new[] {
0, 0, 0, 0,
0, 0, 1, 0,
0, 2, 0, 0,
0, 0, 0, 0 }, grid);
grid.ShrinkToFit();
CollectionAssert.AreEqual(new[] {
0, 1,
2, 0 }, grid);
grid.Clear();
CollectionAssert.AreEqual(Enumerable.Repeat(0, grid.Capacity), grid);
}
示例3: Generate
public static List<GPoint> Generate (Grid g, GPoint.PType walkType, int steps)
{
//make the last direction random, to randomise the opposite of the first direction
//start at 1
//pick a new direction
//if the direction is okay
//move the test vector
//if the new position is in bounds
//add the point
//iterate the loop
//set the last direction to the new direction
List<GPoint> points = new List<GPoint> ();
//set the scanpoint in the middle of the grid
ScanPoint scan = new ScanPoint (g.GetSize () / 2);
//set the last direction as a new direction
Direction lastDir = PickNewDirection ();
//set the stepcount at 1
int stepcount = 1;
//if the stepcount is less than or equal to the max number of steps
while (stepcount<=steps) {
//pick a new direction and set it as the new direction
Direction newDir = PickNewDirection ();
//if the new direction is not the opposite of the last direction
if (IsValidDirection (newDir, lastDir)) {
//move the testposition in the new direction
Vector2 testPos = scan.VirtualMove (newDir);
//check if the new position is within the constraints
if (g.PositionInBounds (testPos)) {
//if it is, move the scanpoint in the direction
scan.Move (newDir);
//iterate the stepcount
stepcount++;
//add a new gpoint to the list of the designated type
points.Add (new GPoint (scan.Position (), walkType));
//Debug.Log ("point added to grid at " + scan.Position ());
}
//set the last dir to the new dir to ensure accurate direction checking
//when the loop repeats
lastDir = newDir;
}
//otherwise, do absolutely nothing
}
Debug.Log ("generated a " + points.Count + " point line of " + walkType);
Grid tg = new Grid (g);
tg.Clear ();
tg.UpdatePoints (points);
List<GPoint> processed = new List<GPoint> ();
processed = PostProcess (tg, walkType, walkType);
return processed;
}
示例4: TestClearMethodToRetturnZeroValue
public void TestClearMethodToRetturnZeroValue()
{
var grid = new Grid();
var tile = new Tile("1", 1, TileType.Number);
grid.AddTile(tile);
grid.Clear();
var actual = grid.TilesCount;
var expected = 0;
Assert.AreEqual(actual, expected);
}