diff --git a/Greenshot/Forms/CaptureForm.cs b/Greenshot/Forms/CaptureForm.cs index 393f88f97..b6a7a97f4 100644 --- a/Greenshot/Forms/CaptureForm.cs +++ b/Greenshot/Forms/CaptureForm.cs @@ -335,7 +335,7 @@ namespace Greenshot.Forms { bool fileWritten = false; if (captureDestinations.Contains(CaptureDestination.File)) { string filename = FilenameHelper.GetFilenameFromPattern(conf.OutputFileFilenamePattern, conf.OutputFileFormat, captureDetails); - fullPath = Path.Combine(conf.Output_File_Path,filename); + fullPath = Path.Combine(conf.OutputFilePath,filename); // Catching any exception to prevent that the user can't write in the directory. // This is done for e.g. bugs #2974608, #2963943, #2816163, #2795317, #2789218, #3004642 diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs index cfbd67aa4..6c7b9f8d7 100644 --- a/Greenshot/Forms/MainForm.cs +++ b/Greenshot/Forms/MainForm.cs @@ -601,8 +601,8 @@ namespace Greenshot { string path; if (lastImagePath != null && Directory.Exists(lastImagePath)) { path = lastImagePath; - } else if (Directory.Exists(conf.Output_File_Path)) { - path = conf.Output_File_Path; + } else if (Directory.Exists(conf.OutputFilePath)) { + path = conf.OutputFilePath; } else { // What do I open when nothing can be found? Right, nothing... return; diff --git a/Greenshot/Test/SaveImageFileDialogTest.cs b/Greenshot/Test/SaveImageFileDialogTest.cs index 8384b0840..470e88166 100644 --- a/Greenshot/Test/SaveImageFileDialogTest.cs +++ b/Greenshot/Test/SaveImageFileDialogTest.cs @@ -64,7 +64,7 @@ namespace Greenshot.Test public void SuggestBasicFileNameTest() { CoreConfiguration conf = IniConfig.GetIniSection(); //conf.Output_FileAs_Fullpath = @"c:\path\to\greenshot_testdir\gstest_28.jpg"; - conf.Output_File_Path = @"c:\path\to\greenshot_testdir\"; + conf.OutputFilePath = @"c:\path\to\greenshot_testdir\"; conf.OutputFileFilenamePattern = "gstest_%NUM%"; conf.OutputFileFormat = OutputFormat.Jpeg; conf.OutputFileIncrementingNumber = 28; diff --git a/GreenshotCore/Configuration/CoreConfiguration.cs b/GreenshotCore/Configuration/CoreConfiguration.cs index 3a4ee3a25..f378f9550 100644 --- a/GreenshotCore/Configuration/CoreConfiguration.cs +++ b/GreenshotCore/Configuration/CoreConfiguration.cs @@ -61,14 +61,17 @@ namespace Greenshot.Core { [IniProperty("PlayCameraSound", Description="Play a camera sound after taking a capture.", DefaultValue="false")] public bool PlayCameraSound = false; - public string Output_File_Path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); + [IniProperty("OutputFilePath", Description="Output file path.")] + public string OutputFilePath; [IniProperty("OutputFileFilenamePattern", Description="Filename pattern for screenshot.", DefaultValue="%title%_%YYYY%-%MM%-%DD%_%hh%-%mm%-%ss%")] public string OutputFileFilenamePattern; [IniProperty("OutputFileFormat", Description="Default file type for writing screenshots. (Bmp, Gif, Jepg, Png, Tiff)", DefaultValue="Png")] public OutputFormat OutputFileFormat = OutputFormat.Png; [IniProperty("OutputFileCopyPathToClipboard", Description="When saving a screenshot, copy the path to the clipboard?", DefaultValue="true")] public bool OutputFileCopyPathToClipboard; - + [IniProperty("OutputFileAsFullpath", Description="SaveAs Full path?")] + public string OutputFileAsFullpath; + [IniProperty("OutputFileJpegQuality", Description="JPEG file save quality in %.", DefaultValue="80")] public int OutputFileJpegQuality; [IniProperty("OutputFilePromptJpegQuality", Description="Ask for the JPEQ quality before saving?", DefaultValue="false")] @@ -76,8 +79,6 @@ namespace Greenshot.Core { [IniProperty("OutputFileIncrementingNumber", Description="The number for the %NUM% in the filename pattern, is increased automatically after each save.", DefaultValue="1")] public uint OutputFileIncrementingNumber; - public string Output_FileAs_Fullpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop),"dummy.png"); - [IniProperty("OutputPrintPromptOptions", Description="Ask for print options when printing?", DefaultValue="true")] public bool OutputPrintPromptOptions; [IniProperty("OutputPrintAllowRotate", Description="Allow rotating the picture for fitting on paper?", DefaultValue="true")] @@ -90,5 +91,23 @@ namespace Greenshot.Core { public bool OutputPrintCenter; [IniProperty("OutputPrintTimestamp", Description="Print timestamp on print?", DefaultValue="true")] public bool OutputPrintTimestamp; + + //[IniProperty("Test", Description="Print timestamp on print?", DefaultValue="")] + //public Dictionary testProp; + + /// + /// Supply values we can't put as defaults + /// + /// The property to return a default for + /// string with the default value for the supplied property + public override string GetDefault(string property) { + switch(property) { + case "OutputFileAsFullpath": + return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop),"dummy.png"); + case "OutputFilePath": + return Environment.GetFolderPath(Environment.SpecialFolder.Desktop); + } + return null; + } } } diff --git a/GreenshotCore/Core/ConfigHelper.cs b/GreenshotCore/Core/ConfigHelper.cs index 50b15508c..ebe6fb725 100644 --- a/GreenshotCore/Core/ConfigHelper.cs +++ b/GreenshotCore/Core/ConfigHelper.cs @@ -61,10 +61,21 @@ namespace Greenshot.Core { } } - // Interface for - public class IniSection { - // Flag to specify if values have been changed + /// + /// Base class for all IniSections + /// + public abstract class IniSection { + /// Flag to specify if values have been changed public bool IsDirty = false; + + /// + /// Supply values we can't put as defaults + /// + /// The property to return a default for + /// string with the default value for the supplied property + public virtual string GetDefault(string property) { + return null; + } } public class IniConfig { @@ -179,8 +190,12 @@ namespace Greenshot.Core { } else { // Mark as dirty, we didn't use properties from the file (even defaults from the default file are allowed) section.IsDirty = true; - propertyValue = iniPropertyAttribute.DefaultValue; - LOG.Debug("Using default property for " + propertyName + " : " + propertyValue); + if (iniPropertyAttribute.DefaultValue != null) { + propertyValue = iniPropertyAttribute.DefaultValue; + } else { + propertyValue = section.GetDefault(propertyName); + } + LOG.Debug("Using default: " + propertyName + "=" + propertyValue); } // Get the type, or the underlying type for nullables diff --git a/GreenshotCore/Forms/SaveImageFileDialog.cs b/GreenshotCore/Forms/SaveImageFileDialog.cs index b9a953cc6..92dd6a116 100644 --- a/GreenshotCore/Forms/SaveImageFileDialog.cs +++ b/GreenshotCore/Forms/SaveImageFileDialog.cs @@ -57,7 +57,7 @@ namespace Greenshot.Forms { private void init() { saveFileDialog = new SaveFileDialog(); applyFilterOptions(); - saveFileDialog.InitialDirectory = Path.GetDirectoryName(conf.Output_FileAs_Fullpath); + saveFileDialog.InitialDirectory = Path.GetDirectoryName(conf.OutputFileAsFullpath); // The following property fixes a problem that the directory where we save is locked (bug #2899790) saveFileDialog.RestoreDirectory = true; @@ -73,7 +73,7 @@ namespace Greenshot.Forms { for(int i=0; i