private void form_MouseClick(object sender, EventArgs e) { PictureBox picturebox = sender as PictureBox; SaveFileDialog savefile = new SaveFileDialog(); savefile.Filter = @"Images|*.png"; if (savefile.ShowDialog() == DialogResult.OK) { string filepath = Path.GetExtension(savefile.FileName); if (picturebox != null && filepath != null) { Image image = picturebox.Image; SaveImage(image, savefile.FileName); } } disable_clickevent(); } private static void SaveImage(Image image, string destPath) { image.Save(destPath, System.Drawing.Imaging.ImageFormat.Png); } private void savaImageToolStripMenuItem_Click(object sender, EventArgs e) { pictureBox1.MouseEnter += form_MouseClick; pictureBox2.MouseEnter += form_MouseClick; } private void disable_clickevent() { pictureBox1.MouseEnter -= form_MouseClick; pictureBox2.MouseEnter -= form_MouseClick; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)