Improved MessageBus contract
This commit is contained in:
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 GrpcMultiMode = "multi";
|
||||
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 SpeedUnit = "";
|
||||
public const int MinFontSize = 10;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace ServiceLib.Handler
|
||||
{
|
||||
return;
|
||||
}
|
||||
MessageBus.Current.SendMessage(content, Global.CommandSendSnackMsg);
|
||||
MessageBus.Current.SendMessage(content, EMsgCommand.SendSnackMsg.ToString());
|
||||
}
|
||||
|
||||
public void SendMessage(string? content)
|
||||
@@ -22,7 +22,7 @@ namespace ServiceLib.Handler
|
||||
{
|
||||
return;
|
||||
}
|
||||
MessageBus.Current.SendMessage(content, Global.CommandSendMsgView);
|
||||
MessageBus.Current.SendMessage(content, EMsgCommand.SendMsgView.ToString());
|
||||
}
|
||||
|
||||
public void SendMessageEx(string? content)
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace ServiceLib.ViewModels
|
||||
_updateView = updateView;
|
||||
_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();
|
||||
SelectedServer = new();
|
||||
@@ -453,7 +453,7 @@ namespace ServiceLib.ViewModels
|
||||
|
||||
private void RefreshServers()
|
||||
{
|
||||
MessageBus.Current.SendMessage("", Global.CommandRefreshProfiles);
|
||||
MessageBus.Current.SendMessage("", EMsgCommand.RefreshProfiles.ToString());
|
||||
}
|
||||
|
||||
public void RefreshServersBiz()
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace ServiceLib.ViewModels
|
||||
_config = AppHandler.Instance.Config;
|
||||
_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;
|
||||
AutoRefresh = _config.msgUIItem.autoRefresh ?? true;
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace ServiceLib.ViewModels
|
||||
|
||||
_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();
|
||||
SelectedSub = new();
|
||||
@@ -345,7 +345,7 @@ namespace ServiceLib.ViewModels
|
||||
|
||||
public void RefreshServers()
|
||||
{
|
||||
MessageBus.Current.SendMessage("", Global.CommandRefreshProfiles);
|
||||
MessageBus.Current.SendMessage("", EMsgCommand.RefreshProfiles.ToString());
|
||||
}
|
||||
|
||||
public void RefreshServersBiz()
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace v2rayN.Desktop.Views
|
||||
menuBackupAndRestore.Click += MenuBackupAndRestore_Click;
|
||||
|
||||
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);
|
||||
Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel));
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace v2rayN.Views
|
||||
menuBackupAndRestore.Click += MenuBackupAndRestore_Click;
|
||||
|
||||
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);
|
||||
Locator.CurrentMutable.RegisterLazySingleton(() => ViewModel, typeof(MainWindowViewModel));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user