PhotoPrism

This commit is contained in:
2022-12-27 08:57:12 -07:00
parent d08cffe50d
commit e5dc8c1c05
25 changed files with 318 additions and 228 deletions

View File

@ -25,6 +25,7 @@ public partial class Form : System.Windows.Forms.Form
private readonly string _WorkingDirectory;
private readonly Configuration _Configuration;
private readonly IsEnvironment _IsEnvironment;
private readonly ProgressBar _InnerProgressBar;
private readonly Dictionary<int, Item> _IdToItem;
private readonly string _ResizeFileNameExtension;
private readonly IConfigurationRoot _ConfigurationRoot;
@ -73,8 +74,10 @@ public partial class Form : System.Windows.Forms.Form
_ResizeFileNameExtension = resizeFileNameExtension;
_TextBox = new() { Location = new(5, 5), Dock = DockStyle.Top };
_ProgressBar = new() { Location = new(5, 5), Dock = DockStyle.Top, Visible = false };
_InnerProgressBar = new() { Location = new(5, 5), Dock = DockStyle.Top, Visible = false };
Load += new EventHandler(Form1_Load);
Controls.Add(_ProgressBar);
Controls.Add(_InnerProgressBar);
Controls.Add(_TextBox);
}
@ -176,15 +179,15 @@ public partial class Form : System.Windows.Forms.Form
string checkFile;
DateTime? dateTime;
FileHolder fileHolder;
_ProgressBar.Step = 1;
bool isIgnoreExtension;
_ProgressBar.Value = 0;
string checkFileExtension;
bool skipOneAllAreNumbers;
DateTime? minimumDateTime;
const string jpg = ".jpg";
_InnerProgressBar.Step = 1;
_InnerProgressBar.Value = 0;
const string jpeg = ".jpeg";
_ProgressBar.Visible = true;
_InnerProgressBar.Visible = true;
bool isValidImageFormatExtension;
string? extraLargeBitmapThumbnail;
string[] files = Directory.GetFiles(directory, searchPattern, SearchOption.TopDirectoryOnly);
@ -193,10 +196,10 @@ public partial class Form : System.Windows.Forms.Form
foreach (string file in files)
File.Delete(file);
}
_ProgressBar.Maximum = files.Length;
_InnerProgressBar.Maximum = files.Length;
foreach (string file in files)
{
_ProgressBar.PerformStep();
_InnerProgressBar.PerformStep();
fileHolder = new(file);
_Lines.Add(fileHolder.NameWithoutExtension);
if (fileHolder.ExtensionLowered == ".id" || fileHolder.DirectoryName is null)
@ -262,7 +265,7 @@ public partial class Form : System.Windows.Forms.Form
File.Move(fileHolder.FullName, checkFile);
File.WriteAllText($"{checkFile}.id", $"{id.Value}{Environment.NewLine}{fileHolder.Name}");
}
_ProgressBar.Visible = false;
_InnerProgressBar.Visible = false;
}
private string? SaveExtraLargeBitmapThumbnail(FileHolder fileHolder)
@ -402,10 +405,15 @@ public partial class Form : System.Windows.Forms.Form
{
string directoryName;
ReadOnlySpan<char> span;
_ProgressBar.Step = 1;
_ProgressBar.Visible = true;
_ProgressBar.Maximum = directories.Count;
for (int i = 1; i < 3; i++)
{
_ProgressBar.Value = 0;
foreach (string directory in directories)
{
_ProgressBar.PerformStep();
if (directory.Length < 6)
continue;
directoryName = Path.GetFileName(directory);
@ -438,6 +446,7 @@ public partial class Form : System.Windows.Forms.Form
}
File.WriteAllLines($"D:/Tmp/Phares/{DateTime.Now.Ticks}.tsv", _Lines);
_Lines.Clear();
_ProgressBar.Visible = false;
}
void Form1_DragDrop(object? sender, DragEventArgs e)