From 3967fecf6ae9ce3e573ac30d318cabe86d583639 Mon Sep 17 00:00:00 2001 From: anon Date: Sat, 25 Dec 2021 18:37:47 +0900 Subject: [PATCH] Optimize showing forms - Each forms will be only open 1 instance. - Save size of add new game dropping form - Show only installed games or all games - Changed to include language resources in one exec binary --- KsGameLauncher/App.config | 6 ++ KsGameLauncher/Forms/AboutForm.cs | 2 +- KsGameLauncher/Forms/AccountForm.cs | 65 +++++++++----- ...Designer.cs => AddNewGameForm.Designer.cs} | 13 +-- .../{AddNewGame.cs => AddNewGameForm.cs} | 25 ++++-- .../{AddNewGame.resx => AddNewGameForm.resx} | 0 KsGameLauncher/Forms/MainForm.Designer.cs | 1 - KsGameLauncher/Forms/MainForm.cs | 88 ++++++++++++------- KsGameLauncher/Forms/OptionsForm.Designer.cs | 21 ++++- KsGameLauncher/Forms/OptionsForm.cs | 26 ++++-- KsGameLauncher/KsGameLauncher.csproj | 28 ++++-- KsGameLauncher/Launcher.cs | 30 +++++-- .../Properties/Settings.Designer.cs | 24 +++++ KsGameLauncher/Properties/Settings.settings | 6 ++ KsGameLauncher/Resources.Designer.cs | 9 ++ KsGameLauncher/Resources.ja-JP.resx | 3 + KsGameLauncher/Resources.resx | 3 + KsGameLauncher/packages.config | 3 +- 18 files changed, 257 insertions(+), 96 deletions(-) rename KsGameLauncher/Forms/{AddNewGame.Designer.cs => AddNewGameForm.Designer.cs} (89%) rename KsGameLauncher/Forms/{AddNewGame.cs => AddNewGameForm.cs} (81%) rename KsGameLauncher/Forms/{AddNewGame.resx => AddNewGameForm.resx} (100%) diff --git a/KsGameLauncher/App.config b/KsGameLauncher/App.config index 436c105..4aaebda 100644 --- a/KsGameLauncher/App.config +++ b/KsGameLauncher/App.config @@ -117,6 +117,12 @@ #login>div>a.link-btn + + True + + + 400, 300 + diff --git a/KsGameLauncher/Forms/AboutForm.cs b/KsGameLauncher/Forms/AboutForm.cs index cd74252..e4c7638 100644 --- a/KsGameLauncher/Forms/AboutForm.cs +++ b/KsGameLauncher/Forms/AboutForm.cs @@ -19,7 +19,7 @@ private void About_Load(object sender, EventArgs e) label_Version.Text = "ver. " + Application.ProductVersion; label_Develop.Text = Resources.LabelDeveloper; AppDeveloper.Text = Properties.Resources.Developers; - textBox_SpecialThanks.Text = + textBox_SpecialThanks.Text = //string.Format("AppIcon: {0}", Properties.Resources.AppIconDesigner) + Properties.Resources.SpecialThanks; linkLabel_Support.Text = Properties.Resources.SupportLabelText; diff --git a/KsGameLauncher/Forms/AccountForm.cs b/KsGameLauncher/Forms/AccountForm.cs index 41ec60e..065da14 100644 --- a/KsGameLauncher/Forms/AccountForm.cs +++ b/KsGameLauncher/Forms/AccountForm.cs @@ -35,23 +35,33 @@ private void AccountForm_Load(object sender, EventArgs e) button_Remove.Enabled = false; if (!RefreshRegisteredAccounts()) { - // There are no account registered - // Display credential input prompt - bool save = true; - credential = CredentialManager.PromptForCredentials(CredentialName, ref save, - Resources.EnterYourAccountPasswordPrompt, Resources.AppName, ""); - if (credential != null) + try + { + + // There are no account registered + // Display credential input prompt + bool save = true; + credential = CredentialManager.PromptForCredentials(CredentialName, ref save, + Resources.EnterYourAccountPasswordPrompt, Resources.AppName, ""); + if (credential != null) + { + credential.Domain = Properties.Resources.AuthorizeDomain; + CredentialManager.SaveCredentials(CredentialName, credential); + } + + } + catch (ArgumentNullException) { - credential.Domain = Properties.Resources.AuthorizeDomain; - CredentialManager.SaveCredentials(CredentialName, credential); } RefreshRegisteredAccounts(); } } - async private void Button_Remove_Click(object sender, EventArgs e) + private async void Button_Remove_Click(object sender, EventArgs e) { - DialogResult result = MessageBox.Show(Resources.ConfirmToRemoveAccountFromList, Resources.ConfirmToRemove, MessageBoxButtons.YesNo, MessageBoxIcon.Question); + DialogResult result = MessageBox.Show(Resources.ConfirmToRemoveAccountFromList, Resources.ConfirmToRemove, + MessageBoxButtons.YesNo, MessageBoxIcon.Question, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); if (result == DialogResult.Yes) { try @@ -59,12 +69,15 @@ async private void Button_Remove_Click(object sender, EventArgs e) if (CredentialManager.RemoveCredentials(CredentialName)) { await Launcher.Logout(); + credential = CredentialManager.GetCredentials(CredentialName); RefreshRegisteredAccounts(); MessageBox.Show(Resources.AccountRemoveSucceeded); } else { - result = MessageBox.Show(Resources.AccountRemoveFailed, Resources.AppName, MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); + result = MessageBox.Show(Resources.AccountRemoveFailed, Resources.AppName, + MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); if (result == DialogResult.Retry) { Utils.Common.OpenControlPanel("keymgr.dll,KRShowKeyMgr"); @@ -73,7 +86,9 @@ async private void Button_Remove_Click(object sender, EventArgs e) } catch (CredentialAPIException) { - result = MessageBox.Show(Resources.AccountRemoveFailed, Resources.AppName, MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); + result = MessageBox.Show(Resources.AccountRemoveFailed, Resources.AppName, + MessageBoxButtons.RetryCancel, MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); if (result == DialogResult.Retry) { Utils.Common.OpenControlPanel("keymgr.dll,KRShowKeyMgr"); @@ -82,22 +97,32 @@ async private void Button_Remove_Click(object sender, EventArgs e) } } - private void Button_Update_Click(object sender, EventArgs e) + private async void Button_Update_Click(object sender, EventArgs e) { bool save = true; string defaultUserName = ""; if (credential != null) defaultUserName = credential.UserName; - - credential = CredentialManager.PromptForCredentials(CredentialName, ref save, Resources.EnterYourAccountPasswordPrompt, Resources.AppName, defaultUserName); - if (credential != null) + try { - credential.Domain = Properties.Resources.AuthorizeDomain; - CredentialManager.SaveCredentials(CredentialName, credential); + + credential = CredentialManager.PromptForCredentials(CredentialName, ref save, + Resources.EnterYourAccountPasswordPrompt, Resources.AppName, defaultUserName); + if (credential != null) + { + credential.Domain = Properties.Resources.AuthorizeDomain; + CredentialManager.SaveCredentials(CredentialName, credential); + } + + if (save) + { + await Launcher.Logout(); + RefreshRegisteredAccounts(); + } } - if (save) + catch (ArgumentNullException) { - RefreshRegisteredAccounts(); + } } diff --git a/KsGameLauncher/Forms/AddNewGame.Designer.cs b/KsGameLauncher/Forms/AddNewGameForm.Designer.cs similarity index 89% rename from KsGameLauncher/Forms/AddNewGame.Designer.cs rename to KsGameLauncher/Forms/AddNewGameForm.Designer.cs index 89d847a..b74c1de 100644 --- a/KsGameLauncher/Forms/AddNewGame.Designer.cs +++ b/KsGameLauncher/Forms/AddNewGameForm.Designer.cs @@ -1,6 +1,6 @@ -namespace KsGameLauncher.Forms +namespace KsGameLauncher { - partial class AddNewGame + partial class AddNewGameForm { /// /// Required designer variable. @@ -38,24 +38,25 @@ private void InitializeComponent() | System.Windows.Forms.AnchorStyles.Right))); this.groupBox_DragHere.Location = new System.Drawing.Point(12, 12); this.groupBox_DragHere.Name = "groupBox_DragHere"; - this.groupBox_DragHere.Size = new System.Drawing.Size(371, 225); + this.groupBox_DragHere.Size = new System.Drawing.Size(360, 237); this.groupBox_DragHere.TabIndex = 0; this.groupBox_DragHere.TabStop = false; this.groupBox_DragHere.Text = "Drag here"; this.groupBox_DragHere.DragDrop += new System.Windows.Forms.DragEventHandler(this.AddNewGame_DragDrop); this.groupBox_DragHere.DragEnter += new System.Windows.Forms.DragEventHandler(this.AddNewGame_DragEnter); // - // AddNewGame + // AddNewGameForm // this.AllowDrop = true; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(395, 249); + this.ClientSize = new System.Drawing.Size(384, 261); this.Controls.Add(this.groupBox_DragHere); this.MinimizeBox = false; - this.Name = "AddNewGame"; + this.Name = "AddNewGameForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "AddNewGame"; + this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.AddNewGameForm_FormClosed); this.Load += new System.EventHandler(this.AddNewGame_Load); this.DragDrop += new System.Windows.Forms.DragEventHandler(this.AddNewGame_DragDrop); this.DragEnter += new System.Windows.Forms.DragEventHandler(this.AddNewGame_DragEnter); diff --git a/KsGameLauncher/Forms/AddNewGame.cs b/KsGameLauncher/Forms/AddNewGameForm.cs similarity index 81% rename from KsGameLauncher/Forms/AddNewGame.cs rename to KsGameLauncher/Forms/AddNewGameForm.cs index 485ec66..d016c40 100644 --- a/KsGameLauncher/Forms/AddNewGame.cs +++ b/KsGameLauncher/Forms/AddNewGameForm.cs @@ -3,11 +3,11 @@ using System.IO; using System.Windows.Forms; -namespace KsGameLauncher.Forms +namespace KsGameLauncher { - public partial class AddNewGame : Form + public partial class AddNewGameForm : Form { - public AddNewGame() + public AddNewGameForm() { InitializeComponent(); } @@ -66,14 +66,14 @@ private void AddNewGame_DragDrop(object sender, DragEventArgs e) if (AppInfo.ContainID(appInfo.ID)) { MessageBox.Show(string.Format(Resources.AlreadyGameExists, appInfo.Name), Resources.AppName, - MessageBoxButtons.OK, - MessageBoxIcon.Error); + MessageBoxButtons.OK, MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); return; } var result = MessageBox.Show(String.Format(Resources.ConfirmAddNewGame, appInfo.Name), - Resources.AppName, MessageBoxButtons.YesNo, - MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); + Resources.AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Question, + MessageBoxDefaultButton.Button2, MessageBoxOptions.DefaultDesktopOnly); if (result == DialogResult.Yes) { // TODO AppInfoリストに追加し、JSON化して保存する @@ -88,7 +88,9 @@ private void AddNewGame_DragDrop(object sender, DragEventArgs e) } catch (FileFormatException ex) { - MessageBox.Show(ex.Message, Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(ex.Message, Resources.AppName, + MessageBoxButtons.OK, MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } // Save loaded games to local file @@ -113,6 +115,13 @@ private void AddNewGame_Load(object sender, EventArgs e) Icon = Properties.Resources.app; Text = Resources.AddNewGameWindowTitle; groupBox_DragHere.Text = Resources.DropHere; + Size = Properties.Settings.Default.NewGameFormSize; + } + + private void AddNewGameForm_FormClosed(object sender, FormClosedEventArgs e) + { + Properties.Settings.Default.NewGameFormSize = Size; + Properties.Settings.Default.Save(); } } } diff --git a/KsGameLauncher/Forms/AddNewGame.resx b/KsGameLauncher/Forms/AddNewGameForm.resx similarity index 100% rename from KsGameLauncher/Forms/AddNewGame.resx rename to KsGameLauncher/Forms/AddNewGameForm.resx diff --git a/KsGameLauncher/Forms/MainForm.Designer.cs b/KsGameLauncher/Forms/MainForm.Designer.cs index f0b7671..376993e 100644 --- a/KsGameLauncher/Forms/MainForm.Designer.cs +++ b/KsGameLauncher/Forms/MainForm.Designer.cs @@ -99,7 +99,6 @@ private void InitializeComponent() this.Name = "MainForm"; this.ShowInTaskbar = false; this.WindowState = System.Windows.Forms.FormWindowState.Minimized; - this.Deactivate += new System.EventHandler(this.MainForm_Deactivate); this.Load += new System.EventHandler(this.MainForm_Load); this.contextMenuStrip_Sub.ResumeLayout(false); this.ResumeLayout(false); diff --git a/KsGameLauncher/Forms/MainForm.cs b/KsGameLauncher/Forms/MainForm.cs index cbd5678..9b383b5 100644 --- a/KsGameLauncher/Forms/MainForm.cs +++ b/KsGameLauncher/Forms/MainForm.cs @@ -1,5 +1,4 @@ -using KsGameLauncher.Forms; -using System; +using System; using System.Diagnostics; using System.Drawing; using System.IO; @@ -8,15 +7,11 @@ using System.Threading.Tasks; using System.Windows.Forms; -#if DEBUG -using System.Diagnostics; -#endif namespace KsGameLauncher { public partial class MainForm : Form { - private static NotifyIcon notifyIcon; private bool _launcherMutex = false; @@ -41,6 +36,11 @@ protected override CreateParams CreateParams } } + private AboutForm _aboutForm; + private AccountForm _accountForm; + private OptionsForm _optionsForm; + private AddNewGameForm _addNewGameForm; + /// /// Finalizer @@ -161,13 +161,15 @@ async private Task GetJson() catch (FileNotFoundException) { MessageBox.Show(String.Format(Resources.FailedToLoadFile, Properties.Settings.Default.appInfoLocal), - Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error); + Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } } - catch (HttpRequestException ex) + catch (HttpRequestException) { MessageBox.Show(Resources.ErrorGetAppInfoFailed, Resources.SyncWithServerDialogTitle, - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBoxButtons.OK, MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } return null; @@ -200,6 +202,12 @@ private ContextMenuStrip InitGameMenu() var item = CreateNewMenuItem(appInfo, font, iconSize); menu.Items.Add(item); } + else if (!Properties.Settings.Default.ShowOnlyInstalledGames) + { + var item = CreateNewMenuItem(appInfo, font, iconSize); + item.Enabled = false; + menu.Items.Add(item); + } } } menu.ImageScalingSize = new Size(iconSize, iconSize); @@ -260,7 +268,8 @@ internal ToolStripMenuItem CreateNewMenuItem(AppInfo appInfo, Font font, int ico if (_launcherMutex) { MessageBox.Show(Resources.StartngLauncher, Resources.AppName, - MessageBoxButtons.OK, MessageBoxIcon.Exclamation); + MessageBoxButtons.OK, MessageBoxIcon.Exclamation, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); return; } @@ -275,21 +284,24 @@ internal ToolStripMenuItem CreateNewMenuItem(AppInfo appInfo, Font font, int ico MessageBox.Show(String.Format( "Launcher: {0}, Exception: {1}\nMessage: {2}\n\nSource: {3}\n\n{4}", appInfo.Name, ex.GetType().Name, ex.Message, ex.Source, ex.StackTrace) - , Resources.ErrorWhileLogin, MessageBoxButtons.OK, MessageBoxIcon.Error); + , Resources.ErrorWhileLogin, MessageBoxButtons.OK, MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } catch (LauncherException ex) { MessageBox.Show(String.Format( "Launcher: {0}, Exception: {1}\nMessage: {2}\n\nSource: {3}\n\n{4}", appInfo.Name, ex.GetType().Name, ex.Message, ex.Source, ex.StackTrace) - , ex.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error); + , ex.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } catch (Exception ex) { MessageBox.Show(String.Format( "Launcher: {0}, Exception: {1}\nMessage: {2}\n\nSource: {3}\n\n{4}", appInfo.Name, ex.GetType().Name, ex.Message, ex.Source, ex.StackTrace) - , ex.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error); + , ex.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } finally { @@ -344,22 +356,40 @@ private void ExitingProcess() private void AboutToolStripMenuItem_Click(object sender, EventArgs e) { - AboutForm aboutForm = new AboutForm - { - ShowInTaskbar = false - }; - aboutForm.ShowDialog(this); + if (_aboutForm == null || _aboutForm.IsDisposed) + _aboutForm = new AboutForm + { + ShowInTaskbar = false + }; + + if (!_aboutForm.Visible) + _aboutForm.ShowDialog(this); + else + _aboutForm.Activate(); } private void ManageAccountsToolStripMenuItem_Click(object sender, EventArgs e) { - (new AccountForm()).Show(this); + if (_accountForm == null || _accountForm.IsDisposed) + _accountForm = new AccountForm(); + + if (!_accountForm.Visible) + _accountForm.ShowDialog(this); + else + _accountForm.Activate(); + } private void OptionsToolStripMenuItem_Click(object sender, EventArgs e) { - (new OptionsForm()).ShowDialog(this); + if (_optionsForm == null || _optionsForm.IsDisposed) + _optionsForm = new OptionsForm(); + + if (!_optionsForm.Visible) + _optionsForm.ShowDialog(this); + else + _optionsForm.Activate(); } public static void DisplayToolTip(string message, int timeout) @@ -383,7 +413,13 @@ private void MainForm_Load(object sender, EventArgs e) private void AddNewGameToolStripMenuItem_Click(object sender, EventArgs e) { - (new AddNewGame()).ShowDialog(this); + if (_addNewGameForm == null || _addNewGameForm.IsDisposed) + _addNewGameForm = new AddNewGameForm(); + + if (!_addNewGameForm.Visible) + _addNewGameForm.ShowDialog(this); + else + _addNewGameForm.Activate(); } internal ContextMenuStrip GetMenuStrip() @@ -395,15 +431,5 @@ internal void SetMenuStrip(ContextMenuStrip menu) { menuStripMain = menu; } - - private void MainForm_Deactivate(object sender, EventArgs e) - { - Debug.WriteLine(String.Format("{0} Created: {1}, Capture :{2}", - menuStripMain.GetType().Name, menuStripMain.Created, menuStripMain.Capture)); - if (menuStripMain.Created && !menuStripMain.Capture) - menuStripMain.Close(); - if (contextMenuStrip_Sub.Created && !contextMenuStrip_Sub.Capture) - contextMenuStrip_Sub.Close(); - } } } diff --git a/KsGameLauncher/Forms/OptionsForm.Designer.cs b/KsGameLauncher/Forms/OptionsForm.Designer.cs index eb5720d..0a23da6 100644 --- a/KsGameLauncher/Forms/OptionsForm.Designer.cs +++ b/KsGameLauncher/Forms/OptionsForm.Designer.cs @@ -36,6 +36,7 @@ private void InitializeComponent() this.comboBox_ContextMenuSize = new System.Windows.Forms.ComboBox(); this.label_ContextMenuSize = new System.Windows.Forms.Label(); this.button_SyncAppInfo = new System.Windows.Forms.Button(); + this.checkBox_DisplayInstalledGamesOnly = new System.Windows.Forms.CheckBox(); this.SuspendLayout(); // // checkBox_UseProxy @@ -102,7 +103,7 @@ private void InitializeComponent() // this.comboBox_ContextMenuSize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBox_ContextMenuSize.FormattingEnabled = true; - this.comboBox_ContextMenuSize.Location = new System.Drawing.Point(12, 139); + this.comboBox_ContextMenuSize.Location = new System.Drawing.Point(10, 159); this.comboBox_ContextMenuSize.Name = "comboBox_ContextMenuSize"; this.comboBox_ContextMenuSize.Size = new System.Drawing.Size(121, 20); this.comboBox_ContextMenuSize.TabIndex = 5; @@ -110,7 +111,7 @@ private void InitializeComponent() // label_ContextMenuSize // this.label_ContextMenuSize.AutoSize = true; - this.label_ContextMenuSize.Location = new System.Drawing.Point(12, 124); + this.label_ContextMenuSize.Location = new System.Drawing.Point(10, 144); this.label_ContextMenuSize.Name = "label_ContextMenuSize"; this.label_ContextMenuSize.Size = new System.Drawing.Size(100, 12); this.label_ContextMenuSize.TabIndex = 6; @@ -118,7 +119,7 @@ private void InitializeComponent() // // button_SyncAppInfo // - this.button_SyncAppInfo.Location = new System.Drawing.Point(12, 224); + this.button_SyncAppInfo.Location = new System.Drawing.Point(10, 196); this.button_SyncAppInfo.Name = "button_SyncAppInfo"; this.button_SyncAppInfo.Size = new System.Drawing.Size(100, 23); this.button_SyncAppInfo.TabIndex = 7; @@ -127,6 +128,18 @@ private void InitializeComponent() this.button_SyncAppInfo.UseVisualStyleBackColor = true; this.button_SyncAppInfo.Click += new System.EventHandler(this.Button_SyncAppInfo_Click); // + // checkBox_DisplayInstalledGamesOnly + // + this.checkBox_DisplayInstalledGamesOnly.AutoSize = true; + this.checkBox_DisplayInstalledGamesOnly.Checked = true; + this.checkBox_DisplayInstalledGamesOnly.CheckState = System.Windows.Forms.CheckState.Checked; + this.checkBox_DisplayInstalledGamesOnly.Location = new System.Drawing.Point(12, 115); + this.checkBox_DisplayInstalledGamesOnly.Name = "checkBox_DisplayInstalledGamesOnly"; + this.checkBox_DisplayInstalledGamesOnly.Size = new System.Drawing.Size(171, 16); + this.checkBox_DisplayInstalledGamesOnly.TabIndex = 4; + this.checkBox_DisplayInstalledGamesOnly.Text = "Display installed games only"; + this.checkBox_DisplayInstalledGamesOnly.UseVisualStyleBackColor = true; + // // OptionsForm // this.AcceptButton = this.button_Save; @@ -136,6 +149,7 @@ private void InitializeComponent() this.Controls.Add(this.button_SyncAppInfo); this.Controls.Add(this.label_ContextMenuSize); this.Controls.Add(this.comboBox_ContextMenuSize); + this.Controls.Add(this.checkBox_DisplayInstalledGamesOnly); this.Controls.Add(this.checkBox_ConfirmExit); this.Controls.Add(this.checkBox_Notification); this.Controls.Add(this.button_Save); @@ -165,5 +179,6 @@ private void InitializeComponent() private System.Windows.Forms.ComboBox comboBox_ContextMenuSize; private System.Windows.Forms.Label label_ContextMenuSize; private System.Windows.Forms.Button button_SyncAppInfo; + private System.Windows.Forms.CheckBox checkBox_DisplayInstalledGamesOnly; } } \ No newline at end of file diff --git a/KsGameLauncher/Forms/OptionsForm.cs b/KsGameLauncher/Forms/OptionsForm.cs index 47c6bcc..5866d97 100644 --- a/KsGameLauncher/Forms/OptionsForm.cs +++ b/KsGameLauncher/Forms/OptionsForm.cs @@ -35,6 +35,7 @@ private void OptionsForm_Load(object sender, EventArgs e) checkBox_UseProxy.Checked = Properties.Settings.Default.UseProxy; checkBox_Notification.Checked = Properties.Settings.Default.EnableNotification; checkBox_ConfirmExit.Checked = Properties.Settings.Default.ShowConfirmExit; + checkBox_DisplayInstalledGamesOnly.Checked = Properties.Settings.Default.ShowOnlyInstalledGames; comboBox_ContextMenuSize.SelectedIndex = Properties.Settings.Default.ContextMenuSize; // String @@ -43,6 +44,7 @@ private void OptionsForm_Load(object sender, EventArgs e) checkBox_UseProxy.Text = Resources.OptionsUseProxyText; checkBox_Notification.Text = Resources.OptionsDisplayNotification; checkBox_ConfirmExit.Text = Resources.ShowConfirmExit; + checkBox_DisplayInstalledGamesOnly.Text = Resources.ShowOnlyInstalledGames; linkLabel_OpenProxySettings.Text = Resources.OptionsProxySettingsLink; button_Save.Text = Resources.ButtonSave; button_SyncAppInfo.Text = Resources.SynchWithServerButton; @@ -56,16 +58,18 @@ private void LinkLabel_OpenProxySettings_LinkClicked(object sender, LinkLabelLin private void Button_Save_Click(object sender, EventArgs e) { - bool menuSizeChanged = - (Properties.Settings.Default.ContextMenuSize != comboBox_ContextMenuSize.SelectedIndex); + bool needsUpdateGames = + (Properties.Settings.Default.ShowOnlyInstalledGames != checkBox_DisplayInstalledGamesOnly.Checked) + || (Properties.Settings.Default.ContextMenuSize != comboBox_ContextMenuSize.SelectedIndex); // Save settings Properties.Settings.Default.UseProxy = checkBox_UseProxy.Checked; Properties.Settings.Default.EnableNotification = checkBox_Notification.Checked; Properties.Settings.Default.ShowConfirmExit = checkBox_ConfirmExit.Checked; + Properties.Settings.Default.ShowOnlyInstalledGames = checkBox_DisplayInstalledGamesOnly.Checked; Properties.Settings.Default.ContextMenuSize = comboBox_ContextMenuSize.SelectedIndex; Properties.Settings.Default.Save(); - if (menuSizeChanged) + if (needsUpdateGames) Program.mainForm.LoadGamesMenu(); // Re-load menu Close(); @@ -79,9 +83,10 @@ private void OptionsForm_KeyPress(object sender, KeyPressEventArgs e) private async void Button_SyncAppInfo_Click(object sender, EventArgs e) { - + var dialogResult = MessageBox.Show(Resources.SyncWithServerConfirmMessage, Resources.SyncWithServerDialogTitle, - MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2); + MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button2, + MessageBoxOptions.DefaultDesktopOnly); if (dialogResult == DialogResult.Yes) { try @@ -92,18 +97,21 @@ private async void Button_SyncAppInfo_Click(object sender, EventArgs e) Program.mainForm.LoadGamesMenu(); MessageBox.Show(Resources.SyncWithServerSuccessMessage, Resources.SyncWithServerDialogTitle, - MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBoxButtons.OK, MessageBoxIcon.Information, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } else { MessageBox.Show(Resources.SyncWithServerFailedMessage, Resources.SyncWithServerDialogTitle, - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBoxButtons.OK, MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } } - catch (System.Net.Http.HttpRequestException ex) + catch (System.Net.Http.HttpRequestException) { MessageBox.Show(Resources.ErrorGetAppInfoFailed, Resources.SyncWithServerDialogTitle, - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBoxButtons.OK, MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } } } diff --git a/KsGameLauncher/KsGameLauncher.csproj b/KsGameLauncher/KsGameLauncher.csproj index fa761a4..fe2f2f3 100644 --- a/KsGameLauncher/KsGameLauncher.csproj +++ b/KsGameLauncher/KsGameLauncher.csproj @@ -1,6 +1,7 @@  - + + Debug @@ -97,6 +98,9 @@ + + OnBuildSuccess + ..\packages\AdysTech.CredentialManager.2.5.0\lib\net45\AdysTech.CredentialManager.dll @@ -104,6 +108,8 @@ ..\packages\AngleSharp.0.16.1\lib\net472\AngleSharp.dll + + @@ -146,11 +152,11 @@ AccountForm.cs - + Form - - AddNewGame.cs + + AddNewGameForm.cs @@ -207,8 +213,8 @@ AccountForm.cs - - AddNewGame.cs + + AddNewGameForm.cs LicensesForm.cs @@ -283,11 +289,15 @@ このプロジェクトは、このコンピューター上にない NuGet パッケージを参照しています。それらのパッケージをダウンロードするには、[NuGet パッケージの復元] を使用します。詳細については、http://go.microsoft.com/fwlink/?LinkID=322105 を参照してください。見つからないファイルは {0} です。 - + + set output=$(TargetFileName) -mkdir ILMerge -"$(SolutionDir)\packages\ILMerge.3.0.41\tools\net452\ILMerge.exe" /wildcards /ndebug:fase /out:ILMerge\$(TargetFileName) $(TargetFileName) *.dll +set outpath=publish +set ILMERGE="$(SolutionDir)\packages\ILMerge.3.0.40\tools\net452\ILMerge.exe" +if not exist %25outpath%25 mkdir %25outpath%25 + +%25ILMERGE%25 /wildcards /ndebug:fase /out:%25outpath%25\%25output%25 $(TargetFileName) *.dll \ No newline at end of file diff --git a/KsGameLauncher/Launcher.cs b/KsGameLauncher/Launcher.cs index 6372785..ad54c36 100644 --- a/KsGameLauncher/Launcher.cs +++ b/KsGameLauncher/Launcher.cs @@ -207,7 +207,8 @@ async public void StartApp(AppInfo app) if (credential == null) { MessageBox.Show(Resources.ShouldBeSetAccountBeforeLaunch, Resources.ErrorText, - MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBoxButtons.OK, MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); return; } @@ -230,7 +231,9 @@ async public void StartApp(AppInfo app) } catch (LoginException ex) { - MessageBox.Show(ex.Message, Resources.LoginExceptionDialogName, MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(ex.Message, Resources.LoginExceptionDialogName, + MessageBoxButtons.OK, MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); return; } catch (Exception ex) @@ -255,7 +258,9 @@ async public void StartApp(AppInfo app) if (response.RequestMessage.RequestUri.Host.Contains(Properties.Resources.AuthorizeDomain)) { - MessageBox.Show(Resources.IncorrectUsernameOrPassword); + MessageBox.Show(Resources.IncorrectUsernameOrPassword, Resources.AppName, + MessageBoxButtons.OK, MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); return; } @@ -265,7 +270,9 @@ async public void StartApp(AppInfo app) { case HttpStatusCode.Redirect: Uri redirectUri = response.Headers.Location; - MessageBox.Show(Resources.CheckFollowingPage); + MessageBox.Show(Resources.CheckFollowingPage, + Resources.AppName, MessageBoxButtons.OK, MessageBoxIcon.Warning, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); Utils.Common.OpenUrlByDefaultBrowser(redirectUri); break; @@ -358,11 +365,15 @@ async public void StartApp(AppInfo app) } catch (LoginException e) { - MessageBox.Show(e.Message, Resources.LoginExceptionDialogName); + MessageBox.Show(e.Message, Resources.LoginExceptionDialogName, + MessageBoxButtons.OK, MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } catch (GameTermsOfServiceException ex) { - MessageBox.Show(ex.Message, Resources.GameTermsOfServiceExceptionDialogName, MessageBoxButtons.OK, MessageBoxIcon.Information); + MessageBox.Show(ex.Message, Resources.GameTermsOfServiceExceptionDialogName, + MessageBoxButtons.OK, MessageBoxIcon.Information, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); Utils.Common.OpenUrlByDefaultBrowser(ex.GetTosURL()); } catch (Exception e) @@ -385,7 +396,9 @@ async void LauncherLoginPage(string content, string querySelector) AngleSharp.Dom.IElement launchButton = document.QuerySelector(querySelector); if (launchButton == null) { - MessageBox.Show("Failed to parse page!", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Failed to parse page!", Application.ProductName, + MessageBoxButtons.OK, MessageBoxIcon.Error, + MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); return; } string launcherCustomProtocol = launchButton.GetAttribute("href"); @@ -436,6 +449,9 @@ private string GetGamePathFromLauncher(string launcherPath) async public static Task Logout() { Launcher instance = Create(); + if (instance.httpClient == null) + instance.httpClient = instance.CreateHttp(); + HttpResponseMessage response = await instance.httpClient.GetAsync(Properties.Settings.Default.LogoutURL); response.EnsureSuccessStatusCode(); diff --git a/KsGameLauncher/Properties/Settings.Designer.cs b/KsGameLauncher/Properties/Settings.Designer.cs index ffc2cde..a529a6a 100644 --- a/KsGameLauncher/Properties/Settings.Designer.cs +++ b/KsGameLauncher/Properties/Settings.Designer.cs @@ -231,5 +231,29 @@ public int MenuIconSize_Default { return ((int)(this["MenuIconSize_Default"])); } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("True")] + public bool ShowOnlyInstalledGames { + get { + return ((bool)(this["ShowOnlyInstalledGames"])); + } + set { + this["ShowOnlyInstalledGames"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("400, 300")] + public global::System.Drawing.Size NewGameFormSize { + get { + return ((global::System.Drawing.Size)(this["NewGameFormSize"])); + } + set { + this["NewGameFormSize"] = value; + } + } } } diff --git a/KsGameLauncher/Properties/Settings.settings b/KsGameLauncher/Properties/Settings.settings index f034cbc..5cf324f 100644 --- a/KsGameLauncher/Properties/Settings.settings +++ b/KsGameLauncher/Properties/Settings.settings @@ -59,5 +59,11 @@ 16 + + True + + + 400, 300 + \ No newline at end of file diff --git a/KsGameLauncher/Resources.Designer.cs b/KsGameLauncher/Resources.Designer.cs index c2c7f9f..b637d0d 100644 --- a/KsGameLauncher/Resources.Designer.cs +++ b/KsGameLauncher/Resources.Designer.cs @@ -566,6 +566,15 @@ internal static string ShowLicense { } } + /// + /// Show only installed games に類似しているローカライズされた文字列を検索します。 + /// + internal static string ShowOnlyInstalledGames { + get { + return ResourceManager.GetString("ShowOnlyInstalledGames", resourceCulture); + } + } + /// /// Game has been starting, please wait. に類似しているローカライズされた文字列を検索します。 /// diff --git a/KsGameLauncher/Resources.ja-JP.resx b/KsGameLauncher/Resources.ja-JP.resx index c09b9f8..e3dd506 100644 --- a/KsGameLauncher/Resources.ja-JP.resx +++ b/KsGameLauncher/Resources.ja-JP.resx @@ -294,6 +294,9 @@ ライセンスを表示 + + インストール済みゲームのみ表示 + ゲームを起動しています。しばらくお待ちください。 diff --git a/KsGameLauncher/Resources.resx b/KsGameLauncher/Resources.resx index 776cd39..4573fc2 100644 --- a/KsGameLauncher/Resources.resx +++ b/KsGameLauncher/Resources.resx @@ -298,6 +298,9 @@ This file may not exist or may be temporarily unavailable. Show licenses + + Show only installed games + Game has been starting, please wait. diff --git a/KsGameLauncher/packages.config b/KsGameLauncher/packages.config index 71fa9ee..eff855f 100644 --- a/KsGameLauncher/packages.config +++ b/KsGameLauncher/packages.config @@ -2,7 +2,8 @@ - + +