99using Flow . Launcher . Infrastructure . UserSettings ;
1010using Flow . Launcher . Plugin . SharedCommands ;
1111using System . Linq ;
12+ using CommunityToolkit . Mvvm . DependencyInjection ;
13+ using Flow . Launcher . Plugin ;
1214
1315namespace Flow . Launcher . Core . Configuration
1416{
1517 public class Portable : IPortable
1618 {
19+ private readonly IPublicAPI API = Ioc . Default . GetRequiredService < IPublicAPI > ( ) ;
20+
1721 /// <summary>
1822 /// As at Squirrel.Windows version 1.5.2, UpdateManager needs to be disposed after finish
1923 /// </summary>
@@ -40,7 +44,7 @@ public void DisablePortableMode()
4044#endif
4145 IndicateDeletion ( DataLocation . PortableDataPath ) ;
4246
43- MessageBoxEx . Show ( "Flow Launcher needs to restart to finish disabling portable mode, " +
47+ API . ShowMsgBox ( "Flow Launcher needs to restart to finish disabling portable mode, " +
4448 "after the restart your portable data profile will be deleted and roaming data profile kept" ) ;
4549
4650 UpdateManager . RestartApp ( Constant . ApplicationFileName ) ;
@@ -64,7 +68,7 @@ public void EnablePortableMode()
6468#endif
6569 IndicateDeletion ( DataLocation . RoamingDataPath ) ;
6670
67- MessageBoxEx . Show ( "Flow Launcher needs to restart to finish enabling portable mode, " +
71+ API . ShowMsgBox ( "Flow Launcher needs to restart to finish enabling portable mode, " +
6872 "after the restart your roaming data profile will be deleted and portable data profile kept" ) ;
6973
7074 UpdateManager . RestartApp ( Constant . ApplicationFileName ) ;
@@ -95,13 +99,13 @@ public void RemoveUninstallerEntry()
9599
96100 public void MoveUserDataFolder ( string fromLocation , string toLocation )
97101 {
98- FilesFolders . CopyAll ( fromLocation , toLocation , MessageBoxEx . Show ) ;
102+ FilesFolders . CopyAll ( fromLocation , toLocation , ( s ) => API . ShowMsgBox ( s ) ) ;
99103 VerifyUserDataAfterMove ( fromLocation , toLocation ) ;
100104 }
101105
102106 public void VerifyUserDataAfterMove ( string fromLocation , string toLocation )
103107 {
104- FilesFolders . VerifyBothFolderFilesEqual ( fromLocation , toLocation , MessageBoxEx . Show ) ;
108+ FilesFolders . VerifyBothFolderFilesEqual ( fromLocation , toLocation , ( s ) => API . ShowMsgBox ( s ) ) ;
105109 }
106110
107111 public void CreateShortcuts ( )
@@ -157,13 +161,13 @@ public void PreStartCleanUpAfterPortabilityUpdate()
157161 // delete it and prompt the user to pick the portable data location
158162 if ( File . Exists ( roamingDataDeleteFilePath ) )
159163 {
160- FilesFolders . RemoveFolderIfExists ( roamingDataDir , MessageBoxEx . Show ) ;
164+ FilesFolders . RemoveFolderIfExists ( roamingDataDir , ( s ) => API . ShowMsgBox ( s ) ) ;
161165
162- if ( MessageBoxEx . Show ( "Flow Launcher has detected you enabled portable mode, " +
166+ if ( API . ShowMsgBox ( "Flow Launcher has detected you enabled portable mode, " +
163167 "would you like to move it to a different location?" , string . Empty ,
164168 MessageBoxButton . YesNo ) == MessageBoxResult . Yes )
165169 {
166- FilesFolders . OpenPath ( Constant . RootDirectory , MessageBoxEx . Show ) ;
170+ FilesFolders . OpenPath ( Constant . RootDirectory , ( s ) => API . ShowMsgBox ( s ) ) ;
167171
168172 Environment . Exit ( 0 ) ;
169173 }
@@ -172,9 +176,9 @@ public void PreStartCleanUpAfterPortabilityUpdate()
172176 // delete it and notify the user about it.
173177 else if ( File . Exists ( portableDataDeleteFilePath ) )
174178 {
175- FilesFolders . RemoveFolderIfExists ( portableDataDir , MessageBoxEx . Show ) ;
179+ FilesFolders . RemoveFolderIfExists ( portableDataDir , ( s ) => API . ShowMsgBox ( s ) ) ;
176180
177- MessageBoxEx . Show ( "Flow Launcher has detected you disabled portable mode, " +
181+ API . ShowMsgBox ( "Flow Launcher has detected you disabled portable mode, " +
178182 "the relevant shortcuts and uninstaller entry have been created" ) ;
179183 }
180184 }
@@ -186,7 +190,7 @@ public bool CanUpdatePortability()
186190
187191 if ( roamingLocationExists && portableLocationExists )
188192 {
189- MessageBoxEx . Show ( string . Format ( "Flow Launcher detected your user data exists both in {0} and " +
193+ API . ShowMsgBox ( string . Format ( "Flow Launcher detected your user data exists both in {0} and " +
190194 "{1}. {2}{2}Please delete {1} in order to proceed. No changes have occurred." ,
191195 DataLocation . PortableDataPath , DataLocation . RoamingDataPath , Environment . NewLine ) ) ;
192196
0 commit comments