Skip to content

Commit ce6b4d9

Browse files
authored
Merge pull request #3093 from Jack251970/dev4
Replace original MessageBox with MessageBoxEx & Improve MessageBoxEx display style & Add new public api for using MessageBoxEx
2 parents 5f46ee7 + 676a5b1 commit ce6b4d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+376
-332
lines changed

Flow.Launcher.Core/Configuration/Portable.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void DisablePortableMode()
4040
#endif
4141
IndicateDeletion(DataLocation.PortableDataPath);
4242

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

4646
UpdateManager.RestartApp(Constant.ApplicationFileName);
@@ -64,7 +64,7 @@ public void EnablePortableMode()
6464
#endif
6565
IndicateDeletion(DataLocation.RoamingDataPath);
6666

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

7070
UpdateManager.RestartApp(Constant.ApplicationFileName);
@@ -95,13 +95,13 @@ public void RemoveUninstallerEntry()
9595

9696
public void MoveUserDataFolder(string fromLocation, string toLocation)
9797
{
98-
FilesFolders.CopyAll(fromLocation, toLocation);
98+
FilesFolders.CopyAll(fromLocation, toLocation, MessageBoxEx.Show);
9999
VerifyUserDataAfterMove(fromLocation, toLocation);
100100
}
101101

102102
public void VerifyUserDataAfterMove(string fromLocation, string toLocation)
103103
{
104-
FilesFolders.VerifyBothFolderFilesEqual(fromLocation, toLocation);
104+
FilesFolders.VerifyBothFolderFilesEqual(fromLocation, toLocation, MessageBoxEx.Show);
105105
}
106106

107107
public void CreateShortcuts()
@@ -157,13 +157,13 @@ public void PreStartCleanUpAfterPortabilityUpdate()
157157
// delete it and prompt the user to pick the portable data location
158158
if (File.Exists(roamingDataDeleteFilePath))
159159
{
160-
FilesFolders.RemoveFolderIfExists(roamingDataDir);
160+
FilesFolders.RemoveFolderIfExists(roamingDataDir, MessageBoxEx.Show);
161161

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

168168
Environment.Exit(0);
169169
}
@@ -172,9 +172,9 @@ public void PreStartCleanUpAfterPortabilityUpdate()
172172
// delete it and notify the user about it.
173173
else if (File.Exists(portableDataDeleteFilePath))
174174
{
175-
FilesFolders.RemoveFolderIfExists(portableDataDir);
175+
FilesFolders.RemoveFolderIfExists(portableDataDir, MessageBoxEx.Show);
176176

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

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

Flow.Launcher.Core/ExternalPlugins/Environments/AbstractPluginEnvironment.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
using Flow.Launcher.Plugin.SharedCommands;
55
using System;
66
using System.Collections.Generic;
7-
using System.IO;
87
using System.Linq;
8+
using System.Windows;
99
using System.Windows.Forms;
1010
using Flow.Launcher.Core.Resource;
1111

@@ -57,7 +57,7 @@ internal IEnumerable<PluginPair> Setup()
5757
EnvName,
5858
Environment.NewLine
5959
);
60-
if (MessageBox.Show(noRuntimeMessage, string.Empty, MessageBoxButtons.YesNo) == DialogResult.No)
60+
if (MessageBoxEx.Show(noRuntimeMessage, string.Empty, MessageBoxButton.YesNo) == MessageBoxResult.No)
6161
{
6262
var msg = string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginChooseRuntimeExecutable"), EnvName);
6363
string selectedFile;
@@ -82,7 +82,7 @@ internal IEnumerable<PluginPair> Setup()
8282
}
8383
else
8484
{
85-
MessageBox.Show(string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginUnableToSetExecutablePath"), Language));
85+
MessageBoxEx.Show(string.Format(InternationalizationManager.Instance.GetTranslation("runtimePluginUnableToSetExecutablePath"), Language));
8686
Log.Error("PluginsLoader",
8787
$"Not able to successfully set {EnvName} path, setting's plugin executable path variable is still an empty string.",
8888
$"{Language}Environment");
@@ -98,7 +98,7 @@ private void EnsureLatestInstalled(string expectedPath, string currentPath, stri
9898
if (expectedPath == currentPath)
9999
return;
100100

101-
FilesFolders.RemoveFolderIfExists(installedDirPath);
101+
FilesFolders.RemoveFolderIfExists(installedDirPath, MessageBoxEx.Show);
102102

103103
InstallEnvironment();
104104

Flow.Launcher.Core/ExternalPlugins/Environments/PythonEnvironment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ internal PythonEnvironment(List<PluginMetadata> pluginMetadataList, PluginsSetti
2828

2929
internal override void InstallEnvironment()
3030
{
31-
FilesFolders.RemoveFolderIfExists(InstallPath);
31+
FilesFolders.RemoveFolderIfExists(InstallPath, MessageBoxEx.Show);
3232

3333
// Python 3.11.4 is no longer Windows 7 compatible. If user is on Win 7 and
3434
// uses Python plugin they need to custom install and use v3.8.9

Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptEnvironment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal TypeScriptEnvironment(List<PluginMetadata> pluginMetadataList, PluginsS
2525

2626
internal override void InstallEnvironment()
2727
{
28-
FilesFolders.RemoveFolderIfExists(InstallPath);
28+
FilesFolders.RemoveFolderIfExists(InstallPath, MessageBoxEx.Show);
2929

3030
DroplexPackage.Drop(App.nodejs_16_18_0, InstallPath).Wait();
3131

Flow.Launcher.Core/ExternalPlugins/Environments/TypeScriptV2Environment.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal TypeScriptV2Environment(List<PluginMetadata> pluginMetadataList, Plugin
2525

2626
internal override void InstallEnvironment()
2727
{
28-
FilesFolders.RemoveFolderIfExists(InstallPath);
28+
FilesFolders.RemoveFolderIfExists(InstallPath, MessageBoxEx.Show);
2929

3030
DroplexPackage.Drop(App.nodejs_16_18_0, InstallPath).Wait();
3131

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

Lines changed: 38 additions & 25 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"
@@ -21,7 +21,7 @@
2121
<KeyBinding Key="Escape" Command="Close" />
2222
</Window.InputBindings>
2323
<Window.CommandBindings>
24-
<CommandBinding Command="Close" Executed="cmdEsc_OnPress" />
24+
<CommandBinding Command="Close" Executed="KeyEsc_OnPress" />
2525
</Window.CommandBindings>
2626
<Grid>
2727
<Grid.RowDefinitions>
@@ -33,14 +33,11 @@
3333
<StackPanel>
3434
<Grid>
3535
<Grid.ColumnDefinitions>
36-
<ColumnDefinition Width="Auto" />
3736
<ColumnDefinition Width="*" />
3837
<ColumnDefinition Width="Auto" />
39-
<ColumnDefinition Width="Auto" />
40-
<ColumnDefinition Width="Auto" />
4138
</Grid.ColumnDefinitions>
4239
<Button
43-
Grid.Column="4"
40+
Grid.Column="1"
4441
Click="Button_Cancel"
4542
Style="{StaticResource TitleBarCloseButtonStyle}">
4643
<Path
@@ -63,8 +60,12 @@
6360
</Grid>
6461
</StackPanel>
6562
</StackPanel>
66-
<StackPanel Grid.Row="1" Margin="30 0 30 24">
67-
<Grid Grid.Column="0" Margin="0 0 0 12">
63+
<Grid Grid.Row="1" Margin="30 0 30 24">
64+
<Grid.RowDefinitions>
65+
<RowDefinition Height="Auto" />
66+
<RowDefinition Height="Auto" />
67+
</Grid.RowDefinitions>
68+
<Grid Grid.Row="0" Margin="0 0 0 12">
6869
<Grid.ColumnDefinitions>
6970
<ColumnDefinition Width="Auto" />
7071
<ColumnDefinition Width="*" />
@@ -74,7 +75,7 @@
7475
Grid.Column="0"
7576
Width="18"
7677
Height="18"
77-
Margin="0 0 0 0"
78+
Margin="0 0 10 0"
7879
HorizontalAlignment="Left"
7980
VerticalAlignment="Center"
8081
RenderOptions.BitmapScalingMode="Fant"
@@ -84,7 +85,7 @@
8485
x:Name="TitleTextBlock"
8586
Grid.Column="1"
8687
MaxWidth="400"
87-
Margin="10 0 26 0"
88+
Margin="0 0 26 0"
8889
VerticalAlignment="Center"
8990
FontFamily="Segoe UI"
9091
FontSize="20"
@@ -94,14 +95,26 @@
9495
</Grid>
9596
<TextBlock
9697
x:Name="DescTextBlock"
97-
Grid.Column="1"
98+
Grid.Row="1"
9899
MaxWidth="400"
99100
Margin="0 0 26 0"
100101
HorizontalAlignment="Stretch"
101102
FontSize="14"
102103
TextAlignment="Left"
103104
TextWrapping="Wrap" />
104-
</StackPanel>
105+
<TextBlock
106+
x:Name="DescOnlyTextBlock"
107+
Grid.Row="0"
108+
Grid.RowSpan="2"
109+
MaxWidth="400"
110+
Margin="0 0 26 0"
111+
HorizontalAlignment="Stretch"
112+
VerticalAlignment="Center"
113+
FontSize="14"
114+
TextAlignment="Left"
115+
TextWrapping="Wrap"
116+
Visibility="Collapsed" />
117+
</Grid>
105118
<Border
106119
Grid.Row="2"
107120
Margin="0 0 0 0"
@@ -113,29 +126,29 @@
113126
VerticalAlignment="Center"
114127
Orientation="Horizontal">
115128
<Button
116-
x:Name="btnCancel"
117-
MinWidth="140"
129+
x:Name="btnOk"
130+
MinWidth="120"
118131
Margin="5 0 5 0"
119132
Click="Button_Click"
120-
Content="{DynamicResource commonCancel}" />
133+
Content="{DynamicResource commonOK}" />
121134
<Button
122-
x:Name="btnNo"
123-
MinWidth="140"
135+
x:Name="btnYes"
136+
MinWidth="120"
124137
Margin="5 0 5 0"
125138
Click="Button_Click"
126-
Content="{DynamicResource commonNo}" />
139+
Content="{DynamicResource commonYes}" />
127140
<Button
128-
x:Name="btnOk"
129-
MinWidth="140"
141+
x:Name="btnNo"
142+
MinWidth="120"
130143
Margin="5 0 5 0"
131144
Click="Button_Click"
132-
Content="{DynamicResource commonOK}" />
145+
Content="{DynamicResource commonNo}" />
133146
<Button
134-
x:Name="btnYes"
135-
MinWidth="140"
147+
x:Name="btnCancel"
148+
MinWidth="120"
136149
Margin="5 0 5 0"
137150
Click="Button_Click"
138-
Content="{DynamicResource commonYes}" />
151+
Content="{DynamicResource commonCancel}" />
139152
</WrapPanel>
140153
</Border>
141154
</Grid>

0 commit comments

Comments
 (0)