diff --git a/KsGameLauncher/App.config b/KsGameLauncher/App.config index 8465ddb..9ccb3c5 100644 --- a/KsGameLauncher/App.config +++ b/KsGameLauncher/App.config @@ -158,6 +158,12 @@ system + + 0 + + + 0 + diff --git a/KsGameLauncher/Forms/OptionsForm.Designer.cs b/KsGameLauncher/Forms/OptionsForm.Designer.cs index 9a9a349..0f5925e 100644 --- a/KsGameLauncher/Forms/OptionsForm.Designer.cs +++ b/KsGameLauncher/Forms/OptionsForm.Designer.cs @@ -40,6 +40,9 @@ private void InitializeComponent() this.checkBox_RegisterCustomURI = new System.Windows.Forms.CheckBox(); this.comboBox_Languages = new System.Windows.Forms.ComboBox(); this.label_Language = new System.Windows.Forms.Label(); + this.label_CheckAutoUpdateInterval = new System.Windows.Forms.Label(); + this.comboBox_CheckInterval = new System.Windows.Forms.ComboBox(); + this.button_ManualCheck = new System.Windows.Forms.Button(); this.SuspendLayout(); // // checkBox_UseProxy @@ -68,7 +71,7 @@ private void InitializeComponent() // button_Save // this.button_Save.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); - this.button_Save.Location = new System.Drawing.Point(249, 428); + this.button_Save.Location = new System.Drawing.Point(249, 511); this.button_Save.Name = "button_Save"; this.button_Save.Size = new System.Drawing.Size(81, 38); this.button_Save.TabIndex = 3; @@ -107,7 +110,7 @@ private void InitializeComponent() this.comboBox_ContextMenuSize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.comboBox_ContextMenuSize.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBox_ContextMenuSize.FormattingEnabled = true; - this.comboBox_ContextMenuSize.Location = new System.Drawing.Point(15, 292); + this.comboBox_ContextMenuSize.Location = new System.Drawing.Point(12, 284); this.comboBox_ContextMenuSize.Margin = new System.Windows.Forms.Padding(4); this.comboBox_ContextMenuSize.Name = "comboBox_ContextMenuSize"; this.comboBox_ContextMenuSize.Size = new System.Drawing.Size(180, 26); @@ -117,7 +120,7 @@ private void InitializeComponent() // this.label_ContextMenuSize.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.label_ContextMenuSize.AutoSize = true; - this.label_ContextMenuSize.Location = new System.Drawing.Point(15, 270); + this.label_ContextMenuSize.Location = new System.Drawing.Point(12, 262); this.label_ContextMenuSize.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); this.label_ContextMenuSize.Name = "label_ContextMenuSize"; this.label_ContextMenuSize.Size = new System.Drawing.Size(146, 18); @@ -127,7 +130,7 @@ private void InitializeComponent() // button_SyncAppInfo // this.button_SyncAppInfo.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); - this.button_SyncAppInfo.Location = new System.Drawing.Point(15, 332); + this.button_SyncAppInfo.Location = new System.Drawing.Point(12, 324); this.button_SyncAppInfo.Margin = new System.Windows.Forms.Padding(4); this.button_SyncAppInfo.Name = "button_SyncAppInfo"; this.button_SyncAppInfo.Size = new System.Drawing.Size(150, 34); @@ -156,7 +159,7 @@ private void InitializeComponent() this.checkBox_RegisterCustomURI.Appearance = System.Windows.Forms.Appearance.Button; this.checkBox_RegisterCustomURI.AutoSize = true; this.checkBox_RegisterCustomURI.FlatStyle = System.Windows.Forms.FlatStyle.System; - this.checkBox_RegisterCustomURI.Location = new System.Drawing.Point(15, 380); + this.checkBox_RegisterCustomURI.Location = new System.Drawing.Point(12, 372); this.checkBox_RegisterCustomURI.Margin = new System.Windows.Forms.Padding(4); this.checkBox_RegisterCustomURI.Name = "checkBox_RegisterCustomURI"; this.checkBox_RegisterCustomURI.Size = new System.Drawing.Size(173, 28); @@ -185,12 +188,47 @@ private void InitializeComponent() this.label_Language.TabIndex = 10; this.label_Language.Text = "Language"; // + // label_CheckAutoUpdateInterval + // + this.label_CheckAutoUpdateInterval.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.label_CheckAutoUpdateInterval.AutoSize = true; + this.label_CheckAutoUpdateInterval.Location = new System.Drawing.Point(12, 418); + this.label_CheckAutoUpdateInterval.Name = "label_CheckAutoUpdateInterval"; + this.label_CheckAutoUpdateInterval.Size = new System.Drawing.Size(149, 18); + this.label_CheckAutoUpdateInterval.TabIndex = 11; + this.label_CheckAutoUpdateInterval.Text = "Check auto update"; + // + // comboBox_CheckInterval + // + this.comboBox_CheckInterval.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.comboBox_CheckInterval.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.comboBox_CheckInterval.FlatStyle = System.Windows.Forms.FlatStyle.System; + this.comboBox_CheckInterval.FormattingEnabled = true; + this.comboBox_CheckInterval.Location = new System.Drawing.Point(12, 439); + this.comboBox_CheckInterval.Name = "comboBox_CheckInterval"; + this.comboBox_CheckInterval.Size = new System.Drawing.Size(219, 26); + this.comboBox_CheckInterval.TabIndex = 12; + // + // button_ManualCheck + // + this.button_ManualCheck.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.button_ManualCheck.Location = new System.Drawing.Point(12, 471); + this.button_ManualCheck.Name = "button_ManualCheck"; + this.button_ManualCheck.Size = new System.Drawing.Size(146, 35); + this.button_ManualCheck.TabIndex = 13; + this.button_ManualCheck.Text = "Manual check"; + this.button_ManualCheck.UseVisualStyleBackColor = true; + this.button_ManualCheck.Click += new System.EventHandler(this.Button_ManualCheck_Click); + // // OptionsForm // this.AcceptButton = this.button_Save; this.AutoScaleDimensions = new System.Drawing.SizeF(144F, 144F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; - this.ClientSize = new System.Drawing.Size(340, 477); + this.ClientSize = new System.Drawing.Size(340, 560); + this.Controls.Add(this.button_ManualCheck); + this.Controls.Add(this.comboBox_CheckInterval); + this.Controls.Add(this.label_CheckAutoUpdateInterval); this.Controls.Add(this.label_Language); this.Controls.Add(this.comboBox_Languages); this.Controls.Add(this.checkBox_RegisterCustomURI); @@ -230,5 +268,8 @@ private void InitializeComponent() private System.Windows.Forms.CheckBox checkBox_RegisterCustomURI; private System.Windows.Forms.ComboBox comboBox_Languages; private System.Windows.Forms.Label label_Language; + private System.Windows.Forms.Label label_CheckAutoUpdateInterval; + private System.Windows.Forms.ComboBox comboBox_CheckInterval; + private System.Windows.Forms.Button button_ManualCheck; } } \ No newline at end of file diff --git a/KsGameLauncher/Forms/OptionsForm.cs b/KsGameLauncher/Forms/OptionsForm.cs index 64e48bc..2aaf3fe 100644 --- a/KsGameLauncher/Forms/OptionsForm.cs +++ b/KsGameLauncher/Forms/OptionsForm.cs @@ -1,4 +1,5 @@ using KsGameLauncher.Utils; +using KsGameLauncher.Structures; using System; using System.Diagnostics; using System.Windows.Forms; @@ -24,15 +25,15 @@ public OptionsForm() private void OptionsForm_Load(object sender, EventArgs e) { Icon = Properties.Resources.appIcon; - string[] items = { + string[] menuSizes = { // Normal Properties.Strings.ContextMenuSize_Text_Normal, // Large Properties.Strings.ContextMenuSize_Text_Large }; comboBox_ContextMenuSize.Items.Clear(); - comboBox_ContextMenuSize.Items.AddRange(items); - // Language + comboBox_ContextMenuSize.Items.AddRange(menuSizes); + // Languages Language currentLang = (string.IsNullOrEmpty(Properties.Settings.Default.Language) || Properties.Settings.Default.Language == Properties.Resources.DefaultLanguage) ? Languages.GetLanguage(Properties.Resources.DefaultLanguage) @@ -47,6 +48,25 @@ private void OptionsForm_Load(object sender, EventArgs e) Debug.WriteLine(String.Format("[OPTION:Load] Language comboBox selectedIndex: {0}", comboBox_Languages.Items.IndexOf(currentLang))); #endif + // Check update + int[] updateIntervalsDays = { 1, 3, 7, 14 }; // None, everyday, 3 days, 7 days, 2 weeks + comboBox_CheckInterval.Items.Clear(); + comboBox_CheckInterval.Items.Add(new CheckInterval(0, CheckInterval.UnitType.None)); + for (int i = 0; i < updateIntervalsDays.Length; i++) + { + CheckInterval check = new CheckInterval(updateIntervalsDays[i], CheckInterval.UnitType.Days); + comboBox_CheckInterval.Items.Add(check); + } +#if DEBUG + for (int i = 0; i < updateIntervalsDays.Length; i++) + { + CheckInterval check = new CheckInterval(updateIntervalsDays[i], CheckInterval.UnitType.Minutes); + comboBox_CheckInterval.Items.Add(check); + } +#endif + + + // Default values checkBox_UseProxy.Checked = Properties.Settings.Default.UseProxy; checkBox_Notification.Checked = Properties.Settings.Default.EnableNotification; @@ -54,6 +74,22 @@ private void OptionsForm_Load(object sender, EventArgs e) checkBox_DisplayInstalledGamesOnly.Checked = Properties.Settings.Default.ShowOnlyInstalledGames; checkBox_RegisterCustomURI.Checked = Properties.Settings.Default.RegisterCustomURI; comboBox_ContextMenuSize.SelectedIndex = Properties.Settings.Default.ContextMenuSize; + int intervalSelectedIndex = 0; + if (Properties.Settings.Default.UpdateCheckInterval > 0) + { + int settingInterval = Properties.Settings.Default.UpdateCheckInterval; + CheckInterval.UnitType settingUnit = Properties.Settings.Default.UpdateCheckIntervalUnit; + for (int i = 0; i < comboBox_CheckInterval.Items.Count; i++) + { + CheckInterval intervalItem = (CheckInterval)comboBox_CheckInterval.Items[i]; + if (intervalItem.Interval == settingInterval && intervalItem.Unit == settingUnit) + { + intervalSelectedIndex = i; + break; + } + } + } + comboBox_CheckInterval.SelectedIndex = intervalSelectedIndex; // String Text = Properties.Strings.OptionsWindowTitle; @@ -66,6 +102,8 @@ private void OptionsForm_Load(object sender, EventArgs e) linkLabel_OpenProxySettings.Text = Properties.Strings.OptionsProxySettingsLink; button_Save.Text = Properties.Strings.ButtonSave; button_SyncAppInfo.Text = Properties.Strings.SynchWithServerButton; + label_CheckAutoUpdateInterval.Text = Properties.Strings.CheckAutoUpdate; + button_ManualCheck.Text = Properties.Strings.ManualUpdateCheckButton; checkBox_RegisterCustomURI.Text = (checkBox_RegisterCustomURI.Checked) ? Properties.Strings.ShortcutLaunchCheckboxDisable @@ -104,17 +142,38 @@ private void Button_Save_Click(object sender, EventArgs e) restartApp = true; } + // AutoUpdate settings + CheckInterval selectedInterval = (CheckInterval)comboBox_CheckInterval.Items[comboBox_CheckInterval.SelectedIndex]; +#if DEBUG + Debug.WriteLine(String.Format("[OPTION:Save] AutoUpdateCheck.Interval before changes: {0}", Properties.Settings.Default.UpdateCheckInterval)); + Debug.WriteLine(String.Format("[OPTION:Save] AutoUpdateCheck.Interval before unit: {0}", Properties.Settings.Default.UpdateCheckIntervalUnit)); + Debug.WriteLine(String.Format("[OPTION:Save] AutoUpdateCheck.Interval selected: {0}", selectedInterval.Interval)); + Debug.WriteLine(String.Format("[OPTION:Save] AutoUpdateCheck.Interval unit: {0}", selectedInterval.Unit)); +#endif + // need to update thread interval + bool reloadAutoUpdate = false; + if (Properties.Settings.Default.UpdateCheckInterval != selectedInterval.Interval + || Properties.Settings.Default.UpdateCheckIntervalUnit != selectedInterval.Unit) + reloadAutoUpdate = true; + + // 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.Language = ((Language)comboBox_Languages.Items[comboBox_Languages.SelectedIndex]).ID; + Properties.Settings.Default.Language = selectedLang.ID; + Properties.Settings.Default.UpdateCheckInterval = selectedInterval.Interval; + Properties.Settings.Default.UpdateCheckIntervalUnit = selectedInterval.Unit; Properties.Settings.Default.Save(); if (needsUpdateGames) - Program.mainContext.LoadGamesMenu(); // Re-load menu + Program.mainContext.LoadGamesMenu(); // Reload menu + + if (reloadAutoUpdate) + UpdateChecker.UpdateInterval(selectedInterval.Interval, selectedInterval.Unit); + if (restartApp) { @@ -203,5 +262,13 @@ private void CheckBox_RegisterCustomURI_Click(object sender, EventArgs e) checkBox_RegisterCustomURI.Checked = true; } } + + private void Button_ManualCheck_Click(object sender, EventArgs e) + { + DialogResult result = MessageBox.Show(Properties.Strings.ConfirmToExecuteCheckManualUpdate, + Properties.Strings.AppName, MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk); + if (result == DialogResult.Yes) + AppUtil.CheckUpdate(); + } } } diff --git a/KsGameLauncher/KsGameLauncher.csproj b/KsGameLauncher/KsGameLauncher.csproj index 7102669..86e6335 100644 --- a/KsGameLauncher/KsGameLauncher.csproj +++ b/KsGameLauncher/KsGameLauncher.csproj @@ -108,6 +108,9 @@ ..\packages\AngleSharp.0.16.1\lib\net472\AngleSharp.dll + + ..\packages\Autoupdater.NET.Official.1.7.0\lib\net45\AutoUpdater.NET.dll + @@ -118,7 +121,9 @@ + + ..\packages\System.Memory.4.5.4\lib\net461\System.Memory.dll @@ -128,6 +133,7 @@ ..\packages\System.Runtime.CompilerServices.Unsafe.6.0.0\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + ..\packages\System.Text.Encoding.CodePages.6.0.0\lib\net461\System.Text.Encoding.CodePages.dll @@ -145,6 +151,7 @@ + @@ -228,9 +235,11 @@ True Strings.resx + + @@ -343,6 +352,6 @@ 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 +%25ILMERGE%25 /wildcards /ndebug:fase /allowDup /out:%25outpath%25\%25output%25 $(TargetFileName) *.dll \ No newline at end of file diff --git a/KsGameLauncher/MainContext.cs b/KsGameLauncher/MainContext.cs index 5fb5f42..2c48315 100644 --- a/KsGameLauncher/MainContext.cs +++ b/KsGameLauncher/MainContext.cs @@ -26,6 +26,13 @@ public MainContext(MainForm _form) : base() mainForm = _form; InitializeComponent(); CreateNotificationIcon(); + + + if (Properties.Settings.Default.UpdateCheckInterval > 0) + Utils.UpdateChecker.CreateUpdateCheker(Properties.Settings.Default.UpdateCheckInterval, + Properties.Settings.Default.UpdateCheckIntervalUnit); + else + Utils.AppUtil.CheckUpdate(); } ~MainContext() diff --git a/KsGameLauncher/Properties/AssemblyInfo.cs b/KsGameLauncher/Properties/AssemblyInfo.cs index 96c2eba..54dc0de 100644 --- a/KsGameLauncher/Properties/AssemblyInfo.cs +++ b/KsGameLauncher/Properties/AssemblyInfo.cs @@ -31,5 +31,5 @@ // すべての値を指定するか、次を使用してビルド番号とリビジョン番号を既定に設定できます // 既定値にすることができます: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.1.1")] -[assembly: AssemblyFileVersion("1.0.1.1")] +[assembly: AssemblyVersion("1.0.1.2")] +[assembly: AssemblyFileVersion("1.0.1.2")] diff --git a/KsGameLauncher/Properties/Resources.Designer.cs b/KsGameLauncher/Properties/Resources.Designer.cs index 75e42ca..7fcc010 100644 --- a/KsGameLauncher/Properties/Resources.Designer.cs +++ b/KsGameLauncher/Properties/Resources.Designer.cs @@ -164,6 +164,7 @@ internal static System.Drawing.Bitmap icon { /// /// AdysTech.CredentialManager (https://github.com/AdysTech/CredentialManager) + ///AutoUpdater.NET (https://github.com/ravibpatel/AutoUpdater.NET) /// ///HtmlAgilityPack (https://github.com/atifaziz/Hazz) に類似しているローカライズされた文字列を検索します。 /// @@ -217,5 +218,14 @@ internal static string TosCheckPath { return ResourceManager.GetString("TosCheckPath", resourceCulture); } } + + /// + /// https://launcher-app.sdvx.net/update.xml に類似しているローカライズされた文字列を検索します。 + /// + internal static string UpdateXML { + get { + return ResourceManager.GetString("UpdateXML", resourceCulture); + } + } } } diff --git a/KsGameLauncher/Properties/Resources.resx b/KsGameLauncher/Properties/Resources.resx index 4b31131..1bd5d5b 100644 --- a/KsGameLauncher/Properties/Resources.resx +++ b/KsGameLauncher/Properties/Resources.resx @@ -153,6 +153,7 @@ AdysTech.CredentialManager (https://github.com/AdysTech/CredentialManager) +AutoUpdater.NET (https://github.com/ravibpatel/AutoUpdater.NET) HtmlAgilityPack (https://github.com/atifaziz/Hazz) Using libraries @@ -174,4 +175,7 @@ HtmlAgilityPack (https://github.com/atifaziz/Hazz) /terms_of_service/index.html + + https://launcher-app.sdvx.net/update.xml + \ No newline at end of file diff --git a/KsGameLauncher/Properties/Settings.Designer.cs b/KsGameLauncher/Properties/Settings.Designer.cs index dba182b..354c875 100644 --- a/KsGameLauncher/Properties/Settings.Designer.cs +++ b/KsGameLauncher/Properties/Settings.Designer.cs @@ -369,5 +369,18 @@ public string Language { return ((global::System.Collections.Specialized.StringCollection)(this["SupportedLanguage"])); } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("0")] + public int UpdateCheckInterval { + get { + return ((int)(this["UpdateCheckInterval"])); + } + set { + this["UpdateCheckInterval"] = value; + } + } + } } diff --git a/KsGameLauncher/Properties/Settings.settings b/KsGameLauncher/Properties/Settings.settings index c25e9dc..ef26f90 100644 --- a/KsGameLauncher/Properties/Settings.settings +++ b/KsGameLauncher/Properties/Settings.settings @@ -99,5 +99,11 @@ <string>ja-JP</string> </ArrayOfString> + + 0 + + + 0 + \ No newline at end of file diff --git a/KsGameLauncher/Properties/Strings.Designer.cs b/KsGameLauncher/Properties/Strings.Designer.cs index b5013b0..8243483 100644 --- a/KsGameLauncher/Properties/Strings.Designer.cs +++ b/KsGameLauncher/Properties/Strings.Designer.cs @@ -214,6 +214,15 @@ internal static string CannotSaveGameList { } } + /// + /// Check auto update に類似しているローカライズされた文字列を検索します。 + /// + internal static string CheckAutoUpdate { + get { + return ResourceManager.GetString("CheckAutoUpdate", resourceCulture); + } + } + /// /// Please check following page. (will open the web browser) に類似しているローカライズされた文字列を検索します。 /// @@ -223,6 +232,69 @@ internal static string CheckFollowingPage { } } + /// + /// Daily に類似しているローカライズされた文字列を検索します。 + /// + internal static string CheckUpdateInterval_Daily { + get { + return ResourceManager.GetString("CheckUpdateInterval_Daily", resourceCulture); + } + } + + /// + /// Per {0} days に類似しているローカライズされた文字列を検索します。 + /// + internal static string CheckUpdateInterval_Days { + get { + return ResourceManager.GetString("CheckUpdateInterval_Days", resourceCulture); + } + } + + /// + /// Hourly に類似しているローカライズされた文字列を検索します。 + /// + internal static string CheckUpdateInterval_Hourly { + get { + return ResourceManager.GetString("CheckUpdateInterval_Hourly", resourceCulture); + } + } + + /// + /// Per {0} hours に類似しているローカライズされた文字列を検索します。 + /// + internal static string CheckUpdateInterval_Hours { + get { + return ResourceManager.GetString("CheckUpdateInterval_Hours", resourceCulture); + } + } + + /// + /// Minutely に類似しているローカライズされた文字列を検索します。 + /// + internal static string CheckUpdateInterval_Minutely { + get { + return ResourceManager.GetString("CheckUpdateInterval_Minutely", resourceCulture); + } + } + + /// + /// Per {0} minutes に類似しているローカライズされた文字列を検索します。 + /// + internal static string CheckUpdateInterval_Minutes { + get { + return ResourceManager.GetString("CheckUpdateInterval_Minutes", resourceCulture); + } + } + + /// + /// None に類似しているローカライズされた文字列を検索します。 + /// + internal static string CheckUpdateInterval_None { + get { + return ResourceManager.GetString("CheckUpdateInterval_None", resourceCulture); + } + } + /// /// Are you sure you want to add "{0}" ? に類似しているローカライズされた文字列を検索します。 /// @@ -266,6 +338,15 @@ internal static string ConfirmRegisterCustomURI { } } + /// + /// Do you want to check update ? に類似しているローカライズされた文字列を検索します。 + /// + internal static string ConfirmToExecuteCheckManualUpdate { + get { + return ResourceManager.GetString("ConfirmToExecuteCheckManualUpdate", resourceCulture); + } + } + /// /// Remove confirm に類似しているローカライズされた文字列を検索します。 /// @@ -582,6 +663,15 @@ internal static string LoginSessionHasBeenExpired { } } + /// + /// Manual check に類似しているローカライズされた文字列を検索します。 + /// + internal static string ManualUpdateCheckButton { + get { + return ResourceManager.GetString("ManualUpdateCheckButton", resourceCulture); + } + } + /// /// No account registered に類似しているローカライズされた文字列を検索します。 /// diff --git a/KsGameLauncher/Properties/Strings.en-US.resx b/KsGameLauncher/Properties/Strings.en-US.resx index 7b5df0e..a3074e8 100644 --- a/KsGameLauncher/Properties/Strings.en-US.resx +++ b/KsGameLauncher/Properties/Strings.en-US.resx @@ -172,9 +172,36 @@ You can try removing it from "Credential Manager" in Control Panel.\nIf you clic Could not be saved game list, because not allowed write files. + + Check auto update + Please check following page. (will open the web browser) + + Daily + + + Per {0} days + {0} is every N days + + + Hourly + + + Per {0} hours + {0} is every N hours + + + Minutely + + + Per {0} minutes + {0} is every N minutes + + + None + Are you sure you want to add "{0}" ? @@ -194,6 +221,12 @@ If you select "No", this changes will be applied at the next time. This will be registered the protocol to boot as {0}:// on your computer. This is used to launch the game directly from the shortcut. + + Do you want to check update ? + + + Do you want to check update ? + Remove confirm @@ -307,6 +340,9 @@ This file may not exist or may be temporarily unavailable. Login session has been expired. Please login again. + + Manual check + No account registered DIalog error message diff --git a/KsGameLauncher/Properties/Strings.ja-JP.resx b/KsGameLauncher/Properties/Strings.ja-JP.resx index e4d65dd..c010e79 100644 --- a/KsGameLauncher/Properties/Strings.ja-JP.resx +++ b/KsGameLauncher/Properties/Strings.ja-JP.resx @@ -171,9 +171,34 @@ ファイルへの書き込みが許可されていないため ゲーム一覧を保存できませんでした。 + + 自動アップデート確認 + ページを確認してください (ブラウザが開きます) + + 1日1回 + + + {0}日ごと + {0} is every N days + + + 1時間に1回 + + + {0}時間ごと + + + 1分に1回 + + + {0}分ごと + + + しない + "{0}" を追加してよろしいですか? @@ -192,6 +217,12 @@ これはコンピューターに {0}:// として起動するプロトコルを登録します。 これはショートカットからのゲームを起動する際に使用します。 + + アップデートを確認しますか? + + + アップデートの確認をします。よろしいですか? + 削除確認 @@ -300,6 +331,9 @@ ログイン時のセッションが切れました。再度実行し直してください。 + + 手動確認 + アカウントは登録されていません DIalog error message diff --git a/KsGameLauncher/Properties/Strings.resx b/KsGameLauncher/Properties/Strings.resx index 75da01e..4279f44 100644 --- a/KsGameLauncher/Properties/Strings.resx +++ b/KsGameLauncher/Properties/Strings.resx @@ -171,9 +171,36 @@ You can try removing it from "Credential Manager" in Control Panel.\nIf you clic Could not be saved game list, because not allowed write files. + + Check auto update + Please check following page. (will open the web browser) + + Daily + + + Per {0} days + {0} is every N days + + + Hourly + + + Per {0} hours + {0} is every N hours + + + Minutely + + + Per {0} minutes + {0} is every N minutes + + + None + Are you sure you want to add "{0}" ? @@ -193,6 +220,9 @@ If you select "No", this changes will be applied at the next time. This will be registered the protocol to boot as {0}:// on your computer. This is used to launch the game directly from the shortcut. + + Do you want to check update ? + Remove confirm @@ -304,6 +334,9 @@ This file may not exist or may be temporarily unavailable. Login session has been expired. Please login again. + + Manual check + No account registered DIalog error message diff --git a/KsGameLauncher/Settings.cs b/KsGameLauncher/Settings.cs index 45cca02..54456f2 100644 --- a/KsGameLauncher/Settings.cs +++ b/KsGameLauncher/Settings.cs @@ -55,5 +55,20 @@ public System.Net.Cookie Cookie } set { this["Cookie"] = value; } } + + [System.Configuration.UserScopedSettingAttribute()] + [System.Configuration.SettingsDescription("UpdateIntervalUnit")] + [System.Configuration.DefaultSettingValueAttribute("0")] + public Structures.CheckInterval.UnitType UpdateCheckIntervalUnit + { + get + { + return ((Structures.CheckInterval.UnitType)(this["UpdateCheckIntervalUnit"])); + } + set + { + this["UpdateCheckIntervalUnit"] = value; + } + } } } diff --git a/KsGameLauncher/Structures/CheckInterval.cs b/KsGameLauncher/Structures/CheckInterval.cs new file mode 100644 index 0000000..d667c13 --- /dev/null +++ b/KsGameLauncher/Structures/CheckInterval.cs @@ -0,0 +1,66 @@ +using System; + +namespace KsGameLauncher.Structures +{ + internal class CheckInterval + { + public enum UnitType + { + None, + Minutes, + Hours, + Days, + }; + + private UnitType unit; + private int interval; + + public UnitType Unit { get { return unit; } } + public int Interval { get { return interval; } } + + + + public CheckInterval(int value) + { + new CheckInterval(value, UnitType.Days); + } + + + public CheckInterval(int value, UnitType type) + { + interval = value; + unit = type; + } + + + public override string ToString() + { + if (interval == 0) + return Properties.Strings.CheckUpdateInterval_None; + + switch (unit) + { + case UnitType.Days: + if (interval == 1) + return Properties.Strings.CheckUpdateInterval_Daily; + else + return string.Format(Properties.Strings.CheckUpdateInterval_Days, interval); + + case UnitType.Hours: + if (interval == 1) + return Properties.Strings.CheckUpdateInterval_Hourly; + else + return string.Format(Properties.Strings.CheckUpdateInterval_Hours, interval); + + case UnitType.Minutes: + if (interval == 1) + return Properties.Strings.CheckUpdateInterval_Minutely; + else + return string.Format(Properties.Strings.CheckUpdateInterval_Minutes, interval); + + } + + return "Unknown"; + } + } +} diff --git a/KsGameLauncher/Utils/AppUtil.cs b/KsGameLauncher/Utils/AppUtil.cs index 585dd10..beb07d9 100644 --- a/KsGameLauncher/Utils/AppUtil.cs +++ b/KsGameLauncher/Utils/AppUtil.cs @@ -5,6 +5,7 @@ using Microsoft.Win32; using System.Reflection; using System.Windows.Forms; +using AutoUpdaterDotNET; #if DEBUG using System.Diagnostics; #endif @@ -89,5 +90,19 @@ internal static void DeleteScheme() catch (ArgumentException) { } } + + internal static void CheckUpdate() + { +#if DEBUG + Debug.WriteLine(String.Format("[CheckUpdate {0}] Start check update", DateTime.Now)); +#endif + AutoUpdater.Synchronous = true; + AutoUpdater.RunUpdateAsAdmin = false; + AutoUpdater.Start(Properties.Resources.UpdateXML, typeof(Program).Assembly); +#if DEBUG + Debug.WriteLine(String.Format("[CheckUpdate {0}] Done called", DateTime.Now)); +#endif + } + } } diff --git a/KsGameLauncher/Utils/UpdateChecker.cs b/KsGameLauncher/Utils/UpdateChecker.cs new file mode 100644 index 0000000..81f4af0 --- /dev/null +++ b/KsGameLauncher/Utils/UpdateChecker.cs @@ -0,0 +1,115 @@ +using System; +using System.Diagnostics; +using System.Windows.Threading; +using KsGameLauncher.Structures; + +namespace KsGameLauncher.Utils +{ + internal class UpdateChecker + { + private DateTime lastChecked; + private DispatcherTimer timer; + + private static UpdateChecker instance; + + private UpdateChecker() + { + timer = new DispatcherTimer(); + timer.Tick += new EventHandler(CheckUpdate); + timer.Start(); + } + + private static void CreateTimer() + { + if (instance == null) + { + instance = new UpdateChecker(); + } + } + + public static void CreateUpdateCheker() + { + CreateUpdateCheker(0, CheckInterval.UnitType.Minutes); + } + + public static void CreateUpdateCheker(int interval) + { + CheckInterval.UnitType unit = Properties.Settings.Default.UpdateCheckIntervalUnit; + CreateUpdateCheker(interval, unit); + } + + public static void CreateUpdateCheker(int interval, CheckInterval.UnitType unit) + { + CreateTimer(); + + Debug.WriteLine(String.Format("[CreateUpdateCheker {0}] Start check update", DateTime.Now)); + + if (interval == 0) + { + instance.timer.Stop(); + } + else + { + switch (unit) + { + case CheckInterval.UnitType.Hours: + instance.timer.Interval = new TimeSpan(interval, 0, 0); + break; + case CheckInterval.UnitType.Minutes: + instance.timer.Interval = new TimeSpan(0, interval, 0); + break; + case CheckInterval.UnitType.Days: + default: + instance.timer.Interval = new TimeSpan(interval, 0, 0, 0); + break; + } + } + Debug.WriteLine(String.Format("[CreateUpdateCheker {0}] Interval configured {1} {2}", DateTime.Now, interval, unit.ToString())); + } + + public static void UpdateInterval(int interval) + { + UpdateInterval(interval, CheckInterval.UnitType.Days); + } + public static void UpdateInterval(int interval, CheckInterval.UnitType unit) + { + if (instance != null) + { + + instance.timer.Stop(); + + if (interval > 0) + { + switch (unit) + { + case CheckInterval.UnitType.Hours: + instance.timer.Interval = new TimeSpan(interval, 0, 0); + break; + case CheckInterval.UnitType.Minutes: + instance.timer.Interval = new TimeSpan(0, interval, 0); + break; + case CheckInterval.UnitType.Days: + default: + instance.timer.Interval = new TimeSpan(interval, 0, 0, 0); + break; + } + instance.timer.Start(); + } + + Debug.WriteLine(String.Format("[UpdateInterval {0}] Interval updated {1} {2}", DateTime.Now, interval, unit.ToString())); + } + } + + private void CheckUpdate(object sender, EventArgs e) + { + Utils.AppUtil.CheckUpdate(); + instance.lastChecked = DateTime.Now; + } + + public static void Disposed() + { + instance.timer.Stop(); + instance.timer = null; + } + } +} diff --git a/KsGameLauncher/packages.config b/KsGameLauncher/packages.config index eff855f..8a856ce 100644 --- a/KsGameLauncher/packages.config +++ b/KsGameLauncher/packages.config @@ -2,6 +2,7 @@ +