1
0
mirror of https://github.com/greenshot/greenshot.git synced 2025-03-12 05:25:25 -07:00

Changed the date/time on prints to a configurable footer, using the patterns of the filename, didn't change the GUI yet. Changed default to date/time (local format) + capturetitle.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1707 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-03-19 16:34:42 +00:00
parent 0722cbfe22
commit d824b8e893
7 changed files with 60 additions and 36 deletions

@ -168,7 +168,7 @@ namespace Greenshot.Configuration {
coreConfiguration.OutputPrintAllowShrink = (bool)appConfig.Output_Print_AllowShrink;
coreConfiguration.OutputPrintCenter = (bool)appConfig.Output_Print_Center;
coreConfiguration.OutputPrintPromptOptions = (bool)appConfig.Output_Print_PromptOptions;
coreConfiguration.OutputPrintTimestamp = (bool)appConfig.Output_Print_Timestamp;
coreConfiguration.OutputPrintFooter = (bool)appConfig.Output_Print_Timestamp;
int delay = appConfig.Capture_Wait_Time-1;
if (delay < 0) {
delay = 0;

@ -920,7 +920,9 @@ namespace Greenshot {
foreach(string propertyName in conf.Values.Keys) {
if (propertyName.StartsWith("OutputPrint")) {
iniValue = conf.Values[propertyName];
selectList.AddItem(lang.GetString(iniValue.Attributes.LanguageKey), iniValue, (bool)iniValue.Value);
if (iniValue.Attributes.LanguageKey != null) {
selectList.AddItem(lang.GetString(iniValue.Attributes.LanguageKey), iniValue, (bool)iniValue.Value);
}
}
}
selectList.CheckedChanged += new EventHandler(this.QuickSettingBoolItemChanged);

@ -52,7 +52,7 @@ namespace Greenshot.Forms {
this.AllowPrintRotate = this.checkboxAllowRotate.Checked = conf.OutputPrintAllowRotate;
this.AllowPrintShrink = this.checkboxAllowShrink.Checked = conf.OutputPrintAllowShrink;
this.PrintInverted = this.checkboxPrintInverted.Checked = conf.OutputPrintInverted;
this.PrintDateTime = this.checkboxDateTime.Checked = conf.OutputPrintTimestamp;
this.PrintDateTime = this.checkboxDateTime.Checked = conf.OutputPrintFooter;
this.checkbox_dontaskagain.Checked = false;
UpdateUI();
}
@ -82,7 +82,7 @@ namespace Greenshot.Forms {
conf.OutputPrintAllowEnlarge = this.AllowPrintEnlarge;
conf.OutputPrintAllowRotate = this.AllowPrintRotate;
conf.OutputPrintAllowShrink = this.AllowPrintShrink;
conf.OutputPrintTimestamp = this.PrintDateTime;
conf.OutputPrintFooter = this.PrintDateTime;
conf.OutputPrintInverted = this.PrintInverted;
conf.OutputPrintPromptOptions = !this.checkbox_dontaskagain.Checked;
IniConfig.Save();

@ -289,7 +289,7 @@ namespace Greenshot {
checkboxAllowEnlarge.Checked = coreConfiguration.OutputPrintAllowEnlarge;
checkboxAllowRotate.Checked = coreConfiguration.OutputPrintAllowRotate;
checkboxAllowShrink.Checked = coreConfiguration.OutputPrintAllowShrink;
checkboxTimestamp.Checked = coreConfiguration.OutputPrintTimestamp;
checkboxTimestamp.Checked = coreConfiguration.OutputPrintFooter;
checkbox_alwaysshowprintoptionsdialog.Checked = coreConfiguration.OutputPrintPromptOptions;
checkbox_capture_mousepointer.Checked = coreConfiguration.CaptureMousepointer;
checkbox_capture_windows_interactive.Checked = coreConfiguration.CaptureWindowsInteractive;
@ -348,7 +348,7 @@ namespace Greenshot {
coreConfiguration.OutputPrintAllowEnlarge = checkboxAllowEnlarge.Checked;
coreConfiguration.OutputPrintAllowRotate = checkboxAllowRotate.Checked;
coreConfiguration.OutputPrintAllowShrink = checkboxAllowShrink.Checked;
coreConfiguration.OutputPrintTimestamp = checkboxTimestamp.Checked;
coreConfiguration.OutputPrintFooter = checkboxTimestamp.Checked;
coreConfiguration.OutputPrintPromptOptions = checkbox_alwaysshowprintoptionsdialog.Checked;
coreConfiguration.CaptureMousepointer = checkbox_capture_mousepointer.Checked;
coreConfiguration.CaptureWindowsInteractive = checkbox_capture_windows_interactive.Checked;

@ -84,7 +84,7 @@ namespace Greenshot.Helpers {
}
public static string GetFilenameWithoutExtensionFromPattern(string pattern, ICaptureDetails captureDetails) {
return FillPattern(pattern, captureDetails);
return FillPattern(pattern, captureDetails, true);
}
public static string GetFilenameFromPattern(string pattern, OutputFormat imageFormat) {
@ -92,7 +92,7 @@ namespace Greenshot.Helpers {
}
public static string GetFilenameFromPattern(string pattern, OutputFormat imageFormat, ICaptureDetails captureDetails) {
return FillPattern(pattern, captureDetails) + "." + imageFormat.ToString().ToLower();
return FillPattern(pattern, captureDetails, true) + "." + imageFormat.ToString().ToLower();
}
/// <summary>
@ -175,25 +175,25 @@ namespace Greenshot.Helpers {
}
}
if (processVars != null && processVars.Contains(variable)) {
replaceValue = (string)processVars[variable];
if (filenameSafeMode) {
replaceValue = MakePathSafe((string)processVars[variable]);
} else {
replaceValue = (string)processVars[variable];
replaceValue = MakePathSafe(replaceValue);
}
} else if (userVars != null && userVars.Contains(variable)) {
replaceValue = (string)userVars[variable];
if (filenameSafeMode) {
replaceValue = MakePathSafe((string)userVars[variable]);
} else {
replaceValue = (string)userVars[variable];
replaceValue = MakePathSafe(replaceValue);
}
} else if (machineVars != null && machineVars.Contains(variable)) {
replaceValue = (string)machineVars[variable];
if (filenameSafeMode) {
replaceValue = MakePathSafe((string)machineVars[variable]);
} else {
replaceValue = (string)machineVars[variable];
replaceValue = MakePathSafe(replaceValue);
}
} else if (captureDetails != null && captureDetails.MetaData != null && captureDetails.MetaData.ContainsKey(variable)) {
replaceValue = MakePathSafe(captureDetails.MetaData[variable]);
replaceValue = captureDetails.MetaData[variable];
if (filenameSafeMode) {
replaceValue = MakePathSafe(replaceValue);
}
} else {
// Handle other variables
// Default use "now" for the capture take´n
@ -264,10 +264,16 @@ namespace Greenshot.Helpers {
replaceValue = capturetime.Second.ToString();
break;
case "now":
replaceValue = MakeFilenameSafe(DateTime.Now.ToString(dateFormat));
replaceValue = DateTime.Now.ToString(dateFormat);
if (filenameSafeMode) {
replaceValue = MakeFilenameSafe(replaceValue);
}
break;
case "capturetime":
replaceValue = MakeFilenameSafe(capturetime.ToString(dateFormat));
replaceValue = capturetime.ToString(dateFormat);
if (filenameSafeMode) {
replaceValue = MakeFilenameSafe(replaceValue);
}
break;
case "NUM":
conf.OutputFileIncrementingNumber++;
@ -280,7 +286,10 @@ namespace Greenshot.Helpers {
break;
case "title":
replaceValue = MakeFilenameSafe(title);
replaceValue = title;
if (filenameSafeMode) {
replaceValue = MakeFilenameSafe(replaceValue);
}
break;
}
}
@ -350,7 +359,14 @@ namespace Greenshot.Helpers {
);
}
private static string FillPattern(string pattern, ICaptureDetails captureDetails) {
/// <summary>
/// Fill the pattern wit the supplied details
/// </summary>
/// <param name="pattern">Pattern</param>
/// <param name="captureDetails">CaptureDetails</param>
/// <param name="filenameSafeMode">Should the result be made "filename" safe?</param>
/// <returns>Filled pattern</returns>
public static string FillPattern(string pattern, ICaptureDetails captureDetails, bool filenameSafeMode) {
IDictionary processVars = null;
IDictionary userVars = null;
IDictionary machineVars = null;
@ -374,7 +390,7 @@ namespace Greenshot.Helpers {
try {
return VAR_REGEXP.Replace(pattern,
new MatchEvaluator(delegate(Match m) { return MatchVarEvaluator(m, captureDetails, processVars, userVars, machineVars, true); })
new MatchEvaluator(delegate(Match m) { return MatchVarEvaluator(m, captureDetails, processVars, userVars, machineVars, filenameSafeMode); })
);
} catch (Exception e) {
// adding additional data for bug tracking

@ -132,13 +132,14 @@ namespace Greenshot.Helpers {
ContentAlignment alignment = pod.AllowPrintCenter ? ContentAlignment.MiddleCenter : ContentAlignment.TopLeft;
// prepare timestamp
float dateStringWidth = 0;
float dateStringHeight = 0;
string dateString = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString();
if (conf.OutputPrintTimestamp) {
float footerStringWidth = 0;
float footerStringHeight = 0;
string footerString = null; //DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString();
if (conf.OutputPrintFooter) {
footerString = FilenameHelper.FillPattern(conf.OutputPrintFooterPattern, captureDetails, false);
using (Font f = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular)) {
dateStringWidth = e.Graphics.MeasureString(dateString, f).Width;
dateStringHeight = e.Graphics.MeasureString(dateString, f).Height;
footerStringWidth = e.Graphics.MeasureString(footerString, f).Width;
footerStringHeight = e.Graphics.MeasureString(footerString, f).Height;
}
}
@ -146,7 +147,7 @@ namespace Greenshot.Helpers {
RectangleF pageRect = e.PageSettings.PrintableArea;
// Subtract the dateString height from the available area, this way the area stays free
pageRect.Height -= dateStringHeight;
pageRect.Height -= footerStringHeight;
GraphicsUnit gu = GraphicsUnit.Pixel;
RectangleF imageRect = image.GetBounds(ref gu);
@ -172,10 +173,10 @@ namespace Greenshot.Helpers {
// align the image
printRect = ScaleHelper.GetAlignedRectangle(printRect, new RectangleF(0, 0, pageRect.Width, pageRect.Height), alignment);
if (conf.OutputPrintTimestamp) {
if (conf.OutputPrintFooter) {
//printRect = new RectangleF(0, 0, printRect.Width, printRect.Height - (dateStringHeight * 2));
using (Font f = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Regular)) {
e.Graphics.DrawString(dateString, f, Brushes.Black, pageRect.Width / 2 - (dateStringWidth / 2), pageRect.Height);
e.Graphics.DrawString(footerString, f, Brushes.Black, pageRect.Width / 2 - (footerStringWidth / 2), pageRect.Height);
}
}
if (conf.OutputPrintInverted) {

@ -86,7 +86,7 @@ namespace GreenshotPlugin.Core {
[IniProperty("OutputFilePath", Description="Output file path.")]
public string OutputFilePath;
[IniProperty("OutputFileFilenamePattern", Description="Filename pattern for screenshot.", DefaultValue="${capturetime}_${title}")]
[IniProperty("OutputFileFilenamePattern", Description="Filename pattern for screenshot.", DefaultValue="${capturetime:d\"yyyy-MM-dd HH_mm_ss\"}-${title}")]
public string OutputFileFilenamePattern;
[IniProperty("OutputFileFormat", Description="Default file type for writing screenshots. (bmp, gif, jpg, png, tiff)", DefaultValue="png")]
public OutputFormat OutputFileFormat = OutputFormat.png;
@ -122,8 +122,10 @@ namespace GreenshotPlugin.Core {
public bool OutputPrintCenter;
[IniProperty("OutputPrintInverted", LanguageKey="printoptions_inverted", Description="Print image inverted (use e.g. for console captures)", DefaultValue="false")]
public bool OutputPrintInverted;
[IniProperty("OutputPrintTimestamp", LanguageKey="printoptions_timestamp", Description="Print timestamp on print?", DefaultValue="true")]
public bool OutputPrintTimestamp;
[IniProperty("OutputPrintFooter", LanguageKey = "printoptions_timestamp", Description = "Print footer on print?", DefaultValue = "true")]
public bool OutputPrintFooter;
[IniProperty("OutputPrintFooterPattern", Description = "Footer pattern", DefaultValue = "${capturetime:d\"D\"} ${capturetime:d\"T\"} - ${title}")]
public string OutputPrintFooterPattern;
[IniProperty("UseProxy", Description="Use your global proxy?", DefaultValue="True")]
public bool UseProxy;
@ -153,7 +155,7 @@ namespace GreenshotPlugin.Core {
[IniProperty("NoDWMCaptureForProduct", Description="List of products for which DWM capturing doesn't work.", DefaultValue="Citrix ICA Client")]
public List<string> NoDWMCaptureForProduct;
[IniProperty("OptimizeForRDP", Description="Make some optimizations for remote desktop usage", DefaultValue="False")]
[IniProperty("OptimizeForRDP", Description="Make some optimizations for usage with remote desktop", DefaultValue="False")]
public bool OptimizeForRDP;
[IniProperty("ActiveTitleFixes", Description="The fixes that are active.")]
@ -227,6 +229,9 @@ namespace GreenshotPlugin.Core {
/// <returns>object with the default value for the supplied property</returns>
public override object GetDefault(string property) {
switch(property) {
case "OutputPrintFooterPattern":
break;
case "PluginWhitelist":
case "PluginBacklist":
return new List<string>();