Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved workflow (auto-create directories, quick save to sub directories, move/delete original file) #97

Open
wants to merge 37 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d06ecce
Add dialog to save in a specific subdirectory by pressing a digit key
l3if3rik Jun 16, 2024
a364648
Autosize quick subdirectory form, disable manual resizing
l3if3rik Jun 16, 2024
12ca1a2
Re-add event handlers, rename methods (convention)
l3if3rik Jun 16, 2024
b39b9f4
Use KeyPreview, improve Layout
l3if3rik Jun 18, 2024
db806a6
Change text box background color, change explanation; refactor
l3if3rik Jun 18, 2024
723456d
Add functionality to delete or move the original file after the cut w…
l3if3rik Jun 24, 2024
a7bd4c3
Assign ActionName to radio buttons tag to reduce redundant string lit…
l3if3rik Jun 25, 2024
a2e559a
Change wording
l3if3rik Jun 25, 2024
fdc4fa2
Add option to create missing directories automatically
l3if3rik Jun 25, 2024
6222835
Add buttons to quick sub directory dialog; allow escape key to close
l3if3rik Jun 28, 2024
be1402c
Use abstract class for actions; allows serialization
l3if3rik Jul 2, 2024
f77600e
Use "new" keyword
l3if3rik Jul 2, 2024
a8d5936
Follow naming conventions
l3if3rik Jul 2, 2024
bff0079
Make task readonly
l3if3rik Jul 2, 2024
5c27b13
Handle potential null references
l3if3rik Jul 2, 2024
8790f6c
Prevent PlaceholderFiller being null
l3if3rik Jul 3, 2024
8feda58
Remove debug logging
l3if3rik Jul 3, 2024
88d6b2f
Indicate Windows support
l3if3rik Jul 3, 2024
f1ebb97
Declare event handler as nullable
l3if3rik Jul 3, 2024
c006500
Adjust wording/variable name
l3if3rik Jul 3, 2024
b8e374b
Use text box instead of combo box
l3if3rik Jul 7, 2024
577bc6c
Remove obsolete property
l3if3rik Jul 7, 2024
d9efacb
Adjust control name
l3if3rik Jul 7, 2024
0824ea9
Move PlaceholderFiller to MainForm
l3if3rik Jul 8, 2024
e610412
Save in settings whether there should be a deletion confirmation
l3if3rik Jul 11, 2024
6c2f4d6
After action executed, do not open next file
l3if3rik Jul 13, 2024
673ac10
Update GUI after unloading video
l3if3rik Jul 13, 2024
6390664
Rename "EnableButtons" to "UpdateButtonStates"
l3if3rik Jul 13, 2024
6598cd0
Fix message
l3if3rik Jul 13, 2024
23027c9
Remove redundant fallback
l3if3rik Jul 13, 2024
af6f4c2
Refactor action system
l3if3rik Jul 15, 2024
40bf362
Adjust code to conventions
l3if3rik Jul 15, 2024
f2a6958
Store settings when leaving edit mode
l3if3rik Jul 15, 2024
372aac0
Fix button states after unloading/opening video
l3if3rik Jul 16, 2024
4ffd7e5
Reset file info labels after unloading file
l3if3rik Jul 25, 2024
2416a1c
Fix displayed index of current file
l3if3rik Jul 25, 2024
1efa3e2
Determine file index case-insensitively
l3if3rik Jul 25, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add option to create missing directories automatically
  • Loading branch information
l3if3rik committed Jun 25, 2024
commit fdc4fa29a360a1ddb85521056ef215803fffa078
10 changes: 6 additions & 4 deletions src/SimpleVideoCutter/Actions/MoveOriginalFileToDirectory.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using static SimpleVideoCutter.FileHelper;

namespace SimpleVideoCutter.Actions
{
Expand All @@ -26,9 +25,12 @@ public MoveOriginalFileToDirectory(string originalFilePath, string targetDirecto
public void Execute()
{
this.ActionExecuting?.Invoke(this, new ActionExecutingEventArgs(this, ActionName));
string TargetPath = Path.Combine(TargetDirectory, Path.GetFileName(OriginalFilePath));

string targetPath = Path.Combine(TargetDirectory, Path.GetFileName(OriginalFilePath));

File.Move(this.OriginalFilePath, TargetPath);
MaybeCreateParentDirectory(targetPath);

File.Move(this.OriginalFilePath, targetPath);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using static SimpleVideoCutter.FileHelper;

namespace SimpleVideoCutter.Actions
{
Expand All @@ -24,8 +25,12 @@ public MoveOriginalFileToRelativeDirectory(string originalFilePath, string targe
public void Execute()
{
this.ActionExecuting?.Invoke(this, new ActionExecutingEventArgs(this, ActionName));

string targetDirectory = Path.Combine(Path.GetDirectoryName(this.OriginalFilePath) ?? ".", this.TargetRelativeDirectory);
string targetPath = Path.Combine(targetDirectory, Path.GetFileName(this.OriginalFilePath));

MaybeCreateParentDirectory(targetPath);

File.Move(this.OriginalFilePath, targetPath);
}
}
Expand Down
22 changes: 22 additions & 0 deletions src/SimpleVideoCutter/FileHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.IO;

namespace SimpleVideoCutter
{
internal class FileHelper
{
public static void MaybeCreateParentDirectory(string? path)
{
if (path != null && VideoCutterSettings.Instance.CreateMissingDirectories)
{
string? parentDirectory = Path.GetDirectoryName(path);

if (parentDirectory == null)
{
return;
}

Directory.CreateDirectory(parentDirectory);
}
}
}
}
17 changes: 17 additions & 0 deletions src/SimpleVideoCutter/FormSettings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions src/SimpleVideoCutter/FormSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ private void SettingsToGUI()
.Checked = true;
textBoxOriginalFileAfterCutAbsoluteTargetDirectory.Text = settings.OriginalFileAfterCutAbsoluteTargetDirectory;
comboBoxOriginalFileAfterCutRelativeTargetDirectory.Text = settings.OriginalFileAfterCutRelativeTargetDirectory;
checkBoxCreateMissingDirectories.Checked = settings.CreateMissingDirectories;

SetBackgroundOfFFmpegPath();
}
Expand All @@ -99,6 +100,7 @@ private void GUIToSettings()
settings.OriginalFileActionAfterCut = groupOriginalFileActions.Controls.OfType<RadioButton>().First(rb => rb.Checked).Tag?.ToString() ?? "keep";
settings.OriginalFileAfterCutAbsoluteTargetDirectory = textBoxOriginalFileAfterCutAbsoluteTargetDirectory.Text;
settings.OriginalFileAfterCutRelativeTargetDirectory = comboBoxOriginalFileAfterCutRelativeTargetDirectory.Text;
settings.CreateMissingDirectories = checkBoxCreateMissingDirectories.Checked;

// TODO: parse VideoFilesExtensions

Expand Down
Loading