From 5551bdf9d07a754a8c0b773ceb42d746aef71866 Mon Sep 17 00:00:00 2001
From: Jack251970 <1160210343@qq.com>
Date: Fri, 13 Jun 2025 13:23:33 +0800
Subject: [PATCH] Remove uac dialog api function
---
Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs | 15 --
Flow.Launcher/Languages/en.xaml | 5 -
Flow.Launcher/PublicAPIInstance.cs | 3 -
Flow.Launcher/UACDialog.xaml | 155 ------------------
Flow.Launcher/UACDialog.xaml.cs | 109 ------------
5 files changed, 287 deletions(-)
delete mode 100644 Flow.Launcher/UACDialog.xaml
delete mode 100644 Flow.Launcher/UACDialog.xaml.cs
diff --git a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
index 9e8e203b3..9e28a72bd 100644
--- a/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
+++ b/Flow.Launcher.Plugin/Interfaces/IPublicAPI.cs
@@ -594,20 +594,5 @@ namespace Flow.Launcher.Plugin
/// The verb to use when starting the process, e.g. "runas" for elevated permissions. If not specified, no verb will be used.
/// Whether process is started successfully
public bool StartProcess(string filePath, string workingDirectory = "", string arguments = "", bool useShellExecute = true, string verb = "");
-
- ///
- /// Displays a User Account Control (UAC) dialog to request elevated permissions for the specified application.
- ///
- ///
- /// If Flow is running under administrator mode, executing elevated actions will not trigger UAC dialog.
- /// So this method is used to manually show the UAC dialog when needed.
- ///
- /// The name of the application requesting elevation. This will be displayed in the dialog.
- /// The file path to the icon that will be displayed in the dialog. Must be a valid path to an image file.
- /// The full file path of the executable requesting elevation. This is shown to the user for verification.
- /// A indicating the user's response to the dialog. Possible values include
- /// if the user grants permission,
- /// or if the user denies permission.
- public MessageBoxResult ShowUACDialog(string appName, string iconPath = "", string fullPath = "");
}
}
diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml
index aea9d4a60..97f294b14 100644
--- a/Flow.Launcher/Languages/en.xaml
+++ b/Flow.Launcher/Languages/en.xaml
@@ -379,11 +379,6 @@
Flow Launcher has been updated to {0}
Click here to view the release notes
-
- User Account Control
- Do you want to allow this app to make changes to your device?
- Program location: {0}
-
Select File Manager
Learn more
diff --git a/Flow.Launcher/PublicAPIInstance.cs b/Flow.Launcher/PublicAPIInstance.cs
index 461f24aa7..877e3feef 100644
--- a/Flow.Launcher/PublicAPIInstance.cs
+++ b/Flow.Launcher/PublicAPIInstance.cs
@@ -617,9 +617,6 @@ namespace Flow.Launcher
}
}
- public MessageBoxResult ShowUACDialog(string appName, string iconPath = "", string fullPath = "") =>
- UACDialog.Show(appName, iconPath, fullPath);
-
#endregion
#region Private Methods
diff --git a/Flow.Launcher/UACDialog.xaml b/Flow.Launcher/UACDialog.xaml
deleted file mode 100644
index 9d13a2c7b..000000000
--- a/Flow.Launcher/UACDialog.xaml
+++ /dev/null
@@ -1,155 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Flow.Launcher/UACDialog.xaml.cs b/Flow.Launcher/UACDialog.xaml.cs
deleted file mode 100644
index 040f10328..000000000
--- a/Flow.Launcher/UACDialog.xaml.cs
+++ /dev/null
@@ -1,109 +0,0 @@
-using System;
-using System.IO;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Input;
-
-namespace Flow.Launcher
-{
- public partial class UACDialog : Window
- {
- private static readonly string ClassName = nameof(UACDialog);
-
- private static UACDialog msgBox;
- private static MessageBoxResult _result = MessageBoxResult.None;
-
- private UACDialog()
- {
- InitializeComponent();
- }
-
- public static MessageBoxResult Show(string appName, string iconPath, string fullPath)
- {
- if (!Application.Current.Dispatcher.CheckAccess())
- {
- return Application.Current.Dispatcher.Invoke(() => Show(appName, iconPath, fullPath));
- }
-
- try
- {
- msgBox = new UACDialog();
-
- // Set icon & app name & program location
- _ = msgBox.SetImageAsync(iconPath);
- msgBox.AppName.Text = appName;
- if (string.IsNullOrEmpty(fullPath))
- {
- msgBox.ProgramLocation.Text = string.Format(
- App.API.GetTranslation("userAccountControlProgramLocation"),
- appName);
- }
- else
- {
- msgBox.ProgramLocation.Text = string.Format(
- App.API.GetTranslation("userAccountControlProgramLocation"),
- fullPath);
- }
-
- // Focus No by default
- msgBox.btnNo.Focus();
- _result = MessageBoxResult.No;
-
- msgBox.ShowDialog();
- return _result;
- }
- catch (Exception e)
- {
- App.API.LogError(ClassName, $"An error occurred: {e.Message}");
- msgBox = null;
- return MessageBoxResult.None;
- }
- }
-
- private async Task SetImageAsync(string imagePath)
- {
- try
- {
- if (string.IsNullOrEmpty(imagePath) || !File.Exists(imagePath))
- {
- Img.Visibility = Visibility.Collapsed;
- return;
- }
- var imageSource = await App.API.LoadImageAsync(imagePath);
- Img.Source = imageSource;
- Img.Visibility = Visibility.Visible;
- }
- catch (Exception ex)
- {
- App.API.LogException(ClassName, $"Failed to load UAC dialog image: {imagePath}", ex);
- Img.Visibility = Visibility.Collapsed;
- }
- }
-
- private void KeyEsc_OnPress(object sender, ExecutedRoutedEventArgs e)
- {
- _result = MessageBoxResult.Cancel;
- DialogResult = false;
- Close();
- }
-
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- if (sender == btnYes)
- _result = MessageBoxResult.Yes;
- else if (sender == btnNo)
- _result = MessageBoxResult.No;
- else
- _result = MessageBoxResult.None;
- msgBox.Close();
- msgBox = null;
- }
-
- private void Button_Cancel(object sender, RoutedEventArgs e)
- {
- _result = MessageBoxResult.Cancel;
- msgBox.Close();
- msgBox = null;
- }
- }
-}