Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
3ae960d
Replace System.Windows.Message with MessageBoxEx
Jack251970 Nov 24, 2024
6feca10
Improve MessageBoxEx paramters as System.Windows.MessageBox for reada…
Jack251970 Nov 24, 2024
ab087bd
Remove useless columns
Jack251970 Nov 24, 2024
fd78972
Improve OK MessageBoxEx display style
Jack251970 Nov 24, 2024
c103244
Merge branch 'dev4' of https://github.com/Jack251970/Flow.Launcher in…
Jack251970 Nov 24, 2024
b30cc4f
Replace System.Windows.MessageBox with MessageBoxEx
Jack251970 Nov 25, 2024
4bc9e86
Improve MessageBoxEx style as System.Windows.MessageBox
Jack251970 Nov 25, 2024
dcea54a
Fix parameter bug under release mode
Jack251970 Nov 26, 2024
897fd7a
Replace Flow.Launcher.Core.MessageBoxType & MessageBoxImage with Syst…
Jack251970 Nov 26, 2024
32c138b
Improve MessageBoxEx show function, making experience like System.Win…
Jack251970 Nov 26, 2024
7cb17ab
Improve title display experience & Fix three button dialog display is…
Jack251970 Nov 26, 2024
7ba8d58
Improve result handle & Improve exception support
Jack251970 Nov 27, 2024
9b75acd
Add ShowMsgBox functions in public api
Jack251970 Nov 27, 2024
534a111
Use public api to call ShowMsgBox functions & remove useless Core pro…
Jack251970 Nov 27, 2024
5d8f277
Use image loader to load image
Jack251970 Nov 27, 2024
5312505
Improve code quality
Jack251970 Nov 27, 2024
0d362b3
Add default messageboxShow parameter for functions in FilesFolders
Jack251970 Dec 1, 2024
b568d2d
Combine ShowMsgBox into one function.
Jack251970 Dec 1, 2024
57cbe10
Fix parameter bug
Jack251970 Dec 1, 2024
676a5b1
add defaults to MessageBoxEx Show & update WebSearch to use api call
jjw24 Dec 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Flow.Launcher.Core/Configuration/Portable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin.SharedCommands;
using System.Linq;
using static Flow.Launcher.Core.MessageBoxEx;

namespace Flow.Launcher.Core.Configuration
{
Expand Down Expand Up @@ -40,7 +41,7 @@ public void DisablePortableMode()
#endif
IndicateDeletion(DataLocation.PortableDataPath);

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

UpdateManager.RestartApp(Constant.ApplicationFileName);
Expand All @@ -64,7 +65,7 @@ public void EnablePortableMode()
#endif
IndicateDeletion(DataLocation.RoamingDataPath);

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

UpdateManager.RestartApp(Constant.ApplicationFileName);
Expand Down Expand Up @@ -159,9 +160,9 @@ public void PreStartCleanUpAfterPortabilityUpdate()
{
FilesFolders.RemoveFolderIfExists(roamingDataDir);

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

Expand All @@ -174,7 +175,7 @@ public void PreStartCleanUpAfterPortabilityUpdate()
{
FilesFolders.RemoveFolderIfExists(portableDataDir);

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

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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Window
x:Class="Flow.Launcher.MessageBoxEx"
x:Class="Flow.Launcher.Core.MessageBoxEx"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Flow.Launcher"
xmlns:local="clr-namespace:Flow.Launcher.Core"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Name="MessageBoxWindow"
Width="420"
Expand Down Expand Up @@ -33,14 +33,11 @@
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Button
Grid.Column="4"
Grid.Column="1"
Click="Button_Cancel"
Style="{StaticResource TitleBarCloseButtonStyle}">
<Path
Expand All @@ -63,8 +60,12 @@
</Grid>
</StackPanel>
</StackPanel>
<StackPanel Grid.Row="1" Margin="30 0 30 24">
<Grid Grid.Column="0" Margin="0 0 0 12">
<Grid Grid.Row="1" Margin="30 0 30 24">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" Margin="0 0 0 12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
Expand Down Expand Up @@ -94,14 +95,25 @@
</Grid>
<TextBlock
x:Name="DescTextBlock"
Grid.Column="1"
Grid.Row="1"
MaxWidth="400"
Margin="0 0 26 0"
HorizontalAlignment="Stretch"
FontSize="14"
TextAlignment="Left"
TextWrapping="Wrap" />
</StackPanel>
<TextBlock
x:Name="DescOnlyTextBlock"
Grid.Row="0"
Grid.RowSpan="2"
MaxWidth="400"
Margin="0 0 26 0"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
FontSize="14"
TextAlignment="Left"
TextWrapping="Wrap" />
</Grid>
<Border
Grid.Row="2"
Margin="0 0 0 0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Forms;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Flow.Launcher.Core.Resource;
using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Image;
using YamlDotNet.Core.Tokens;

namespace Flow.Launcher
namespace Flow.Launcher.Core
{
public partial class MessageBoxEx : Window
{
Expand Down Expand Up @@ -50,54 +37,62 @@ public enum MessageBoxImage


/// 1 parameter
public static MessageBoxResult Show(string msg)
public static MessageBoxResult Show(string messageBoxText)
{
return Show(string.Empty, msg, MessageBoxButton.OK, MessageBoxImage.None);
return Show(messageBoxText, string.Empty, MessageBoxButton.OK, MessageBoxImage.None);
}

// 2 parameter
public static MessageBoxResult Show(string caption, string text)
public static MessageBoxResult Show(string messageBoxText, string title)
{
return Show(caption, text, MessageBoxButton.OK, MessageBoxImage.None);
return Show(messageBoxText, title, MessageBoxButton.OK, MessageBoxImage.None);
}

/// 3 parameter
public static MessageBoxResult Show(string caption, string msg, MessageBoxType type)
public static MessageBoxResult Show(string messageBoxText, string title, MessageBoxType type)
{
switch (type)
{
case MessageBoxType.ConfirmationWithYesNo:
return Show(caption, msg, MessageBoxButton.YesNo,
return Show(messageBoxText, title, MessageBoxButton.YesNo,
MessageBoxImage.Question);
case MessageBoxType.YesNo:
return Show(caption, msg, MessageBoxButton.YesNo,
return Show(messageBoxText, title, MessageBoxButton.YesNo,
MessageBoxImage.Question);
case MessageBoxType.ConfirmationWithYesNoCancel:
return Show(caption, msg, MessageBoxButton.YesNoCancel,
return Show(messageBoxText, title, MessageBoxButton.YesNoCancel,
MessageBoxImage.Question);
case MessageBoxType.Information:
return Show(caption, msg, MessageBoxButton.OK,
return Show(messageBoxText, title, MessageBoxButton.OK,
MessageBoxImage.Information);
case MessageBoxType.Error:
return Show(caption, msg, MessageBoxButton.OK,
return Show(messageBoxText, title, MessageBoxButton.OK,
MessageBoxImage.Error);
case MessageBoxType.Warning:
return Show(caption, msg, MessageBoxButton.OK,
return Show(messageBoxText, title, MessageBoxButton.OK,
MessageBoxImage.Warning);
default:
return MessageBoxResult.No;
}
}

// 4 parameter, Final Display Message.
public static MessageBoxResult Show(string caption, string text, MessageBoxButton button, MessageBoxImage image)
public static MessageBoxResult Show(string messageBoxText, string title, MessageBoxButton button, MessageBoxImage image)
{
msgBox = new MessageBoxEx();
msgBox.TitleTextBlock.Text = text;
msgBox.DescTextBlock.Text = caption;
msgBox.Title = text;
if (title == string.Empty && button == MessageBoxButton.OK && image == MessageBoxImage.None)
{
msgBox.DescOnlyTextBlock.Text = messageBoxText;
msgBox.Title = messageBoxText;
}
else
{
msgBox.TitleTextBlock.Text = title;
msgBox.DescTextBlock.Text = messageBoxText;
msgBox.Title = title;
SetImageOfMessageBox(image);
}
SetVisibilityOfButtons(button);
SetImageOfMessageBox(image);
msgBox.ShowDialog();
return _result;
}
Expand Down
3 changes: 2 additions & 1 deletion Flow.Launcher.Core/Resource/Internationalization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Flow.Launcher.Plugin;
using System.Globalization;
using System.Threading.Tasks;
using static Flow.Launcher.Core.MessageBoxEx;

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

if (MessageBox.Show(text, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
if (MessageBoxEx.Show(text, string.Empty, MessageBoxType.YesNo) == MessageBoxResult.No)
return false;

return true;
Expand Down
4 changes: 2 additions & 2 deletions Flow.Launcher.Core/Resource/Theme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public bool ChangeTheme(string theme)
Log.Error($"|Theme.ChangeTheme|Theme <{theme}> path can't be found");
if (theme != defaultTheme)
{
MessageBox.Show(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_path_not_exists"), theme));
MessageBoxEx.Show(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_path_not_exists"), theme));
ChangeTheme(defaultTheme);
}
return false;
Expand All @@ -120,7 +120,7 @@ public bool ChangeTheme(string theme)
Log.Error($"|Theme.ChangeTheme|Theme <{theme}> fail to parse");
if (theme != defaultTheme)
{
MessageBox.Show(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_parse_error"), theme));
MessageBoxEx.Show(string.Format(InternationalizationManager.Instance.GetTranslation("theme_load_failure_parse_error"), theme));
ChangeTheme(defaultTheme);
}
return false;
Expand Down
7 changes: 4 additions & 3 deletions Flow.Launcher.Core/Updater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
using Flow.Launcher.Plugin;
using System.Text.Json.Serialization;
using System.Threading;
using static Flow.Launcher.Core.MessageBoxEx;

namespace Flow.Launcher.Core
{
Expand Down Expand Up @@ -53,7 +54,7 @@ public async Task UpdateAppAsync(IPublicAPI api, bool silentUpdate = true)
if (newReleaseVersion <= currentVersion)
{
if (!silentUpdate)
MessageBox.Show(api.GetTranslation("update_flowlauncher_already_on_latest"));
MessageBoxEx.Show(api.GetTranslation("update_flowlauncher_already_on_latest"));
return;
}

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

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

if (MessageBox.Show(newVersionTips, api.GetTranslation("update_flowlauncher_new_update"), MessageBoxButton.YesNo) == MessageBoxResult.Yes)
if (MessageBoxEx.Show(newVersionTips, api.GetTranslation("update_flowlauncher_new_update"), MessageBoxType.YesNo) == MessageBoxResult.Yes)
{
UpdateManager.RestartApp(Constant.ApplicationFileName);
}
Expand Down
3 changes: 2 additions & 1 deletion Flow.Launcher/ActionKeywords.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Flow.Launcher.Core.Resource;
using Flow.Launcher.Plugin;
using Flow.Launcher.ViewModel;
using Flow.Launcher.Core;

namespace Flow.Launcher
{
Expand Down Expand Up @@ -43,7 +44,7 @@ private void btnDone_OnClick(object sender, RoutedEventArgs _)
else
{
string msg = translater.GetTranslation("newActionKeywordsHasBeenAssigned");
MessageBox.Show(msg);
MessageBoxEx.Show(msg);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Flow.Launcher/CustomQueryHotkeySetting.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using System.Windows;
using System.Windows.Input;
using System.Windows.Controls;
using Flow.Launcher.ViewModel;
using Flow.Launcher.Core;

namespace Flow.Launcher
{
Expand Down Expand Up @@ -63,7 +63,7 @@ public void UpdateItem(CustomPluginHotkey item)
o.ActionKeyword == item.ActionKeyword && o.Hotkey == item.Hotkey);
if (updateCustomHotkey == null)
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidPluginHotkey"));
MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("invalidPluginHotkey"));
Close();
return;
}
Expand Down
5 changes: 3 additions & 2 deletions Flow.Launcher/CustomShortcutSetting.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Windows;
using System.Windows.Input;
using Flow.Launcher.SettingPages.ViewModels;
using Flow.Launcher.Core;

namespace Flow.Launcher
{
Expand Down Expand Up @@ -42,13 +43,13 @@ private void BtnAdd_OnClick(object sender, RoutedEventArgs e)
{
if (String.IsNullOrEmpty(Key) || String.IsNullOrEmpty(Value))
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("emptyShortcut"));
MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("emptyShortcut"));
return;
}
// Check if key is modified or adding a new one
if (((update && originalKey != Key) || !update) && _hotkeyVm.DoesShortcutExist(Key))
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("duplicateShortcut"));
MessageBoxEx.Show(InternationalizationManager.Instance.GetTranslation("duplicateShortcut"));
return;
}
DialogResult = !update || originalKey != Key || originalValue != Value;
Expand Down
4 changes: 2 additions & 2 deletions Flow.Launcher/Helper/HotKeyMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
using NHotkey;
using NHotkey.Wpf;
using Flow.Launcher.Core.Resource;
using System.Windows;
using Flow.Launcher.ViewModel;
using Flow.Launcher.Core;

namespace Flow.Launcher.Helper;

Expand Down Expand Up @@ -46,7 +46,7 @@ internal static void SetHotkey(HotkeyModel hotkey, EventHandler<HotkeyEventArgs>
{
string errorMsg = string.Format(InternationalizationManager.Instance.GetTranslation("registerHotkeyFailed"), hotkeyStr);
string errorMsgTitle = InternationalizationManager.Instance.GetTranslation("MessageBoxTitle");
MessageBox.Show(errorMsg,errorMsgTitle);
MessageBoxEx.Show(errorMsg, errorMsgTitle);
}
}

Expand Down
Loading
Loading