From 81510e0036861b7e8e310a472246e697b59d9379 Mon Sep 17 00:00:00 2001
From: LovelyWei <16489620+LovelyWei@users.noreply.github.com>
Date: Tue, 18 Feb 2020 13:14:24 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=90=AF=E5=8A=A8?=
=?UTF-8?q?=E5=90=8E=E9=9A=90=E8=97=8F=E9=80=89=E9=A1=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Netch/Forms/MainForm.cs | 20 ++++++++++++++++++++
Netch/Forms/SettingForm.Designer.cs | 27 ++++++++++++++++++++-------
Netch/Forms/SettingForm.cs | 3 +++
Netch/Models/Setting.cs | 5 +++++
Netch/Resources/zh-CN | 1 +
5 files changed, 49 insertions(+), 7 deletions(-)
diff --git a/Netch/Forms/MainForm.cs b/Netch/Forms/MainForm.cs
index c80cdb37..4eaa9bd8 100644
--- a/Netch/Forms/MainForm.cs
+++ b/Netch/Forms/MainForm.cs
@@ -836,6 +836,26 @@ namespace Netch.Forms
}
State = Models.State.Started;
+
+ // 如果勾选启动后最小化
+ if (Global.Settings.MinimizeWhenStarted)
+ {
+ WindowState = FormWindowState.Minimized;
+ NotifyIcon.Visible = true;
+
+ if (IsFirstOpened)
+ {
+ // 显示提示语
+ NotifyIcon.ShowBalloonTip(5,
+ UpdateChecker.Name,
+ Utils.i18N.Translate("Netch is now minimized to the notification bar, double click this icon to restore."),
+ ToolTipIcon.Info);
+
+ IsFirstOpened = false;
+ }
+
+ Hide();
+ }
}
else
{
diff --git a/Netch/Forms/SettingForm.Designer.cs b/Netch/Forms/SettingForm.Designer.cs
index 7fe2621e..a72ef5ec 100644
--- a/Netch/Forms/SettingForm.Designer.cs
+++ b/Netch/Forms/SettingForm.Designer.cs
@@ -50,6 +50,7 @@
this.ControlButton = new System.Windows.Forms.Button();
this.GlobalBypassIPsButton = new System.Windows.Forms.Button();
this.BehaviorGroupBox = new System.Windows.Forms.GroupBox();
+ this.MinimizeWhenStartedCheckBox = new System.Windows.Forms.CheckBox();
this.ProfileCount_Label = new System.Windows.Forms.Label();
this.ProfileCount_TextBox = new System.Windows.Forms.TextBox();
this.CheckUpdateWhenOpenedCheckBox = new System.Windows.Forms.CheckBox();
@@ -239,7 +240,7 @@
// ControlButton
//
this.ControlButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
- this.ControlButton.Location = new System.Drawing.Point(357, 514);
+ this.ControlButton.Location = new System.Drawing.Point(357, 549);
this.ControlButton.Name = "ControlButton";
this.ControlButton.Size = new System.Drawing.Size(75, 23);
this.ControlButton.TabIndex = 11;
@@ -250,7 +251,7 @@
// GlobalBypassIPsButton
//
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, 514);
+ this.GlobalBypassIPsButton.Location = new System.Drawing.Point(12, 549);
this.GlobalBypassIPsButton.Name = "GlobalBypassIPsButton";
this.GlobalBypassIPsButton.Size = new System.Drawing.Size(128, 23);
this.GlobalBypassIPsButton.TabIndex = 10;
@@ -260,6 +261,7 @@
//
// BehaviorGroupBox
//
+ this.BehaviorGroupBox.Controls.Add(this.MinimizeWhenStartedCheckBox);
this.BehaviorGroupBox.Controls.Add(this.ProfileCount_Label);
this.BehaviorGroupBox.Controls.Add(this.ProfileCount_TextBox);
this.BehaviorGroupBox.Controls.Add(this.CheckUpdateWhenOpenedCheckBox);
@@ -268,15 +270,25 @@
this.BehaviorGroupBox.Controls.Add(this.ExitWhenClosedCheckBox);
this.BehaviorGroupBox.Location = new System.Drawing.Point(12, 330);
this.BehaviorGroupBox.Name = "BehaviorGroupBox";
- this.BehaviorGroupBox.Size = new System.Drawing.Size(420, 178);
+ this.BehaviorGroupBox.Size = new System.Drawing.Size(420, 213);
this.BehaviorGroupBox.TabIndex = 8;
this.BehaviorGroupBox.TabStop = false;
this.BehaviorGroupBox.Text = "Behavior";
//
+ // MinimizeWhenStartedCheckBox
+ //
+ this.MinimizeWhenStartedCheckBox.AutoSize = true;
+ this.MinimizeWhenStartedCheckBox.Location = new System.Drawing.Point(120, 103);
+ this.MinimizeWhenStartedCheckBox.Name = "MinimizeWhenStartedCheckBox";
+ this.MinimizeWhenStartedCheckBox.Size = new System.Drawing.Size(158, 21);
+ this.MinimizeWhenStartedCheckBox.TabIndex = 10;
+ this.MinimizeWhenStartedCheckBox.Text = "Minimize when started";
+ this.MinimizeWhenStartedCheckBox.UseVisualStyleBackColor = true;
+ //
// ProfileCount_Label
//
this.ProfileCount_Label.AutoSize = true;
- this.ProfileCount_Label.Location = new System.Drawing.Point(9, 133);
+ this.ProfileCount_Label.Location = new System.Drawing.Point(9, 185);
this.ProfileCount_Label.Name = "ProfileCount_Label";
this.ProfileCount_Label.Size = new System.Drawing.Size(79, 17);
this.ProfileCount_Label.TabIndex = 8;
@@ -284,7 +296,7 @@
//
// ProfileCount_TextBox
//
- this.ProfileCount_TextBox.Location = new System.Drawing.Point(222, 130);
+ this.ProfileCount_TextBox.Location = new System.Drawing.Point(222, 182);
this.ProfileCount_TextBox.Name = "ProfileCount_TextBox";
this.ProfileCount_TextBox.Size = new System.Drawing.Size(192, 23);
this.ProfileCount_TextBox.TabIndex = 9;
@@ -293,7 +305,7 @@
// CheckUpdateWhenOpenedCheckBox
//
this.CheckUpdateWhenOpenedCheckBox.AutoSize = true;
- this.CheckUpdateWhenOpenedCheckBox.Location = new System.Drawing.Point(120, 103);
+ this.CheckUpdateWhenOpenedCheckBox.Location = new System.Drawing.Point(120, 130);
this.CheckUpdateWhenOpenedCheckBox.Name = "CheckUpdateWhenOpenedCheckBox";
this.CheckUpdateWhenOpenedCheckBox.Size = new System.Drawing.Size(190, 21);
this.CheckUpdateWhenOpenedCheckBox.TabIndex = 8;
@@ -338,7 +350,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
- this.ClientSize = new System.Drawing.Size(444, 548);
+ this.ClientSize = new System.Drawing.Size(444, 583);
this.Controls.Add(this.BehaviorGroupBox);
this.Controls.Add(this.PortGroupBox);
this.Controls.Add(this.GlobalBypassIPsButton);
@@ -393,5 +405,6 @@
private System.Windows.Forms.CheckBox CheckUpdateWhenOpenedCheckBox;
private System.Windows.Forms.Label ProfileCount_Label;
private System.Windows.Forms.TextBox ProfileCount_TextBox;
+ private System.Windows.Forms.CheckBox MinimizeWhenStartedCheckBox;
}
}
\ No newline at end of file
diff --git a/Netch/Forms/SettingForm.cs b/Netch/Forms/SettingForm.cs
index 9e3af674..59408626 100644
--- a/Netch/Forms/SettingForm.cs
+++ b/Netch/Forms/SettingForm.cs
@@ -57,6 +57,7 @@ namespace Netch.Forms
StopWhenExitedCheckBox.Checked = Global.Settings.StopWhenExited;
StartWhenOpenedCheckBox.Checked = Global.Settings.StartWhenOpened;
CheckUpdateWhenOpenedCheckBox.Checked = Global.Settings.CheckUpdateWhenOpened;
+ MinimizeWhenStartedCheckBox.Checked = Global.Settings.MinimizeWhenStarted;
Socks5PortTextBox.Text = Global.Settings.Socks5LocalPort.ToString();
HTTPPortTextBox.Text = Global.Settings.HTTPLocalPort.ToString();
@@ -72,6 +73,7 @@ namespace Netch.Forms
ExitWhenClosedCheckBox.Text = Utils.i18N.Translate(ExitWhenClosedCheckBox.Text);
StopWhenExitedCheckBox.Text = Utils.i18N.Translate(StopWhenExitedCheckBox.Text);
StartWhenOpenedCheckBox.Text = Utils.i18N.Translate(StartWhenOpenedCheckBox.Text);
+ MinimizeWhenStartedCheckBox.Text = Utils.i18N.Translate(MinimizeWhenStartedCheckBox.Text);
CheckUpdateWhenOpenedCheckBox.Text = Utils.i18N.Translate(CheckUpdateWhenOpenedCheckBox.Text);
ProfileCount_Label.Text = Utils.i18N.Translate(ProfileCount_Label.Text);
@@ -133,6 +135,7 @@ namespace Netch.Forms
Global.Settings.StopWhenExited = StopWhenExitedCheckBox.Checked;
Global.Settings.StartWhenOpened = StartWhenOpenedCheckBox.Checked;
Global.Settings.CheckUpdateWhenOpened = CheckUpdateWhenOpenedCheckBox.Checked;
+ Global.Settings.MinimizeWhenStarted = MinimizeWhenStartedCheckBox.Checked;
try
{
diff --git a/Netch/Models/Setting.cs b/Netch/Models/Setting.cs
index 39585a3c..cd74666b 100644
--- a/Netch/Models/Setting.cs
+++ b/Netch/Models/Setting.cs
@@ -63,6 +63,11 @@ namespace Netch.Models
///
public bool StartWhenOpened = false;
+ ///
+ /// 是否启动后自动最小化
+ ///
+ public bool MinimizeWhenStarted = false;
+
///
/// 是否打开软件时检查更新
///
diff --git a/Netch/Resources/zh-CN b/Netch/Resources/zh-CN
index ae44eca3..d5e27f32 100644
--- a/Netch/Resources/zh-CN
+++ b/Netch/Resources/zh-CN
@@ -119,6 +119,7 @@
"Settings": "设置",
"Start when opened": "打开软件时启动加速",
+ "Minimize when started": "启动加速后隐藏",
"Local Port": "本地端口",
"Allow other Devices to connect": "允许其他设备连入",
"Netmask": "子网掩码",
From df706037f0dff95529381886a888d762b44a5b66 Mon Sep 17 00:00:00 2001
From: BingLingGroup <42505588+BingLingGroup@users.noreply.github.com>
Date: Tue, 18 Feb 2020 15:16:58 +0800
Subject: [PATCH 2/2] Refactor hiding codes
---
Netch/Forms/MainForm.cs | 42 ++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/Netch/Forms/MainForm.cs b/Netch/Forms/MainForm.cs
index 4eaa9bd8..558571e2 100644
--- a/Netch/Forms/MainForm.cs
+++ b/Netch/Forms/MainForm.cs
@@ -1,4 +1,4 @@
-using Netch.Controllers;
+using Netch.Controllers;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@@ -791,6 +791,26 @@ namespace Netch.Forms
// UsedBandwidthLabel.Visible = UploadSpeedLabel.Visible = DownloadSpeedLabel.Visible = true;
// MainController.pNFController.OnBandwidthUpdated += OnBandwidthUpdated;
+ // 如果勾选启动后最小化
+ if (Global.Settings.MinimizeWhenStarted)
+ {
+ WindowState = FormWindowState.Minimized;
+ NotifyIcon.Visible = true;
+
+ if (IsFirstOpened)
+ {
+ // 显示提示语
+ NotifyIcon.ShowBalloonTip(5,
+ UpdateChecker.Name,
+ Utils.i18N.Translate("Netch is now minimized to the notification bar, double click this icon to restore."),
+ ToolTipIcon.Info);
+
+ IsFirstOpened = false;
+ }
+
+ Hide();
+ }
+
ControlButton.Enabled = true;
ControlButton.Text = Utils.i18N.Translate("Stop");
@@ -836,26 +856,6 @@ namespace Netch.Forms
}
State = Models.State.Started;
-
- // 如果勾选启动后最小化
- if (Global.Settings.MinimizeWhenStarted)
- {
- WindowState = FormWindowState.Minimized;
- NotifyIcon.Visible = true;
-
- if (IsFirstOpened)
- {
- // 显示提示语
- NotifyIcon.ShowBalloonTip(5,
- UpdateChecker.Name,
- Utils.i18N.Translate("Netch is now minimized to the notification bar, double click this icon to restore."),
- ToolTipIcon.Info);
-
- IsFirstOpened = false;
- }
-
- Hide();
- }
}
else
{