public void PasteRegionTest() { // Generate a white 20 x 20 bitmap Bitmap bmp = new Bitmap(20, 20); Random r = new Random(); for (int x = 0; x < bmp.Width; x++) { for (int y = 0; y < bmp.Height; y++) { bmp.SetPixel(x, y, Color.White); } } // Generate a grid from the bitmap DrawingGrid grid = new DrawingGrid(bmp, 10, 1); // Generate a randomly colored 5 x 5 region DrawingGrid.GridCell[,] region = new DrawingGrid.GridCell[5, 5]; for (int x = 0; x < region.GetLength(0); x++) { for (int y = 0; y < region.GetLength(1); y++) { region[x, y] = new DrawingGrid.GridCell(Color.FromArgb(255, Color.FromArgb(r.Next()))); } } // Paste the region in at (0,0) grid.PasteRegion(0, 0, region); // Verify that the region was correctly copied for (int x = 0; x < region.GetLength(0); x++) { for (int y = 0; y < region.GetLength(1); y++) { AreEqual(region[x, y].color, grid.GetCell(x, y)); } } }
private void DragUp(MouseEventArgs e) { dragable = false; Grid.PasteRegion(selectedRegion.X, selectedRegion.Y, tempClipboard); DisplayImage(); }