Skip to content

Commit

Permalink
Splash screen implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
XyLe-GBP committed Apr 29, 2022
1 parent 8ffacf4 commit 1283de4
Show file tree
Hide file tree
Showing 16 changed files with 395 additions and 11 deletions.
72 changes: 72 additions & 0 deletions Localization/Strings.Designer.cs

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

24 changes: 24 additions & 0 deletions Localization/Strings.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,30 @@ Please configure the settings from the 'Settings' item.</value>
<data name="SizeString" xml:space="preserve">
<value>Bytes.</value>
</data>
<data name="SplashFormConfigCaption" xml:space="preserve">
<value>Checking configuration information...</value>
</data>
<data name="SplashFormFFCaption" xml:space="preserve">
<value>Check for FFmpeg updates...</value>
</data>
<data name="SplashFormFileCaption" xml:space="preserve">
<value>Loaded: '{0}'</value>
</data>
<data name="SplashFormFinalCaption" xml:space="preserve">
<value>Running...</value>
</data>
<data name="SplashFormSystemCaption" xml:space="preserve">
<value>Getting system information...</value>
</data>
<data name="SplashFormUpdateCaption" xml:space="preserve">
<value>Check for updates...</value>
</data>
<data name="SplashFormUpdatedCaption" xml:space="preserve">
<value>Update Successfuly.</value>
</data>
<data name="SplashFormUpdatingCaption" xml:space="preserve">
<value>Updating application...</value>
</data>
<data name="UnExpectedError" xml:space="preserve">
<value>An unexpected error has occurred.
{0}</value>
Expand Down
24 changes: 24 additions & 0 deletions Localization/Strings.ja.resx
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,30 @@ Real-ESRGAN Photo: 写真等をアップスケールする際に適したモデ
<data name="SizeString" xml:space="preserve">
<value>バイト</value>
</data>
<data name="SplashFormConfigCaption" xml:space="preserve">
<value>アプリケーション設定の確認中...</value>
</data>
<data name="SplashFormFFCaption" xml:space="preserve">
<value>FFmpegのアップデートを確認中...</value>
</data>
<data name="SplashFormFileCaption" xml:space="preserve">
<value>読み込み:'{0}'</value>
</data>
<data name="SplashFormFinalCaption" xml:space="preserve">
<value>起動中…</value>
</data>
<data name="SplashFormSystemCaption" xml:space="preserve">
<value>システム情報の取得中…</value>
</data>
<data name="SplashFormUpdateCaption" xml:space="preserve">
<value>更新の確認中...</value>
</data>
<data name="SplashFormUpdatedCaption" xml:space="preserve">
<value>アップデート完了</value>
</data>
<data name="SplashFormUpdatingCaption" xml:space="preserve">
<value>アプリケーションのアップデート中…</value>
</data>
<data name="UnExpectedError" xml:space="preserve">
<value>予期せぬエラーが発生しました。
{0}</value>
Expand Down
24 changes: 24 additions & 0 deletions Localization/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,30 @@ Please configure the settings from the 'Settings' item.</value>
<data name="SizeString" xml:space="preserve">
<value>Bytes.</value>
</data>
<data name="SplashFormConfigCaption" xml:space="preserve">
<value>Checking configuration information...</value>
</data>
<data name="SplashFormFFCaption" xml:space="preserve">
<value>Check for FFmpeg updates...</value>
</data>
<data name="SplashFormFileCaption" xml:space="preserve">
<value>Loaded: '{0}'</value>
</data>
<data name="SplashFormFinalCaption" xml:space="preserve">
<value>Running...</value>
</data>
<data name="SplashFormSystemCaption" xml:space="preserve">
<value>Getting system information...</value>
</data>
<data name="SplashFormUpdateCaption" xml:space="preserve">
<value>Check for updates...</value>
</data>
<data name="SplashFormUpdatedCaption" xml:space="preserve">
<value>Update Successfuly.</value>
</data>
<data name="SplashFormUpdatingCaption" xml:space="preserve">
<value>Updating application...</value>
</data>
<data name="UnExpectedError" xml:space="preserve">
<value>An unexpected error has occurred.
{0}</value>
Expand Down
24 changes: 24 additions & 0 deletions Localization/Strings.zh.resx
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,30 @@ Real-ESRGAN Photo:该模型适用于放大照片等。</value>
<data name="SizeString" xml:space="preserve">
<value>字节</value>
</data>
<data name="SplashFormConfigCaption" xml:space="preserve">
<value>检查应用程序设置...</value>
</data>
<data name="SplashFormFFCaption" xml:space="preserve">
<value>检查FFmpeg的更新...</value>
</data>
<data name="SplashFormFileCaption" xml:space="preserve">
<value>阅读:'{0}'</value>
</data>
<data name="SplashFormFinalCaption" xml:space="preserve">
<value>激活...</value>
</data>
<data name="SplashFormSystemCaption" xml:space="preserve">
<value>获取系统信息的过程中...</value>
</data>
<data name="SplashFormUpdateCaption" xml:space="preserve">
<value>检查更新...</value>
</data>
<data name="SplashFormUpdatedCaption" xml:space="preserve">
<value>更新完成。</value>
</data>
<data name="SplashFormUpdatingCaption" xml:space="preserve">
<value>更新正在进行的申请...</value>
</data>
<data name="UnExpectedError" xml:space="preserve">
<value>发生了一个意外的错误。
{0}</value>
Expand Down
10 changes: 10 additions & 0 deletions Properties/Resources.Designer.cs

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

9 changes: 6 additions & 3 deletions Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="opencv_logo" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>opencv-logo.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
Expand All @@ -136,4 +136,7 @@
<data name="_2021_9_13_18_29_59_Upscaled" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>2021-9-13-18-29-59_Upscaled.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="waifu2x_splash" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>waifu2x-splash.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
Binary file added Properties/waifu2x-splash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion VERSIONINFO
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version:1.29.2220.412
version:1.29.2220.429
6 changes: 6 additions & 0 deletions src/Common.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,12 @@ public static async Task<Stream> GetWebStreamAsync(HttpClient httpClient, Uri ur
{
return await httpClient.GetStreamAsync(uri);
}

public static async Task<Image> GetWebImageAsync(HttpClient httpClient, Uri uri)
{
using Stream stream = await GetWebStreamAsync(httpClient, uri);
return Image.FromStream(stream);
}
}
}

Expand Down
41 changes: 37 additions & 4 deletions src/Forms/FormMain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@ private void FormMain_Load(object sender, EventArgs e)
FileVersionInfo ver = FileVersionInfo.GetVersionInfo(Application.ExecutablePath);
Text = "waifu2x-nvger ( build: " + ver.FileVersion.ToString() + "-Beta )";

using FormSplash splash = new();
splash.Show();
splash.Refresh();

foreach (var files in Directory.GetFiles(Directory.GetCurrentDirectory() + @"\res", "*", SearchOption.AllDirectories))
{
FileInfo fi = new(files);
RefleshSplashForm(splash, string.Format(Strings.SplashFormFileCaption, fi.Name));
}

RefleshSplashForm(splash, Strings.SplashFormSystemCaption);

label1.Text = Strings.DragDropCaption;

string[] OSInfo = new string[17];
Expand All @@ -51,6 +63,8 @@ private void FormMain_Load(object sender, EventArgs e)
label_Graphic.Text = GPUInfo[0] + " - " + GPUInfo[1] + " [ " + GPUInfo[2] + " RAM ]";
toolStripStatusLabel_Status.ForeColor = Color.FromArgb(0, 255, 0, 0);

RefleshSplashForm(splash, Strings.SplashFormConfigCaption);

if (!File.Exists(Common.xmlpath))
{
Common.InitConfig();
Expand Down Expand Up @@ -97,20 +111,32 @@ private void FormMain_Load(object sender, EventArgs e)

if (File.Exists(Directory.GetCurrentDirectory() + @"\updated.dat"))
{
RefleshSplashForm(splash, Strings.SplashFormUpdatingCaption);
File.Delete(Directory.GetCurrentDirectory() + @"\updated.dat");
string updpath = Directory.GetCurrentDirectory()[..Directory.GetCurrentDirectory().LastIndexOf('\\')];
File.Delete(updpath + @"\updater.exe");
File.Delete(updpath + @"\waifu2x-nvger.zip");
Common.DeleteDirectory(updpath + @"\updater-temp");

RefleshSplashForm(splash, Strings.SplashFormUpdatedCaption);
MessageBox.Show(Strings.UpdateCompletedCaption, Strings.MSGInfo, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
CheckForUpdatesForInit();
RefleshSplashForm(splash, Strings.SplashFormUpdateCaption);
var update = Task.Run(() => CheckForUpdatesForInit());
update.Wait();
}

Task.Run(() => CheckForFFmpeg());
RefleshSplashForm(splash, Strings.SplashFormFFCaption);

var ffupdate = Task.Run(() => CheckForFFmpeg());
ffupdate.Wait();

RefleshSplashForm(splash, Strings.SplashFormFinalCaption);

splash.Close();
Activate();
}

private void OpenImegeIToolStripMenuItem_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -4190,7 +4216,7 @@ private async void CheckForUpdatesUToolStripMenuItem_Click(object sender, EventA
/// <summary>
/// 起動時のアップデート確認
/// </summary>
private async void CheckForUpdatesForInit()
private async Task CheckForUpdatesForInit()
{
if (NetworkInterface.GetIsNetworkAvailable())
{
Expand Down Expand Up @@ -4289,7 +4315,7 @@ private async void CheckForUpdatesForInit()
}
}

private async void CheckForFFmpeg()
private async Task CheckForFFmpeg()
{
if (NetworkInterface.GetIsNetworkAvailable())
{
Expand Down Expand Up @@ -4537,5 +4563,12 @@ private async void CheckForFFmpeg()
return;
}
}

private static void RefleshSplashForm(FormSplash form, string text)
{
form.ProgressMsg = text;
Application.DoEvents();
System.Threading.Thread.Sleep(10);
}
}
}
Loading

0 comments on commit 1283de4

Please sign in to comment.