mirror of
https://github.com/2dust/v2rayN.git
synced 2025-04-19 21:52:25 +00:00
Improved MessageBus contract
This commit is contained in:
parent
b172b03927
commit
a0286ff810
8 changed files with 19 additions and 14 deletions
10
v2rayN/ServiceLib/Enums/EMsgCommand.cs
Normal file
10
v2rayN/ServiceLib/Enums/EMsgCommand.cs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
namespace ServiceLib.Enums
|
||||||
|
{
|
||||||
|
public enum EMsgCommand
|
||||||
|
{
|
||||||
|
ClearMsg,
|
||||||
|
SendMsgView,
|
||||||
|
SendSnackMsg,
|
||||||
|
RefreshProfiles
|
||||||
|
}
|
||||||
|
}
|
|
@ -68,11 +68,6 @@
|
||||||
public const string GrpcGunMode = "gun";
|
public const string GrpcGunMode = "gun";
|
||||||
public const string GrpcMultiMode = "multi";
|
public const string GrpcMultiMode = "multi";
|
||||||
public const int MaxPort = 65536;
|
public const int MaxPort = 65536;
|
||||||
public const string CommandClearMsg = "CommandClearMsg";
|
|
||||||
public const string CommandSendMsgView = "CommandSendMsgView";
|
|
||||||
public const string CommandSendSnackMsg = "CommandSendSnackMsg";
|
|
||||||
public const string CommandStopSpeedTest = "CommandStopSpeedTest";
|
|
||||||
public const string CommandRefreshProfiles = "CommandRefreshProfiles";
|
|
||||||
public const string DelayUnit = "";
|
public const string DelayUnit = "";
|
||||||
public const string SpeedUnit = "";
|
public const string SpeedUnit = "";
|
||||||
public const int MinFontSize = 10;
|
public const int MinFontSize = 10;
|
||||||
|
|
|
@ -13,7 +13,7 @@ namespace ServiceLib.Handler
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MessageBus.Current.SendMessage(content, Global.CommandSendSnackMsg);
|
MessageBus.Current.SendMessage(content, EMsgCommand.SendSnackMsg.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendMessage(string? content)
|
public void SendMessage(string? content)
|
||||||
|
@ -22,7 +22,7 @@ namespace ServiceLib.Handler
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MessageBus.Current.SendMessage(content, Global.CommandSendMsgView);
|
MessageBus.Current.SendMessage(content, EMsgCommand.SendMsgView.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SendMessageEx(string? content)
|
public void SendMessageEx(string? content)
|
||||||
|
|
|
@ -150,7 +150,7 @@ namespace ServiceLib.ViewModels
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
_isAdministrator = isAdministrator;
|
_isAdministrator = isAdministrator;
|
||||||
|
|
||||||
MessageBus.Current.Listen<string>(Global.CommandRefreshProfiles).Subscribe(async x => await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null));
|
MessageBus.Current.Listen<string>(EMsgCommand.RefreshProfiles.ToString()).Subscribe(async x => await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null));
|
||||||
|
|
||||||
SelectedRouting = new();
|
SelectedRouting = new();
|
||||||
SelectedServer = new();
|
SelectedServer = new();
|
||||||
|
@ -453,7 +453,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
private void RefreshServers()
|
private void RefreshServers()
|
||||||
{
|
{
|
||||||
MessageBus.Current.SendMessage("", Global.CommandRefreshProfiles);
|
MessageBus.Current.SendMessage("", EMsgCommand.RefreshProfiles.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RefreshServersBiz()
|
public void RefreshServersBiz()
|
||||||
|
|
|
@ -24,7 +24,7 @@ namespace ServiceLib.ViewModels
|
||||||
_config = AppHandler.Instance.Config;
|
_config = AppHandler.Instance.Config;
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
|
||||||
MessageBus.Current.Listen<string>(Global.CommandSendMsgView).Subscribe(async x => await AppendQueueMsg(x));
|
MessageBus.Current.Listen<string>(EMsgCommand.SendMsgView.ToString()).Subscribe(async x => await AppendQueueMsg(x));
|
||||||
|
|
||||||
MsgFilter = _config.msgUIItem.mainMsgFilter ?? string.Empty;
|
MsgFilter = _config.msgUIItem.mainMsgFilter ?? string.Empty;
|
||||||
AutoRefresh = _config.msgUIItem.autoRefresh ?? true;
|
AutoRefresh = _config.msgUIItem.autoRefresh ?? true;
|
||||||
|
|
|
@ -101,7 +101,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
_updateView = updateView;
|
_updateView = updateView;
|
||||||
|
|
||||||
MessageBus.Current.Listen<string>(Global.CommandRefreshProfiles).Subscribe(async x => await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null));
|
MessageBus.Current.Listen<string>(EMsgCommand.RefreshProfiles.ToString()).Subscribe(async x => await _updateView?.Invoke(EViewAction.DispatcherRefreshServersBiz, null));
|
||||||
|
|
||||||
SelectedProfile = new();
|
SelectedProfile = new();
|
||||||
SelectedSub = new();
|
SelectedSub = new();
|
||||||
|
@ -345,7 +345,7 @@ namespace ServiceLib.ViewModels
|
||||||
|
|
||||||
public void RefreshServers()
|
public void RefreshServers()
|
||||||
{
|
{
|
||||||
MessageBus.Current.SendMessage("", Global.CommandRefreshProfiles);
|
MessageBus.Current.SendMessage("", EMsgCommand.RefreshProfiles.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RefreshServersBiz()
|
public void RefreshServersBiz()
|
||||||
|
|
|
@ -41,7 +41,7 @@ namespace v2rayN.Desktop.Views
|
||||||
menuBackupAndRestore.Click += MenuBackupAndRestore_Click;
|
menuBackupAndRestore.Click += MenuBackupAndRestore_Click;
|
||||||
|
|
||||||
var IsAdministrator = Utils.IsAdministrator();
|
var IsAdministrator = Utils.IsAdministrator();
|
||||||
MessageBus.Current.Listen<string>(Global.CommandSendSnackMsg).Subscribe(x => DelegateSnackMsg(x));
|
MessageBus.Current.Listen<string>(EMsgCommand.SendSnackMsg.ToString()).Subscribe(x => DelegateSnackMsg(x));
|
||||||
ViewModel = new MainWindowViewModel(IsAdministrator, UpdateViewHandler);
|
ViewModel = new MainWindowViewModel(IsAdministrator, UpdateViewHandler);
|
||||||
Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel));
|
Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel));
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ namespace v2rayN.Views
|
||||||
menuBackupAndRestore.Click += MenuBackupAndRestore_Click;
|
menuBackupAndRestore.Click += MenuBackupAndRestore_Click;
|
||||||
|
|
||||||
var IsAdministrator = Utils.IsAdministrator();
|
var IsAdministrator = Utils.IsAdministrator();
|
||||||
MessageBus.Current.Listen<string>(Global.CommandSendSnackMsg).Subscribe(x => DelegateSnackMsg(x));
|
MessageBus.Current.Listen<string>(EMsgCommand.SendSnackMsg.ToString()).Subscribe(x => DelegateSnackMsg(x));
|
||||||
ViewModel = new MainWindowViewModel(IsAdministrator, UpdateViewHandler);
|
ViewModel = new MainWindowViewModel(IsAdministrator, UpdateViewHandler);
|
||||||
Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel));
|
Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel));
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue