Beispiel #1
0
        // Method for the "Fill Floor" button on the menu bar.
        private void fillFloorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // Open the image select diaglog box and check if the user selected "OK"
            if (selectImageDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    // Load the image
                    Bitmap newImage = new Bitmap(Image.FromFile(selectImageDialog.FileName), ImagePalette.IMAGE_SIZE, ImagePalette.IMAGE_SIZE);

                    // Add it to the image palette
                    map.GetImagePalette().AddNewImage(selectImageDialog.FileName, newImage);

                    // Call the FillFloor() method, passing the loaded image to it.
                    map.FillFloor(selectImageDialog.FileName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Could not load image: " + selectImageDialog.FileName);
                    Console.WriteLine("Could not load image: " + selectImageDialog.FileName);
                    Console.WriteLine(ex.ToString());
                }
            }

            Refresh();
        }