Skip to content

Commit

Permalink
2.3.2.5 - Macro tag expressions can now parse date time format.
Browse files Browse the repository at this point in the history
  • Loading branch information
gavinkendall committed Sep 1, 2020
1 parent 5dc52d1 commit 037ceb9
Show file tree
Hide file tree
Showing 10 changed files with 64 additions and 29 deletions.
4 changes: 2 additions & 2 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.3.2.4")]
[assembly: AssemblyFileVersion("2.3.2.4")]
[assembly: AssemblyVersion("2.3.2.5")]
[assembly: AssemblyFileVersion("2.3.2.5")]
[assembly: NeutralResourcesLanguageAttribute("en-CA")]
2 changes: 1 addition & 1 deletion app.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<assemblyIdentity
type="win32"
name="GavinKendall.AutoScreenCapture"
version="2.3.2.4"/>
version="2.3.2.5"/>
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>True/PM</dpiAware>
Expand Down
2 changes: 1 addition & 1 deletion interface/FormAbout.resx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="richTextBoxDeveloper.Text" xml:space="preserve">
<value>Auto Screen Capture 2.3.2.4 ("Boombayah")
<value>Auto Screen Capture 2.3.2.5 ("Boombayah")
Developed by Gavin Kendall (2008 - 2020)

https://autoscreen.sourceforge.io/
Expand Down
3 changes: 2 additions & 1 deletion interface/main/FormMain-Editors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,8 @@ private bool RunEditor(Editor editor, Screenshot screenshot)
{
// Execute the chosen image editor. If the %filepath% argument happens to be included
// then we'll use that argument as the screenshot file path when executing the image editor.
if (editor != null && (screenshot != null && !string.IsNullOrEmpty(screenshot.Path) && FileSystem.FileExists(screenshot.Path)))
if (editor != null && (screenshot != null && !string.IsNullOrEmpty(screenshot.Path) &&
FileSystem.FileExists(editor.Application) && FileSystem.FileExists(screenshot.Path)))
{
Log.WriteDebugMessage("Starting process for editor \"" + editor.Name + "\" ...");
Log.WriteDebugMessage("Application: " + editor.Application);
Expand Down
28 changes: 28 additions & 0 deletions interface/main/FormMain-SystemTrayIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,27 @@ public partial class FormMain : Form
private void ContextMenuStripSystemTrayIcon_Opening(object sender, CancelEventArgs e)
{
PopulateLabelList();

if (ScreenCapture.LockScreenCaptureSession)
{
// Hide the "Show Screen Capture Status" menu item.
toolStripSeparatorTools.Visible = false;
toolStripMenuItemShowScreenCaptureStatus.Visible = false;

// Hide the "Capture Now" memu items.
toolStripMenuItemCaptureNowEdit.Visible = false;
toolStripMenuItemCaptureNowArchive.Visible = false;
}
else
{
// Show the "Show Screen Capture Status" menu item.
toolStripSeparatorTools.Visible = true;
toolStripMenuItemShowScreenCaptureStatus.Visible = true;

// Show the "Capture Now" memu items.
toolStripMenuItemCaptureNowEdit.Visible = true;
toolStripMenuItemCaptureNowArchive.Visible = true;
}
}

/// <summary>
Expand Down Expand Up @@ -82,6 +103,13 @@ private void ShowInfo()
{
try
{
if (ScreenCapture.LockScreenCaptureSession)
{
notifyIcon.Text = string.Empty;

return;
}

notifyIcon.Text = "Ready to start taking screenshots";

if (_screenCapture.ApplicationError || _screenCapture.ApplicationWarning)
Expand Down
2 changes: 1 addition & 1 deletion macro/MacroParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ public static string TimeFormatForWindows
sb.Append(MinuteFormat);
sb.Append("-");
sb.Append(SecondFormat);
sb.Append("-");
sb.Append(".");
sb.Append(MillisecondFormat);

return sb.ToString();
Expand Down
29 changes: 15 additions & 14 deletions macro/MacroTagExpressionParser.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//-----------------------------------------------------------------------
// <copyright file="MacroTagFunctionParser.cs" company="Gavin Kendall">
// <copyright file="MacroTagExpressionParser.cs" company="Gavin Kendall">
// Copyright (c) 2020 Gavin Kendall
// </copyright>
// <author>Gavin Kendall</author>
Expand Down Expand Up @@ -34,7 +34,7 @@ public static class MacroTagExpressionParser
// For example ...
// {year-1} 1 year behind the given DateTime
// {minute+5} 5 minutes ahead the given DateTime
private static readonly string DateTimeFormatTagExpressionRegex = @"^\{(?<DateTimePart>year|month|day|hour|minute|second)(?<Operator>[\-\+])(?<Value>\d{1,5})\}$";
private static readonly string DateTimeFormatTagExpressionRegex = @"^\{(?<DateTimePart>year|month|day|hour|minute|second)(?<Operator>[\-\+])(?<Value>\d{1,5})\}(?<DateTimeFormat>\[.+\])?$";

/// <summary>
/// Parses macro tag expressions for date/time format.
Expand All @@ -51,43 +51,44 @@ public static string ParseTagExpressionForDateTimeFormat(DateTime dateTime, stri
string dateTimePart = Regex.Match(tagExpression, DateTimeFormatTagExpressionRegex).Groups["DateTimePart"].Value;
string @operator = Regex.Match(tagExpression, DateTimeFormatTagExpressionRegex).Groups["Operator"].Value;
int @value = Convert.ToInt32(Regex.Match(tagExpression, DateTimeFormatTagExpressionRegex).Groups["Value"].Value);
string dateTimeFormat = Regex.Match(tagExpression, DateTimeFormatTagExpressionRegex).Groups["DateTimeFormat"].Value.TrimStart('[').TrimEnd(']');

if (@operator.Equals("-"))
{
if (dateTimePart.Equals("year"))
{
dateTime = dateTime.AddYears(-@value);
result = dateTime.ToString(MacroParser.YearFormat);
result = string.IsNullOrEmpty(dateTimeFormat) ? dateTime.ToString(MacroParser.YearFormat) : dateTime.ToString(dateTimeFormat);
}

if (dateTimePart.Equals("month"))
{
dateTime = dateTime.AddMonths(-@value);
result = dateTime.ToString(MacroParser.MonthFormat);
result = string.IsNullOrEmpty(dateTimeFormat) ? dateTime.ToString(MacroParser.MonthFormat) : dateTime.ToString(dateTimeFormat);
}

if (dateTimePart.Equals("day"))
{
dateTime = dateTime.AddDays(-@value);
result = dateTime.ToString(MacroParser.DayFormat);
result = string.IsNullOrEmpty(dateTimeFormat) ? dateTime.ToString(MacroParser.DayFormat) : dateTime.ToString(dateTimeFormat);
}

if (dateTimePart.Equals("hour"))
{
dateTime = dateTime.AddHours(-@value);
result = dateTime.ToString(MacroParser.HourFormat);
result = string.IsNullOrEmpty(dateTimeFormat) ? dateTime.ToString(MacroParser.HourFormat) : dateTime.ToString(dateTimeFormat);
}

if (dateTimePart.Equals("minute"))
{
dateTime = dateTime.AddMinutes(-@value);
result = dateTime.ToString(MacroParser.MinuteFormat);
result = string.IsNullOrEmpty(dateTimeFormat) ? dateTime.ToString(MacroParser.MinuteFormat) : dateTime.ToString(dateTimeFormat);
}

if (dateTimePart.Equals("second"))
{
dateTime = dateTime.AddSeconds(-@value);
result = dateTime.ToString(MacroParser.SecondFormat);
result = string.IsNullOrEmpty(dateTimeFormat) ? dateTime.ToString(MacroParser.SecondFormat) : dateTime.ToString(dateTimeFormat);
}
}

Expand All @@ -96,37 +97,37 @@ public static string ParseTagExpressionForDateTimeFormat(DateTime dateTime, stri
if (dateTimePart.Equals("year"))
{
dateTime = dateTime.AddYears(+@value);
result = dateTime.ToString(MacroParser.YearFormat);
result = string.IsNullOrEmpty(dateTimeFormat) ? dateTime.ToString(MacroParser.YearFormat) : dateTime.ToString(dateTimeFormat);
}

if (dateTimePart.Equals("month"))
{
dateTime = dateTime.AddMonths(+@value);
result = dateTime.ToString(MacroParser.MonthFormat);
result = string.IsNullOrEmpty(dateTimeFormat) ? dateTime.ToString(MacroParser.MonthFormat) : dateTime.ToString(dateTimeFormat);
}

if (dateTimePart.Equals("day"))
{
dateTime = dateTime.AddDays(+@value);
result = dateTime.ToString(MacroParser.DayFormat);
result = string.IsNullOrEmpty(dateTimeFormat) ? dateTime.ToString(MacroParser.DayFormat) : dateTime.ToString(dateTimeFormat);
}

if (dateTimePart.Equals("hour"))
{
dateTime = dateTime.AddHours(+@value);
result = dateTime.ToString(MacroParser.HourFormat);
result = string.IsNullOrEmpty(dateTimeFormat) ? dateTime.ToString(MacroParser.HourFormat) : dateTime.ToString(dateTimeFormat);
}

if (dateTimePart.Equals("minute"))
{
dateTime = dateTime.AddMinutes(+@value);
result = dateTime.ToString(MacroParser.MinuteFormat);
result = string.IsNullOrEmpty(dateTimeFormat) ? dateTime.ToString(MacroParser.MinuteFormat) : dateTime.ToString(dateTimeFormat);
}

if (dateTimePart.Equals("second"))
{
dateTime = dateTime.AddSeconds(+@value);
result = dateTime.ToString(MacroParser.SecondFormat);
result = string.IsNullOrEmpty(dateTimeFormat) ? dateTime.ToString(MacroParser.SecondFormat) : dateTime.ToString(dateTimeFormat);
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions modules/tags/TagCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -335,10 +335,10 @@ public bool LoadXmlFileAndAddTags()
Add(new Tag("millisecond", "The current millisecond (%millisecond%)", TagType.DateTimeFormat, MacroParser.MillisecondFormat, active: true));
Add(new Tag("lastyear", "The previous year (%lastyear%)", TagType.DateTimeFormatExpression, "{year-1}", active: true));
Add(new Tag("lastmonth", "The previous month (%lastmonth%)", TagType.DateTimeFormatExpression, "{month-1}", active: true));
Add(new Tag("yesterday", "The previous day (%yesterday%)", TagType.DateTimeFormatExpression, "{day-1}", active: true));
Add(new Tag("tomorrow", "The next day (%tomorrow%)", TagType.DateTimeFormatExpression, "{day+1}", active: true));
Add(new Tag("6hoursbehind", "Six hours behind the current hour (%6hoursbehind%)", TagType.DateTimeFormatExpression, "{hour-6}", active: true));
Add(new Tag("6hoursahead", "Six hours ahead the current hour (%6hoursahead%)", TagType.DateTimeFormatExpression, "{hour+6}", active: true));
Add(new Tag("yesterday", "The previous day (%yesterday%)", TagType.DateTimeFormatExpression, "{day-1}[yyyy-MM-dd]", active: true));
Add(new Tag("tomorrow", "The next day (%tomorrow%)", TagType.DateTimeFormatExpression, "{day+1}[yyyy-MM-dd]", active: true));
Add(new Tag("6hoursbehind", "Six hours behind the current hour (%6hoursbehind%)", TagType.DateTimeFormatExpression, "{hour-6}[yyyy-MM-dd_HH-mm-ss.fff]", active: true));
Add(new Tag("6hoursahead", "Six hours ahead the current hour (%6hoursahead%)", TagType.DateTimeFormatExpression, "{hour+6}[yyyy-MM-dd_HH-mm-ss.fff]", active: true));
Add(new Tag("count", "The number of capture cycles during a running screen capture session. For example, the first round of screenshots taken is the first cycle count or count 1", TagType.ScreenCaptureCycleCount, active: true));
Add(new Tag("user", "The user using this computer (%user%)", TagType.User, active: true));
Add(new Tag("machine", "The name of the computer (%machine%)", TagType.Machine, active: true));
Expand Down
11 changes: 7 additions & 4 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Auto Screen Capture by Gavin Kendall
Last updated on 2020-08-24 (August 24, 2020)
[The information presented here refers to the latest version of the application (which is currently 2.3.2.4)]
Last updated on 2020-09-01 (September 1, 2020)
[The information presented here refers to the latest version of the application (which is currently 2.3.2.5)]
=============================================================================================================


Expand Down Expand Up @@ -352,6 +352,9 @@ text field will be available to enter a value. This value can be a date/time for
to represent the current date/time as a defined pattern or a date/time tag expression (such as "{month-1}")
which represents the current date/time modified by an operator and an applied amount of time.

As of version 2.3.2.5 you can use date/time format in a tag expression. For example, the value of the tag
expression can be "{day-1}[yyyy-MM-dd]" to show the previous day in the format yyyy-MM-dd.

If you select the Time of Day type then the Time of Day group of controls will be available. This includes
three sets of controls that enable you to specify the start time, end time, and value of three time ranges
for what you want Auto Screen Capture to consider as the morning, afternoon, and evening. The value can be
Expand All @@ -375,8 +378,8 @@ Macro tags available by default are ...
%millisecond% Date/Time Format Current millisecond as "fff"
%lastyear% Date/Time Format Expression Current year minus 1 with expression "{year-1}"
%lastmonth% Date/Time Format Expression Current month minus 1 with expression "{month-1}"
%yesterday% Date/Time Format Expression Current day minus 1 with expression "{day-1}"
%tomorrow% Date/Time Format Expression Current day plus 1 with expression "{day+1}"
%yesterday% Date/Time Format Expression Current day minus 1 with expression "{day-1}[yyyy-MM-dd]"
%tomorrow% Date/Time Format Expression Current day plus 1 with expression "{day+1}[yyyy-MM-dd]"
%6hoursbehind% Date/Time Format Expression Current hour minus 6 with expression "{hour-6}"
%6hoursahead% Date/Time Format Expression Current hour plus 6 with expression "{hour+6}"
%count% Screen Capture Cycle Count
Expand Down
4 changes: 3 additions & 1 deletion settings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public static class Settings
// screenshots data from, what could be, a very large XML document of screenshot nodes.
// This version also introduces keyboard shortcuts and it populates the Editors module with a list of applications it finds on the user's machine.
// The startup time is also faster since we no longer initialize the threads in the beginning (that, in turn, reads from the XML documents).
// New system tray icon menu items such as Region Select / Clipboard, Region Select / Auto Save, and Region Select / Edit also introduced.
private const string CODENAME_BOOMBAYAH = "Boombayah";

/// <summary>
Expand Down Expand Up @@ -154,7 +155,8 @@ public static void Initialize()
new Version(CODENAME_BOOMBAYAH, "2.3.2.0"), // Region Select Auto Save region is created if the regions.xml file is not found so you can view screenshots taken with Region Select Auto Save.
new Version(CODENAME_BOOMBAYAH, "2.3.2.1"), // Fixed bug with inactive schedules that should not perform any actions when inactive.
new Version(CODENAME_BOOMBAYAH, "2.3.2.2"), // Information Window implemented.
new Version(CODENAME_BOOMBAYAH, "2.3.2.3") // Information Window renamed to Show Screen Capture Status
new Version(CODENAME_BOOMBAYAH, "2.3.2.3"), // Information Window renamed to Show Screen Capture Status
new Version(CODENAME_BOOMBAYAH, "2.3.2.4") // ListboxScreenshots sorted.
};

Application = new SettingCollection
Expand Down

0 comments on commit 037ceb9

Please sign in to comment.