Skip to content

Commit

Permalink
打开软件时自动更新订阅;
Browse files Browse the repository at this point in the history
  • Loading branch information
AmazingDM committed Sep 4, 2020
1 parent e3bc370 commit a47395c
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 5 deletions.
8 changes: 7 additions & 1 deletion Netch/Forms/MainForm.MenuStrip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions Netch/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 18 additions & 4 deletions Netch/Forms/SettingForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Netch/Forms/SettingForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions Netch/Models/Setting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ public class Setting
/// </summary>
public bool CheckBetaUpdate = false;

/// <summary>
/// 是否打开软件时更新订阅
/// </summary>
public bool UpdateSubscribeatWhenOpened = false;

/// <summary>
/// 修改系统 DNS
/// </summary>
Expand Down
1 change: 1 addition & 0 deletions Netch/Resources/zh-CN
Original file line number Diff line number Diff line change
Expand Up @@ -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": "快捷配置数量",
Expand Down

0 comments on commit a47395c

Please sign in to comment.