mirror of
https://github.com/netchx/netch.git
synced 2026-04-03 19:35:10 +08:00
Revert Binding Server,Mode
This commit is contained in:
@@ -1,9 +1,3 @@
|
||||
using Microsoft.Win32;
|
||||
using Netch.Controllers;
|
||||
using Netch.Forms.Mode;
|
||||
using Netch.Models;
|
||||
using Netch.Properties;
|
||||
using Netch.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@@ -14,9 +8,15 @@ using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.Win32;
|
||||
using Netch.Controllers;
|
||||
using Netch.Enums;
|
||||
using Netch.Forms.Mode;
|
||||
using Netch.Interfaces;
|
||||
using Netch.Models;
|
||||
using Netch.Properties;
|
||||
using Netch.Services;
|
||||
using Netch.Utils;
|
||||
using Serilog;
|
||||
using Vanara.PInvoke;
|
||||
|
||||
@@ -71,14 +71,12 @@ namespace Netch.Forms
|
||||
// 计算 ComboBox绘制 目标宽度
|
||||
RecordSize();
|
||||
|
||||
// Bind Server
|
||||
ServerComboBox.DataSource = Global.Settings.Server;
|
||||
LoadServers();
|
||||
SelectLastServer();
|
||||
ServerHelper.DelayTestHelper.UpdateInterval();
|
||||
|
||||
// Load and Bind Mode
|
||||
ModeHelper.Load();
|
||||
ModeComboBox.DataSource = Global.Modes;
|
||||
LoadModes();
|
||||
SelectLastMode();
|
||||
|
||||
// 加载翻译
|
||||
@@ -220,6 +218,7 @@ namespace Netch.Forms
|
||||
Global.Settings.Server.AddRange(servers);
|
||||
NotifyTip(i18N.TranslateFormat("Import {0} server(s) form Clipboard", servers.Count));
|
||||
|
||||
LoadServers();
|
||||
await Configuration.SaveAsync();
|
||||
}
|
||||
}
|
||||
@@ -234,6 +233,7 @@ namespace Netch.Forms
|
||||
Hide();
|
||||
util.Create();
|
||||
|
||||
LoadServers();
|
||||
await Configuration.SaveAsync();
|
||||
Show();
|
||||
}
|
||||
@@ -264,6 +264,7 @@ namespace Netch.Forms
|
||||
{
|
||||
Hide();
|
||||
new SubscribeForm().ShowDialog();
|
||||
LoadServers();
|
||||
Show();
|
||||
}
|
||||
|
||||
@@ -292,6 +293,7 @@ namespace Netch.Forms
|
||||
{
|
||||
await Subscription.UpdateServersAsync();
|
||||
|
||||
LoadServers();
|
||||
await Configuration.SaveAsync();
|
||||
StatusText(i18N.Translate("Subscription updated"));
|
||||
}
|
||||
@@ -432,9 +434,7 @@ namespace Netch.Forms
|
||||
catch (Exception exception)
|
||||
{
|
||||
if (exception is not MessageException)
|
||||
{
|
||||
Log.Error(exception, "更新未处理异常");
|
||||
}
|
||||
|
||||
NotifyTip(exception.Message, info: false);
|
||||
}
|
||||
@@ -510,7 +510,6 @@ namespace Netch.Forms
|
||||
_ = Task.Run(() =>
|
||||
{
|
||||
while (State == State.Started)
|
||||
{
|
||||
if (Global.Settings.StartedPingInterval >= 0)
|
||||
{
|
||||
server.Test();
|
||||
@@ -522,7 +521,6 @@ namespace Netch.Forms
|
||||
{
|
||||
Thread.Sleep(5000);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -541,6 +539,7 @@ namespace Netch.Forms
|
||||
{
|
||||
i18N.Load(Global.Settings.Language);
|
||||
TranslateControls();
|
||||
LoadModes();
|
||||
LoadProfiles();
|
||||
}
|
||||
|
||||
@@ -557,6 +556,13 @@ namespace Netch.Forms
|
||||
|
||||
#region Server
|
||||
|
||||
private void LoadServers()
|
||||
{
|
||||
ServerComboBox.Items.Clear();
|
||||
ServerComboBox.Items.AddRange(Global.Settings.Server.Cast<object>().ToArray());
|
||||
SelectLastServer();
|
||||
}
|
||||
|
||||
private void SelectLastServer()
|
||||
{
|
||||
// 如果值合法,选中该位置
|
||||
@@ -588,6 +594,7 @@ namespace Netch.Forms
|
||||
|
||||
Hide();
|
||||
ServerHelper.GetUtilByTypeName(server.Type).Edit(server);
|
||||
LoadServers();
|
||||
await Configuration.SaveAsync();
|
||||
Show();
|
||||
}
|
||||
@@ -661,12 +668,21 @@ namespace Netch.Forms
|
||||
}
|
||||
|
||||
Global.Settings.Server.Remove(server);
|
||||
LoadServers();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Mode
|
||||
|
||||
public void LoadModes()
|
||||
{
|
||||
ModeComboBox.Items.Clear();
|
||||
ModeComboBox.Items.AddRange(Global.Modes.Cast<object>().ToArray());
|
||||
ModeComboBox.Tag = null;
|
||||
SelectLastMode();
|
||||
}
|
||||
|
||||
private void SelectLastMode()
|
||||
{
|
||||
// 如果值合法,选中该位置
|
||||
|
||||
Reference in New Issue
Block a user