From a47395cc6cd9404812ed0e5240af987ccf8f1945 Mon Sep 17 00:00:00 2001 From: AmazingDM Date: Fri, 4 Sep 2020 11:11:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=BC=80=E8=BD=AF=E4=BB=B6=E6=97=B6?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=9B=B4=E6=96=B0=E8=AE=A2=E9=98=85=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Netch/Forms/MainForm.MenuStrip.cs | 8 +++++++- Netch/Forms/MainForm.cs | 10 ++++++++++ Netch/Forms/SettingForm.Designer.cs | 22 ++++++++++++++++++---- Netch/Forms/SettingForm.cs | 3 +++ Netch/Models/Setting.cs | 5 +++++ Netch/Resources/zh-CN | 1 + 6 files changed, 44 insertions(+), 5 deletions(-) diff --git a/Netch/Forms/MainForm.MenuStrip.cs b/Netch/Forms/MainForm.MenuStrip.cs index 124908187e..c4cd97656d 100644 --- a/Netch/Forms/MainForm.MenuStrip.cs +++ b/Netch/Forms/MainForm.MenuStrip.cs @@ -52,7 +52,7 @@ private void ImportServersFromClipboardToolStripMenuItem_Click(object sender, Ev private void AddServerToolStripMenuItem_Click(object sender, EventArgs e) { - Form form = ((ToolStripMenuItem) sender).Name switch + Form form = ((ToolStripMenuItem)sender).Name switch { "AddSocks5ServerToolStripMenuItem" => new Socks5(), "AddShadowsocksServerToolStripMenuItem" => new Shadowsocks(), @@ -113,6 +113,12 @@ private void ManageSubscribeLinksToolStripMenuItem_Click(object sender, EventArg private async void UpdateServersFromSubscribeLinksToolStripMenuItem_Click(object sender, EventArgs e) { + UpdateServersFromSubscribe(); + } + + public async void UpdateServersFromSubscribe() + { + void DisableItems(bool v) { MenuStrip.Enabled = ConfigurationGroupBox.Enabled = ProfileGroupBox.Enabled = ControlButton.Enabled = v; diff --git a/Netch/Forms/MainForm.cs b/Netch/Forms/MainForm.cs index b4b99427f9..f6a44cdc6a 100644 --- a/Netch/Forms/MainForm.cs +++ b/Netch/Forms/MainForm.cs @@ -83,6 +83,16 @@ private void MainForm_Load(object sender, EventArgs e) CheckUpdate(); } }); + + + Task.Run(() => + { + // 检查订阅更新 + if (Global.Settings.UpdateSubscribeatWhenOpened) + { + UpdateServersFromSubscribe(); + } + }); } private void OnCalled(object sender, OnlyInstance.Commands e) diff --git a/Netch/Forms/SettingForm.Designer.cs b/Netch/Forms/SettingForm.Designer.cs index c219086a28..01e501c4e2 100644 --- a/Netch/Forms/SettingForm.Designer.cs +++ b/Netch/Forms/SettingForm.Designer.cs @@ -72,6 +72,7 @@ private void InitializeComponent() this.StartWhenOpenedCheckBox = new System.Windows.Forms.CheckBox(); this.StopWhenExitedCheckBox = new System.Windows.Forms.CheckBox(); this.ExitWhenClosedCheckBox = new System.Windows.Forms.CheckBox(); + this.UpdateSubscribeatWhenOpenedCheckBox = new System.Windows.Forms.CheckBox(); this.PortGroupBox.SuspendLayout(); this.TUNTAPGroupBox.SuspendLayout(); this.BehaviorGroupBox.SuspendLayout(); @@ -276,7 +277,7 @@ private void InitializeComponent() // // ControlButton // - this.ControlButton.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); + this.ControlButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.ControlButton.Location = new System.Drawing.Point(804, 356); this.ControlButton.Name = "ControlButton"; this.ControlButton.Size = new System.Drawing.Size(75, 23); @@ -287,7 +288,7 @@ private void InitializeComponent() // // GlobalBypassIPsButton // - this.GlobalBypassIPsButton.Anchor = ((System.Windows.Forms.AnchorStyles) ((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); + this.GlobalBypassIPsButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.GlobalBypassIPsButton.Location = new System.Drawing.Point(12, 356); this.GlobalBypassIPsButton.Name = "GlobalBypassIPsButton"; this.GlobalBypassIPsButton.Size = new System.Drawing.Size(128, 23); @@ -298,6 +299,7 @@ private void InitializeComponent() // // BehaviorGroupBox // + this.BehaviorGroupBox.Controls.Add(this.UpdateSubscribeatWhenOpenedCheckBox); this.BehaviorGroupBox.Controls.Add(this.LanguageLabel); this.BehaviorGroupBox.Controls.Add(this.LanguageComboBox); this.BehaviorGroupBox.Controls.Add(this.ModifySystemDNSCheckBox); @@ -517,6 +519,17 @@ private void InitializeComponent() this.ExitWhenClosedCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight; this.ExitWhenClosedCheckBox.UseVisualStyleBackColor = true; // + // UpdateSubscribeatWhenOpenedCheckBox + // + this.UpdateSubscribeatWhenOpenedCheckBox.AutoSize = true; + this.UpdateSubscribeatWhenOpenedCheckBox.Location = new System.Drawing.Point(206, 129); + this.UpdateSubscribeatWhenOpenedCheckBox.Name = "UpdateSubscribeatWhenOpenedCheckBox"; + this.UpdateSubscribeatWhenOpenedCheckBox.Size = new System.Drawing.Size(224, 21); + this.UpdateSubscribeatWhenOpenedCheckBox.TabIndex = 24; + this.UpdateSubscribeatWhenOpenedCheckBox.Text = "Update subscribeat when opened"; + this.UpdateSubscribeatWhenOpenedCheckBox.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + this.UpdateSubscribeatWhenOpenedCheckBox.UseVisualStyleBackColor = true; + // // SettingForm // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); @@ -527,9 +540,9 @@ private void InitializeComponent() this.Controls.Add(this.GlobalBypassIPsButton); this.Controls.Add(this.ControlButton); this.Controls.Add(this.TUNTAPGroupBox); - this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte) (134))); + this.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; - this.Icon = ((System.Drawing.Icon) (resources.GetObject("$this.Icon"))); + this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.MaximizeBox = false; this.Name = "SettingForm"; @@ -590,5 +603,6 @@ private void InitializeComponent() private System.Windows.Forms.ComboBox LanguageComboBox; private System.Windows.Forms.CheckBox ModifySystemDNSCheckBox; private System.Windows.Forms.CheckBox CheckBetaUpdateCheckBox; + private System.Windows.Forms.CheckBox UpdateSubscribeatWhenOpenedCheckBox; } } \ No newline at end of file diff --git a/Netch/Forms/SettingForm.cs b/Netch/Forms/SettingForm.cs index 975cc918b3..71cbbb317b 100644 --- a/Netch/Forms/SettingForm.cs +++ b/Netch/Forms/SettingForm.cs @@ -109,6 +109,7 @@ private void InitValue() BootShadowsocksFromDLLCheckBox.Checked = Global.Settings.BootShadowsocksFromDLL; ModifySystemDNSCheckBox.Checked = Global.Settings.ModifySystemDNS; CheckBetaUpdateCheckBox.Checked = Global.Settings.CheckBetaUpdate; + UpdateSubscribeatWhenOpenedCheckBox.Checked = Global.Settings.UpdateSubscribeatWhenOpened; ProfileCountTextBox.Text = Global.Settings.ProfileCount.ToString(); TcpingAtStartedCheckBox.Checked = Global.Settings.StartedTcping; @@ -142,6 +143,7 @@ private void InitText() StartWhenOpenedCheckBox.Text = i18N.Translate(StartWhenOpenedCheckBox.Text); MinimizeWhenStartedCheckBox.Text = i18N.Translate(MinimizeWhenStartedCheckBox.Text); RunAtStartupCheckBox.Text = i18N.Translate(RunAtStartupCheckBox.Text); + UpdateSubscribeatWhenOpenedCheckBox.Text = i18N.Translate(UpdateSubscribeatWhenOpenedCheckBox.Text); CheckUpdateWhenOpenedCheckBox.Text = i18N.Translate(CheckUpdateWhenOpenedCheckBox.Text); ProfileCountLabel.Text = i18N.Translate(ProfileCountLabel.Text); TcpingAtStartedCheckBox.Text = i18N.Translate(TcpingAtStartedCheckBox.Text); @@ -186,6 +188,7 @@ private void ControlButton_Click(object sender, EventArgs e) Global.Settings.StartWhenOpened = StartWhenOpenedCheckBox.Checked; Global.Settings.CheckUpdateWhenOpened = CheckUpdateWhenOpenedCheckBox.Checked; Global.Settings.CheckBetaUpdate = CheckBetaUpdateCheckBox.Checked; + Global.Settings.UpdateSubscribeatWhenOpened = UpdateSubscribeatWhenOpenedCheckBox.Checked; Global.Settings.MinimizeWhenStarted = MinimizeWhenStartedCheckBox.Checked; Global.Settings.RunAtStartup = RunAtStartupCheckBox.Checked; Global.Settings.BootShadowsocksFromDLL = BootShadowsocksFromDLLCheckBox.Checked; diff --git a/Netch/Models/Setting.cs b/Netch/Models/Setting.cs index b5ba722576..eedc56dbd3 100644 --- a/Netch/Models/Setting.cs +++ b/Netch/Models/Setting.cs @@ -94,6 +94,11 @@ public class Setting /// public bool CheckBetaUpdate = false; + /// + /// 是否打开软件时更新订阅 + /// + public bool UpdateSubscribeatWhenOpened = false; + /// /// 修改系统 DNS /// diff --git a/Netch/Resources/zh-CN b/Netch/Resources/zh-CN index ef28bd5dac..5bf3349af6 100644 --- a/Netch/Resources/zh-CN +++ b/Netch/Resources/zh-CN @@ -165,6 +165,7 @@ "Port value illegal. Try again.": "端口值非法。请重试。", "Check update when opened": "打开软件时检查更新", "Check Beta update": "检查 Beta 更新", + "Update subscribeat when opened": "自动更新订阅", "SS DLL(No ACL support)": "SS DLL(不支持 ACL)", "Modify System DNS": "修改系统 DNS", "ProfileCount": "快捷配置数量",