OSDN Git Service

na-get-lib, a4ab378a911e444c1d35e49e4de87bc1ea86755b でのミスを修正。
[applistation/AppliStation.git] / AppliStation / UserPrefForm.cs
index 5b32a77..712222e 100644 (file)
@@ -37,13 +37,18 @@ namespace AppliStation
                /// </summary>\r
                public void loadCurrentPref()\r
                {\r
-                       this.RepositoriesListSetting = NaGet.Utils.GetDeserializedObject<RepositoriesList>(NaGet.Env.RepositoriesListFile);\r
+                       try {\r
+                               this.RepositoriesListSetting = NaGet.Utils.GetDeserializedObject<RepositoriesList>(NaGet.Env.RepositoriesListFile);\r
+                       } catch {\r
+                               this.RepositoriesListSetting = new RepositoriesList();\r
+                       }\r
                        \r
                        NaGet.NaGetLibPref userPref = NaGet.Env.Pref;\r
                        this.ProxyAddress = userPref.ProxyAddress;\r
                        this.EnableScanInstallerFile = userPref.EnableScanInstallerFile;\r
                        this.InstallOnBackground = userPref.InstallOnBackground;\r
                        this.CacheFolder = userPref.CacheFolder;\r
+                       this.ExcludeUpdatePackageNames = userPref.ExcludeUpdatePackageNames;\r
                }\r
                \r
                #region レポジトリリスト設定関連\r
@@ -169,7 +174,7 @@ namespace AppliStation
                        }\r
                }\r
                \r
-               void RepoUrlTextBoxLeave(object sender, EventArgs e)\r
+               void RepoUrlTextBoxValidated(object sender, EventArgs e)\r
                {\r
                        int selectedIndex = repoListCheckedListBox.SelectedIndex;\r
                        if ((0 <= selectedIndex) && (selectedIndex < repos.Count)) {\r
@@ -330,6 +335,37 @@ namespace AppliStation
                \r
                #endregion\r
                \r
+               #region ソフト更新設定関連\r
+               \r
+               \r
+               public string[] ExcludeUpdatePackageNames {\r
+                       set {\r
+                               this.upgradeExcludeTextBox.Lines = value;\r
+                       }\r
+                       get {\r
+                               List<string> list = new List<string>();\r
+                               \r
+                               foreach (string line in this.upgradeExcludeTextBox.Lines) {\r
+                                       if (!string.IsNullOrEmpty(line)) {\r
+                                               list.Add(line);\r
+                                       }\r
+                               }\r
+                               \r
+                               return list.ToArray();\r
+                       }\r
+               }\r
+               \r
+               /// <summary>\r
+               /// ソフト更新関連設定を、指定された設定オブジェクトに設定する。\r
+               /// </summary>\r
+               /// <param name="pref">設定オブジェクト</param>\r
+               private void commitUpgradeSetting(NaGet.NaGetLibPref pref)\r
+               {\r
+                       pref.ExcludeUpdatePackageNames = this.ExcludeUpdatePackageNames;\r
+               }\r
+               \r
+               #endregion\r
+               \r
                /// <summary>\r
                /// 指定された設定オブジェクトをファイルとして保存する\r
                /// </summary>\r
@@ -351,6 +387,7 @@ namespace AppliStation
                        commitRepositoryListSetting();\r
                        commitProxySetting(pref);\r
                        commitInstallSetting(pref);\r
+                       commitUpgradeSetting(pref);\r
                        \r
                        commitNaGetLibPref(pref);\r
                }\r
@@ -440,5 +477,33 @@ namespace AppliStation
                                MessageBox.Show(string.Format("フォルダーパス\"{0}\"は存在しませんでした。", folderPath), "キャッシュフォルダー", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
                        }\r
                }\r
+               \r
+               void CacheFolderClearLinkLabelLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)\r
+               {\r
+                       string folderPath;\r
+                       \r
+                       if (cacheFolderCustomCheckBox.Checked) {\r
+                               folderPath = cacheFolderTextBox.Text;\r
+                       } else {\r
+                               // デフォルトは AppDataFolderPath/Cache。\r
+                               folderPath = System.IO.Path.Combine(NaGet.Env.AppDataFolderPath, "Cache");\r
+                       }\r
+                       \r
+                       if (System.IO.Directory.Exists(folderPath)) {\r
+                               DialogResult result = MessageBox.Show(string.Format("フォルダーパス\"{0}\"のファイルを削除して構いませんか?", folderPath), "キャッシュフォルダー", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);\r
+                               if (result == DialogResult.OK) {\r
+                                       foreach (string targetDir in System.IO.Directory.GetDirectories(folderPath)) {\r
+                                               try {\r
+                                                       NaGet.Utils.SetAttributeRecursive(targetDir, System.IO.FileAttributes.Normal);\r
+                                                       System.IO.Directory.Delete(targetDir, true);\r
+                                               } catch {\r
+                                                       // 何もせずに静かに先に進む\r
+                                               }\r
+                                       }\r
+                               }\r
+                       } else {\r
+                               MessageBox.Show(string.Format("フォルダーパス\"{0}\"は存在しませんでした。", folderPath), "キャッシュフォルダー", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                       }\r
+               }\r
        }\r
 }\r