mirror of
https://github.com/2dust/v2rayN.git
synced 2025-10-25 01:34:41 +00:00
Compare commits
3 commits
d68c6170ef
...
32334ada6b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
32334ada6b | ||
|
|
d86003df55 | ||
|
|
4301415b4c |
26 changed files with 215 additions and 84 deletions
32
v2rayN/ServiceLib/Events/AppEvents.cs
Normal file
32
v2rayN/ServiceLib/Events/AppEvents.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
using System.Reactive;
|
||||||
|
|
||||||
|
namespace ServiceLib.Events;
|
||||||
|
|
||||||
|
public static class AppEvents
|
||||||
|
{
|
||||||
|
public static readonly EventChannel<Unit> ReloadRequested = new();
|
||||||
|
public static readonly EventChannel<bool?> ShowHideWindowRequested = new();
|
||||||
|
public static readonly EventChannel<Unit> AddServerViaScanRequested = new();
|
||||||
|
public static readonly EventChannel<Unit> AddServerViaClipboardRequested = new();
|
||||||
|
public static readonly EventChannel<bool> SubscriptionsUpdateRequested = new();
|
||||||
|
|
||||||
|
public static readonly EventChannel<Unit> ProfilesRefreshRequested = new();
|
||||||
|
public static readonly EventChannel<Unit> SubscriptionsRefreshRequested = new();
|
||||||
|
public static readonly EventChannel<Unit> ProxiesReloadRequested = new();
|
||||||
|
public static readonly EventChannel<ServerSpeedItem> DispatcherStatisticsRequested = new();
|
||||||
|
|
||||||
|
public static readonly EventChannel<string> SendSnackMsgRequested = new();
|
||||||
|
public static readonly EventChannel<string> SendMsgViewRequested = new();
|
||||||
|
|
||||||
|
public static readonly EventChannel<Unit> AppExitRequested = new();
|
||||||
|
public static readonly EventChannel<bool> ShutdownRequested = new();
|
||||||
|
|
||||||
|
public static readonly EventChannel<Unit> AdjustMainLvColWidthRequested = new();
|
||||||
|
|
||||||
|
public static readonly EventChannel<string> SetDefaultServerRequested = new();
|
||||||
|
|
||||||
|
public static readonly EventChannel<Unit> RoutingsMenuRefreshRequested = new();
|
||||||
|
public static readonly EventChannel<Unit> TestServerRequested = new();
|
||||||
|
public static readonly EventChannel<Unit> InboundDisplayRequested = new();
|
||||||
|
public static readonly EventChannel<ESysProxyType> SysProxyChangeRequested = new();
|
||||||
|
}
|
||||||
29
v2rayN/ServiceLib/Events/EventChannel.cs
Normal file
29
v2rayN/ServiceLib/Events/EventChannel.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
using System.Reactive;
|
||||||
|
using System.Reactive.Linq;
|
||||||
|
using System.Reactive.Subjects;
|
||||||
|
|
||||||
|
namespace ServiceLib.Events;
|
||||||
|
|
||||||
|
public sealed class EventChannel<T>
|
||||||
|
{
|
||||||
|
private readonly ISubject<T> _subject = Subject.Synchronize(new Subject<T>());
|
||||||
|
|
||||||
|
public IObservable<T> AsObservable()
|
||||||
|
{
|
||||||
|
return _subject.AsObservable();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Publish(T value)
|
||||||
|
{
|
||||||
|
_subject.OnNext(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Publish()
|
||||||
|
{
|
||||||
|
if (typeof(T) != typeof(Unit))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Publish() without value is only valid for EventChannel<Unit>.");
|
||||||
|
}
|
||||||
|
_subject.OnNext((T)(object)Unit.Default);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -87,6 +87,8 @@ public class Global
|
||||||
public const string SingboxFinalResolverTag = "final_resolver";
|
public const string SingboxFinalResolverTag = "final_resolver";
|
||||||
public const string SingboxHostsDNSTag = "hosts_dns";
|
public const string SingboxHostsDNSTag = "hosts_dns";
|
||||||
public const string SingboxFakeDNSTag = "fake_dns";
|
public const string SingboxFakeDNSTag = "fake_dns";
|
||||||
|
public const string RoutingRuleType = "Routing";
|
||||||
|
public const string DNSRuleType = "DNS";
|
||||||
|
|
||||||
public static readonly List<string> IEProxyProtocols =
|
public static readonly List<string> IEProxyProtocols =
|
||||||
[
|
[
|
||||||
|
|
@ -471,6 +473,12 @@ public class Global
|
||||||
"tcp,udp"
|
"tcp,udp"
|
||||||
];
|
];
|
||||||
|
|
||||||
|
public static readonly List<string> RuleTypes =
|
||||||
|
[
|
||||||
|
RoutingRuleType,
|
||||||
|
DNSRuleType
|
||||||
|
];
|
||||||
|
|
||||||
public static readonly List<string> destOverrideProtocols =
|
public static readonly List<string> destOverrideProtocols =
|
||||||
[
|
[
|
||||||
"http",
|
"http",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
global using ServiceLib.Base;
|
global using ServiceLib.Base;
|
||||||
global using ServiceLib.Common;
|
global using ServiceLib.Common;
|
||||||
global using ServiceLib.Enums;
|
global using ServiceLib.Enums;
|
||||||
|
global using ServiceLib.Events;
|
||||||
global using ServiceLib.Handler;
|
global using ServiceLib.Handler;
|
||||||
global using ServiceLib.Helper;
|
global using ServiceLib.Helper;
|
||||||
global using ServiceLib.Manager;
|
global using ServiceLib.Manager;
|
||||||
|
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
using System.Reactive;
|
|
||||||
using System.Reactive.Subjects;
|
|
||||||
|
|
||||||
namespace ServiceLib.Handler;
|
|
||||||
|
|
||||||
public static class AppEvents
|
|
||||||
{
|
|
||||||
public static readonly Subject<Unit> ReloadRequested = new();
|
|
||||||
public static readonly Subject<bool?> ShowHideWindowRequested = new();
|
|
||||||
public static readonly Subject<Unit> AddServerViaScanRequested = new();
|
|
||||||
public static readonly Subject<Unit> AddServerViaClipboardRequested = new();
|
|
||||||
public static readonly Subject<bool> SubscriptionsUpdateRequested = new();
|
|
||||||
|
|
||||||
public static readonly Subject<Unit> ProfilesRefreshRequested = new();
|
|
||||||
public static readonly Subject<Unit> SubscriptionsRefreshRequested = new();
|
|
||||||
public static readonly Subject<Unit> ProxiesReloadRequested = new();
|
|
||||||
public static readonly Subject<ServerSpeedItem> DispatcherStatisticsRequested = new();
|
|
||||||
|
|
||||||
public static readonly Subject<string> SendSnackMsgRequested = new();
|
|
||||||
public static readonly Subject<string> SendMsgViewRequested = new();
|
|
||||||
|
|
||||||
public static readonly Subject<Unit> AppExitRequested = new();
|
|
||||||
public static readonly Subject<bool> ShutdownRequested = new();
|
|
||||||
|
|
||||||
public static readonly Subject<Unit> AdjustMainLvColWidthRequested = new();
|
|
||||||
|
|
||||||
public static readonly Subject<string> SetDefaultServerRequested = new();
|
|
||||||
|
|
||||||
public static readonly Subject<Unit> RoutingsMenuRefreshRequested = new();
|
|
||||||
public static readonly Subject<Unit> TestServerRequested = new();
|
|
||||||
public static readonly Subject<Unit> InboundDisplayRequested = new();
|
|
||||||
public static readonly Subject<ESysProxyType> SysProxyChangeRequested = new();
|
|
||||||
}
|
|
||||||
|
|
@ -96,7 +96,7 @@ public sealed class AppManager
|
||||||
Logging.SaveLog("AppExitAsync Begin");
|
Logging.SaveLog("AppExitAsync Begin");
|
||||||
|
|
||||||
await SysProxyHandler.UpdateSysProxy(_config, true);
|
await SysProxyHandler.UpdateSysProxy(_config, true);
|
||||||
AppEvents.AppExitRequested.OnNext(Unit.Default);
|
AppEvents.AppExitRequested.Publish();
|
||||||
await Task.Delay(50); //Wait for AppExitRequested to be processed
|
await Task.Delay(50); //Wait for AppExitRequested to be processed
|
||||||
|
|
||||||
await ConfigHandler.SaveConfig(_config);
|
await ConfigHandler.SaveConfig(_config);
|
||||||
|
|
@ -119,7 +119,7 @@ public sealed class AppManager
|
||||||
|
|
||||||
public void Shutdown(bool byUser)
|
public void Shutdown(bool byUser)
|
||||||
{
|
{
|
||||||
AppEvents.ShutdownRequested.OnNext(byUser);
|
AppEvents.ShutdownRequested.Publish(byUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task RebootAsAdmin()
|
public async Task RebootAsAdmin()
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ public class NoticeManager
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AppEvents.SendSnackMsgRequested.OnNext(content);
|
AppEvents.SendSnackMsgRequested.Publish(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendMessage(string? content)
|
public void SendMessage(string? content)
|
||||||
|
|
@ -20,7 +20,7 @@ public class NoticeManager
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AppEvents.SendMsgViewRequested.OnNext(content);
|
AppEvents.SendMsgViewRequested.Publish(content);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendMessageEx(string? content)
|
public void SendMessageEx(string? content)
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,5 @@ public class RulesItem
|
||||||
public List<string>? Process { get; set; }
|
public List<string>? Process { get; set; }
|
||||||
public bool Enabled { get; set; } = true;
|
public bool Enabled { get; set; } = true;
|
||||||
public string? Remarks { get; set; }
|
public string? Remarks { get; set; }
|
||||||
|
public List<string>? RuleTypes { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -253,6 +253,11 @@ public partial class CoreConfigSingboxService
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((item.RuleTypes?.Count ?? 0) > 0 && !item.RuleTypes.Contains(Global.DNSRuleType))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
var rule = new Rule4Sbox();
|
var rule = new Rule4Sbox();
|
||||||
var validDomains = item.Domain.Count(it => ParseV2Domain(it, rule));
|
var validDomains = item.Domain.Count(it => ParseV2Domain(it, rule));
|
||||||
if (validDomains <= 0)
|
if (validDomains <= 0)
|
||||||
|
|
|
||||||
|
|
@ -136,13 +136,21 @@ public partial class CoreConfigSingboxService
|
||||||
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet);
|
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet);
|
||||||
foreach (var item1 in rules ?? [])
|
foreach (var item1 in rules ?? [])
|
||||||
{
|
{
|
||||||
if (item1.Enabled)
|
if (!item1.Enabled)
|
||||||
{
|
{
|
||||||
await GenRoutingUserRule(item1, singboxConfig);
|
continue;
|
||||||
if (item1.Ip != null && item1.Ip.Count > 0)
|
}
|
||||||
{
|
|
||||||
ipRules.Add(item1);
|
if ((item1.RuleTypes?.Count ?? 0) > 0 && !item1.RuleTypes.Contains(Global.RoutingRuleType))
|
||||||
}
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
await GenRoutingUserRule(item1, singboxConfig);
|
||||||
|
|
||||||
|
if (item1.Ip?.Count > 0)
|
||||||
|
{
|
||||||
|
ipRules.Add(item1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,6 +142,11 @@ public partial class CoreConfigV2rayService
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((item.RuleTypes?.Count ?? 0) > 0 && !item.RuleTypes.Contains(Global.DNSRuleType))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var domain in item.Domain)
|
foreach (var domain in item.Domain)
|
||||||
{
|
{
|
||||||
if (domain.StartsWith('#'))
|
if (domain.StartsWith('#'))
|
||||||
|
|
|
||||||
|
|
@ -20,11 +20,18 @@ public partial class CoreConfigV2rayService
|
||||||
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet);
|
var rules = JsonUtils.Deserialize<List<RulesItem>>(routing.RuleSet);
|
||||||
foreach (var item in rules)
|
foreach (var item in rules)
|
||||||
{
|
{
|
||||||
if (item.Enabled)
|
if (!item.Enabled)
|
||||||
{
|
{
|
||||||
var item2 = JsonUtils.Deserialize<RulesItem4Ray>(JsonUtils.Serialize(item));
|
continue;
|
||||||
await GenRoutingUserRule(item2, v2rayConfig);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((item.RuleTypes?.Count ?? 0) > 0 && !item.RuleTypes.Contains(Global.RoutingRuleType))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var item2 = JsonUtils.Deserialize<RulesItem4Ray>(JsonUtils.Serialize(item));
|
||||||
|
await GenRoutingUserRule(item2, v2rayConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -223,7 +223,7 @@ public class CheckUpdateViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
if (blReload)
|
if (blReload)
|
||||||
{
|
{
|
||||||
AppEvents.ReloadRequested.OnNext(Unit.Default);
|
AppEvents.ReloadRequested.Publish();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -292,7 +292,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
if (_config.UiItem.EnableAutoAdjustMainLvColWidth)
|
if (_config.UiItem.EnableAutoAdjustMainLvColWidth)
|
||||||
{
|
{
|
||||||
AppEvents.AdjustMainLvColWidthRequested.OnNext(Unit.Default);
|
AppEvents.AdjustMainLvColWidthRequested.Publish();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -303,7 +303,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AppEvents.DispatcherStatisticsRequested.OnNext(update);
|
AppEvents.DispatcherStatisticsRequested.Publish(update);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Actions
|
#endregion Actions
|
||||||
|
|
@ -312,14 +312,14 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
|
|
||||||
private async Task RefreshServers()
|
private async Task RefreshServers()
|
||||||
{
|
{
|
||||||
AppEvents.ProfilesRefreshRequested.OnNext(Unit.Default);
|
AppEvents.ProfilesRefreshRequested.Publish();
|
||||||
|
|
||||||
await Task.Delay(200);
|
await Task.Delay(200);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshSubscriptions()
|
private void RefreshSubscriptions()
|
||||||
{
|
{
|
||||||
AppEvents.SubscriptionsRefreshRequested.OnNext(Unit.Default);
|
AppEvents.SubscriptionsRefreshRequested.Publish();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Servers && Groups
|
#endregion Servers && Groups
|
||||||
|
|
@ -451,7 +451,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
var ret = await _updateView?.Invoke(EViewAction.OptionSettingWindow, null);
|
var ret = await _updateView?.Invoke(EViewAction.OptionSettingWindow, null);
|
||||||
if (ret == true)
|
if (ret == true)
|
||||||
{
|
{
|
||||||
AppEvents.InboundDisplayRequested.OnNext(Unit.Default);
|
AppEvents.InboundDisplayRequested.Publish();
|
||||||
await Reload();
|
await Reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -462,7 +462,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
if (ret == true)
|
if (ret == true)
|
||||||
{
|
{
|
||||||
await ConfigHandler.InitBuiltinRouting(_config);
|
await ConfigHandler.InitBuiltinRouting(_config);
|
||||||
AppEvents.RoutingsMenuRefreshRequested.OnNext(Unit.Default);
|
AppEvents.RoutingsMenuRefreshRequested.Publish();
|
||||||
await Reload();
|
await Reload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -530,12 +530,12 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
await SysProxyHandler.UpdateSysProxy(_config, false);
|
await SysProxyHandler.UpdateSysProxy(_config, false);
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
});
|
});
|
||||||
AppEvents.TestServerRequested.OnNext(Unit.Default);
|
AppEvents.TestServerRequested.Publish();
|
||||||
|
|
||||||
var showClashUI = _config.IsRunningCore(ECoreType.sing_box);
|
var showClashUI = _config.IsRunningCore(ECoreType.sing_box);
|
||||||
if (showClashUI)
|
if (showClashUI)
|
||||||
{
|
{
|
||||||
AppEvents.ProxiesReloadRequested.OnNext(Unit.Default);
|
AppEvents.ProxiesReloadRequested.Publish();
|
||||||
}
|
}
|
||||||
|
|
||||||
RxApp.MainThreadScheduler.Schedule(() => ReloadResult(showClashUI));
|
RxApp.MainThreadScheduler.Schedule(() => ReloadResult(showClashUI));
|
||||||
|
|
@ -565,7 +565,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
if (_config.UiItem.AutoHideStartup)
|
if (_config.UiItem.AutoHideStartup)
|
||||||
{
|
{
|
||||||
AppEvents.ShowHideWindowRequested.OnNext(false);
|
AppEvents.ShowHideWindowRequested.Publish(false);
|
||||||
}
|
}
|
||||||
await Task.CompletedTask;
|
await Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
@ -578,7 +578,7 @@ public class MainWindowViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
await ConfigHandler.ApplyRegionalPreset(_config, type);
|
await ConfigHandler.ApplyRegionalPreset(_config, type);
|
||||||
await ConfigHandler.InitRouting(_config);
|
await ConfigHandler.InitRouting(_config);
|
||||||
AppEvents.RoutingsMenuRefreshRequested.OnNext(Unit.Default);
|
AppEvents.RoutingsMenuRefreshRequested.Publish();
|
||||||
|
|
||||||
await ConfigHandler.SaveConfig(_config);
|
await ConfigHandler.SaveConfig(_config);
|
||||||
await new UpdateService().UpdateGeoFileAll(_config, UpdateTaskHandler);
|
await new UpdateService().UpdateGeoFileAll(_config, UpdateTaskHandler);
|
||||||
|
|
|
||||||
|
|
@ -275,7 +275,7 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
|
|
||||||
private void Reload()
|
private void Reload()
|
||||||
{
|
{
|
||||||
AppEvents.ReloadRequested.OnNext(Unit.Default);
|
AppEvents.ReloadRequested.Publish();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SetSpeedTestResult(SpeedTestResult result)
|
public async Task SetSpeedTestResult(SpeedTestResult result)
|
||||||
|
|
@ -361,7 +361,7 @@ public class ProfilesViewModel : MyReactiveObject
|
||||||
|
|
||||||
public async Task RefreshServers()
|
public async Task RefreshServers()
|
||||||
{
|
{
|
||||||
AppEvents.ProfilesRefreshRequested.OnNext(Unit.Default);
|
AppEvents.ProfilesRefreshRequested.Publish();
|
||||||
|
|
||||||
await Task.Delay(200);
|
await Task.Delay(200);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ public class RoutingRuleDetailsViewModel : MyReactiveObject
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public string Process { get; set; }
|
public string Process { get; set; }
|
||||||
|
|
||||||
|
public IList<string> Types { get; set; }
|
||||||
|
|
||||||
[Reactive]
|
[Reactive]
|
||||||
public bool AutoSort { get; set; }
|
public bool AutoSort { get; set; }
|
||||||
|
|
||||||
|
|
@ -51,6 +53,11 @@ public class RoutingRuleDetailsViewModel : MyReactiveObject
|
||||||
Domain = Utils.List2String(SelectedSource.Domain, true);
|
Domain = Utils.List2String(SelectedSource.Domain, true);
|
||||||
IP = Utils.List2String(SelectedSource.Ip, true);
|
IP = Utils.List2String(SelectedSource.Ip, true);
|
||||||
Process = Utils.List2String(SelectedSource.Process, true);
|
Process = Utils.List2String(SelectedSource.Process, true);
|
||||||
|
Types = SelectedSource.RuleTypes?.ToList();
|
||||||
|
if (Types == null || Types.Count == 0)
|
||||||
|
{
|
||||||
|
Types = Global.RuleTypes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SaveRulesAsync()
|
private async Task SaveRulesAsync()
|
||||||
|
|
@ -73,6 +80,7 @@ public class RoutingRuleDetailsViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
SelectedSource.Protocol = ProtocolItems?.ToList();
|
SelectedSource.Protocol = ProtocolItems?.ToList();
|
||||||
SelectedSource.InboundTag = InboundTagItems?.ToList();
|
SelectedSource.InboundTag = InboundTagItems?.ToList();
|
||||||
|
SelectedSource.RuleTypes = Types?.ToList();
|
||||||
|
|
||||||
var hasRule = SelectedSource.Domain?.Count > 0
|
var hasRule = SelectedSource.Domain?.Count > 0
|
||||||
|| SelectedSource.Ip?.Count > 0
|
|| SelectedSource.Ip?.Count > 0
|
||||||
|
|
|
||||||
|
|
@ -148,17 +148,17 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
|
|
||||||
NotifyLeftClickCmd = ReactiveCommand.CreateFromTask(async () =>
|
NotifyLeftClickCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
{
|
{
|
||||||
AppEvents.ShowHideWindowRequested.OnNext(null);
|
AppEvents.ShowHideWindowRequested.Publish(null);
|
||||||
await Task.CompletedTask;
|
await Task.CompletedTask;
|
||||||
});
|
});
|
||||||
ShowWindowCmd = ReactiveCommand.CreateFromTask(async () =>
|
ShowWindowCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
{
|
{
|
||||||
AppEvents.ShowHideWindowRequested.OnNext(true);
|
AppEvents.ShowHideWindowRequested.Publish(true);
|
||||||
await Task.CompletedTask;
|
await Task.CompletedTask;
|
||||||
});
|
});
|
||||||
HideWindowCmd = ReactiveCommand.CreateFromTask(async () =>
|
HideWindowCmd = ReactiveCommand.CreateFromTask(async () =>
|
||||||
{
|
{
|
||||||
AppEvents.ShowHideWindowRequested.OnNext(false);
|
AppEvents.ShowHideWindowRequested.Publish(false);
|
||||||
await Task.CompletedTask;
|
await Task.CompletedTask;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -274,19 +274,19 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
|
|
||||||
private async Task AddServerViaClipboard()
|
private async Task AddServerViaClipboard()
|
||||||
{
|
{
|
||||||
AppEvents.AddServerViaClipboardRequested.OnNext(Unit.Default);
|
AppEvents.AddServerViaClipboardRequested.Publish();
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task AddServerViaScan()
|
private async Task AddServerViaScan()
|
||||||
{
|
{
|
||||||
AppEvents.AddServerViaScanRequested.OnNext(Unit.Default);
|
AppEvents.AddServerViaScanRequested.Publish();
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task UpdateSubscriptionProcess(bool blProxy)
|
private async Task UpdateSubscriptionProcess(bool blProxy)
|
||||||
{
|
{
|
||||||
AppEvents.SubscriptionsUpdateRequested.OnNext(blProxy);
|
AppEvents.SubscriptionsUpdateRequested.Publish(blProxy);
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -348,7 +348,7 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
AppEvents.SetDefaultServerRequested.OnNext(SelectedServer.ID);
|
AppEvents.SetDefaultServerRequested.Publish(SelectedServer.ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task TestServerAvailability()
|
public async Task TestServerAvailability()
|
||||||
|
|
@ -449,7 +449,7 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
if (await ConfigHandler.SetDefaultRouting(_config, item) == 0)
|
if (await ConfigHandler.SetDefaultRouting(_config, item) == 0)
|
||||||
{
|
{
|
||||||
NoticeManager.Instance.SendMessageEx(ResUI.TipChangeRouting);
|
NoticeManager.Instance.SendMessageEx(ResUI.TipChangeRouting);
|
||||||
AppEvents.ReloadRequested.OnNext(Unit.Default);
|
AppEvents.ReloadRequested.Publish();
|
||||||
_updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null);
|
_updateView?.Invoke(EViewAction.DispatcherRefreshIcon, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -496,7 +496,7 @@ public class StatusBarViewModel : MyReactiveObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await ConfigHandler.SaveConfig(_config);
|
await ConfigHandler.SaveConfig(_config);
|
||||||
AppEvents.ReloadRequested.OnNext(Unit.Default);
|
AppEvents.ReloadRequested.Publish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool AllowEnableTun()
|
private bool AllowEnableTun()
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ public partial class App : Application
|
||||||
{
|
{
|
||||||
if (desktop.MainWindow != null)
|
if (desktop.MainWindow != null)
|
||||||
{
|
{
|
||||||
AppEvents.AddServerViaClipboardRequested.OnNext(Unit.Default);
|
AppEvents.AddServerViaClipboardRequested.Publish();
|
||||||
await Task.Delay(1000);
|
await Task.Delay(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ global using ServiceLib;
|
||||||
global using ServiceLib.Base;
|
global using ServiceLib.Base;
|
||||||
global using ServiceLib.Common;
|
global using ServiceLib.Common;
|
||||||
global using ServiceLib.Enums;
|
global using ServiceLib.Enums;
|
||||||
|
global using ServiceLib.Events;
|
||||||
global using ServiceLib.Handler;
|
global using ServiceLib.Handler;
|
||||||
global using ServiceLib.Manager;
|
global using ServiceLib.Manager;
|
||||||
global using ServiceLib.Models;
|
global using ServiceLib.Models;
|
||||||
|
|
|
||||||
|
|
@ -253,7 +253,7 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
|
||||||
case EGlobalHotkey.SystemProxySet:
|
case EGlobalHotkey.SystemProxySet:
|
||||||
case EGlobalHotkey.SystemProxyUnchanged:
|
case EGlobalHotkey.SystemProxyUnchanged:
|
||||||
case EGlobalHotkey.SystemProxyPac:
|
case EGlobalHotkey.SystemProxyPac:
|
||||||
AppEvents.SysProxyChangeRequested.OnNext((ESysProxyType)((int)e - 1));
|
AppEvents.SysProxyChangeRequested.Publish((ESysProxyType)((int)e - 1));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,13 +33,25 @@
|
||||||
Width="300"
|
Width="300"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
HorizontalAlignment="Left" />
|
HorizontalAlignment="Left" />
|
||||||
<ToggleSwitch
|
<StackPanel
|
||||||
x:Name="togEnabled"
|
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Grid.Column="2"
|
Grid.Column="2"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<ToggleSwitch
|
||||||
|
x:Name="togEnabled"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
<ListBox
|
||||||
|
x:Name="clbRuleTypes"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
SelectionMode="Multiple,Toggle"
|
||||||
|
Theme="{DynamicResource CardCheckGroupListBox}" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
|
|
@ -58,17 +70,15 @@
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
Grid.Column="2"
|
Grid.Column="2"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
Orientation="Horizontal"
|
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
VerticalAlignment="Center">
|
VerticalAlignment="Center"
|
||||||
|
Orientation="Horizontal">
|
||||||
<Button
|
<Button
|
||||||
x:Name="btnSelectProfile"
|
x:Name="btnSelectProfile"
|
||||||
Margin="0,0,8,0"
|
Margin="0,0,8,0"
|
||||||
Content="{x:Static resx:ResUI.TbSelectProfile}"
|
Click="BtnSelectProfile_Click"
|
||||||
Click="BtnSelectProfile_Click" />
|
Content="{x:Static resx:ResUI.TbSelectProfile}" />
|
||||||
<TextBlock
|
<TextBlock VerticalAlignment="Center" Text="{x:Static resx:ResUI.TbRuleOutboundTagTip}" />
|
||||||
VerticalAlignment="Center"
|
|
||||||
Text="{x:Static resx:ResUI.TbRuleOutboundTagTip}" />
|
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,16 @@ public partial class RoutingRuleDetailsWindow : WindowBase<RoutingRuleDetailsVie
|
||||||
clbInboundTag.ItemsSource = Global.InboundTags;
|
clbInboundTag.ItemsSource = Global.InboundTags;
|
||||||
cmbNetwork.ItemsSource = Global.RuleNetworks;
|
cmbNetwork.ItemsSource = Global.RuleNetworks;
|
||||||
|
|
||||||
|
clbRuleTypes.SelectionChanged += ClbRuleTypes_SelectionChanged;
|
||||||
|
clbRuleTypes.ItemsSource = Global.RuleTypes;
|
||||||
|
if (ViewModel.Types != null)
|
||||||
|
{
|
||||||
|
foreach (var it in ViewModel.Types)
|
||||||
|
{
|
||||||
|
clbRuleTypes.SelectedItems.Add(it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!rulesItem.Id.IsNullOrEmpty())
|
if (!rulesItem.Id.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
rulesItem.Protocol?.ForEach(it =>
|
rulesItem.Protocol?.ForEach(it =>
|
||||||
|
|
@ -108,4 +118,12 @@ public partial class RoutingRuleDetailsWindow : WindowBase<RoutingRuleDetailsVie
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ClbRuleTypes_SelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (ViewModel != null)
|
||||||
|
{
|
||||||
|
ViewModel.Types = clbRuleTypes.SelectedItems.Cast<string>().ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ global using ServiceLib;
|
||||||
global using ServiceLib.Base;
|
global using ServiceLib.Base;
|
||||||
global using ServiceLib.Common;
|
global using ServiceLib.Common;
|
||||||
global using ServiceLib.Enums;
|
global using ServiceLib.Enums;
|
||||||
|
global using ServiceLib.Events;
|
||||||
global using ServiceLib.Handler;
|
global using ServiceLib.Handler;
|
||||||
global using ServiceLib.Manager;
|
global using ServiceLib.Manager;
|
||||||
global using ServiceLib.Models;
|
global using ServiceLib.Models;
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,7 @@ public partial class MainWindow
|
||||||
case EGlobalHotkey.SystemProxySet:
|
case EGlobalHotkey.SystemProxySet:
|
||||||
case EGlobalHotkey.SystemProxyUnchanged:
|
case EGlobalHotkey.SystemProxyUnchanged:
|
||||||
case EGlobalHotkey.SystemProxyPac:
|
case EGlobalHotkey.SystemProxyPac:
|
||||||
AppEvents.SysProxyChangeRequested.OnNext((ESysProxyType)((int)e - 1));
|
AppEvents.SysProxyChangeRequested.Publish((ESysProxyType)((int)e - 1));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,13 +48,25 @@
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Style="{StaticResource DefTextBox}" />
|
Style="{StaticResource DefTextBox}" />
|
||||||
<ToggleButton
|
<StackPanel
|
||||||
x:Name="togEnabled"
|
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Grid.Column="2"
|
Grid.Column="2"
|
||||||
Margin="{StaticResource Margin4}"
|
Margin="{StaticResource Margin4}"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
VerticalAlignment="Center" />
|
VerticalAlignment="Center"
|
||||||
|
Orientation="Horizontal">
|
||||||
|
<ToggleButton
|
||||||
|
x:Name="togEnabled"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
VerticalAlignment="Center" />
|
||||||
|
<ListBox
|
||||||
|
x:Name="clbRuleTypes"
|
||||||
|
Margin="{StaticResource Margin4}"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
FontSize="{DynamicResource StdFontSize}"
|
||||||
|
Style="{StaticResource MaterialDesignFilterChipPrimaryListBox}" />
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,16 @@ public partial class RoutingRuleDetailsWindow
|
||||||
clbInboundTag.ItemsSource = Global.InboundTags;
|
clbInboundTag.ItemsSource = Global.InboundTags;
|
||||||
cmbNetwork.ItemsSource = Global.RuleNetworks;
|
cmbNetwork.ItemsSource = Global.RuleNetworks;
|
||||||
|
|
||||||
|
clbRuleTypes.SelectionChanged += ClbRuleTypes_SelectionChanged;
|
||||||
|
clbRuleTypes.ItemsSource = Global.RuleTypes;
|
||||||
|
if (ViewModel.Types != null)
|
||||||
|
{
|
||||||
|
foreach (var it in ViewModel.Types)
|
||||||
|
{
|
||||||
|
clbRuleTypes.SelectedItems.Add(it);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!rulesItem.Id.IsNullOrEmpty())
|
if (!rulesItem.Id.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
rulesItem.Protocol?.ForEach(it =>
|
rulesItem.Protocol?.ForEach(it =>
|
||||||
|
|
@ -101,4 +111,12 @@ public partial class RoutingRuleDetailsWindow
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ClbRuleTypes_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (ViewModel != null)
|
||||||
|
{
|
||||||
|
ViewModel.Types = clbRuleTypes.SelectedItems.Cast<string>().ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue