Skip to content

Commit

Permalink
2.3.3.2 - Can now run an Editor without arguments or without %filepat…
Browse files Browse the repository at this point in the history
…h% tag when using Run Editor trigger action. Includes changes to version collection, change to how Application Focus behaves when application not found (so now adds the application to the process list regardless), and bug fix applied to threads.
  • Loading branch information
gavinkendall committed Nov 10, 2020
1 parent c008210 commit b01de4c
Show file tree
Hide file tree
Showing 11 changed files with 186 additions and 134 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.3.1")]
[assembly: AssemblyFileVersion("2.3.3.1")]
[assembly: AssemblyVersion("2.3.3.2")]
[assembly: AssemblyFileVersion("2.3.3.2")]
[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.3.1"/>
version="2.3.3.2"/>
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>True/PM</dpiAware>
Expand Down
3 changes: 2 additions & 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.3.1 ("Boombayah")
<value>Auto Screen Capture 2.3.3.2 ("Boombayah")
Developed by Gavin Kendall (2008 - 2020)

SourceForge Project Site
Expand Down Expand Up @@ -322,6 +322,7 @@ END OF TERMS AND CONDITIONS</value>
</data>
<data name="richTextBoxChangelog.Text" xml:space="preserve">
<value>Codename "Boombayah"
2.3.3.2 Can now run an Editor without arguments or without %filepath% tag when using Run Editor trigger action. Includes changes to version collection, change to how Application Focus behaves when application not found (so now adds the application to the process list regardless), and bug fix applied to threads.
2.3.3.1 New command line arguments -activeWindowTitle, -applicationFocus, and -label.
2.3.3.0 Application Focus moved from Screen to Setup. Fixed Application Focus bug with Active Window Title. Renamed user setting keys. New method for capturing device display resolution.
2.3.2.9 Application Focus implemented for Screen.
Expand Down
75 changes: 60 additions & 15 deletions interface/main/FormMain-Editors.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ private void runEditor_Click(object sender, EventArgs e)
{
Editor editor = _formEditor.EditorCollection.GetByName(sender.ToString());

if (!RunEditor(editor))
if (!RunEditor(editor, Slideshow.SelectedSlide))
{
MessageBox.Show("No image is available to edit.", "No Image", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Expand Down Expand Up @@ -134,22 +134,21 @@ private void changeEditor_Click(object sender, EventArgs e)
/// Executes a chosen image editor from the interface.
/// </summary>
/// <param name="editor">The image editor to execute.</param>
private bool RunEditor(Editor editor)
/// <param name="slide">The slide to use when running the editor.</param>
private bool RunEditor(Editor editor, Slide slide)
{
if (editor != null && Slideshow.SelectedSlide != null)
if (editor != null && slide != null)
{
Slide selectedSlide = Slideshow.SelectedSlide;

if (tabControlViews.SelectedTab.Tag.GetType() == typeof(Screen))
{
Screen screen = (Screen)tabControlViews.SelectedTab.Tag;
return RunEditor(editor, _screenshotCollection.GetScreenshot(selectedSlide.Name, screen.ViewId));
return RunEditor(editor, _screenshotCollection.GetScreenshot(slide.Name, screen.ViewId));
}

if (tabControlViews.SelectedTab.Tag.GetType() == typeof(Region))
{
Region region = (Region)tabControlViews.SelectedTab.Tag;
return RunEditor(editor, _screenshotCollection.GetScreenshot(selectedSlide.Name, region.ViewId));
return RunEditor(editor, _screenshotCollection.GetScreenshot(slide.Name, region.ViewId));
}
}

Expand All @@ -165,20 +164,32 @@ private void RunEditor(Editor editor, TriggerActionType triggerActionType)
{
if (editor != null && triggerActionType == TriggerActionType.RunEditor)
{
DateTime dt = _screenCapture.DateTimeScreenshotsTaken;

foreach (Screenshot screenshot in _screenshotCollection.GetScreenshots(dt.ToString(MacroParser.DateFormat), dt.ToString(MacroParser.TimeFormat)))
// Assume we're going to be passing in the path of the screenshot image to the program.
if (editor.Arguments.Contains("%filepath%"))
{
if (screenshot != null && screenshot.Slide != null && !string.IsNullOrEmpty(screenshot.Path))
{
Log.WriteDebugMessage("Running editor (based on TriggerActionType.RunEditor) \"" + editor.Name + "\" using screenshot path \"" + screenshot.Path + "\"");
DateTime dt = _screenCapture.DateTimeScreenshotsTaken;

if (!RunEditor(editor, screenshot))
foreach (Screenshot screenshot in _screenshotCollection.GetScreenshots(dt.ToString(MacroParser.DateFormat), dt.ToString(MacroParser.TimeFormat)))
{
if (screenshot != null && screenshot.Slide != null && !string.IsNullOrEmpty(screenshot.Path))
{
Log.WriteDebugMessage("Running editor failed. Perhaps the filepath of the screenshot file is no longer available");
Log.WriteDebugMessage("Running editor (based on TriggerActionType.RunEditor) \"" + editor.Name + "\" using screenshot path \"" + screenshot.Path + "\"");

if (!RunEditor(editor, screenshot))
{
Log.WriteDebugMessage("Running editor failed. Perhaps the filepath of the screenshot file is no longer available");
}
}
}
}
else
{
// Just run the program without passing in the path of the screenshot.
if (!RunEditor(editor))
{
Log.WriteDebugMessage("Running editor failed.");
}
}
}
}

Expand All @@ -187,6 +198,7 @@ private void RunEditor(Editor editor, TriggerActionType triggerActionType)
/// </summary>
/// <param name="editor">The editor to use.</param>
/// <param name="screenshot">The screenshot to use.</param>
/// <returns>Determines if the editor was executed successfully or not.</returns>
private bool RunEditor(Editor editor, Screenshot screenshot)
{
// Execute the chosen image editor. If the %filepath% argument happens to be included
Expand All @@ -208,5 +220,38 @@ private bool RunEditor(Editor editor, Screenshot screenshot)
// We failed to open the editor with the given screenshot path.
return false;
}

/// <summary>
/// Runs an editor.
/// </summary>
/// <param name="editor">The editor to run.</param>
/// <returns>Determines if the editor was executed successfully or not.</returns>
private bool RunEditor(Editor editor)
{
try
{
if (editor != null && FileSystem.FileExists(editor.Application))
{
if (!string.IsNullOrEmpty(editor.Arguments))
{
_ = Process.Start(editor.Application, editor.Arguments);
}
else
{
_ = Process.Start(editor.Application);
}

return true;
}

return false;
}
catch (Exception ex)
{
Log.WriteExceptionMessage("FormMain-Editors::RunEditor", ex);

return false;
}
}
}
}
8 changes: 3 additions & 5 deletions interface/main/FormMain-Filters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,10 @@ private void SearchFilterValues()

runFilterSearchThread.DoWork += new DoWorkEventHandler(DoWork_runFilterSearchThread);
}
else

if (!runFilterSearchThread.IsBusy)
{
if (!runFilterSearchThread.IsBusy)
{
runFilterSearchThread.RunWorkerAsync();
}
runFilterSearchThread.RunWorkerAsync();
}

comboBoxFilterValue.EndUpdate();
Expand Down
16 changes: 6 additions & 10 deletions interface/main/FormMain-Screenshots.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,10 @@ private void SaveScreenshots()

runSaveScreenshotsThread.DoWork += new DoWorkEventHandler(DoWork_runSaveScreenshotsThread);
}
else

if (!runSaveScreenshotsThread.IsBusy)
{
if (!runSaveScreenshotsThread.IsBusy)
{
runSaveScreenshotsThread.RunWorkerAsync();
}
runSaveScreenshotsThread.RunWorkerAsync();
}
}

Expand Down Expand Up @@ -138,12 +136,10 @@ private void SearchScreenshots()

runScreenshotSearchThread.DoWork += new DoWorkEventHandler(DoWork_runScreenshotSearchThread);
}
else

if (!runScreenshotSearchThread.IsBusy)
{
if (!runScreenshotSearchThread.IsBusy)
{
runScreenshotSearchThread.RunWorkerAsync();
}
runScreenshotSearchThread.RunWorkerAsync();
}

listBoxScreenshots.EndUpdate();
Expand Down
13 changes: 9 additions & 4 deletions interface/main/FormMain-Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -283,16 +283,21 @@ private void RefreshApplicationFocusList()
}
}

int indexOf = comboBoxProcessList.Items.IndexOf(Settings.User.GetByKey("ApplicationFocus", DefaultSettings.ApplicationFocus).Value.ToString());
string applicationFocus = Settings.User.GetByKey("ApplicationFocus", DefaultSettings.ApplicationFocus).Value.ToString();

if (indexOf == -1)
if (string.IsNullOrEmpty(applicationFocus))
{
comboBoxProcessList.SelectedIndex = 0;

return;
}
else

if (!comboBoxProcessList.Items.Contains(applicationFocus))
{
comboBoxProcessList.SelectedIndex = indexOf;
comboBoxProcessList.Items.Add(applicationFocus);
}

comboBoxProcessList.SelectedIndex = comboBoxProcessList.Items.IndexOf(applicationFocus);
}
}
}
21 changes: 9 additions & 12 deletions interface/main/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public FormMain()
InitializeComponent();

RegisterKeyboardShortcuts();
_hotKeyMap.KeyPressed += new EventHandler<KeyPressedEventArgs>(hotKey_KeyPressed);
_hotKeyMap.KeyPressed += new EventHandler<KeyPressedEventArgs>(hotKey_KeyPressed);

LoadSettings();

Expand Down Expand Up @@ -204,13 +204,12 @@ private void SearchDates()

runDateSearchThread.DoWork += new DoWorkEventHandler(DoWork_runDateSearchThread);
}
else

if (!runDateSearchThread.IsBusy)
{
if (!runDateSearchThread.IsBusy)
{
runDateSearchThread.RunWorkerAsync();
}
runDateSearchThread.RunWorkerAsync();
}

}

private void DeleteSlides()
Expand All @@ -227,12 +226,10 @@ private void DeleteSlides()

runDeleteSlidesThread.DoWork += new DoWorkEventHandler(DoWork_runDeleteSlidesThread);
}
else

if (!runDeleteSlidesThread.IsBusy)
{
if (!runDeleteSlidesThread.IsBusy)
{
runDeleteSlidesThread.RunWorkerAsync();
}
runDeleteSlidesThread.RunWorkerAsync();
}
}

Expand All @@ -244,7 +241,7 @@ private void RunDateSearch(DoWorkEventArgs e)
{
if (monthCalendar.InvokeRequired)
{
monthCalendar.Invoke(new RunDateSearchDelegate(RunDateSearch), new object[] {e});
monthCalendar.Invoke(new RunDateSearchDelegate(RunDateSearch), new object[] { e });
}
else
{
Expand Down
4 changes: 2 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Auto Screen Capture by Gavin Kendall
This file was last updated on 2020-11-03 (November 3, 2020)
[The information presented here refers to the latest version of the application (which is currently 2.3.3.1)]

[The information presented here refers to the latest version of the application (which is currently 2.3.3.2)]
========================================================================================================================


Expand Down
Loading

0 comments on commit b01de4c

Please sign in to comment.