Exemplo n.º 1
0
        /*******************************************************
         * Save File Menu
         *
         * Arguments: Object Sender and EventArgs e
         * Return Type: void
         * Use Case:
         ******************************************************/
        private void saveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (savePath != null)
            {
                Bitmap imageMap = new Bitmap(PaintCanvas.Width, PaintCanvas.Height);
                PaintCanvas.DrawToBitmap(imageMap, PaintCanvas.Bounds);

                PictureBox saveBox = new PictureBox();
                saveBox.Image = imageMap;

                //code to save the file;
                saveBox.Image.Save(savePath, ImageFormat.Png);
            }
            else
            {
                SaveFileDialog saveDialog1 = new SaveFileDialog();
                saveDialog1.Filter = "png (*.png)|*.png";

                DialogResult result = saveDialog1.ShowDialog();
                if (result == DialogResult.OK)
                {
                    string fileName = saveDialog1.FileName;
                    savePath = fileName;

                    Bitmap imageMap = new Bitmap(PaintCanvas.Width, PaintCanvas.Height);
                    PaintCanvas.DrawToBitmap(imageMap, PaintCanvas.Bounds);

                    PictureBox saveBox = new PictureBox();
                    saveBox.Image = imageMap;

                    //code to save the file;
                    saveBox.Image.Save(fileName, ImageFormat.Png);
                }
            }
        }