From 837b8b31813eb9c711b1a821c1a2bad3053938c8 Mon Sep 17 00:00:00 2001 From: m-hayabusa Date: Sat, 17 Aug 2024 12:21:22 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Exiftool=E3=81=AE=E3=83=80=E3=82=A6?= =?UTF-8?q?=E3=83=B3=E3=83=AD=E3=83=BC=E3=83=89=E3=81=AB=E5=A4=B1=E6=95=97?= =?UTF-8?q?=E3=81=99=E3=82=8B=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VRCImageHelper/Program.cs | 9 +++++- VRCImageHelper/Tools/Executables.cs | 2 +- VRCImageHelper/Tools/ExifTool.cs | 7 +++-- VRCImageHelper/UI/ConfigWindow.cs | 30 ++++++------------- .../UI/DownloadProgressDialog.Designer.cs | 9 +++--- VRCImageHelper/UI/DownloadProgressDialog.cs | 26 ++++++++++++++++ 6 files changed, 54 insertions(+), 29 deletions(-) diff --git a/VRCImageHelper/Program.cs b/VRCImageHelper/Program.cs index 782d596..48698ac 100644 --- a/VRCImageHelper/Program.cs +++ b/VRCImageHelper/Program.cs @@ -7,6 +7,7 @@ using VRCImageHelper.Core; using VRCImageHelper.Core.StateChecker; using VRCImageHelper.Utils; +using VRCImageHelper.Tools; internal static class Program { @@ -24,11 +25,17 @@ private static void Main() { if (args.Contains("--setup")) { + new UI.DownloadProgressDialog().Download("exiftool", () => + { + ExifTool.GetExifTool(); + return true; + }); new UI.ConfigWindow().ShowDialog(); if (VRCExifWriter.Remove()) return; var logFile = LogReader.FindLogFile(); - if (logFile != null && logFile.Exists && logFile.CreationTime == logFile.LastWriteTime) { + if (logFile != null && logFile.Exists && logFile.CreationTime == logFile.LastWriteTime) + { UI.SendNotify.Send(Properties.Resources.NotifyErrorLogFileSeemsEmptyOnSetup, false); } Process.Start(Application.ExecutablePath); diff --git a/VRCImageHelper/Tools/Executables.cs b/VRCImageHelper/Tools/Executables.cs index 9b7dc06..8676054 100644 --- a/VRCImageHelper/Tools/Executables.cs +++ b/VRCImageHelper/Tools/Executables.cs @@ -17,7 +17,7 @@ public static string Download(string fileName, string url, CancellationToken can Directory.CreateDirectory(destPath); var archive = new ZipArchive(request.Result); - archive.ExtractToDirectory(destPath); + archive.ExtractToDirectory(destPath, true); return destPath; } diff --git a/VRCImageHelper/Tools/ExifTool.cs b/VRCImageHelper/Tools/ExifTool.cs index 5dcc21e..c10557b 100644 --- a/VRCImageHelper/Tools/ExifTool.cs +++ b/VRCImageHelper/Tools/ExifTool.cs @@ -12,7 +12,7 @@ internal class ExifTool public static CancellationToken s_cancellationToken; private static string? s_exitToolPath; private static bool s_exitToolDownloading; - private static string GetExifTool() + public static string GetExifTool() { while (s_exitToolDownloading) { @@ -37,7 +37,10 @@ private static string CheckExistsAndDownload(string fileName, string url) if (path is not null) return path; var dir = Executables.Download(fileName, url, s_cancellationToken); - File.Move(dir + "\\exiftool(-k).exe", dir + "\\exiftool.exe"); + + var extracted = Directory.GetDirectories(dir).First(); + + File.Move(extracted + "\\exiftool(-k).exe", dir + "\\exiftool.exe"); return dir + "\\exiftool.exe"; } diff --git a/VRCImageHelper/UI/ConfigWindow.cs b/VRCImageHelper/UI/ConfigWindow.cs index 683cc94..2c184c6 100644 --- a/VRCImageHelper/UI/ConfigWindow.cs +++ b/VRCImageHelper/UI/ConfigWindow.cs @@ -118,7 +118,6 @@ private void ButtonResetFilePattern_Click(object sender, EventArgs e) } } - public delegate void FFMpegDownloadEnd(); private void ComboBoxFileFormat_SelectedIndexChanged(object sender, EventArgs e) { var control = (Control)sender; @@ -145,29 +144,18 @@ private void ComboBoxFileFormat_SelectedIndexChanged(object sender, EventArgs e) var res = MessageBox.Show(Resources.FFMpegDownloadMessage, Resources.FFMpegDownloadTitle, MessageBoxButtons.OKCancel); if (res == DialogResult.OK) { - var downloadingDialog = new DownloadProgressDialog() + new DownloadProgressDialog().Download("ffmpeg", () => { - Text = "Downloading...", - }; - var downloading = true; - downloadingDialog.FormClosing += (sender, e) => - { - if (downloading) - e.Cancel = true; - }; - downloadingDialog.Load += (sender, e) => - { - new Task(() => + try { FFMpeg.Download(); - BeginInvoke(new FFMpegDownloadEnd(() => - { - downloading = false; - downloadingDialog.Close(); - })); - }).Start(); - }; - downloadingDialog.ShowDialog(); + return true; + } + catch + { + return false; + } + }); } } diff --git a/VRCImageHelper/UI/DownloadProgressDialog.Designer.cs b/VRCImageHelper/UI/DownloadProgressDialog.Designer.cs index 6919147..a9931db 100644 --- a/VRCImageHelper/UI/DownloadProgressDialog.Designer.cs +++ b/VRCImageHelper/UI/DownloadProgressDialog.Designer.cs @@ -36,18 +36,19 @@ private void InitializeComponent() progressBar1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; progressBar1.Location = new Point(12, 12); progressBar1.Name = "progressBar1"; - progressBar1.Size = new Size(210, 23); + progressBar1.Size = new Size(260, 23); progressBar1.Style = ProgressBarStyle.Marquee; progressBar1.TabIndex = 0; + progressBar1.UseWaitCursor = true; // - // DownloadProgressBar + // DownloadProgressDialog // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(234, 47); + ClientSize = new Size(284, 47); Controls.Add(progressBar1); FormBorderStyle = FormBorderStyle.FixedDialog; - Name = "DownloadProgressBar"; + Name = "DownloadProgressDialog"; Text = "DownloadProgressBar"; UseWaitCursor = true; ResumeLayout(false); diff --git a/VRCImageHelper/UI/DownloadProgressDialog.cs b/VRCImageHelper/UI/DownloadProgressDialog.cs index d69485f..b138864 100644 --- a/VRCImageHelper/UI/DownloadProgressDialog.cs +++ b/VRCImageHelper/UI/DownloadProgressDialog.cs @@ -1,5 +1,6 @@ namespace VRCImageHelper.UI; using System.Windows.Forms; +using VRCImageHelper.Properties; public partial class DownloadProgressDialog : Form { @@ -7,4 +8,29 @@ public DownloadProgressDialog() { InitializeComponent(); } + + public delegate void DownloadEnd(); + public void Download(string target, Func download) + { + Text = "Downloading " + target + "..."; + var downloading = true; + FormClosing += (sender, e) => + { + if (downloading) + e.Cancel = true; + }; + Load += (sender, e) => + { + new Task(() => + { + download(); + BeginInvoke(new DownloadEnd(() => + { + downloading = false; + Close(); + })); + }).Start(); + }; + ShowDialog(); + } } From 550a9ff79eb205f74a6b9e4132f08c36aa1c6737 Mon Sep 17 00:00:00 2001 From: m-hayabusa Date: Sat, 17 Aug 2024 12:46:29 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E5=BF=85=E8=A6=81=E3=81=AA=E3=83=95?= =?UTF-8?q?=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92=E7=A7=BB=E5=8B=95=E3=81=97?= =?UTF-8?q?=E3=81=A6=E3=81=84=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F=E3=81=AE?= =?UTF-8?q?=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VRCImageHelper/Tools/ExifTool.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/VRCImageHelper/Tools/ExifTool.cs b/VRCImageHelper/Tools/ExifTool.cs index c10557b..8e53357 100644 --- a/VRCImageHelper/Tools/ExifTool.cs +++ b/VRCImageHelper/Tools/ExifTool.cs @@ -41,6 +41,7 @@ private static string CheckExistsAndDownload(string fileName, string url) var extracted = Directory.GetDirectories(dir).First(); File.Move(extracted + "\\exiftool(-k).exe", dir + "\\exiftool.exe"); + Directory.Move(extracted + "\\exiftool_files", dir + "\\exiftool_files"); return dir + "\\exiftool.exe"; }