Skip to content

Commit

Permalink
Remove some pop-up messages
Browse files Browse the repository at this point in the history
  • Loading branch information
2dust committed Mar 4, 2024
1 parent afaad49 commit 0185b3b
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 48 deletions.
2 changes: 1 addition & 1 deletion v2rayN/v2rayN/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ private void Init()
{
if (ConfigHandler.LoadConfig(ref _config) != 0)
{
UI.ShowWarning($"Loading GUI configuration file is abnormal,please restart the application{Environment.NewLine}加载GUI配置文件异常,请重启应用");
UI.Show($"Loading GUI configuration file is abnormal,please restart the application{Environment.NewLine}加载GUI配置文件异常,请重启应用");
Application.Current.Shutdown();
Environment.Exit(0);
return;
Expand Down
5 changes: 0 additions & 5 deletions v2rayN/v2rayN/Common/UI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ public static void Show(string msg)
MessageBox.Show(msg, caption, MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK);
}

public static void ShowWarning(string msg)
{
MessageBox.Show(msg, caption, MessageBoxButton.OK, MessageBoxImage.Warning, MessageBoxResult.OK);
}

public static MessageBoxResult ShowYesNo(string msg)
{
return MessageBox.Show(msg, caption, MessageBoxButton.YesNo, MessageBoxImage.Question);
Expand Down
2 changes: 1 addition & 1 deletion v2rayN/v2rayN/Handler/ConfigHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1186,7 +1186,7 @@ static bool Contains(string str, params string[] s)

ProfileItem profileItem = new();
//Is v2ray configuration
V2rayConfig? v2rayConfig = JsonUtile.Deserialize<V2rayConfig>(clipboardData);
var v2rayConfig = JsonUtile.Deserialize<V2rayConfig>(clipboardData);
if (v2rayConfig?.inbounds?.Count > 0
&& v2rayConfig.outbounds?.Count > 0)
{
Expand Down
8 changes: 5 additions & 3 deletions v2rayN/v2rayN/Handler/MainFormHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Win32;
using Splat;
using System.Drawing;
using System.IO;
using System.Windows.Media.Imaging;
Expand Down Expand Up @@ -125,7 +126,7 @@ public void Export2ClientConfig(ProfileItem item, Config config)
}
if (item.configType == EConfigType.Custom)
{
UI.Show(ResUI.NonVmessService);
Locator.Current.GetService<NoticeHandler>()?.Enqueue(ResUI.NonVmessService);
return;
}

Expand All @@ -146,11 +147,12 @@ public void Export2ClientConfig(ProfileItem item, Config config)
}
if (CoreConfigHandler.GenerateClientConfig(item, fileName, out string msg, out string content) != 0)
{
UI.Show(msg);
Locator.Current.GetService<NoticeHandler>()?.Enqueue(msg);
}
else
{
UI.ShowWarning(string.Format(ResUI.SaveClientConfigurationIn, fileName));
msg = string.Format(ResUI.SaveClientConfigurationIn, fileName);
Locator.Current.GetService<NoticeHandler>()?.SendMessageAndEnqueue(msg);
}
}

Expand Down
6 changes: 6 additions & 0 deletions v2rayN/v2rayN/Handler/NoticeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,11 @@ public void SendMessage(string msg, bool time)
msg = $"{DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")} {msg}";
MessageBus.Current.SendMessage(msg, Global.CommandSendMsgView);
}

public void SendMessageAndEnqueue(string msg)
{
_snackbarMessageQueue?.Enqueue(msg);
MessageBus.Current.SendMessage(msg, Global.CommandSendMsgView);
}
}
}
12 changes: 6 additions & 6 deletions v2rayN/v2rayN/ViewModels/AddServer2ViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ private void SaveServer()
string remarks = SelectedSource.remarks;
if (Utile.IsNullOrEmpty(remarks))
{
UI.Show(ResUI.PleaseFillRemarks);
_noticeHandler?.Enqueue(ResUI.PleaseFillRemarks);
return;
}

if (Utile.IsNullOrEmpty(SelectedSource.address))
{
UI.Show(ResUI.FillServerAddressCustom);
_noticeHandler?.Enqueue(ResUI.FillServerAddressCustom);
return;
}

Expand All @@ -95,13 +95,13 @@ private void SaveServer()
}
else
{
UI.Show(ResUI.OperationFailed);
_noticeHandler?.Enqueue(ResUI.OperationFailed);
}
}

private void BrowseServer()
{
//UI.Show(ResUI.CustomServerTips);
//_noticeHandler?.Enqueue(ResUI.CustomServerTips);

if (UI.OpenFileDialog(out string fileName,
"Config|*.json|YAML|*.yaml;*.yml|All|*.*") != true)
Expand All @@ -127,7 +127,7 @@ private void BrowseServer()
}
else
{
UI.ShowWarning(ResUI.FailedImportedCustomServer);
_noticeHandler?.Enqueue(ResUI.FailedImportedCustomServer);
}
}

Expand All @@ -136,7 +136,7 @@ private void EditServer()
var address = SelectedSource.address;
if (Utile.IsNullOrEmpty(address))
{
UI.Show(ResUI.FillServerAddressCustom);
_noticeHandler?.Enqueue(ResUI.FillServerAddressCustom);
return;
}

Expand Down
14 changes: 7 additions & 7 deletions v2rayN/v2rayN/ViewModels/AddServerViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,40 +51,40 @@ private void SaveServer()
{
if (Utile.IsNullOrEmpty(SelectedSource.remarks))
{
UI.Show(ResUI.PleaseFillRemarks);
_noticeHandler?.Enqueue(ResUI.PleaseFillRemarks);
return;
}

if (Utile.IsNullOrEmpty(SelectedSource.address))
{
UI.Show(ResUI.FillServerAddress);
_noticeHandler?.Enqueue(ResUI.FillServerAddress);
return;
}
var port = SelectedSource.port.ToString();
if (Utile.IsNullOrEmpty(port) || !Utile.IsNumeric(port)
|| SelectedSource.port <= 0 || SelectedSource.port >= Global.MaxPort)
{
UI.Show(ResUI.FillCorrectServerPort);
_noticeHandler?.Enqueue(ResUI.FillCorrectServerPort);
return;
}
if (SelectedSource.configType == EConfigType.Shadowsocks)
{
if (Utile.IsNullOrEmpty(SelectedSource.id))
{
UI.Show(ResUI.FillPassword);
_noticeHandler?.Enqueue(ResUI.FillPassword);
return;
}
if (Utile.IsNullOrEmpty(SelectedSource.security))
{
UI.Show(ResUI.PleaseSelectEncryption);
_noticeHandler?.Enqueue(ResUI.PleaseSelectEncryption);
return;
}
}
if (SelectedSource.configType != EConfigType.Socks)
{
if (Utile.IsNullOrEmpty(SelectedSource.id))
{
UI.Show(ResUI.FillUUID);
_noticeHandler?.Enqueue(ResUI.FillUUID);
return;
}
}
Expand Down Expand Up @@ -143,7 +143,7 @@ private void SaveServer()
}
else
{
UI.Show(ResUI.OperationFailed);
_noticeHandler?.Enqueue(ResUI.OperationFailed);
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions v2rayN/v2rayN/ViewModels/DNSSettingViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ private void SaveSetting()
{
if (normalDNS.Contains("{") || normalDNS.Contains("}"))
{
UI.Show(ResUI.FillCorrectDNSText);
_noticeHandler?.Enqueue(ResUI.FillCorrectDNSText);
return;
}
}
Expand All @@ -81,7 +81,7 @@ private void SaveSetting()
var obj2 = JsonUtile.Deserialize<Dns4Sbox>(normalDNS2);
if (obj2 == null)
{
UI.Show(ResUI.FillCorrectDNSText);
_noticeHandler?.Enqueue(ResUI.FillCorrectDNSText);
return;
}
}
Expand All @@ -90,7 +90,7 @@ private void SaveSetting()
var obj2 = JsonUtile.Deserialize<Dns4Sbox>(tunDNS2);
if (obj2 == null)
{
UI.Show(ResUI.FillCorrectDNSText);
_noticeHandler?.Enqueue(ResUI.FillCorrectDNSText);
return;
}
}
Expand Down
4 changes: 2 additions & 2 deletions v2rayN/v2rayN/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1434,11 +1434,11 @@ private void ImportOldGuiConfig()
InitSubscriptionView();
RefreshServers();
Reload();
UI.Show(ResUI.OperationSuccess);
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
}
else
{
_noticeHandler.Enqueue(ResUI.OperationFailed);
_noticeHandler?.Enqueue(ResUI.OperationFailed);
}
}

Expand Down
6 changes: 3 additions & 3 deletions v2rayN/v2rayN/ViewModels/OptionSettingViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ private void SaveSetting()
if (Utile.IsNullOrEmpty(localPort.ToString()) || !Utile.IsNumeric(localPort.ToString())
|| localPort <= 0 || localPort >= Global.MaxPort)
{
UI.Show(ResUI.FillLocalListeningPort);
_noticeHandler?.Enqueue(ResUI.FillLocalListeningPort);
return;
}

Expand All @@ -263,7 +263,7 @@ private void SaveSetting()
// || Utile.IsNullOrEmpty(KcpreadBufferSize.ToString()) || !Utile.IsNumeric(KcpreadBufferSize.ToString())
// || Utile.IsNullOrEmpty(KcpwriteBufferSize.ToString()) || !Utile.IsNumeric(KcpwriteBufferSize.ToString()))
//{
// UI.Show(ResUI.FillKcpParameters);
// _noticeHandler?.Enqueue(ResUI.FillKcpParameters);
// return;
//}

Expand Down Expand Up @@ -342,7 +342,7 @@ private void SaveSetting()
}
else
{
UI.ShowWarning(ResUI.OperationFailed);
_noticeHandler?.Enqueue(ResUI.OperationFailed);
}
}

Expand Down
2 changes: 1 addition & 1 deletion v2rayN/v2rayN/ViewModels/RoutingRuleDetailsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private void SaveRules()

if (!hasRule)
{
UI.ShowWarning(string.Format(ResUI.RoutingRuleDetailRequiredTips, "Port/Protocol/Domain/IP/Process"));
_noticeHandler?.Enqueue(string.Format(ResUI.RoutingRuleDetailRequiredTips, "Port/Protocol/Domain/IP/Process"));
return;
}
//_noticeHandler?.Enqueue(ResUI.OperationSuccess);
Expand Down
20 changes: 10 additions & 10 deletions v2rayN/v2rayN/ViewModels/RoutingRuleSettingViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void RuleRemove()
{
if (SelectedSource is null || SelectedSource.outboundTag.IsNullOrEmpty())
{
UI.Show(ResUI.PleaseSelectRules);
_noticeHandler?.Enqueue(ResUI.PleaseSelectRules);
return;
}
if (UI.ShowYesNo(ResUI.RemoveRules) == MessageBoxResult.No)
Expand All @@ -192,7 +192,7 @@ public void RuleExportSelected()
{
if (SelectedSource is null || SelectedSource.outboundTag.IsNullOrEmpty())
{
UI.Show(ResUI.PleaseSelectRules);
_noticeHandler?.Enqueue(ResUI.PleaseSelectRules);
return;
}

Expand All @@ -208,15 +208,15 @@ public void RuleExportSelected()
if (lst.Count > 0)
{
Utile.SetClipboardData(JsonUtile.Serialize(lst));
//UI.Show(ResUI.OperationSuccess"));
//_noticeHandler?.Enqueue(ResUI.OperationSuccess"));
}
}

public void MoveRule(EMove eMove)
{
if (SelectedSource is null || SelectedSource.outboundTag.IsNullOrEmpty())
{
UI.Show(ResUI.PleaseSelectRules);
_noticeHandler?.Enqueue(ResUI.PleaseSelectRules);
return;
}

Expand All @@ -237,7 +237,7 @@ private void SaveRouting()
string remarks = SelectedRouting.remarks;
if (Utile.IsNullOrEmpty(remarks))
{
UI.Show(ResUI.PleaseFillRemarks);
_noticeHandler?.Enqueue(ResUI.PleaseFillRemarks);
return;
}
var item = SelectedRouting;
Expand All @@ -255,7 +255,7 @@ private void SaveRouting()
}
else
{
UI.ShowWarning(ResUI.OperationFailed);
_noticeHandler?.Enqueue(ResUI.OperationFailed);
}
}

Expand All @@ -282,7 +282,7 @@ private void ImportRulesFromFile()
if (AddBatchRoutingRules(SelectedRouting, result) == 0)
{
RefreshRulesItems();
UI.Show(ResUI.OperationSuccess);
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
}
}

Expand All @@ -292,7 +292,7 @@ private void ImportRulesFromClipboard()
if (AddBatchRoutingRules(SelectedRouting, clipboardData) == 0)
{
RefreshRulesItems();
UI.Show(ResUI.OperationSuccess);
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
}
}

Expand All @@ -301,7 +301,7 @@ private async Task ImportRulesFromUrl()
var url = SelectedRouting.url;
if (Utile.IsNullOrEmpty(url))
{
UI.Show(ResUI.MsgNeedUrl);
_noticeHandler?.Enqueue(ResUI.MsgNeedUrl);
return;
}

Expand All @@ -313,7 +313,7 @@ private async Task ImportRulesFromUrl()
{
RefreshRulesItems();
}));
UI.Show(ResUI.OperationSuccess);
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
}
}

Expand Down
8 changes: 4 additions & 4 deletions v2rayN/v2rayN/ViewModels/RoutingSettingViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private void SaveRouting()
}
else
{
UI.ShowWarning(ResUI.OperationFailed);
_noticeHandler?.Enqueue(ResUI.OperationFailed);
}
}

Expand All @@ -229,7 +229,7 @@ private void RoutingBasicImportRules()
BlockDomain = "geosite:category-ads-all";

//_noticeHandler?.Enqueue(ResUI.OperationSuccess);
UI.Show(ResUI.OperationSuccess);
_noticeHandler?.Enqueue(ResUI.OperationSuccess);
}

public void RoutingAdvancedEdit(bool blNew)
Expand Down Expand Up @@ -259,7 +259,7 @@ public void RoutingAdvancedRemove()
{
if (SelectedSource is null || SelectedSource.remarks.IsNullOrEmpty())
{
UI.Show(ResUI.PleaseSelectRules);
_noticeHandler?.Enqueue(ResUI.PleaseSelectRules);
return;
}
if (UI.ShowYesNo(ResUI.RemoveRules) == MessageBoxResult.No)
Expand All @@ -284,7 +284,7 @@ public void RoutingAdvancedSetDefault()
var item = LazyConfig.Instance.GetRoutingItem(SelectedSource?.id);
if (item is null)
{
UI.Show(ResUI.PleaseSelectRules);
_noticeHandler?.Enqueue(ResUI.PleaseSelectRules);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion v2rayN/v2rayN/ViewModels/SubEditViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private void SaveSub()
string remarks = SelectedSource.remarks;
if (string.IsNullOrEmpty(remarks))
{
UI.Show(ResUI.PleaseFillRemarks);
_noticeHandler?.Enqueue(ResUI.PleaseFillRemarks);
return;
}

Expand Down
2 changes: 1 addition & 1 deletion v2rayN/v2rayN/Views/GlobalHotkeySettingWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private void btnSave_Click(object sender, RoutedEventArgs e)
}
else
{
UI.ShowWarning(ResUI.OperationFailed);
UI.Show(ResUI.OperationFailed);
}
}

Expand Down

0 comments on commit 0185b3b

Please sign in to comment.