private void saveButton_Click(object sender, EventArgs e)
{
// set file name
var fileName = cleanNameCheckbox.Checked ?
CleanName(fileInfo.MovieName) : fileInfo.MovieName;
var sfd = new SaveFileDialog
{
FileName = fileName + "_snapshot[1].png",
Filter = "PNG Images|*.png|" +
"Bitmap Images|*.bmp|" +
"GIF Images|*.gif|" +
"JPEG Images|*.jpg|" +
"TIFF Images|*.tiff"
};
int total = 1;
while (File.Exists(string.Format("{0}\\{1}_snapshot[{2}].png", fileInfo.GetDirectoryName, fileName, total)))
{
total++;
sfd.FileName = string.Format("{0}_snapshot[{1}].png", fileName, total);
}
if (sfd.ShowDialog() == DialogResult.OK && sfd.FileName.Length > 0)
{
switch (sfd.FilterIndex)
{
case 1:
SnapshotImage.Save(sfd.FileName, System.Drawing.Imaging.ImageFormat.Png);
break;
case 2:
SnapshotImage.Save(sfd.FileName, System.Drawing.Imaging.ImageFormat.Bmp);
break;
case 3:
SnapshotImage.Save(sfd.FileName, System.Drawing.Imaging.ImageFormat.Gif);
break;
case 4:
SnapshotImage.Save(sfd.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
break;
case 5:
SnapshotImage.Save(sfd.FileName, System.Drawing.Imaging.ImageFormat.Tiff);
break;
}
}
}