From: ttp Date: Sun, 11 Dec 2011 04:01:57 +0000 (+0900) Subject: AppliStation,キャッシュフォルダ一旦ひらいて消すのが面倒になったから、キャッシュフォルダをクリーンアップする機能を設定画面に追加 X-Git-Tag: v1.4.1~1 X-Git-Url: http://git.sourceforge.jp/view?p=applistation%2FAppliStation.git;a=commitdiff_plain;h=98ee1854c5d7a3a52a845728bd389f3f7205203d;ds=sidebyside AppliStation,キャッシュフォルダ一旦ひらいて消すのが面倒になったから、キャッシュフォルダをクリーンアップする機能を設定画面に追加 --- diff --git a/AppliStation/UserPrefForm.Designer.cs b/AppliStation/UserPrefForm.Designer.cs index 8ccd8e1..68b8162 100644 --- a/AppliStation/UserPrefForm.Designer.cs +++ b/AppliStation/UserPrefForm.Designer.cs @@ -65,6 +65,7 @@ this.cacheFolderCustomCheckBox = new System.Windows.Forms.CheckBox(); this.cacheFolderTextBox = new System.Windows.Forms.TextBox(); this.cacheFolderBrowseButton = new System.Windows.Forms.Button(); + this.cacheFolderFlowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel(); this.cacheFolderOpenLinkLabel = new System.Windows.Forms.LinkLabel(); this.upgradeTabPage = new System.Windows.Forms.TabPage(); this.upgradeTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); @@ -72,6 +73,7 @@ this.upgradeExcludeTextBox = new System.Windows.Forms.TextBox(); this.toolTip = new System.Windows.Forms.ToolTip(this.components); this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components); + this.cacheFolderClearLinkLabel = new System.Windows.Forms.LinkLabel(); upgradeExcludeDescLabel = new System.Windows.Forms.Label(); this.tableLayoutPanel.SuspendLayout(); this.buttonsPanel.SuspendLayout(); @@ -86,11 +88,22 @@ this.installTableLayoutPanel.SuspendLayout(); this.cacheFolderGroupBox.SuspendLayout(); this.cacheFolderTableLayoutPanel.SuspendLayout(); + this.cacheFolderFlowLayoutPanel.SuspendLayout(); this.upgradeTabPage.SuspendLayout(); this.upgradeTableLayoutPanel.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); this.SuspendLayout(); // + // upgradeExcludeDescLabel + // + upgradeExcludeDescLabel.AutoSize = true; + upgradeExcludeDescLabel.Dock = System.Windows.Forms.DockStyle.Fill; + upgradeExcludeDescLabel.Location = new System.Drawing.Point(3, 196); + upgradeExcludeDescLabel.Name = "upgradeExcludeDescLabel"; + upgradeExcludeDescLabel.Size = new System.Drawing.Size(434, 12); + upgradeExcludeDescLabel.TabIndex = 1; + upgradeExcludeDescLabel.Text = "除外するソフト名称を改行で区切って入力します。"; + // // proxyURLLabel // this.proxyURLLabel.AutoSize = true; @@ -175,10 +188,10 @@ // reposListTabPage // this.reposListTabPage.Controls.Add(this.repoTableLayoutPanel); - this.reposListTabPage.Location = new System.Drawing.Point(4, 21); + this.reposListTabPage.Location = new System.Drawing.Point(4, 22); this.reposListTabPage.Name = "reposListTabPage"; this.reposListTabPage.Padding = new System.Windows.Forms.Padding(3); - this.reposListTabPage.Size = new System.Drawing.Size(446, 215); + this.reposListTabPage.Size = new System.Drawing.Size(446, 214); this.reposListTabPage.TabIndex = 0; this.reposListTabPage.Text = "レポジトリ"; // @@ -200,7 +213,7 @@ this.repoTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.repoTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.repoTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.repoTableLayoutPanel.Size = new System.Drawing.Size(440, 209); + this.repoTableLayoutPanel.Size = new System.Drawing.Size(440, 208); this.repoTableLayoutPanel.TabIndex = 1; // // repoListCheckedListBox @@ -212,7 +225,7 @@ this.repoListCheckedListBox.Location = new System.Drawing.Point(3, 15); this.repoListCheckedListBox.Name = "repoListCheckedListBox"; this.repoListCheckedListBox.ScrollAlwaysVisible = true; - this.repoListCheckedListBox.Size = new System.Drawing.Size(347, 166); + this.repoListCheckedListBox.Size = new System.Drawing.Size(347, 165); this.repoListCheckedListBox.TabIndex = 1; this.repoListCheckedListBox.SelectedIndexChanged += new System.EventHandler(this.RepoListCheckedListBoxSelectedIndexChanged); this.repoListCheckedListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.RepoListCheckedListBoxItemCheck); @@ -276,7 +289,7 @@ this.repoUrlTextBox.Dock = System.Windows.Forms.DockStyle.Fill; this.repoUrlTextBox.Enabled = false; this.repoUrlTextBox.ImeMode = System.Windows.Forms.ImeMode.Off; - this.repoUrlTextBox.Location = new System.Drawing.Point(122, 187); + this.repoUrlTextBox.Location = new System.Drawing.Point(122, 186); this.repoUrlTextBox.Name = "repoUrlTextBox"; this.repoUrlTextBox.Size = new System.Drawing.Size(315, 19); this.repoUrlTextBox.TabIndex = 3; @@ -288,7 +301,7 @@ this.repoUrlLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this.repoUrlLabel.AutoSize = true; this.repoUrlLabel.Enabled = false; - this.repoUrlLabel.Location = new System.Drawing.Point(3, 190); + this.repoUrlLabel.Location = new System.Drawing.Point(3, 189); this.repoUrlLabel.Name = "repoUrlLabel"; this.repoUrlLabel.Size = new System.Drawing.Size(113, 12); this.repoUrlLabel.TabIndex = 2; @@ -308,10 +321,10 @@ // networkTabPage // this.networkTabPage.Controls.Add(this.proxyGroupBox); - this.networkTabPage.Location = new System.Drawing.Point(4, 21); + this.networkTabPage.Location = new System.Drawing.Point(4, 22); this.networkTabPage.Name = "networkTabPage"; this.networkTabPage.Padding = new System.Windows.Forms.Padding(3); - this.networkTabPage.Size = new System.Drawing.Size(446, 215); + this.networkTabPage.Size = new System.Drawing.Size(446, 214); this.networkTabPage.TabIndex = 1; this.networkTabPage.Text = "接続"; // @@ -321,7 +334,7 @@ this.proxyGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; this.proxyGroupBox.Location = new System.Drawing.Point(3, 3); this.proxyGroupBox.Name = "proxyGroupBox"; - this.proxyGroupBox.Size = new System.Drawing.Size(440, 209); + this.proxyGroupBox.Size = new System.Drawing.Size(440, 208); this.proxyGroupBox.TabIndex = 1; this.proxyGroupBox.TabStop = false; this.proxyGroupBox.Text = "プロキシサーバー"; @@ -350,7 +363,7 @@ this.proxyTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.proxyTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.proxyTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.proxyTableLayoutPanel.Size = new System.Drawing.Size(434, 191); + this.proxyTableLayoutPanel.Size = new System.Drawing.Size(434, 190); this.proxyTableLayoutPanel.TabIndex = 0; // // proxySameAsIERadioButton @@ -436,10 +449,10 @@ // installTabPage // this.installTabPage.Controls.Add(this.installTableLayoutPanel); - this.installTabPage.Location = new System.Drawing.Point(4, 21); + this.installTabPage.Location = new System.Drawing.Point(4, 22); this.installTabPage.Name = "installTabPage"; this.installTabPage.Padding = new System.Windows.Forms.Padding(3); - this.installTabPage.Size = new System.Drawing.Size(446, 215); + this.installTabPage.Size = new System.Drawing.Size(446, 214); this.installTabPage.TabIndex = 2; this.installTabPage.Text = "インストール"; // @@ -458,7 +471,7 @@ this.installTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.installTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.installTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.installTableLayoutPanel.Size = new System.Drawing.Size(440, 209); + this.installTableLayoutPanel.Size = new System.Drawing.Size(440, 208); this.installTableLayoutPanel.TabIndex = 1; // // installScanInstallerFileCheckbox @@ -490,7 +503,7 @@ this.cacheFolderGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; this.cacheFolderGroupBox.Location = new System.Drawing.Point(3, 47); this.cacheFolderGroupBox.Name = "cacheFolderGroupBox"; - this.cacheFolderGroupBox.Size = new System.Drawing.Size(434, 81); + this.cacheFolderGroupBox.Size = new System.Drawing.Size(434, 89); this.cacheFolderGroupBox.TabIndex = 2; this.cacheFolderGroupBox.TabStop = false; this.cacheFolderGroupBox.Text = "キャッシュフォルダー"; @@ -505,7 +518,7 @@ this.cacheFolderTableLayoutPanel.Controls.Add(this.cacheFolderCustomCheckBox, 0, 0); this.cacheFolderTableLayoutPanel.Controls.Add(this.cacheFolderTextBox, 1, 1); this.cacheFolderTableLayoutPanel.Controls.Add(this.cacheFolderBrowseButton, 2, 1); - this.cacheFolderTableLayoutPanel.Controls.Add(this.cacheFolderOpenLinkLabel, 0, 2); + this.cacheFolderTableLayoutPanel.Controls.Add(this.cacheFolderFlowLayoutPanel, 0, 3); this.cacheFolderTableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; this.cacheFolderTableLayoutPanel.Location = new System.Drawing.Point(3, 15); this.cacheFolderTableLayoutPanel.Name = "cacheFolderTableLayoutPanel"; @@ -513,7 +526,8 @@ this.cacheFolderTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.cacheFolderTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.cacheFolderTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.cacheFolderTableLayoutPanel.Size = new System.Drawing.Size(428, 63); + this.cacheFolderTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); + this.cacheFolderTableLayoutPanel.Size = new System.Drawing.Size(428, 71); this.cacheFolderTableLayoutPanel.TabIndex = 0; // // cacheFolderCustomCheckBox @@ -551,27 +565,37 @@ this.cacheFolderBrowseButton.Text = "参照(&B)..."; this.cacheFolderBrowseButton.Click += new System.EventHandler(this.CacheFolderBrowseButtonClick); // + // cacheFolderFlowLayoutPanel + // + this.cacheFolderTableLayoutPanel.SetColumnSpan(this.cacheFolderFlowLayoutPanel, 3); + this.cacheFolderFlowLayoutPanel.Controls.Add(this.cacheFolderOpenLinkLabel); + this.cacheFolderFlowLayoutPanel.Controls.Add(this.cacheFolderClearLinkLabel); + this.cacheFolderFlowLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.cacheFolderFlowLayoutPanel.Location = new System.Drawing.Point(3, 54); + this.cacheFolderFlowLayoutPanel.Name = "cacheFolderFlowLayoutPanel"; + this.cacheFolderFlowLayoutPanel.Size = new System.Drawing.Size(422, 14); + this.cacheFolderFlowLayoutPanel.TabIndex = 3; + // // cacheFolderOpenLinkLabel // this.cacheFolderOpenLinkLabel.AutoSize = true; - this.cacheFolderTableLayoutPanel.SetColumnSpan(this.cacheFolderOpenLinkLabel, 3); this.cacheFolderOpenLinkLabel.LinkColor = System.Drawing.SystemColors.HotTrack; - this.cacheFolderOpenLinkLabel.Location = new System.Drawing.Point(3, 51); + this.cacheFolderOpenLinkLabel.Location = new System.Drawing.Point(3, 0); this.cacheFolderOpenLinkLabel.Name = "cacheFolderOpenLinkLabel"; - this.cacheFolderOpenLinkLabel.Size = new System.Drawing.Size(120, 12); - this.cacheFolderOpenLinkLabel.TabIndex = 3; + this.cacheFolderOpenLinkLabel.Size = new System.Drawing.Size(136, 12); + this.cacheFolderOpenLinkLabel.TabIndex = 0; this.cacheFolderOpenLinkLabel.TabStop = true; - this.cacheFolderOpenLinkLabel.Text = "キャッシュフォルダーを開く"; + this.cacheFolderOpenLinkLabel.Text = "キャッシュフォルダーを開く(&O)"; this.cacheFolderOpenLinkLabel.VisitedLinkColor = System.Drawing.SystemColors.HotTrack; this.cacheFolderOpenLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.CacheFolderOpenLinkLabelLinkClicked); // // upgradeTabPage // this.upgradeTabPage.Controls.Add(this.upgradeTableLayoutPanel); - this.upgradeTabPage.Location = new System.Drawing.Point(4, 21); + this.upgradeTabPage.Location = new System.Drawing.Point(4, 22); this.upgradeTabPage.Name = "upgradeTabPage"; this.upgradeTabPage.Padding = new System.Windows.Forms.Padding(3); - this.upgradeTabPage.Size = new System.Drawing.Size(446, 215); + this.upgradeTabPage.Size = new System.Drawing.Size(446, 214); this.upgradeTabPage.TabIndex = 3; this.upgradeTabPage.Text = "ソフト更新"; // @@ -589,7 +613,7 @@ this.upgradeTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); this.upgradeTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); this.upgradeTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle()); - this.upgradeTableLayoutPanel.Size = new System.Drawing.Size(440, 209); + this.upgradeTableLayoutPanel.Size = new System.Drawing.Size(440, 208); this.upgradeTableLayoutPanel.TabIndex = 0; // // upgradeExcludeLabel @@ -610,25 +634,28 @@ this.upgradeExcludeTextBox.Multiline = true; this.upgradeExcludeTextBox.Name = "upgradeExcludeTextBox"; this.upgradeExcludeTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; - this.upgradeExcludeTextBox.Size = new System.Drawing.Size(434, 179); + this.upgradeExcludeTextBox.Size = new System.Drawing.Size(434, 178); this.upgradeExcludeTextBox.TabIndex = 0; this.upgradeExcludeTextBox.WordWrap = false; // - // upgradeExcludeDescLabel - // - upgradeExcludeDescLabel.AutoSize = true; - upgradeExcludeDescLabel.Dock = System.Windows.Forms.DockStyle.Fill; - upgradeExcludeDescLabel.Location = new System.Drawing.Point(3, 197); - upgradeExcludeDescLabel.Name = "upgradeExcludeDescLabel"; - upgradeExcludeDescLabel.Size = new System.Drawing.Size(434, 12); - upgradeExcludeDescLabel.TabIndex = 1; - upgradeExcludeDescLabel.Text = "除外するソフト名称を改行で区切って入力します。"; - // // errorProvider // this.errorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.AlwaysBlink; this.errorProvider.ContainerControl = this; // + // cacheFolderClearLinkLabel + // + this.cacheFolderClearLinkLabel.AutoSize = true; + this.cacheFolderClearLinkLabel.LinkColor = System.Drawing.SystemColors.HotTrack; + this.cacheFolderClearLinkLabel.Location = new System.Drawing.Point(145, 0); + this.cacheFolderClearLinkLabel.Name = "cacheFolderClearLinkLabel"; + this.cacheFolderClearLinkLabel.Size = new System.Drawing.Size(180, 12); + this.cacheFolderClearLinkLabel.TabIndex = 1; + this.cacheFolderClearLinkLabel.TabStop = true; + this.cacheFolderClearLinkLabel.Text = "キャッシュフォルダーをクリーンアップする"; + this.cacheFolderClearLinkLabel.VisitedLinkColor = System.Drawing.SystemColors.HotTrack; + this.cacheFolderClearLinkLabel.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.CacheFolderClearLinkLabelLinkClicked); + // // UserPrefForm // this.AcceptButton = this.okButton; @@ -664,17 +691,21 @@ this.cacheFolderGroupBox.PerformLayout(); this.cacheFolderTableLayoutPanel.ResumeLayout(false); this.cacheFolderTableLayoutPanel.PerformLayout(); + this.cacheFolderFlowLayoutPanel.ResumeLayout(false); + this.cacheFolderFlowLayoutPanel.PerformLayout(); this.upgradeTabPage.ResumeLayout(false); this.upgradeTableLayoutPanel.ResumeLayout(false); this.upgradeTableLayoutPanel.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); this.ResumeLayout(false); } + private System.Windows.Forms.LinkLabel cacheFolderClearLinkLabel; + private System.Windows.Forms.LinkLabel cacheFolderOpenLinkLabel; + private System.Windows.Forms.FlowLayoutPanel cacheFolderFlowLayoutPanel; private System.Windows.Forms.Label upgradeExcludeLabel; private System.Windows.Forms.TextBox upgradeExcludeTextBox; private System.Windows.Forms.TableLayoutPanel upgradeTableLayoutPanel; private System.Windows.Forms.TabPage upgradeTabPage; - private System.Windows.Forms.LinkLabel cacheFolderOpenLinkLabel; private System.Windows.Forms.Button cacheFolderBrowseButton; private System.Windows.Forms.TextBox cacheFolderTextBox; private System.Windows.Forms.CheckBox cacheFolderCustomCheckBox; diff --git a/AppliStation/UserPrefForm.cs b/AppliStation/UserPrefForm.cs index 3f6ff2b..712222e 100644 --- a/AppliStation/UserPrefForm.cs +++ b/AppliStation/UserPrefForm.cs @@ -477,5 +477,33 @@ namespace AppliStation MessageBox.Show(string.Format("フォルダーパス\"{0}\"は存在しませんでした。", folderPath), "キャッシュフォルダー", MessageBoxButtons.OK, MessageBoxIcon.Error); } } + + void CacheFolderClearLinkLabelLinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + string folderPath; + + if (cacheFolderCustomCheckBox.Checked) { + folderPath = cacheFolderTextBox.Text; + } else { + // デフォルトは AppDataFolderPath/Cache。 + folderPath = System.IO.Path.Combine(NaGet.Env.AppDataFolderPath, "Cache"); + } + + if (System.IO.Directory.Exists(folderPath)) { + DialogResult result = MessageBox.Show(string.Format("フォルダーパス\"{0}\"のファイルを削除して構いませんか?", folderPath), "キャッシュフォルダー", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); + if (result == DialogResult.OK) { + foreach (string targetDir in System.IO.Directory.GetDirectories(folderPath)) { + try { + NaGet.Utils.SetAttributeRecursive(targetDir, System.IO.FileAttributes.Normal); + System.IO.Directory.Delete(targetDir, true); + } catch { + // 何もせずに静かに先に進む + } + } + } + } else { + MessageBox.Show(string.Format("フォルダーパス\"{0}\"は存在しませんでした。", folderPath), "キャッシュフォルダー", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } } } diff --git a/AppliStation/UserPrefForm.resx b/AppliStation/UserPrefForm.resx index d8a1879..2f7b5a5 100644 --- a/AppliStation/UserPrefForm.resx +++ b/AppliStation/UserPrefForm.resx @@ -117,12 +117,12 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 17, 17 - False + + 17, 17 + 104, 17