From 037ceb975aef1b22142e5d90cfd9ba302083ce9d Mon Sep 17 00:00:00 2001 From: Gavin Kendall Date: Tue, 1 Sep 2020 10:32:07 -0400 Subject: [PATCH] 2.3.2.5 - Macro tag expressions can now parse date time format. --- Properties/AssemblyInfo.cs | 4 ++-- app.manifest | 2 +- interface/FormAbout.resx | 2 +- interface/main/FormMain-Editors.cs | 3 ++- interface/main/FormMain-SystemTrayIcon.cs | 28 ++++++++++++++++++++++ macro/MacroParser.cs | 2 +- macro/MacroTagExpressionParser.cs | 29 ++++++++++++----------- modules/tags/TagCollection.cs | 8 +++---- readme.txt | 11 +++++---- settings/Settings.cs | 4 +++- 10 files changed, 64 insertions(+), 29 deletions(-) diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index ccd9be9b..bf41893e 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -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")] \ No newline at end of file diff --git a/app.manifest b/app.manifest index fec092e6..818239ec 100644 --- a/app.manifest +++ b/app.manifest @@ -3,7 +3,7 @@ + version="2.3.2.5"/> True/PM diff --git a/interface/FormAbout.resx b/interface/FormAbout.resx index b215a1a7..4b1485e4 100644 --- a/interface/FormAbout.resx +++ b/interface/FormAbout.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Auto Screen Capture 2.3.2.4 ("Boombayah") + Auto Screen Capture 2.3.2.5 ("Boombayah") Developed by Gavin Kendall (2008 - 2020) https://autoscreen.sourceforge.io/ diff --git a/interface/main/FormMain-Editors.cs b/interface/main/FormMain-Editors.cs index 1cde6b57..e59a49a1 100644 --- a/interface/main/FormMain-Editors.cs +++ b/interface/main/FormMain-Editors.cs @@ -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); diff --git a/interface/main/FormMain-SystemTrayIcon.cs b/interface/main/FormMain-SystemTrayIcon.cs index bac80404..7eaf0bad 100644 --- a/interface/main/FormMain-SystemTrayIcon.cs +++ b/interface/main/FormMain-SystemTrayIcon.cs @@ -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; + } } /// @@ -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) diff --git a/macro/MacroParser.cs b/macro/MacroParser.cs index 0728cc57..06871e59 100644 --- a/macro/MacroParser.cs +++ b/macro/MacroParser.cs @@ -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(); diff --git a/macro/MacroTagExpressionParser.cs b/macro/MacroTagExpressionParser.cs index 028b7ff7..4e4939b2 100644 --- a/macro/MacroTagExpressionParser.cs +++ b/macro/MacroTagExpressionParser.cs @@ -1,5 +1,5 @@ //----------------------------------------------------------------------- -// +// // Copyright (c) 2020 Gavin Kendall // // Gavin Kendall @@ -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 = @"^\{(?year|month|day|hour|minute|second)(?[\-\+])(?\d{1,5})\}$"; + private static readonly string DateTimeFormatTagExpressionRegex = @"^\{(?year|month|day|hour|minute|second)(?[\-\+])(?\d{1,5})\}(?\[.+\])?$"; /// /// Parses macro tag expressions for date/time format. @@ -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); } } @@ -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); } } } diff --git a/modules/tags/TagCollection.cs b/modules/tags/TagCollection.cs index 26c5d098..ae656c98 100644 --- a/modules/tags/TagCollection.cs +++ b/modules/tags/TagCollection.cs @@ -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)); diff --git a/readme.txt b/readme.txt index 21b38b5f..d80ffb1c 100644 --- a/readme.txt +++ b/readme.txt @@ -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)] ============================================================================================================= @@ -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 @@ -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 diff --git a/settings/Settings.cs b/settings/Settings.cs index 17f491d2..4d5b8255 100644 --- a/settings/Settings.cs +++ b/settings/Settings.cs @@ -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"; /// @@ -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