mirror of
https://github.com/2dust/v2rayN.git
synced 2025-07-01 12:32:10 +00:00
Refactor_updateView to add task
This commit is contained in:
parent
b936c194e4
commit
b57cdd31bd
27 changed files with 218 additions and 216 deletions
|
@ -5,7 +5,7 @@ namespace ServiceLib.Base
|
||||||
public class MyReactiveObject : ReactiveObject
|
public class MyReactiveObject : ReactiveObject
|
||||||
{
|
{
|
||||||
protected static Config? _config;
|
protected static Config? _config;
|
||||||
protected Func<EViewAction, object?, bool>? _updateView;
|
protected Func<EViewAction, object?, Task<bool>>? _updateView;
|
||||||
protected NoticeHandler? _noticeHandler;
|
protected NoticeHandler? _noticeHandler;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,7 +15,7 @@ namespace ServiceLib.ViewModels
|
||||||
public ReactiveCommand<Unit, Unit> SaveServerCmd { get; }
|
public ReactiveCommand<Unit, Unit> SaveServerCmd { get; }
|
||||||
public bool IsModified { get; set; }
|
public bool IsModified { get; set; }
|
||||||
|
|
||||||
public AddServer2ViewModel(ProfileItem profileItem, Func<EViewAction, object?, bool>? updateView)
|
public AddServer2ViewModel(ProfileItem profileItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||||
_config = LazyConfig.Instance.Config;
|
_config = LazyConfig.Instance.Config;
|
||||||
|
@ -30,9 +30,9 @@ namespace ServiceLib.ViewModels
|
||||||
SelectedSource = JsonUtils.DeepCopy(profileItem);
|
SelectedSource = JsonUtils.DeepCopy(profileItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
BrowseServerCmd = ReactiveCommand.Create(() =>
|
BrowseServerCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.BrowseServer, null);
|
await _updateView?.Invoke(EViewAction.BrowseServer, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
EditServerCmd = ReactiveCommand.Create(() =>
|
EditServerCmd = ReactiveCommand.Create(() =>
|
||||||
|
@ -42,11 +42,11 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
SaveServerCmd = ReactiveCommand.Create(() =>
|
SaveServerCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
SaveServer();
|
SaveServerAsync();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveServer()
|
private async Task SaveServerAsync()
|
||||||
{
|
{
|
||||||
string remarks = SelectedSource.remarks;
|
string remarks = SelectedSource.remarks;
|
||||||
if (Utils.IsNullOrEmpty(remarks))
|
if (Utils.IsNullOrEmpty(remarks))
|
||||||
|
@ -64,7 +64,7 @@ namespace ServiceLib.ViewModels
|
||||||
if (ConfigHandler.EditCustomServer(_config, SelectedSource) == 0)
|
if (ConfigHandler.EditCustomServer(_config, SelectedSource) == 0)
|
||||||
{
|
{
|
||||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
||||||
|
|
||||||
public AddServerViewModel(ProfileItem profileItem, Func<EViewAction, object?, bool>? updateView)
|
public AddServerViewModel(ProfileItem profileItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = LazyConfig.Instance.Config;
|
_config = LazyConfig.Instance.Config;
|
||||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||||
|
@ -33,11 +33,11 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
SaveCmd = ReactiveCommand.Create(() =>
|
SaveCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
SaveServer();
|
SaveServerAsync();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveServer()
|
private async Task SaveServerAsync()
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(SelectedSource.remarks))
|
if (Utils.IsNullOrEmpty(SelectedSource.remarks))
|
||||||
{
|
{
|
||||||
|
@ -83,7 +83,7 @@ namespace ServiceLib.ViewModels
|
||||||
if (ConfigHandler.AddServer(_config, SelectedSource) == 0)
|
if (ConfigHandler.AddServer(_config, SelectedSource) == 0)
|
||||||
{
|
{
|
||||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace ServiceLib.ViewModels
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public bool AutoRefresh { get; set; }
|
public bool AutoRefresh { get; set; }
|
||||||
|
|
||||||
public ClashConnectionsViewModel(Func<EViewAction, object?, bool>? updateView)
|
public ClashConnectionsViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = LazyConfig.Instance.Config;
|
_config = LazyConfig.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
@ -99,14 +99,14 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
private void GetClashConnections()
|
private void GetClashConnections()
|
||||||
{
|
{
|
||||||
ClashApiHandler.Instance.GetClashConnections(_config, (it) =>
|
ClashApiHandler.Instance.GetClashConnections(_config, async (it) =>
|
||||||
{
|
{
|
||||||
if (it == null)
|
if (it == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateView?.Invoke(EViewAction.DispatcherRefreshConnections, it?.connections);
|
await _updateView?.Invoke(EViewAction.DispatcherRefreshConnections, it?.connections);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace ServiceLib.ViewModels
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public bool AutoRefresh { get; set; }
|
public bool AutoRefresh { get; set; }
|
||||||
|
|
||||||
public ClashProxiesViewModel(Func<EViewAction, object?, bool>? updateView)
|
public ClashProxiesViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||||
_config = LazyConfig.Instance.Config;
|
_config = LazyConfig.Instance.Config;
|
||||||
|
@ -167,7 +167,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
private void GetClashProxies(bool refreshUI)
|
private void GetClashProxies(bool refreshUI)
|
||||||
{
|
{
|
||||||
ClashApiHandler.Instance.GetClashProxies(_config, (it, it2) =>
|
ClashApiHandler.Instance.GetClashProxies(_config, async (it, it2) =>
|
||||||
{
|
{
|
||||||
//UpdateHandler(false, "Refresh Clash Proxies");
|
//UpdateHandler(false, "Refresh Clash Proxies");
|
||||||
_proxies = it?.proxies;
|
_proxies = it?.proxies;
|
||||||
|
@ -179,7 +179,7 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
if (refreshUI)
|
if (refreshUI)
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.DispatcherRefreshProxyGroups, null);
|
await _updateView?.Invoke(EViewAction.DispatcherRefreshProxyGroups, null);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -386,7 +386,7 @@ namespace ServiceLib.ViewModels
|
||||||
{
|
{
|
||||||
//UpdateHandler(false, "Clash Proxies Latency Test");
|
//UpdateHandler(false, "Clash Proxies Latency Test");
|
||||||
|
|
||||||
ClashApiHandler.Instance.ClashProxiesDelayTest(blAll, _proxyDetails.ToList(), (item, result) =>
|
ClashApiHandler.Instance.ClashProxiesDelayTest(blAll, _proxyDetails.ToList(), async (item, result) =>
|
||||||
{
|
{
|
||||||
if (item == null)
|
if (item == null)
|
||||||
{
|
{
|
||||||
|
@ -398,7 +398,7 @@ namespace ServiceLib.ViewModels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateView?.Invoke(EViewAction.DispatcherProxiesDelayTest, new SpeedTestResult() { IndexId = item.name, Delay = result });
|
await _updateView?.Invoke(EViewAction.DispatcherProxiesDelayTest, new SpeedTestResult() { IndexId = item.name, Delay = result });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ namespace ServiceLib.ViewModels
|
||||||
public ReactiveCommand<Unit, Unit> ImportDefConfig4V2rayCmd { get; }
|
public ReactiveCommand<Unit, Unit> ImportDefConfig4V2rayCmd { get; }
|
||||||
public ReactiveCommand<Unit, Unit> ImportDefConfig4SingboxCmd { get; }
|
public ReactiveCommand<Unit, Unit> ImportDefConfig4SingboxCmd { get; }
|
||||||
|
|
||||||
public DNSSettingViewModel(Func<EViewAction, object?, bool>? updateView)
|
public DNSSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = LazyConfig.Instance.Config;
|
_config = LazyConfig.Instance.Config;
|
||||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||||
|
@ -41,7 +41,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
SaveCmd = ReactiveCommand.Create(() =>
|
SaveCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
SaveSetting();
|
SaveSettingAsync();
|
||||||
});
|
});
|
||||||
|
|
||||||
ImportDefConfig4V2rayCmd = ReactiveCommand.Create(() =>
|
ImportDefConfig4V2rayCmd = ReactiveCommand.Create(() =>
|
||||||
|
@ -56,7 +56,7 @@ namespace ServiceLib.ViewModels
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveSetting()
|
private async Task SaveSettingAsync()
|
||||||
{
|
{
|
||||||
if (!Utils.IsNullOrEmpty(normalDNS))
|
if (!Utils.IsNullOrEmpty(normalDNS))
|
||||||
{
|
{
|
||||||
|
@ -107,7 +107,7 @@ namespace ServiceLib.ViewModels
|
||||||
ConfigHandler.SaveDNSItems(_config, item2);
|
ConfigHandler.SaveDNSItems(_config, item2);
|
||||||
|
|
||||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -152,13 +152,13 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
#region Init
|
#region Init
|
||||||
|
|
||||||
public MainWindowViewModel(Func<EViewAction, object?, bool>? updateView)
|
public MainWindowViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = LazyConfig.Instance.Config;
|
_config = LazyConfig.Instance.Config;
|
||||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
|
||||||
MessageBus.Current.Listen<string>(Global.CommandRefreshProfiles).Subscribe(x => _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null));
|
MessageBus.Current.Listen<string>(Global.CommandRefreshProfiles).Subscribe(async x => await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null));
|
||||||
|
|
||||||
SelectedRouting = new();
|
SelectedRouting = new();
|
||||||
SelectedServer = new();
|
SelectedServer = new();
|
||||||
|
@ -170,7 +170,7 @@ namespace ServiceLib.ViewModels
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(
|
||||||
x => x.SelectedRouting,
|
x => x.SelectedRouting,
|
||||||
y => y != null && !y.remarks.IsNullOrEmpty())
|
y => y != null && !y.remarks.IsNullOrEmpty())
|
||||||
.Subscribe(c => RoutingSelectedChanged(c));
|
.Subscribe(c => RoutingSelectedChangedAsync(c));
|
||||||
|
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(
|
||||||
x => x.SelectedServer,
|
x => x.SelectedServer,
|
||||||
|
@ -191,57 +191,57 @@ namespace ServiceLib.ViewModels
|
||||||
//servers
|
//servers
|
||||||
AddVmessServerCmd = ReactiveCommand.Create(() =>
|
AddVmessServerCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
AddServer(true, EConfigType.VMess);
|
AddServerAsync(true, EConfigType.VMess);
|
||||||
});
|
});
|
||||||
AddVlessServerCmd = ReactiveCommand.Create(() =>
|
AddVlessServerCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
AddServer(true, EConfigType.VLESS);
|
AddServerAsync(true, EConfigType.VLESS);
|
||||||
});
|
});
|
||||||
AddShadowsocksServerCmd = ReactiveCommand.Create(() =>
|
AddShadowsocksServerCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
AddServer(true, EConfigType.Shadowsocks);
|
AddServerAsync(true, EConfigType.Shadowsocks);
|
||||||
});
|
});
|
||||||
AddSocksServerCmd = ReactiveCommand.Create(() =>
|
AddSocksServerCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
AddServer(true, EConfigType.Socks);
|
AddServerAsync(true, EConfigType.Socks);
|
||||||
});
|
});
|
||||||
AddHttpServerCmd = ReactiveCommand.Create(() =>
|
AddHttpServerCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
AddServer(true, EConfigType.Http);
|
AddServerAsync(true, EConfigType.Http);
|
||||||
});
|
});
|
||||||
AddTrojanServerCmd = ReactiveCommand.Create(() =>
|
AddTrojanServerCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
AddServer(true, EConfigType.Trojan);
|
AddServerAsync(true, EConfigType.Trojan);
|
||||||
});
|
});
|
||||||
AddHysteria2ServerCmd = ReactiveCommand.Create(() =>
|
AddHysteria2ServerCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
AddServer(true, EConfigType.Hysteria2);
|
AddServerAsync(true, EConfigType.Hysteria2);
|
||||||
});
|
});
|
||||||
AddTuicServerCmd = ReactiveCommand.Create(() =>
|
AddTuicServerCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
AddServer(true, EConfigType.Tuic);
|
AddServerAsync(true, EConfigType.Tuic);
|
||||||
});
|
});
|
||||||
AddWireguardServerCmd = ReactiveCommand.Create(() =>
|
AddWireguardServerCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
AddServer(true, EConfigType.Wireguard);
|
AddServerAsync(true, EConfigType.Wireguard);
|
||||||
});
|
});
|
||||||
AddCustomServerCmd = ReactiveCommand.Create(() =>
|
AddCustomServerCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
AddServer(true, EConfigType.Custom);
|
AddServerAsync(true, EConfigType.Custom);
|
||||||
});
|
});
|
||||||
AddServerViaClipboardCmd = ReactiveCommand.Create(() =>
|
AddServerViaClipboardCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
AddServerViaClipboard(null);
|
AddServerViaClipboardAsync(null);
|
||||||
});
|
});
|
||||||
AddServerViaScanCmd = ReactiveCommand.Create(() =>
|
AddServerViaScanCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.ScanScreenTask, null);
|
await _updateView?.Invoke(EViewAction.ScanScreenTask, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
//Subscription
|
//Subscription
|
||||||
SubSettingCmd = ReactiveCommand.Create(() =>
|
SubSettingCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
SubSetting();
|
SubSettingAsync();
|
||||||
});
|
});
|
||||||
|
|
||||||
SubUpdateCmd = ReactiveCommand.Create(() =>
|
SubUpdateCmd = ReactiveCommand.Create(() =>
|
||||||
|
@ -264,19 +264,19 @@ namespace ServiceLib.ViewModels
|
||||||
//Setting
|
//Setting
|
||||||
OptionSettingCmd = ReactiveCommand.Create(() =>
|
OptionSettingCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
OptionSetting();
|
OptionSettingAsync();
|
||||||
});
|
});
|
||||||
RoutingSettingCmd = ReactiveCommand.Create(() =>
|
RoutingSettingCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
RoutingSetting();
|
RoutingSettingAsync();
|
||||||
});
|
});
|
||||||
DNSSettingCmd = ReactiveCommand.Create(() =>
|
DNSSettingCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
DNSSetting();
|
DNSSettingAsync();
|
||||||
});
|
});
|
||||||
GlobalHotkeySettingCmd = ReactiveCommand.Create(() =>
|
GlobalHotkeySettingCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
{
|
{
|
||||||
if (_updateView?.Invoke(EViewAction.GlobalHotkeySettingWindow, null) == true)
|
if (await _updateView?.Invoke(EViewAction.GlobalHotkeySettingWindow, null) == true)
|
||||||
{
|
{
|
||||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||||
}
|
}
|
||||||
|
@ -322,9 +322,9 @@ namespace ServiceLib.ViewModels
|
||||||
Reload();
|
Reload();
|
||||||
});
|
});
|
||||||
|
|
||||||
NotifyLeftClickCmd = ReactiveCommand.Create(() =>
|
NotifyLeftClickCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.ShowHideWindow, null);
|
await _updateView?.Invoke(EViewAction.ShowHideWindow, null);
|
||||||
});
|
});
|
||||||
|
|
||||||
//System proxy
|
//System proxy
|
||||||
|
@ -369,7 +369,7 @@ namespace ServiceLib.ViewModels
|
||||||
//RefreshServers();
|
//RefreshServers();
|
||||||
|
|
||||||
Reload();
|
Reload();
|
||||||
ChangeSystemProxyStatus(_config.systemProxyItem.sysProxyType, true);
|
ChangeSystemProxyStatusAsync(_config.systemProxyItem.sysProxyType, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Init
|
#endregion Init
|
||||||
|
@ -402,7 +402,7 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
if (_config.uiItem.enableAutoAdjustMainLvColWidth)
|
if (_config.uiItem.enableAutoAdjustMainLvColWidth)
|
||||||
{
|
{
|
||||||
Locator.Current.GetService<ProfilesViewModel>()?.AutofitColumnWidth();
|
Locator.Current.GetService<ProfilesViewModel>()?.AutofitColumnWidthAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -434,13 +434,13 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MyAppExit(bool blWindowsShutDown)
|
public async Task MyAppExitAsync(bool blWindowsShutDown)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Logging.SaveLog("MyAppExit Begin");
|
Logging.SaveLog("MyAppExit Begin");
|
||||||
//if (blWindowsShutDown)
|
//if (blWindowsShutDown)
|
||||||
_updateView?.Invoke(EViewAction.UpdateSysProxy, true);
|
await _updateView?.Invoke(EViewAction.UpdateSysProxy, true);
|
||||||
|
|
||||||
ConfigHandler.SaveConfig(_config);
|
ConfigHandler.SaveConfig(_config);
|
||||||
ProfileExHandler.Instance.SaveTo();
|
ProfileExHandler.Instance.SaveTo();
|
||||||
|
@ -453,7 +453,7 @@ namespace ServiceLib.ViewModels
|
||||||
catch { }
|
catch { }
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.Shutdown, null);
|
await _updateView?.Invoke(EViewAction.Shutdown, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -519,7 +519,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
#region Add Servers
|
#region Add Servers
|
||||||
|
|
||||||
public void AddServer(bool blNew, EConfigType eConfigType)
|
public async Task AddServerAsync(bool blNew, EConfigType eConfigType)
|
||||||
{
|
{
|
||||||
ProfileItem item = new()
|
ProfileItem item = new()
|
||||||
{
|
{
|
||||||
|
@ -531,11 +531,11 @@ namespace ServiceLib.ViewModels
|
||||||
bool? ret = false;
|
bool? ret = false;
|
||||||
if (eConfigType == EConfigType.Custom)
|
if (eConfigType == EConfigType.Custom)
|
||||||
{
|
{
|
||||||
ret = _updateView?.Invoke(EViewAction.AddServer2Window, item);
|
ret = await _updateView?.Invoke(EViewAction.AddServer2Window, item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = _updateView?.Invoke(EViewAction.AddServerWindow, item);
|
ret = await _updateView?.Invoke(EViewAction.AddServerWindow, item);
|
||||||
}
|
}
|
||||||
if (ret == true)
|
if (ret == true)
|
||||||
{
|
{
|
||||||
|
@ -547,11 +547,11 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddServerViaClipboard(string? clipboardData)
|
public async Task AddServerViaClipboardAsync(string? clipboardData)
|
||||||
{
|
{
|
||||||
if (clipboardData == null)
|
if (clipboardData == null)
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.AddServerViaClipboard, null);
|
await _updateView?.Invoke(EViewAction.AddServerViaClipboard, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int ret = ConfigHandler.AddBatchServers(_config, clipboardData, _config.subIndexId, false);
|
int ret = ConfigHandler.AddBatchServers(_config, clipboardData, _config.subIndexId, false);
|
||||||
|
@ -629,7 +629,7 @@ namespace ServiceLib.ViewModels
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
(new UpdateHandler()).RunAvailabilityCheck((bool success, string msg) =>
|
(new UpdateHandler()).RunAvailabilityCheck(async (bool success, string msg) =>
|
||||||
{
|
{
|
||||||
_noticeHandler?.SendMessage(msg, true);
|
_noticeHandler?.SendMessage(msg, true);
|
||||||
|
|
||||||
|
@ -637,7 +637,7 @@ namespace ServiceLib.ViewModels
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg);
|
await _updateView?.Invoke(EViewAction.DispatcherServerAvailability, msg);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -650,9 +650,9 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
#region Subscription
|
#region Subscription
|
||||||
|
|
||||||
private void SubSetting()
|
private async Task SubSettingAsync()
|
||||||
{
|
{
|
||||||
if (_updateView?.Invoke(EViewAction.SubSettingWindow, null) == true)
|
if (await _updateView?.Invoke(EViewAction.SubSettingWindow, null) == true)
|
||||||
{
|
{
|
||||||
RefreshSubscriptions();
|
RefreshSubscriptions();
|
||||||
}
|
}
|
||||||
|
@ -667,9 +667,9 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
#region Setting
|
#region Setting
|
||||||
|
|
||||||
private void OptionSetting()
|
private async Task OptionSettingAsync()
|
||||||
{
|
{
|
||||||
var ret = _updateView?.Invoke(EViewAction.OptionSettingWindow, null);
|
var ret = await _updateView?.Invoke(EViewAction.OptionSettingWindow, null);
|
||||||
if (ret == true)
|
if (ret == true)
|
||||||
{
|
{
|
||||||
//RefreshServers();
|
//RefreshServers();
|
||||||
|
@ -677,9 +677,9 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RoutingSetting()
|
private async Task RoutingSettingAsync()
|
||||||
{
|
{
|
||||||
var ret = _updateView?.Invoke(EViewAction.RoutingSettingWindow, null);
|
var ret = await _updateView?.Invoke(EViewAction.RoutingSettingWindow, null);
|
||||||
if (ret == true)
|
if (ret == true)
|
||||||
{
|
{
|
||||||
ConfigHandler.InitBuiltinRouting(_config);
|
ConfigHandler.InitBuiltinRouting(_config);
|
||||||
|
@ -689,9 +689,9 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DNSSetting()
|
private async Task DNSSettingAsync()
|
||||||
{
|
{
|
||||||
var ret = _updateView?.Invoke(EViewAction.DNSSettingWindow, null);
|
var ret = await _updateView?.Invoke(EViewAction.DNSSettingWindow, null);
|
||||||
if (ret == true)
|
if (ret == true)
|
||||||
{
|
{
|
||||||
Reload();
|
Reload();
|
||||||
|
@ -711,7 +711,7 @@ namespace ServiceLib.ViewModels
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Process.Start(startInfo);
|
Process.Start(startInfo);
|
||||||
MyAppExit(false);
|
MyAppExitAsync(false);
|
||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
|
@ -742,7 +742,7 @@ namespace ServiceLib.ViewModels
|
||||||
process.Start();
|
process.Start();
|
||||||
if (process.Id > 0)
|
if (process.Id > 0)
|
||||||
{
|
{
|
||||||
MyAppExit(false);
|
MyAppExitAsync(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -796,17 +796,17 @@ namespace ServiceLib.ViewModels
|
||||||
{
|
{
|
||||||
BlReloadEnabled = false;
|
BlReloadEnabled = false;
|
||||||
|
|
||||||
LoadCore().ContinueWith(task =>
|
LoadCore().ContinueWith(async task =>
|
||||||
{
|
{
|
||||||
TestServerAvailability();
|
TestServerAvailability();
|
||||||
|
|
||||||
_updateView?.Invoke(EViewAction.DispatcherReload, null);
|
await _updateView?.Invoke(EViewAction.DispatcherReload, null);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ReloadResult()
|
public void ReloadResult()
|
||||||
{
|
{
|
||||||
ChangeSystemProxyStatus(_config.systemProxyItem.sysProxyType, false);
|
ChangeSystemProxyStatusAsync(_config.systemProxyItem.sysProxyType, false);
|
||||||
BlReloadEnabled = true;
|
BlReloadEnabled = true;
|
||||||
ShowClashUI = _config.IsRunningCore(ECoreType.clash);
|
ShowClashUI = _config.IsRunningCore(ECoreType.clash);
|
||||||
if (ShowClashUI)
|
if (ShowClashUI)
|
||||||
|
@ -835,7 +835,7 @@ namespace ServiceLib.ViewModels
|
||||||
{
|
{
|
||||||
ConfigHandler.SaveConfig(_config, false);
|
ConfigHandler.SaveConfig(_config, false);
|
||||||
|
|
||||||
ChangeSystemProxyStatus(ESysProxyType.ForcedClear, false);
|
ChangeSystemProxyStatusAsync(ESysProxyType.ForcedClear, false);
|
||||||
|
|
||||||
_coreHandler.CoreStop();
|
_coreHandler.CoreStop();
|
||||||
}
|
}
|
||||||
|
@ -851,15 +851,15 @@ namespace ServiceLib.ViewModels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_config.systemProxyItem.sysProxyType = type;
|
_config.systemProxyItem.sysProxyType = type;
|
||||||
ChangeSystemProxyStatus(type, true);
|
ChangeSystemProxyStatusAsync(type, true);
|
||||||
|
|
||||||
SystemProxySelected = (int)_config.systemProxyItem.sysProxyType;
|
SystemProxySelected = (int)_config.systemProxyItem.sysProxyType;
|
||||||
ConfigHandler.SaveConfig(_config, false);
|
ConfigHandler.SaveConfig(_config, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ChangeSystemProxyStatus(ESysProxyType type, bool blChange)
|
private async Task ChangeSystemProxyStatusAsync(ESysProxyType type, bool blChange)
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.UpdateSysProxy, _config.tunModeItem.enableTun ? true : false);
|
await _updateView?.Invoke(EViewAction.UpdateSysProxy, _config.tunModeItem.enableTun ? true : false);
|
||||||
_noticeHandler?.SendMessage($"{ResUI.TipChangeSystemProxy} - {_config.systemProxyItem.sysProxyType.ToString()}", true);
|
_noticeHandler?.SendMessage($"{ResUI.TipChangeSystemProxy} - {_config.systemProxyItem.sysProxyType.ToString()}", true);
|
||||||
|
|
||||||
BlSystemProxyClear = (type == ESysProxyType.ForcedClear);
|
BlSystemProxyClear = (type == ESysProxyType.ForcedClear);
|
||||||
|
@ -871,7 +871,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
if (blChange)
|
if (blChange)
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null);
|
await _updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -896,7 +896,7 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RoutingSelectedChanged(bool c)
|
private async Task RoutingSelectedChangedAsync(bool c)
|
||||||
{
|
{
|
||||||
if (!c)
|
if (!c)
|
||||||
{
|
{
|
||||||
|
@ -922,7 +922,7 @@ namespace ServiceLib.ViewModels
|
||||||
{
|
{
|
||||||
_noticeHandler?.SendMessage(ResUI.TipChangeRouting, true);
|
_noticeHandler?.SendMessage(ResUI.TipChangeRouting, true);
|
||||||
Reload();
|
Reload();
|
||||||
_updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null);
|
await _updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1001,9 +1001,9 @@ namespace ServiceLib.ViewModels
|
||||||
{
|
{
|
||||||
Observable.Range(1, 1)
|
Observable.Range(1, 1)
|
||||||
.Delay(TimeSpan.FromSeconds(1))
|
.Delay(TimeSpan.FromSeconds(1))
|
||||||
.Subscribe(x =>
|
.Subscribe(async x =>
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.ShowHideWindow, false);
|
await _updateView?.Invoke(EViewAction.ShowHideWindow, false);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
||||||
|
|
||||||
public OptionSettingViewModel(Func<EViewAction, object?, bool>? updateView)
|
public OptionSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = LazyConfig.Instance.Config;
|
_config = LazyConfig.Instance.Config;
|
||||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||||
|
@ -190,7 +190,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
SaveCmd = ReactiveCommand.Create(() =>
|
SaveCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
SaveSetting();
|
SaveSettingAsync();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +246,7 @@ namespace ServiceLib.ViewModels
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveSetting()
|
private async Task SaveSettingAsync()
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(localPort.ToString()) || !Utils.IsNumeric(localPort.ToString())
|
if (Utils.IsNullOrEmpty(localPort.ToString()) || !Utils.IsNumeric(localPort.ToString())
|
||||||
|| localPort <= 0 || localPort >= Global.MaxPort)
|
|| localPort <= 0 || localPort >= Global.MaxPort)
|
||||||
|
@ -343,7 +343,7 @@ namespace ServiceLib.ViewModels
|
||||||
{
|
{
|
||||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||||
}
|
}
|
||||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -95,13 +95,13 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
#region Init
|
#region Init
|
||||||
|
|
||||||
public ProfilesViewModel(Func<EViewAction, object?, bool>? updateView)
|
public ProfilesViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = LazyConfig.Instance.Config;
|
_config = LazyConfig.Instance.Config;
|
||||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
|
||||||
MessageBus.Current.Listen<string>(Global.CommandRefreshProfiles).Subscribe(x => _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null));
|
MessageBus.Current.Listen<string>(Global.CommandRefreshProfiles).Subscribe(async x => await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null));
|
||||||
|
|
||||||
SelectedProfile = new();
|
SelectedProfile = new();
|
||||||
SelectedSub = new();
|
SelectedSub = new();
|
||||||
|
@ -120,7 +120,7 @@ namespace ServiceLib.ViewModels
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(
|
||||||
x => x.SelectedSub,
|
x => x.SelectedSub,
|
||||||
y => y != null && !y.remarks.IsNullOrEmpty() && _config.subIndexId != y.id)
|
y => y != null && !y.remarks.IsNullOrEmpty() && _config.subIndexId != y.id)
|
||||||
.Subscribe(c => SubSelectedChanged(c));
|
.Subscribe(c => SubSelectedChangedAsync(c));
|
||||||
this.WhenAnyValue(
|
this.WhenAnyValue(
|
||||||
x => x.SelectedMoveToGroup,
|
x => x.SelectedMoveToGroup,
|
||||||
y => y != null && !y.remarks.IsNullOrEmpty())
|
y => y != null && !y.remarks.IsNullOrEmpty())
|
||||||
|
@ -139,11 +139,11 @@ namespace ServiceLib.ViewModels
|
||||||
//servers delete
|
//servers delete
|
||||||
EditServerCmd = ReactiveCommand.Create(() =>
|
EditServerCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
EditServer(EConfigType.Custom);
|
EditServerAsync(EConfigType.Custom);
|
||||||
}, canEditRemove);
|
}, canEditRemove);
|
||||||
RemoveServerCmd = ReactiveCommand.Create(() =>
|
RemoveServerCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
RemoveServer();
|
RemoveServerAsync();
|
||||||
}, canEditRemove);
|
}, canEditRemove);
|
||||||
RemoveDuplicateServerCmd = ReactiveCommand.Create(() =>
|
RemoveDuplicateServerCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
|
@ -159,7 +159,7 @@ namespace ServiceLib.ViewModels
|
||||||
}, canEditRemove);
|
}, canEditRemove);
|
||||||
ShareServerCmd = ReactiveCommand.Create(() =>
|
ShareServerCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
ShareServer();
|
ShareServerAsync();
|
||||||
}, canEditRemove);
|
}, canEditRemove);
|
||||||
SetDefaultMultipleServerCmd = ReactiveCommand.Create(() =>
|
SetDefaultMultipleServerCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
|
@ -212,29 +212,29 @@ namespace ServiceLib.ViewModels
|
||||||
//servers export
|
//servers export
|
||||||
Export2ClientConfigCmd = ReactiveCommand.Create(() =>
|
Export2ClientConfigCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
Export2ClientConfig(false);
|
Export2ClientConfigAsync(false);
|
||||||
}, canEditRemove);
|
}, canEditRemove);
|
||||||
Export2ClientConfigClipboardCmd = ReactiveCommand.Create(() =>
|
Export2ClientConfigClipboardCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
Export2ClientConfig(true);
|
Export2ClientConfigAsync(true);
|
||||||
}, canEditRemove);
|
}, canEditRemove);
|
||||||
Export2ShareUrlCmd = ReactiveCommand.Create(() =>
|
Export2ShareUrlCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
Export2ShareUrl(false);
|
Export2ShareUrlAsync(false);
|
||||||
}, canEditRemove);
|
}, canEditRemove);
|
||||||
Export2ShareUrlBase64Cmd = ReactiveCommand.Create(() =>
|
Export2ShareUrlBase64Cmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
Export2ShareUrl(true);
|
Export2ShareUrlAsync(true);
|
||||||
}, canEditRemove);
|
}, canEditRemove);
|
||||||
|
|
||||||
//Subscription
|
//Subscription
|
||||||
AddSubCmd = ReactiveCommand.Create(() =>
|
AddSubCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
EditSub(true);
|
EditSubAsync(true);
|
||||||
});
|
});
|
||||||
EditSubCmd = ReactiveCommand.Create(() =>
|
EditSubCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
EditSub(false);
|
EditSubAsync(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
#endregion WhenAnyValue && ReactiveCommand
|
#endregion WhenAnyValue && ReactiveCommand
|
||||||
|
@ -308,16 +308,16 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AutofitColumnWidth()
|
public async Task AutofitColumnWidthAsync()
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.AdjustMainLvColWidth, null);
|
await _updateView?.Invoke(EViewAction.AdjustMainLvColWidth, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Actions
|
#endregion Actions
|
||||||
|
|
||||||
#region Servers && Groups
|
#region Servers && Groups
|
||||||
|
|
||||||
private void SubSelectedChanged(bool c)
|
private async Task SubSelectedChangedAsync(bool c)
|
||||||
{
|
{
|
||||||
if (!c)
|
if (!c)
|
||||||
{
|
{
|
||||||
|
@ -327,7 +327,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
RefreshServers();
|
RefreshServers();
|
||||||
|
|
||||||
_updateView?.Invoke(EViewAction.ProfilesFocus, null);
|
await _updateView?.Invoke(EViewAction.ProfilesFocus, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ServerFilterChanged(bool c)
|
private void ServerFilterChanged(bool c)
|
||||||
|
@ -420,7 +420,7 @@ namespace ServiceLib.ViewModels
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EditServer(EConfigType eConfigType)
|
public async Task EditServerAsync(EConfigType eConfigType)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(SelectedProfile?.indexId))
|
if (Utils.IsNullOrEmpty(SelectedProfile?.indexId))
|
||||||
{
|
{
|
||||||
|
@ -437,11 +437,11 @@ namespace ServiceLib.ViewModels
|
||||||
bool? ret = false;
|
bool? ret = false;
|
||||||
if (eConfigType == EConfigType.Custom)
|
if (eConfigType == EConfigType.Custom)
|
||||||
{
|
{
|
||||||
ret = _updateView?.Invoke(EViewAction.AddServer2Window, item);
|
ret = await _updateView?.Invoke(EViewAction.AddServer2Window, item);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ret = _updateView?.Invoke(EViewAction.AddServerWindow, item);
|
ret = await _updateView?.Invoke(EViewAction.AddServerWindow, item);
|
||||||
}
|
}
|
||||||
if (ret == true)
|
if (ret == true)
|
||||||
{
|
{
|
||||||
|
@ -453,13 +453,13 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveServer()
|
public async Task RemoveServerAsync()
|
||||||
{
|
{
|
||||||
if (GetProfileItems(out List<ProfileItem> lstSelecteds, true) < 0)
|
if (GetProfileItems(out List<ProfileItem> lstSelecteds, true) < 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -546,7 +546,7 @@ namespace ServiceLib.ViewModels
|
||||||
SetDefaultServer(SelectedServer.ID);
|
SetDefaultServer(SelectedServer.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShareServer()
|
public async Task ShareServerAsync()
|
||||||
{
|
{
|
||||||
var item = LazyConfig.Instance.GetProfileItem(SelectedProfile.indexId);
|
var item = LazyConfig.Instance.GetProfileItem(SelectedProfile.indexId);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
|
@ -560,7 +560,7 @@ namespace ServiceLib.ViewModels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateView?.Invoke(EViewAction.ShareServer, url);
|
await _updateView?.Invoke(EViewAction.ShareServer, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetDefaultMultipleServer(ECoreType coreType)
|
private void SetDefaultMultipleServer(ECoreType coreType)
|
||||||
|
@ -679,7 +679,7 @@ namespace ServiceLib.ViewModels
|
||||||
_speedtestHandler?.ExitLoop();
|
_speedtestHandler?.ExitLoop();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Export2ClientConfig(bool blClipboard)
|
private async Task Export2ClientConfigAsync(bool blClipboard)
|
||||||
{
|
{
|
||||||
var item = LazyConfig.Instance.GetProfileItem(SelectedProfile.indexId);
|
var item = LazyConfig.Instance.GetProfileItem(SelectedProfile.indexId);
|
||||||
if (item is null)
|
if (item is null)
|
||||||
|
@ -695,13 +695,13 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.SetClipboardData, content);
|
await _updateView?.Invoke(EViewAction.SetClipboardData, content);
|
||||||
_noticeHandler?.SendMessage(ResUI.OperationSuccess);
|
_noticeHandler?.SendMessage(ResUI.OperationSuccess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.SaveFileDialog, item);
|
await _updateView?.Invoke(EViewAction.SaveFileDialog, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -722,7 +722,7 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Export2ShareUrl(bool blEncode)
|
public async Task Export2ShareUrlAsync(bool blEncode)
|
||||||
{
|
{
|
||||||
if (GetProfileItems(out List<ProfileItem> lstSelecteds, true) < 0)
|
if (GetProfileItems(out List<ProfileItem> lstSelecteds, true) < 0)
|
||||||
{
|
{
|
||||||
|
@ -744,11 +744,11 @@ namespace ServiceLib.ViewModels
|
||||||
{
|
{
|
||||||
if (blEncode)
|
if (blEncode)
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.SetClipboardData, Utils.Base64Encode(sb.ToString()));
|
await _updateView?.Invoke(EViewAction.SetClipboardData, Utils.Base64Encode(sb.ToString()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.SetClipboardData, sb.ToString());
|
await _updateView?.Invoke(EViewAction.SetClipboardData, sb.ToString());
|
||||||
}
|
}
|
||||||
_noticeHandler?.SendMessage(ResUI.BatchExportURLSuccessfully);
|
_noticeHandler?.SendMessage(ResUI.BatchExportURLSuccessfully);
|
||||||
}
|
}
|
||||||
|
@ -758,7 +758,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
#region Subscription
|
#region Subscription
|
||||||
|
|
||||||
private void EditSub(bool blNew)
|
private async Task EditSubAsync(bool blNew)
|
||||||
{
|
{
|
||||||
SubItem item;
|
SubItem item;
|
||||||
if (blNew)
|
if (blNew)
|
||||||
|
@ -773,10 +773,10 @@ namespace ServiceLib.ViewModels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_updateView?.Invoke(EViewAction.SubEditWindow, item) == true)
|
if (await _updateView?.Invoke(EViewAction.SubEditWindow, item) == true)
|
||||||
{
|
{
|
||||||
RefreshSubscriptions();
|
RefreshSubscriptions();
|
||||||
SubSelectedChanged(true);
|
SubSelectedChangedAsync(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
||||||
|
|
||||||
public RoutingRuleDetailsViewModel(RulesItem rulesItem, Func<EViewAction, object?, bool>? updateView)
|
public RoutingRuleDetailsViewModel(RulesItem rulesItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = LazyConfig.Instance.Config;
|
_config = LazyConfig.Instance.Config;
|
||||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||||
|
@ -51,11 +51,11 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
SaveCmd = ReactiveCommand.Create(() =>
|
SaveCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
SaveRules();
|
SaveRulesAsync();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveRules()
|
private async Task SaveRulesAsync()
|
||||||
{
|
{
|
||||||
Domain = Utils.Convert2Comma(Domain);
|
Domain = Utils.Convert2Comma(Domain);
|
||||||
IP = Utils.Convert2Comma(IP);
|
IP = Utils.Convert2Comma(IP);
|
||||||
|
@ -88,7 +88,7 @@ namespace ServiceLib.ViewModels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
//_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -34,7 +34,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
||||||
|
|
||||||
public RoutingRuleSettingViewModel(RoutingItem routingItem, Func<EViewAction, object?, bool>? updateView)
|
public RoutingRuleSettingViewModel(RoutingItem routingItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = LazyConfig.Instance.Config;
|
_config = LazyConfig.Instance.Config;
|
||||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||||
|
@ -60,15 +60,15 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
RuleAddCmd = ReactiveCommand.Create(() =>
|
RuleAddCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
RuleEdit(true);
|
RuleEditAsync(true);
|
||||||
});
|
});
|
||||||
ImportRulesFromFileCmd = ReactiveCommand.Create(() =>
|
ImportRulesFromFileCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.ImportRulesFromFile, null);
|
await _updateView?.Invoke(EViewAction.ImportRulesFromFile, null);
|
||||||
});
|
});
|
||||||
ImportRulesFromClipboardCmd = ReactiveCommand.Create(() =>
|
ImportRulesFromClipboardCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
ImportRulesFromClipboard(null);
|
ImportRulesFromClipboardAsync(null);
|
||||||
});
|
});
|
||||||
ImportRulesFromUrlCmd = ReactiveCommand.Create(() =>
|
ImportRulesFromUrlCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
|
@ -77,11 +77,11 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
RuleRemoveCmd = ReactiveCommand.Create(() =>
|
RuleRemoveCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
RuleRemove();
|
RuleRemoveAsync();
|
||||||
}, canEditRemove);
|
}, canEditRemove);
|
||||||
RuleExportSelectedCmd = ReactiveCommand.Create(() =>
|
RuleExportSelectedCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
RuleExportSelected();
|
RuleExportSelectedAsync();
|
||||||
}, canEditRemove);
|
}, canEditRemove);
|
||||||
|
|
||||||
MoveTopCmd = ReactiveCommand.Create(() =>
|
MoveTopCmd = ReactiveCommand.Create(() =>
|
||||||
|
@ -103,7 +103,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
SaveCmd = ReactiveCommand.Create(() =>
|
SaveCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
SaveRouting();
|
SaveRoutingAsync();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RuleEdit(bool blNew)
|
public async Task RuleEditAsync(bool blNew)
|
||||||
{
|
{
|
||||||
RulesItem? item;
|
RulesItem? item;
|
||||||
if (blNew)
|
if (blNew)
|
||||||
|
@ -144,7 +144,7 @@ namespace ServiceLib.ViewModels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_updateView?.Invoke(EViewAction.RoutingRuleDetailsWindow, item) == true)
|
if (await _updateView?.Invoke(EViewAction.RoutingRuleDetailsWindow, item) == true)
|
||||||
{
|
{
|
||||||
if (blNew)
|
if (blNew)
|
||||||
{
|
{
|
||||||
|
@ -154,14 +154,14 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RuleRemove()
|
public async Task RuleRemoveAsync()
|
||||||
{
|
{
|
||||||
if (SelectedSource is null || SelectedSource.outboundTag.IsNullOrEmpty())
|
if (SelectedSource is null || SelectedSource.outboundTag.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
_noticeHandler?.Enqueue(ResUI.PleaseSelectRules);
|
_noticeHandler?.Enqueue(ResUI.PleaseSelectRules);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -177,7 +177,7 @@ namespace ServiceLib.ViewModels
|
||||||
RefreshRulesItems();
|
RefreshRulesItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RuleExportSelected()
|
public async Task RuleExportSelectedAsync()
|
||||||
{
|
{
|
||||||
if (SelectedSource is null || SelectedSource.outboundTag.IsNullOrEmpty())
|
if (SelectedSource is null || SelectedSource.outboundTag.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
|
@ -197,7 +197,7 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
if (lst.Count > 0)
|
if (lst.Count > 0)
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.SetClipboardData, JsonUtils.Serialize(lst));
|
await _updateView?.Invoke(EViewAction.SetClipboardData, JsonUtils.Serialize(lst));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveRouting()
|
private async Task SaveRoutingAsync()
|
||||||
{
|
{
|
||||||
string remarks = SelectedRouting.remarks;
|
string remarks = SelectedRouting.remarks;
|
||||||
if (Utils.IsNullOrEmpty(remarks))
|
if (Utils.IsNullOrEmpty(remarks))
|
||||||
|
@ -240,7 +240,7 @@ namespace ServiceLib.ViewModels
|
||||||
if (ConfigHandler.SaveRoutingItem(_config, item) == 0)
|
if (ConfigHandler.SaveRoutingItem(_config, item) == 0)
|
||||||
{
|
{
|
||||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -250,7 +250,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
#region Import rules
|
#region Import rules
|
||||||
|
|
||||||
public void ImportRulesFromFile(string fileName)
|
public async Task ImportRulesFromFileAsync(string fileName)
|
||||||
{
|
{
|
||||||
if (Utils.IsNullOrEmpty(fileName))
|
if (Utils.IsNullOrEmpty(fileName))
|
||||||
{
|
{
|
||||||
|
@ -262,29 +262,30 @@ namespace ServiceLib.ViewModels
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var ret = await AddBatchRoutingRulesAsync(SelectedRouting, result);
|
||||||
if (AddBatchRoutingRules(SelectedRouting, result) == 0)
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
RefreshRulesItems();
|
RefreshRulesItems();
|
||||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ImportRulesFromClipboard(string? clipboardData)
|
public async Task ImportRulesFromClipboardAsync(string? clipboardData)
|
||||||
{
|
{
|
||||||
if (clipboardData == null)
|
if (clipboardData == null)
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.ImportRulesFromClipboard, null);
|
await _updateView?.Invoke(EViewAction.ImportRulesFromClipboard, null);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (AddBatchRoutingRules(SelectedRouting, clipboardData) == 0)
|
var ret = await AddBatchRoutingRulesAsync(SelectedRouting, clipboardData);
|
||||||
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
RefreshRulesItems();
|
RefreshRulesItems();
|
||||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ImportRulesFromUrl()
|
private async void ImportRulesFromUrl()
|
||||||
{
|
{
|
||||||
var url = SelectedRouting.url;
|
var url = SelectedRouting.url;
|
||||||
if (Utils.IsNullOrEmpty(url))
|
if (Utils.IsNullOrEmpty(url))
|
||||||
|
@ -294,18 +295,19 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadHandler downloadHandle = new DownloadHandler();
|
DownloadHandler downloadHandle = new DownloadHandler();
|
||||||
var result = downloadHandle.TryDownloadString(url, true, "").Result;
|
var result = await downloadHandle.TryDownloadString(url, true, "");
|
||||||
if (AddBatchRoutingRules(SelectedRouting, result) == 0)
|
var ret = await AddBatchRoutingRulesAsync(SelectedRouting, result);
|
||||||
|
if (ret == 0)
|
||||||
{
|
{
|
||||||
RefreshRulesItems();
|
RefreshRulesItems();
|
||||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int AddBatchRoutingRules(RoutingItem routingItem, string? clipboardData)
|
private async Task<int> AddBatchRoutingRulesAsync(RoutingItem routingItem, string? clipboardData)
|
||||||
{
|
{
|
||||||
bool blReplace = false;
|
bool blReplace = false;
|
||||||
if (_updateView?.Invoke(EViewAction.AddBatchRoutingRulesYesNo, null) == false)
|
if (await _updateView?.Invoke(EViewAction.AddBatchRoutingRulesYesNo, null) == false)
|
||||||
{
|
{
|
||||||
blReplace = true;
|
blReplace = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
#endregion Reactive
|
#endregion Reactive
|
||||||
|
|
||||||
public RoutingSettingViewModel(Func<EViewAction, object?, bool>? updateView)
|
public RoutingSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = LazyConfig.Instance.Config;
|
_config = LazyConfig.Instance.Config;
|
||||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||||
|
@ -98,11 +98,11 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
RoutingAdvancedAddCmd = ReactiveCommand.Create(() =>
|
RoutingAdvancedAddCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
RoutingAdvancedEdit(true);
|
RoutingAdvancedEditAsync(true);
|
||||||
});
|
});
|
||||||
RoutingAdvancedRemoveCmd = ReactiveCommand.Create(() =>
|
RoutingAdvancedRemoveCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
RoutingAdvancedRemove();
|
RoutingAdvancedRemoveAsync();
|
||||||
}, canEditRemove);
|
}, canEditRemove);
|
||||||
RoutingAdvancedSetDefaultCmd = ReactiveCommand.Create(() =>
|
RoutingAdvancedSetDefaultCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
|
@ -115,7 +115,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
SaveCmd = ReactiveCommand.Create(() =>
|
SaveCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
SaveRouting();
|
SaveRoutingAsync();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ namespace ServiceLib.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveRouting()
|
private async Task SaveRoutingAsync()
|
||||||
{
|
{
|
||||||
_config.routingBasicItem.domainStrategy = domainStrategy;
|
_config.routingBasicItem.domainStrategy = domainStrategy;
|
||||||
_config.routingBasicItem.enableRoutingAdvanced = enableRoutingAdvanced;
|
_config.routingBasicItem.enableRoutingAdvanced = enableRoutingAdvanced;
|
||||||
|
@ -201,7 +201,7 @@ namespace ServiceLib.ViewModels
|
||||||
if (ConfigHandler.SaveConfig(_config) == 0)
|
if (ConfigHandler.SaveConfig(_config) == 0)
|
||||||
{
|
{
|
||||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -223,7 +223,7 @@ namespace ServiceLib.ViewModels
|
||||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RoutingAdvancedEdit(bool blNew)
|
public async Task RoutingAdvancedEditAsync(bool blNew)
|
||||||
{
|
{
|
||||||
RoutingItem item;
|
RoutingItem item;
|
||||||
if (blNew)
|
if (blNew)
|
||||||
|
@ -238,21 +238,21 @@ namespace ServiceLib.ViewModels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_updateView?.Invoke(EViewAction.RoutingRuleSettingWindow, item) == true)
|
if (await _updateView?.Invoke(EViewAction.RoutingRuleSettingWindow, item) == true)
|
||||||
{
|
{
|
||||||
RefreshRoutingItems();
|
RefreshRoutingItems();
|
||||||
IsModified = true;
|
IsModified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RoutingAdvancedRemove()
|
public async Task RoutingAdvancedRemoveAsync()
|
||||||
{
|
{
|
||||||
if (SelectedSource is null || SelectedSource.remarks.IsNullOrEmpty())
|
if (SelectedSource is null || SelectedSource.remarks.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
_noticeHandler?.Enqueue(ResUI.PleaseSelectRules);
|
_noticeHandler?.Enqueue(ResUI.PleaseSelectRules);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
public ReactiveCommand<Unit, Unit> SaveCmd { get; }
|
||||||
|
|
||||||
public SubEditViewModel(SubItem subItem, Func<EViewAction, object?, bool>? updateView)
|
public SubEditViewModel(SubItem subItem, Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = LazyConfig.Instance.Config;
|
_config = LazyConfig.Instance.Config;
|
||||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||||
|
@ -29,11 +29,11 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
SaveCmd = ReactiveCommand.Create(() =>
|
SaveCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
SaveSub();
|
SaveSubAsync();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SaveSub()
|
private async Task SaveSubAsync()
|
||||||
{
|
{
|
||||||
string remarks = SelectedSource.remarks;
|
string remarks = SelectedSource.remarks;
|
||||||
if (Utils.IsNullOrEmpty(remarks))
|
if (Utils.IsNullOrEmpty(remarks))
|
||||||
|
@ -45,7 +45,7 @@ namespace ServiceLib.ViewModels
|
||||||
if (ConfigHandler.AddSubItem(_config, SelectedSource) == 0)
|
if (ConfigHandler.AddSubItem(_config, SelectedSource) == 0)
|
||||||
{
|
{
|
||||||
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
|
||||||
_updateView?.Invoke(EViewAction.CloseWindow, null);
|
await _updateView?.Invoke(EViewAction.CloseWindow, null);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace ServiceLib.ViewModels
|
||||||
public ReactiveCommand<Unit, Unit> SubShareCmd { get; }
|
public ReactiveCommand<Unit, Unit> SubShareCmd { get; }
|
||||||
public bool IsModified { get; set; }
|
public bool IsModified { get; set; }
|
||||||
|
|
||||||
public SubSettingViewModel(Func<EViewAction, object?, bool>? updateView)
|
public SubSettingViewModel(Func<EViewAction, object?, Task<bool>>? updateView)
|
||||||
{
|
{
|
||||||
_config = LazyConfig.Instance.Config;
|
_config = LazyConfig.Instance.Config;
|
||||||
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
_noticeHandler = Locator.Current.GetService<NoticeHandler>();
|
||||||
|
@ -39,19 +39,19 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
SubAddCmd = ReactiveCommand.Create(() =>
|
SubAddCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
EditSub(true);
|
EditSubAsync(true);
|
||||||
});
|
});
|
||||||
SubDeleteCmd = ReactiveCommand.Create(() =>
|
SubDeleteCmd = ReactiveCommand.Create(() =>
|
||||||
{
|
{
|
||||||
DeleteSub();
|
DeleteSubAsync();
|
||||||
}, canEditRemove);
|
}, canEditRemove);
|
||||||
SubEditCmd = ReactiveCommand.Create(() =>
|
SubEditCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
{
|
{
|
||||||
EditSub(false);
|
await EditSubAsync(false);
|
||||||
}, canEditRemove);
|
}, canEditRemove);
|
||||||
SubShareCmd = ReactiveCommand.Create(() =>
|
SubShareCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
{
|
{
|
||||||
_updateView?.Invoke(EViewAction.ShareSub, SelectedSource?.url);
|
await _updateView?.Invoke(EViewAction.ShareSub, SelectedSource?.url);
|
||||||
}, canEditRemove);
|
}, canEditRemove);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ namespace ServiceLib.ViewModels
|
||||||
_subItems.AddRange(LazyConfig.Instance.SubItems().OrderBy(t => t.sort));
|
_subItems.AddRange(LazyConfig.Instance.SubItems().OrderBy(t => t.sort));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EditSub(bool blNew)
|
public async Task EditSubAsync(bool blNew)
|
||||||
{
|
{
|
||||||
SubItem item;
|
SubItem item;
|
||||||
if (blNew)
|
if (blNew)
|
||||||
|
@ -76,16 +76,16 @@ namespace ServiceLib.ViewModels
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_updateView?.Invoke(EViewAction.SubEditWindow, item) == true)
|
if (await _updateView?.Invoke(EViewAction.SubEditWindow, item) == true)
|
||||||
{
|
{
|
||||||
RefreshSubItems();
|
RefreshSubItems();
|
||||||
IsModified = true;
|
IsModified = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DeleteSub()
|
private async Task DeleteSubAsync()
|
||||||
{
|
{
|
||||||
if (_updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
if (await _updateView?.Invoke(EViewAction.ShowYesNo, null) == false)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace v2rayN.Views
|
||||||
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
|
@ -54,7 +54,7 @@ namespace v2rayN.Views
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
|
|
@ -220,7 +220,7 @@ namespace v2rayN.Views
|
||||||
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
|
@ -228,7 +228,7 @@ namespace v2rayN.Views
|
||||||
this.DialogResult = true;
|
this.DialogResult = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
|
|
@ -29,7 +29,7 @@ namespace v2rayN.Views
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
|
@ -42,7 +42,7 @@ namespace v2rayN.Views
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnClose_Click(object sender, System.Windows.RoutedEventArgs e)
|
private void btnClose_Click(object sender, System.Windows.RoutedEventArgs e)
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace v2rayN.Views
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
|
@ -60,7 +60,7 @@ namespace v2rayN.Views
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ProxiesView_KeyDown(object sender, KeyEventArgs e)
|
private void ProxiesView_KeyDown(object sender, KeyEventArgs e)
|
||||||
|
|
|
@ -53,7 +53,7 @@ namespace v2rayN.Views
|
||||||
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
|
@ -61,7 +61,7 @@ namespace v2rayN.Views
|
||||||
this.DialogResult = true;
|
this.DialogResult = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void linkDnsObjectDoc_Click(object sender, RoutedEventArgs e)
|
private void linkDnsObjectDoc_Click(object sender, RoutedEventArgs e)
|
||||||
|
|
|
@ -204,7 +204,7 @@ namespace v2rayN.Views
|
||||||
}), DispatcherPriority.Normal);
|
}), DispatcherPriority.Normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
|
@ -291,11 +291,11 @@ namespace v2rayN.Views
|
||||||
|
|
||||||
case EViewAction.AddServerViaClipboard:
|
case EViewAction.AddServerViaClipboard:
|
||||||
var clipboardData = WindowsUtils.GetClipboardData();
|
var clipboardData = WindowsUtils.GetClipboardData();
|
||||||
ViewModel?.AddServerViaClipboard(clipboardData);
|
ViewModel?.AddServerViaClipboardAsync(clipboardData);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnHotkeyHandler(EGlobalHotkey e)
|
private void OnHotkeyHandler(EGlobalHotkey e)
|
||||||
|
@ -336,14 +336,14 @@ namespace v2rayN.Views
|
||||||
|
|
||||||
tbNotify.Dispose();
|
tbNotify.Dispose();
|
||||||
StorageUI();
|
StorageUI();
|
||||||
ViewModel?.MyAppExit(false);
|
ViewModel?.MyAppExitAsync(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Current_SessionEnding(object sender, SessionEndingCancelEventArgs e)
|
private void Current_SessionEnding(object sender, SessionEndingCancelEventArgs e)
|
||||||
{
|
{
|
||||||
Logging.SaveLog("Current_SessionEnding");
|
Logging.SaveLog("Current_SessionEnding");
|
||||||
StorageUI();
|
StorageUI();
|
||||||
ViewModel?.MyAppExit(true);
|
ViewModel?.MyAppExitAsync(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MainWindow_PreviewKeyDown(object sender, KeyEventArgs e)
|
private void MainWindow_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||||
|
@ -354,7 +354,7 @@ namespace v2rayN.Views
|
||||||
{
|
{
|
||||||
case Key.V:
|
case Key.V:
|
||||||
var clipboardData = WindowsUtils.GetClipboardData();
|
var clipboardData = WindowsUtils.GetClipboardData();
|
||||||
ViewModel?.AddServerViaClipboard(clipboardData);
|
ViewModel?.AddServerViaClipboardAsync(clipboardData);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Key.S:
|
case Key.S:
|
||||||
|
|
|
@ -168,7 +168,7 @@ namespace v2rayN.Views
|
||||||
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
|
@ -177,7 +177,7 @@ namespace v2rayN.Views
|
||||||
this.DialogResult = true;
|
this.DialogResult = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<string> GetFonts(string path)
|
private List<string> GetFonts(string path)
|
||||||
|
|
|
@ -98,7 +98,7 @@ namespace v2rayN.Views
|
||||||
StorageUI();
|
StorageUI();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
|
@ -173,7 +173,7 @@ namespace v2rayN.Views
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void ShareServer(string url)
|
public async void ShareServer(string url)
|
||||||
|
@ -206,7 +206,7 @@ namespace v2rayN.Views
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ViewModel?.EditServer(EConfigType.Custom);
|
ViewModel?.EditServerAsync(EConfigType.Custom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,15 +238,15 @@ namespace v2rayN.Views
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Key.C:
|
case Key.C:
|
||||||
ViewModel?.Export2ShareUrl(false);
|
ViewModel?.Export2ShareUrlAsync(false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Key.D:
|
case Key.D:
|
||||||
ViewModel?.EditServer(EConfigType.Custom);
|
ViewModel?.EditServerAsync(EConfigType.Custom);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Key.F:
|
case Key.F:
|
||||||
ViewModel?.ShareServer();
|
ViewModel?.ShareServerAsync();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Key.O:
|
case Key.O:
|
||||||
|
@ -274,7 +274,7 @@ namespace v2rayN.Views
|
||||||
}
|
}
|
||||||
else if (e.Key == Key.Delete)
|
else if (e.Key == Key.Delete)
|
||||||
{
|
{
|
||||||
ViewModel?.RemoveServer();
|
ViewModel?.RemoveServerAsync();
|
||||||
}
|
}
|
||||||
else if (e.Key == Key.T)
|
else if (e.Key == Key.T)
|
||||||
{
|
{
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace v2rayN.Views
|
||||||
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
|
@ -68,7 +68,7 @@ namespace v2rayN.Views
|
||||||
this.DialogResult = true;
|
this.DialogResult = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
|
|
@ -60,7 +60,7 @@ namespace v2rayN.Views
|
||||||
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
|
@ -95,7 +95,7 @@ namespace v2rayN.Views
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ViewModel?.ImportRulesFromFile(fileName);
|
ViewModel?.ImportRulesFromFileAsync(fileName);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EViewAction.SetClipboardData:
|
case EViewAction.SetClipboardData:
|
||||||
|
@ -105,11 +105,11 @@ namespace v2rayN.Views
|
||||||
|
|
||||||
case EViewAction.ImportRulesFromClipboard:
|
case EViewAction.ImportRulesFromClipboard:
|
||||||
var clipboardData = WindowsUtils.GetClipboardData();
|
var clipboardData = WindowsUtils.GetClipboardData();
|
||||||
ViewModel?.ImportRulesFromClipboard(clipboardData);
|
ViewModel?.ImportRulesFromClipboardAsync(clipboardData);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
@ -127,7 +127,7 @@ namespace v2rayN.Views
|
||||||
}
|
}
|
||||||
else if (e.Key == Key.C)
|
else if (e.Key == Key.C)
|
||||||
{
|
{
|
||||||
ViewModel?.RuleExportSelected();
|
ViewModel?.RuleExportSelectedAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -150,7 +150,7 @@ namespace v2rayN.Views
|
||||||
}
|
}
|
||||||
else if (e.Key == Key.Delete)
|
else if (e.Key == Key.Delete)
|
||||||
{
|
{
|
||||||
ViewModel?.RuleRemove();
|
ViewModel?.RuleRemoveAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -162,7 +162,7 @@ namespace v2rayN.Views
|
||||||
|
|
||||||
private void LstRules_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
private void LstRules_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
ViewModel?.RuleEdit(false);
|
ViewModel?.RuleEditAsync(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void menuRuleSelectAll_Click(object sender, System.Windows.RoutedEventArgs e)
|
private void menuRuleSelectAll_Click(object sender, System.Windows.RoutedEventArgs e)
|
||||||
|
|
|
@ -67,7 +67,7 @@ namespace v2rayN.Views
|
||||||
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
|
@ -87,7 +87,7 @@ namespace v2rayN.Views
|
||||||
if (obj is null) return false;
|
if (obj is null) return false;
|
||||||
return (new RoutingRuleSettingWindow((RoutingItem)obj)).ShowDialog() ?? false;
|
return (new RoutingRuleSettingWindow((RoutingItem)obj)).ShowDialog() ?? false;
|
||||||
}
|
}
|
||||||
return true;
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RoutingSettingWindow_Closing(object? sender, System.ComponentModel.CancelEventArgs e)
|
private void RoutingSettingWindow_Closing(object? sender, System.ComponentModel.CancelEventArgs e)
|
||||||
|
@ -118,7 +118,7 @@ namespace v2rayN.Views
|
||||||
}
|
}
|
||||||
else if (e.Key == Key.Delete)
|
else if (e.Key == Key.Delete)
|
||||||
{
|
{
|
||||||
ViewModel?.RoutingAdvancedRemove();
|
ViewModel?.RoutingAdvancedRemoveAsync();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +134,7 @@ namespace v2rayN.Views
|
||||||
|
|
||||||
private void LstRoutings_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
private void LstRoutings_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
ViewModel?.RoutingAdvancedEdit(false);
|
ViewModel?.RoutingAdvancedEditAsync(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void linkdomainStrategy_Click(object sender, System.Windows.RoutedEventArgs e)
|
private void linkdomainStrategy_Click(object sender, System.Windows.RoutedEventArgs e)
|
||||||
|
|
|
@ -39,7 +39,7 @@ namespace v2rayN.Views
|
||||||
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
|
@ -47,7 +47,7 @@ namespace v2rayN.Views
|
||||||
this.DialogResult = true;
|
this.DialogResult = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Window_Loaded(object sender, RoutedEventArgs e)
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace v2rayN.Views
|
||||||
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
WindowsUtils.SetDarkBorder(this, LazyConfig.Instance.Config.uiItem.followSystemTheme ? !WindowsUtils.IsLightTheme() : LazyConfig.Instance.Config.uiItem.colorModeDark);
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool UpdateViewHandler(EViewAction action, object? obj)
|
private async Task<bool> UpdateViewHandler(EViewAction action, object? obj)
|
||||||
{
|
{
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,7 @@ namespace v2rayN.Views
|
||||||
ShareSub((string)obj);
|
ShareSub((string)obj);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return true;
|
return await Task.FromResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void ShareSub(string url)
|
private async void ShareSub(string url)
|
||||||
|
@ -86,7 +86,7 @@ namespace v2rayN.Views
|
||||||
|
|
||||||
private void LstSubscription_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
private void LstSubscription_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
ViewModel?.EditSub(false);
|
ViewModel?.EditSubAsync(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LstSubscription_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
private void LstSubscription_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||||
|
|
Loading…
Reference in a new issue