public void CopyRegionTest()
        {
            // Generate a random 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.FromArgb(255, Color.FromArgb(r.Next())));
                }
            }

            // Initialize a grid of the random bitmap
            DrawingGrid grid = new DrawingGrid(bmp, 10, 1);

            // Generate a random inbounds rectangle
            Rectangle inBounds = new Rectangle(0, 0, r.Next(20), r.Next(20));

            // Copy the inbounds region
            DrawingGrid.GridCell[,] copy = grid.CopyRegion(inBounds);
            // Verify that the region was correctly copied
            copyVerifier(copy, grid);

            // Generate a random out of bounds (on the right) rectangle
            Rectangle outR = new Rectangle(0, 0, r.Next(21, 40), r.Next(20));

            // Copy the region
            copy = grid.CopyRegion(outR);
            // Verify
            copyVerifier(copy, grid);

            // Generate a random out of bounds (on the bottom) rectangle
            Rectangle outB = new Rectangle(0, 0, r.Next(20), r.Next(21, 40));

            // Copy the region
            copy = grid.CopyRegion(outB);
            // Verify
            copyVerifier(copy, grid);

            // Generate a random out of bounds rectangle
            Rectangle outBR = new Rectangle(0, 0, r.Next(21, 40), r.Next(21, 40));

            // Copy the region
            copy = grid.CopyRegion(outB);
            // Verify
            copyVerifier(copy, grid);
        }
Esempio n. 2
0
        /***********************************************************************/
        /*                                DRAG                                 */
        /***********************************************************************/

        private void DragDown(MouseEventArgs e)
        {
            drawX         = e.X;
            drawY         = e.Y;
            tempClipboard = Grid.CopyRegion(selectedRegion);
            Grid.ClearRegion(selectedRegion);
            dragable = true;
        }