public void GetSetExtensionTest() { SaveImageFileDialog sifd = new SaveImageFileDialog(); sifd.Extension = "jpg"; Assert.AreEqual(sifd.Extension, "jpg"); sifd.Extension = "gif"; Assert.AreEqual(sifd.Extension, "gif"); sifd.Extension = "png"; Assert.AreEqual(sifd.Extension, "png"); sifd.Extension = "bmp"; Assert.AreEqual(sifd.Extension, "bmp"); }
public void SuggestBasicFileNameTest() { //conf.Output_FileAs_Fullpath = @"c:\path\to\greenshot_testdir\gstest_28.jpg"; conf.OutputFilePath = @"c:\path\to\greenshot_testdir\"; conf.OutputFileFilenamePattern = "gstest_${NUM}"; conf.OutputFileFormat = OutputFormat.png; conf.OutputFileIncrementingNumber = 28; SaveImageFileDialog sifd = new SaveImageFileDialog(); Assert.AreEqual(sifd.InitialDirectory, @"c:\path\to\greenshot_testdir"); Assert.AreEqual(sifd.FileNameWithExtension, "gstest_000028.jpg"); }
public void GetFileNameWithExtensionTest() { SaveImageFileDialog sifd = new SaveImageFileDialog(); sifd.InitialDirectory = @"C:\some\path"; sifd.FileName = "myimage.jpg"; sifd.Extension = "jpg"; Assert.AreEqual("myimage.jpg",sifd.FileNameWithExtension); sifd.Extension = "gif"; Assert.AreEqual("myimage.jpg.gif",sifd.FileNameWithExtension); sifd.FileName = "myimage"; Assert.AreEqual("myimage.gif",sifd.FileNameWithExtension); }
public static string SaveWithDialog(Image image, ICaptureDetails captureDetails) { string returnValue = null; SaveImageFileDialog saveImageFileDialog = new SaveImageFileDialog(captureDetails); DialogResult dialogResult = saveImageFileDialog.ShowDialog(); if(dialogResult.Equals(DialogResult.OK)) { try { string fileNameWithExtension = saveImageFileDialog.FileNameWithExtension; // TODO: For now we overwrite, should be changed ImageOutput.Save(image, fileNameWithExtension, true); returnValue = fileNameWithExtension; conf.OutputFileAsFullpath = fileNameWithExtension; IniConfig.Save(); } catch(System.Runtime.InteropServices.ExternalException) { MessageBox.Show(Language.GetInstance().GetFormattedString(LangKey.error_nowriteaccess,saveImageFileDialog.FileName).Replace(@"\\",@"\"), Language.GetInstance().GetString(LangKey.error)); } } return returnValue; }