Review and clean up codes

This commit is contained in:
ema
2024-12-07 00:51:46 +08:00
parent 9d24d0fbe6
commit 4dff887ec1
2 changed files with 8 additions and 9 deletions

View File

@@ -129,8 +129,9 @@ namespace QuickLook.Plugin.HtmlViewer
// Ask user for unsafe schemes. Use dispatcher to avoid blocking thread. // Ask user for unsafe schemes. Use dispatcher to avoid blocking thread.
string associatedApp = GetAssociatedAppForScheme(uri.Scheme); string associatedApp = GetAssociatedAppForScheme(uri.Scheme);
Application.Current.Dispatcher.BeginInvoke(new Action(() => _ = Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{ {
// TODO: translation
var result = MessageBox.Show( var result = MessageBox.Show(
!string.IsNullOrEmpty(associatedApp) ? !string.IsNullOrEmpty(associatedApp) ?
$"The following link will open in {associatedApp}:\n{e.Uri}" : $"The following link will open:\n{e.Uri}", $"The following link will open in {associatedApp}:\n{e.Uri}" : $"The following link will open:\n{e.Uri}",
@@ -193,7 +194,7 @@ namespace QuickLook.Plugin.HtmlViewer
if (pcchOut > 0) if (pcchOut > 0)
{ {
StringBuilder pszOut = new StringBuilder((int)pcchOut); var pszOut = new StringBuilder((int)pcchOut);
AssocQueryString(AssocF.None, AssocStr.FriendlyAppName, scheme, null, pszOut, ref pcchOut); AssocQueryString(AssocF.None, AssocStr.FriendlyAppName, scheme, null, pszOut, ref pcchOut);
var appName = pszOut.ToString().Trim(); var appName = pszOut.ToString().Trim();
@@ -207,7 +208,7 @@ namespace QuickLook.Plugin.HtmlViewer
if (pcchOut > 0) if (pcchOut > 0)
{ {
StringBuilder pszOut = new StringBuilder((int)pcchOut); var pszOut = new StringBuilder((int)pcchOut);
AssocQueryString(AssocF.None, AssocStr.Executable, scheme, null, pszOut, ref pcchOut); AssocQueryString(AssocF.None, AssocStr.Executable, scheme, null, pszOut, ref pcchOut);
var exeName = pszOut.ToString().Trim(); var exeName = pszOut.ToString().Trim();
@@ -277,7 +278,7 @@ namespace QuickLook.Plugin.HtmlViewer
} }
catch (Exception e) catch (Exception e)
{ {
// We dont need to feel burdened by any exceptions // We don't need to feel burdened by any exceptions
Debug.WriteLine(e); Debug.WriteLine(e);
} }
}; };

View File

@@ -32,11 +32,9 @@ namespace QuickLook
{ {
/// <summary> /// <summary>
/// Windows 10 1903, aka 18362, broke the API. /// Windows 10 1903, aka 18362, broke the API.
/// --- /// - Before 18362, the #135 is AllowDarkModeForApp(BOOL)
/// Before 18362, the #135 is AllowDarkModeForApp(BOOL) /// - After 18362, the #135 is SetPreferredAppMode(PreferredMode)
/// After 18362, the #135 SetPreferredAppMode(PreferredMode) /// Since the support of AllowDarkModeForApp is unclear, it will not be considered to use
/// ---
/// Since the support of AllowDarkModeForApp is unclear, it will not be considered
/// </summary> /// </summary>
[DllImport("uxtheme.dll", EntryPoint = "#135", SetLastError = true, CharSet = CharSet.Unicode)] [DllImport("uxtheme.dll", EntryPoint = "#135", SetLastError = true, CharSet = CharSet.Unicode)]
private static extern int SetPreferredAppMode(int preferredAppMode); private static extern int SetPreferredAppMode(int preferredAppMode);