From a3da08dfdefc1d99e48e3c4737989a7f7ecb62d1 Mon Sep 17 00:00:00 2001 From: Mo_Ink <2350745751@qq.com> Date: Tue, 29 Jun 2021 15:59:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=8B=A5=E5=B9=B2=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Configurations.cs | 2 +- src/Forms/WindowMain.Designer.cs | 60 +++++++++++++++++++++++++++++--- src/Forms/WindowMain.cs | 17 ++++++++- src/Models/UISettings.cs | 2 +- src/SeewoHelper.csproj | 2 +- 5 files changed, 75 insertions(+), 8 deletions(-) diff --git a/src/Configurations.cs b/src/Configurations.cs index 4463e99..d59d47c 100644 --- a/src/Configurations.cs +++ b/src/Configurations.cs @@ -14,6 +14,6 @@ public static class Configurations /// /// 配置 /// - public static readonly Configuration UISettings = new(Path.Combine(Constants.ConfigurationPath, "UISettings.json"), new UISettings(UIStyle.LightBlue, LogLevel.Info, false, false, true)); + public static readonly Configuration UISettings = new(Path.Combine(Constants.ConfigurationPath, "UISettings.json"), new UISettings(UIStyle.LightBlue, LogLevel.Info, false, false, true, true)); } } diff --git a/src/Forms/WindowMain.Designer.cs b/src/Forms/WindowMain.Designer.cs index b0e2c24..04a94b1 100644 --- a/src/Forms/WindowMain.Designer.cs +++ b/src/Forms/WindowMain.Designer.cs @@ -43,8 +43,11 @@ private void InitializeComponent() this.buttonFileSortingInfoRemove = new Sunny.UI.UIButton(); this.tabControl = new Sunny.UI.UITabControl(); this.tabPageUsefulFeatures = new System.Windows.Forms.TabPage(); + this.checkBoxDisableServiceWindowsSearch = new Sunny.UI.UICheckBox(); + this.checkBoxDisableServiceWindowsUpdate = new Sunny.UI.UICheckBox(); this.checkBoxDisableServiceShellHardwareDetection = new Sunny.UI.UICheckBox(); this.tabPageSettings = new System.Windows.Forms.TabPage(); + this.checkBoxHideToNotify = new Sunny.UI.UICheckBox(); this.checkBoxDoubleClickNotify = new Sunny.UI.UICheckBox(); this.checkBoxHideWhenStart = new Sunny.UI.UICheckBox(); this.checkBoxAutoCheckUpdate = new Sunny.UI.UICheckBox(); @@ -282,6 +285,8 @@ private void InitializeComponent() // tabPageUsefulFeatures // this.tabPageUsefulFeatures.BackColor = System.Drawing.Color.White; + this.tabPageUsefulFeatures.Controls.Add(this.checkBoxDisableServiceWindowsSearch); + this.tabPageUsefulFeatures.Controls.Add(this.checkBoxDisableServiceWindowsUpdate); this.tabPageUsefulFeatures.Controls.Add(this.checkBoxDisableServiceShellHardwareDetection); this.tabPageUsefulFeatures.ForeColor = System.Drawing.Color.White; this.tabPageUsefulFeatures.Location = new System.Drawing.Point(0, 40); @@ -291,6 +296,34 @@ private void InitializeComponent() this.tabPageUsefulFeatures.TabIndex = 1; this.tabPageUsefulFeatures.Text = "实用功能"; // + // checkBoxDisableServiceWindowsSearch + // + this.checkBoxDisableServiceWindowsSearch.Cursor = System.Windows.Forms.Cursors.Hand; + this.checkBoxDisableServiceWindowsSearch.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.checkBoxDisableServiceWindowsSearch.Location = new System.Drawing.Point(4, 64); + this.checkBoxDisableServiceWindowsSearch.Margin = new System.Windows.Forms.Padding(4); + this.checkBoxDisableServiceWindowsSearch.MinimumSize = new System.Drawing.Size(1, 1); + this.checkBoxDisableServiceWindowsSearch.Name = "checkBoxDisableServiceWindowsSearch"; + this.checkBoxDisableServiceWindowsSearch.Padding = new System.Windows.Forms.Padding(22, 0, 0, 0); + this.checkBoxDisableServiceWindowsSearch.Size = new System.Drawing.Size(195, 22); + this.checkBoxDisableServiceWindowsSearch.Style = Sunny.UI.UIStyle.LightBlue; + this.checkBoxDisableServiceWindowsSearch.TabIndex = 2; + this.checkBoxDisableServiceWindowsSearch.Text = "禁用 Windows Search"; + // + // checkBoxDisableServiceWindowsUpdate + // + this.checkBoxDisableServiceWindowsUpdate.Cursor = System.Windows.Forms.Cursors.Hand; + this.checkBoxDisableServiceWindowsUpdate.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.checkBoxDisableServiceWindowsUpdate.Location = new System.Drawing.Point(4, 34); + this.checkBoxDisableServiceWindowsUpdate.Margin = new System.Windows.Forms.Padding(4); + this.checkBoxDisableServiceWindowsUpdate.MinimumSize = new System.Drawing.Size(1, 1); + this.checkBoxDisableServiceWindowsUpdate.Name = "checkBoxDisableServiceWindowsUpdate"; + this.checkBoxDisableServiceWindowsUpdate.Padding = new System.Windows.Forms.Padding(22, 0, 0, 0); + this.checkBoxDisableServiceWindowsUpdate.Size = new System.Drawing.Size(195, 22); + this.checkBoxDisableServiceWindowsUpdate.Style = Sunny.UI.UIStyle.LightBlue; + this.checkBoxDisableServiceWindowsUpdate.TabIndex = 1; + this.checkBoxDisableServiceWindowsUpdate.Text = "禁用 Windows Update"; + // // checkBoxDisableServiceShellHardwareDetection // this.checkBoxDisableServiceShellHardwareDetection.Cursor = System.Windows.Forms.Cursors.Hand; @@ -300,13 +333,14 @@ private void InitializeComponent() this.checkBoxDisableServiceShellHardwareDetection.MinimumSize = new System.Drawing.Size(1, 1); this.checkBoxDisableServiceShellHardwareDetection.Name = "checkBoxDisableServiceShellHardwareDetection"; this.checkBoxDisableServiceShellHardwareDetection.Padding = new System.Windows.Forms.Padding(22, 0, 0, 0); - this.checkBoxDisableServiceShellHardwareDetection.Size = new System.Drawing.Size(426, 22); + this.checkBoxDisableServiceShellHardwareDetection.Size = new System.Drawing.Size(133, 22); this.checkBoxDisableServiceShellHardwareDetection.Style = Sunny.UI.UIStyle.LightBlue; this.checkBoxDisableServiceShellHardwareDetection.TabIndex = 0; - this.checkBoxDisableServiceShellHardwareDetection.Text = "关闭U盘插入提示修复(禁用Shell Hardware Detection服务)"; + this.checkBoxDisableServiceShellHardwareDetection.Text = "禁用 自动播放"; // // tabPageSettings // + this.tabPageSettings.Controls.Add(this.checkBoxHideToNotify); this.tabPageSettings.Controls.Add(this.checkBoxDoubleClickNotify); this.tabPageSettings.Controls.Add(this.checkBoxHideWhenStart); this.tabPageSettings.Controls.Add(this.checkBoxAutoCheckUpdate); @@ -320,12 +354,27 @@ private void InitializeComponent() this.tabPageSettings.Text = "设置"; this.tabPageSettings.UseVisualStyleBackColor = true; // + // checkBoxHideToNotify + // + this.checkBoxHideToNotify.Checked = true; + this.checkBoxHideToNotify.Cursor = System.Windows.Forms.Cursors.Hand; + this.checkBoxHideToNotify.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); + this.checkBoxHideToNotify.Location = new System.Drawing.Point(6, 144); + this.checkBoxHideToNotify.MinimumSize = new System.Drawing.Size(1, 1); + this.checkBoxHideToNotify.Name = "checkBoxHideToNotify"; + this.checkBoxHideToNotify.Padding = new System.Windows.Forms.Padding(22, 0, 0, 0); + this.checkBoxHideToNotify.Size = new System.Drawing.Size(192, 25); + this.checkBoxHideToNotify.Style = Sunny.UI.UIStyle.LightBlue; + this.checkBoxHideToNotify.TabIndex = 7; + this.checkBoxHideToNotify.Text = "关闭窗口隐藏至托盘"; + this.checkBoxHideToNotify.CheckedChanged += new System.EventHandler(this.CheckBoxHideToNotify_CheckedChanged); + // // checkBoxDoubleClickNotify // this.checkBoxDoubleClickNotify.Checked = true; this.checkBoxDoubleClickNotify.Cursor = System.Windows.Forms.Cursors.Hand; this.checkBoxDoubleClickNotify.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); - this.checkBoxDoubleClickNotify.Location = new System.Drawing.Point(6, 144); + this.checkBoxDoubleClickNotify.Location = new System.Drawing.Point(6, 175); this.checkBoxDoubleClickNotify.MinimumSize = new System.Drawing.Size(1, 1); this.checkBoxDoubleClickNotify.Name = "checkBoxDoubleClickNotify"; this.checkBoxDoubleClickNotify.Padding = new System.Windows.Forms.Padding(22, 0, 0, 0); @@ -370,7 +419,7 @@ private void InitializeComponent() this.buttonCleanLog.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255))))); this.buttonCleanLog.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.buttonCleanLog.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255))))); - this.buttonCleanLog.Location = new System.Drawing.Point(6, 175); + this.buttonCleanLog.Location = new System.Drawing.Point(6, 206); this.buttonCleanLog.MinimumSize = new System.Drawing.Size(1, 1); this.buttonCleanLog.Name = "buttonCleanLog"; this.buttonCleanLog.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255))))); @@ -906,6 +955,9 @@ private void InitializeComponent() private Sunny.UI.UILinkLabel linkLabelRickyGithub; private Sunny.UI.UISymbolLabel symbolLabelRicky; private Sunny.UI.UICheckBox checkBoxDoubleClickNotify; + private Sunny.UI.UICheckBox checkBoxDisableServiceWindowsUpdate; + private Sunny.UI.UICheckBox checkBoxDisableServiceWindowsSearch; + private Sunny.UI.UICheckBox checkBoxHideToNotify; } } diff --git a/src/Forms/WindowMain.cs b/src/Forms/WindowMain.cs index c06bce6..98f56c0 100644 --- a/src/Forms/WindowMain.cs +++ b/src/Forms/WindowMain.cs @@ -81,6 +81,7 @@ private void WindowMain_Load(object sender, EventArgs e) LoadComboBoxLogLevel(); LoadAutoCheckUpdate(); LoadHideWhenStart(); + LoadHideToNotify(); LoadDoubleClickNotify(); checkBoxAutoStart.Checked = AutoStartUtilities.IsAutoStart(); Program.Logger.Info($"{nameof(WindowMain)} 加载完成"); @@ -107,6 +108,11 @@ private void LoadDoubleClickNotify() checkBoxDoubleClickNotify.Checked = Configurations.UISettings.Content.IsDoubleClickNotify; } + private void LoadHideToNotify() + { + checkBoxHideToNotify.Checked = Configurations.UISettings.Content.IsHideToNotify; + } + private async void LoadAutoCheckUpdate() { bool isAutoCheckUpdate = Configurations.UISettings.Content.IsAutoCheckUpdate; @@ -121,6 +127,8 @@ private async void LoadAutoCheckUpdate() private void CreateServiceCheckBox() { checkBoxDisableServiceShellHardwareDetection.Tag = new ServiceCheckBox(checkBoxDisableServiceShellHardwareDetection, "ShellHWDetection", true) { PreAction = () => Cursor = Cursors.WaitCursor, PostAction = () => Cursor = Cursors.Default }; + checkBoxDisableServiceWindowsUpdate.Tag = new ServiceCheckBox(checkBoxDisableServiceWindowsUpdate, "wuauserv", true) { PreAction = () => Cursor = Cursors.WaitCursor, PostAction = () => Cursor = Cursors.Default }; + checkBoxDisableServiceWindowsSearch.Tag = new ServiceCheckBox(checkBoxDisableServiceWindowsSearch, "WSearch", true) { PreAction = () => Cursor = Cursors.WaitCursor, PostAction = () => Cursor = Cursors.Default }; } private void LoadComboBoxStyle() @@ -164,7 +172,7 @@ private void ListViewSubjectStorageInfos_DoubleClick(object sender, EventArgs e) private void WindowMain_FormClosing(object sender, FormClosingEventArgs e) { - if (e.CloseReason == CloseReason.UserClosing) + if (checkBoxHideToNotify.Checked && e.CloseReason == CloseReason.UserClosing) { e.Cancel = true; HideWindow(); @@ -302,5 +310,12 @@ private void CheckBoxDoubleClickNotify_CheckedChanged(object sender, EventArgs e Configurations.UISettings.Content = Configurations.UISettings.Content with { IsDoubleClickNotify = checkBoxDoubleClickNotify.Checked }; Configurations.UISettings.Save(); } + + private void CheckBoxHideToNotify_CheckedChanged(object sender, EventArgs e) + { + checkBoxDoubleClickNotify.Enabled = checkBoxHideToNotify.Checked; + Configurations.UISettings.Content = Configurations.UISettings.Content with { IsHideToNotify = checkBoxHideToNotify.Checked }; + Configurations.UISettings.Save(); + } } } \ No newline at end of file diff --git a/src/Models/UISettings.cs b/src/Models/UISettings.cs index d97e492..f41970a 100644 --- a/src/Models/UISettings.cs +++ b/src/Models/UISettings.cs @@ -5,5 +5,5 @@ namespace SeewoHelper /// /// 表示 UI 设置 /// - public record UISettings(UIStyle Style, LogLevel LogLevel, bool IsHideWhenStart, bool IsAutoCheckUpdate, bool IsDoubleClickNotify); + public record UISettings(UIStyle Style, LogLevel LogLevel, bool IsHideWhenStart, bool IsAutoCheckUpdate, bool IsDoubleClickNotify, bool IsHideToNotify); } diff --git a/src/SeewoHelper.csproj b/src/SeewoHelper.csproj index ab02640..0ffe873 100644 --- a/src/SeewoHelper.csproj +++ b/src/SeewoHelper.csproj @@ -9,7 +9,7 @@ app.manifest favicon.ico SeewoHelper.Program - 0.4.3 + 0.4.5