private System.Drawing.Bitmap GetTileBitmap(Algorithms.Shape s) { int width = s.rotations[0].GetLength(0); int height = s.rotations[0].GetLength(1); System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(width, height); for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if (s.rotations[0][x, y] == 1) { if ((x % 2 == 0 && y % 2 == 0) || (x % 2 != 0 && y % 2 != 0)) { bitmap.SetPixel(x, y, s.c1); } else { bitmap.SetPixel(x, y, s.c2); } } else { bitmap.SetPixel(x, y, BACKGROUND); } } } return(bitmap); }
//constructor from existing shape public TileControl(Algorithms.Shape s) { InitializeComponent(); NumTiles = 1; this.TileImage.Source = BitmapToImageSource(GetTileBitmap(s)); this.TileImage.SnapsToDevicePixels = true; this.Shape = s; IsValid = true; IsDuplicate = false; AdjustForValidationResult(Algorithms.ShapeValidator.isTileValid(this.Shape)); }