Skip to content

Commit 3ae960d

Browse files
committed
Replace System.Windows.Message with MessageBoxEx
1 parent 7e9ed8e commit 3ae960d

15 files changed

+44
-50
lines changed

Flow.Launcher.Core/Configuration/Portable.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Flow.Launcher.Infrastructure.UserSettings;
1010
using Flow.Launcher.Plugin.SharedCommands;
1111
using System.Linq;
12+
using static Flow.Launcher.Core.MessageBoxEx;
1213

1314
namespace Flow.Launcher.Core.Configuration
1415
{
@@ -40,7 +41,7 @@ public void DisablePortableMode()
4041
#endif
4142
IndicateDeletion(DataLocation.PortableDataPath);
4243

43-
MessageBox.Show("Flow Launcher needs to restart to finish disabling portable mode, " +
44+
MessageBoxEx.Show("Flow Launcher needs to restart to finish disabling portable mode, " +
4445
"after the restart your portable data profile will be deleted and roaming data profile kept");
4546

4647
UpdateManager.RestartApp(Constant.ApplicationFileName);
@@ -64,7 +65,7 @@ public void EnablePortableMode()
6465
#endif
6566
IndicateDeletion(DataLocation.RoamingDataPath);
6667

67-
MessageBox.Show("Flow Launcher needs to restart to finish enabling portable mode, " +
68+
MessageBoxEx.Show("Flow Launcher needs to restart to finish enabling portable mode, " +
6869
"after the restart your roaming data profile will be deleted and portable data profile kept");
6970

7071
UpdateManager.RestartApp(Constant.ApplicationFileName);
@@ -159,9 +160,9 @@ public void PreStartCleanUpAfterPortabilityUpdate()
159160
{
160161
FilesFolders.RemoveFolderIfExists(roamingDataDir);
161162

162-
if (MessageBox.Show("Flow Launcher has detected you enabled portable mode, " +
163+
if (MessageBoxEx.Show("Flow Launcher has detected you enabled portable mode, " +
163164
"would you like to move it to a different location?", string.Empty,
164-
MessageBoxButton.YesNo) == MessageBoxResult.Yes)
165+
MessageBoxType.YesNo) == MessageBoxResult.Yes)
165166
{
166167
FilesFolders.OpenPath(Constant.RootDirectory);
167168

@@ -174,7 +175,7 @@ public void PreStartCleanUpAfterPortabilityUpdate()
174175
{
175176
FilesFolders.RemoveFolderIfExists(portableDataDir);
176177

177-
MessageBox.Show("Flow Launcher has detected you disabled portable mode, " +
178+
MessageBoxEx.Show("Flow Launcher has detected you disabled portable mode, " +
178179
"the relevant shortcuts and uninstaller entry have been created");
179180
}
180181
}
@@ -186,7 +187,7 @@ public bool CanUpdatePortability()
186187

187188
if (roamingLocationExists && portableLocationExists)
188189
{
189-
MessageBox.Show(string.Format("Flow Launcher detected your user data exists both in {0} and " +
190+
MessageBoxEx.Show(string.Format("Flow Launcher detected your user data exists both in {0} and " +
190191
"{1}. {2}{2}Please delete {1} in order to proceed. No changes have occurred.",
191192
DataLocation.PortableDataPath, DataLocation.RoamingDataPath, Environment.NewLine));
192193

Flow.Launcher/MessageBoxEx.xaml renamed to Flow.Launcher.Core/MessageBoxEx.xaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<Window
2-
x:Class="Flow.Launcher.MessageBoxEx"
2+
x:Class="Flow.Launcher.Core.MessageBoxEx"
33
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
44
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6-
xmlns:local="clr-namespace:Flow.Launcher"
6+
xmlns:local="clr-namespace:Flow.Launcher.Core"
77
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
88
x:Name="MessageBoxWindow"
99
Width="420"

Flow.Launcher/MessageBoxEx.xaml.cs renamed to Flow.Launcher.Core/MessageBoxEx.xaml.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,10 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
62
using System.Windows;
7-
using System.Windows.Controls;
8-
using System.Windows.Data;
9-
using System.Windows.Documents;
10-
using System.Windows.Forms;
113
using System.Windows.Input;
12-
using System.Windows.Media;
134
using System.Windows.Media.Imaging;
14-
using System.Windows.Shapes;
15-
using Flow.Launcher.Core.Resource;
165
using Flow.Launcher.Infrastructure;
17-
using Flow.Launcher.Infrastructure.Image;
18-
using YamlDotNet.Core.Tokens;
196

20-
namespace Flow.Launcher
7+
namespace Flow.Launcher.Core
218
{
229
public partial class MessageBoxEx : Window
2310
{

Flow.Launcher.Core/Resource/Internationalization.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using Flow.Launcher.Plugin;
1212
using System.Globalization;
1313
using System.Threading.Tasks;
14+
using static Flow.Launcher.Core.MessageBoxEx;
1415

1516
namespace Flow.Launcher.Core.Resource
1617
{
@@ -124,7 +125,7 @@ public bool PromptShouldUsePinyin(string languageCodeToSet)
124125
// "Do you want to search with pinyin?"
125126
string text = languageToSet == AvailableLanguages.Chinese ? "是否启用拼音搜索?" : "是否啓用拼音搜索?" ;
126127

127-
if (MessageBox.Show(text, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
128+
if (MessageBoxEx.Show(text, string.Empty, MessageBoxType.YesNo) == MessageBoxResult.No)
128129
return false;
129130

130131
return true;

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public bool ChangeTheme(string theme)
110110
Log.Error($"|Theme.ChangeTheme|Theme <{theme}> path can't be found");
111111
if (theme != defaultTheme)
112112
{
113-
MessageBox.Show(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_path_not_exists"), theme));
113+
MessageBoxEx.Show(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_path_not_exists"), theme));
114114
ChangeTheme(defaultTheme);
115115
}
116116
return false;
@@ -120,7 +120,7 @@ public bool ChangeTheme(string theme)
120120
Log.Error($"|Theme.ChangeTheme|Theme <{theme}> fail to parse");
121121
if (theme != defaultTheme)
122122
{
123-
MessageBox.Show(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_parse_error"), theme));
123+
MessageBoxEx.Show(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_parse_error"), theme));
124124
ChangeTheme(defaultTheme);
125125
}
126126
return false;

Flow.Launcher.Core/Updater.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Flow.Launcher.Plugin;
1818
using System.Text.Json.Serialization;
1919
using System.Threading;
20+
using static Flow.Launcher.Core.MessageBoxEx;
2021

2122
namespace Flow.Launcher.Core
2223
{
@@ -53,7 +54,7 @@ public async Task UpdateAppAsync(IPublicAPI api, bool silentUpdate = true)
5354
if (newReleaseVersion <= currentVersion)
5455
{
5556
if (!silentUpdate)
56-
MessageBox.Show(api.GetTranslation("update_flowlauncher_already_on_latest"));
57+
MessageBoxEx.Show(api.GetTranslation("update_flowlauncher_already_on_latest"));
5758
return;
5859
}
5960

@@ -70,7 +71,7 @@ public async Task UpdateAppAsync(IPublicAPI api, bool silentUpdate = true)
7071
var targetDestination = updateManager.RootAppDirectory + $"\\app-{newReleaseVersion.ToString()}\\{DataLocation.PortableFolderName}";
7172
FilesFolders.CopyAll(DataLocation.PortableDataPath, targetDestination);
7273
if (!FilesFolders.VerifyBothFolderFilesEqual(DataLocation.PortableDataPath, targetDestination))
73-
MessageBox.Show(string.Format(api.GetTranslation("update_flowlauncher_fail_moving_portable_user_profile_data"),
74+
MessageBoxEx.Show(string.Format(api.GetTranslation("update_flowlauncher_fail_moving_portable_user_profile_data"),
7475
DataLocation.PortableDataPath,
7576
targetDestination));
7677
}
@@ -83,7 +84,7 @@ public async Task UpdateAppAsync(IPublicAPI api, bool silentUpdate = true)
8384

8485
Log.Info($"|Updater.UpdateApp|Update success:{newVersionTips}");
8586

86-
if (MessageBox.Show(newVersionTips, api.GetTranslation("update_flowlauncher_new_update"), MessageBoxButton.YesNo) == MessageBoxResult.Yes)
87+
if (MessageBoxEx.Show(newVersionTips, api.GetTranslation("update_flowlauncher_new_update"), MessageBoxType.YesNo) == MessageBoxResult.Yes)
8788
{
8889
UpdateManager.RestartApp(Constant.ApplicationFileName);
8990
}

Flow.Launcher/ActionKeywords.xaml.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using Flow.Launcher.Core.Resource;
33
using Flow.Launcher.Plugin;
44
using Flow.Launcher.ViewModel;
5+
using Flow.Launcher.Core;
56

67
namespace Flow.Launcher
78
{
@@ -43,7 +44,7 @@ private void btnDone_OnClick(object sender, RoutedEventArgs _)
4344
else
4445
{
4546
string msg = translater.GetTranslation("newActionKeywordsHasBeenAssigned");
46-
MessageBox.Show(msg);
47+
MessageBoxEx.Show(msg);
4748
}
4849
}
4950
}

Flow.Launcher/CustomQueryHotkeySetting.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using System.Windows;
77
using System.Windows.Input;
88
using System.Windows.Controls;
9-
using Flow.Launcher.ViewModel;
9+
using Flow.Launcher.Core;
1010

1111
namespace Flow.Launcher
1212
{
@@ -63,7 +63,7 @@ public void UpdateItem(CustomPluginHotkey item)
6363
o.ActionKeyword == item.ActionKeyword && o.Hotkey == item.Hotkey);
6464
if (updateCustomHotkey == null)
6565
{
66-
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidPluginHotkey"));
66+
MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("invalidPluginHotkey"));
6767
Close();
6868
return;
6969
}

Flow.Launcher/CustomShortcutSetting.xaml.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Windows;
44
using System.Windows.Input;
55
using Flow.Launcher.SettingPages.ViewModels;
6+
using Flow.Launcher.Core;
67

78
namespace Flow.Launcher
89
{
@@ -42,13 +43,13 @@ private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
4243
{
4344
if (String.IsNullOrEmpty(Key) || String.IsNullOrEmpty(Value))
4445
{
45-
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("emptyShortcut"));
46+
MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("emptyShortcut"));
4647
return;
4748
}
4849
// Check if key is modified or adding a new one
4950
if (((update && originalKey != Key) || !update) && _hotkeyVm.DoesShortcutExist(Key))
5051
{
51-
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("duplicateShortcut"));
52+
MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("duplicateShortcut"));
5253
return;
5354
}
5455
DialogResult = !update || originalKey != Key || originalValue != Value;

Flow.Launcher/Helper/HotKeyMapper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
using NHotkey;
55
using NHotkey.Wpf;
66
using Flow.Launcher.Core.Resource;
7-
using System.Windows;
87
using Flow.Launcher.ViewModel;
8+
using Flow.Launcher.Core;
99

1010
namespace Flow.Launcher.Helper;
1111

@@ -46,7 +46,7 @@ internal static void SetHotkey(HotkeyModel hotkey, EventHandler<HotkeyEventArgs>
4646
{
4747
string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr);
4848
string errorMsgTitle = InternationalizationManager.Instance.GetTranslation("MessageBoxTitle");
49-
MessageBox.Show(errorMsg,errorMsgTitle);
49+
MessageBoxEx.Show(errorMsg, errorMsgTitle);
5050
}
5151
}
5252

0 commit comments

Comments
 (0)