Code Cleanup

This commit is contained in:
ema
2025-05-25 01:32:38 +08:00
parent 05a2a819b7
commit 2e8fd2bae7
22 changed files with 68 additions and 145 deletions

View File

@@ -8,13 +8,6 @@
FontSize="14"
UseLayoutRounding="True"
mc:Ignorable="d">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/QuickLook.Common;component/Styles/MainWindowStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="15" />

View File

@@ -35,9 +35,6 @@ public partial class MsiInfoPanel : UserControl, IAppInfoPanel
{
InitializeComponent();
// apply global theme
Resources.MergedDictionaries[0].Clear();
string translationFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Translations.config");
productNameTitle.Text = TranslationHelper.Get("PRODUCT_NAME", translationFile);
productVersionTitle.Text = TranslationHelper.Get("PRODUCT_VERSION", translationFile);

View File

@@ -44,13 +44,13 @@ internal static class WindowsThumbnailProvider
private static extern int SHCreateItemFromParsingName(
[MarshalAs(UnmanagedType.LPWStr)] string path,
// The following parameter is not used - binding context.
IntPtr pbc,
nint pbc,
ref Guid riid,
[MarshalAs(UnmanagedType.Interface)] out IShellItem shellItem);
[DllImport("gdi32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool DeleteObject(IntPtr hObject);
private static extern bool DeleteObject(nint hObject);
public static Bitmap GetThumbnail(string fileName, int width, int height, ThumbnailOptions options)
{
@@ -71,7 +71,7 @@ internal static class WindowsThumbnailProvider
}
}
internal static Bitmap GetBitmapFromHBitmap(IntPtr nativeHBitmap)
internal static Bitmap GetBitmapFromHBitmap(nint nativeHBitmap)
{
var bmp = Image.FromHbitmap(nativeHBitmap);
@@ -115,7 +115,7 @@ internal static class WindowsThumbnailProvider
return srcBitmap;
}
private static IntPtr GetHBitmap(string fileName, int width, int height, ThumbnailOptions options)
private static nint GetHBitmap(string fileName, int width, int height, ThumbnailOptions options)
{
var shellItem2Guid = new Guid(IShellItem2Guid);
var retCode =
@@ -142,18 +142,18 @@ internal static class WindowsThumbnailProvider
[Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe")]
internal interface IShellItem
{
void BindToHandler(IntPtr pbc,
public void BindToHandler(nint pbc,
[MarshalAs(UnmanagedType.LPStruct)] Guid bhid,
[MarshalAs(UnmanagedType.LPStruct)] Guid riid,
out IntPtr ppv);
out nint ppv);
void GetParent(out IShellItem ppsi);
public void GetParent(out IShellItem ppsi);
void GetDisplayName(SIGDN sigdnName, out IntPtr ppszName);
public void GetDisplayName(SIGDN sigdnName, out nint ppszName);
void GetAttributes(uint sfgaoMask, out uint psfgaoAttribs);
public void GetAttributes(uint sfgaoMask, out uint psfgaoAttribs);
void Compare(IShellItem psi, uint hint, out int piOrder);
public void Compare(IShellItem psi, uint hint, out int piOrder);
}
internal enum SIGDN : uint
@@ -165,7 +165,7 @@ internal static class WindowsThumbnailProvider
PARENTRELATIVEEDITING = 0x80031001,
DESKTOPABSOLUTEEDITING = 0x8004c000,
FILESYSPATH = 0x80058000,
URL = 0x80068000
URL = 0x80068000,
}
internal enum HResult
@@ -182,7 +182,7 @@ internal static class WindowsThumbnailProvider
Win32ErrorCanceled = 1223,
Canceled = unchecked((int)0x800704C7),
ResourceInUse = unchecked((int)0x800700AA),
AccessDenied = unchecked((int)0x80030005)
AccessDenied = unchecked((int)0x80030005),
}
[ComImport]
@@ -191,10 +191,10 @@ internal static class WindowsThumbnailProvider
internal interface IShellItemImageFactory
{
[PreserveSig]
HResult GetImage(
public HResult GetImage(
[In][MarshalAs(UnmanagedType.Struct)] NativeSize size,
[In] ThumbnailOptions flags,
[Out] out IntPtr phbm);
[Out] out nint phbm);
}
[StructLayout(LayoutKind.Sequential)]

View File

@@ -20,9 +20,6 @@ using System.Windows.Controls;
namespace QuickLook.Plugin.ArchiveViewer;
/// <summary>
/// Interaction logic for ArchiveFileListView.xaml
/// </summary>
public partial class ArchiveFileListView : UserControl, IDisposable
{
public ArchiveFileListView()

View File

@@ -32,9 +32,6 @@ using System.Windows.Controls;
namespace QuickLook.Plugin.ArchiveViewer;
/// <summary>
/// Interaction logic for ArchiveInfoPanel.xaml
/// </summary>
public partial class ArchiveInfoPanel : UserControl, IDisposable, INotifyPropertyChanged
{
private readonly Dictionary<string, ArchiveFileEntry> _fileEntries = [];

View File

@@ -196,7 +196,7 @@ public static class IconManager
public const uint FileAttributeDirectory = 0x00000010;
[DllImport("Shell32.dll")]
public static extern IntPtr SHGetFileInfo(
public static extern nint SHGetFileInfo(
string pszPath,
uint dwFileAttributes,
ref Shfileinfo psfi,
@@ -208,7 +208,7 @@ public static class IconManager
public struct Shfileinfo
{
private const int Namesize = 80;
public readonly IntPtr hIcon;
public readonly nint hIcon;
private readonly int iIcon;
private readonly uint dwAttributes;
@@ -232,6 +232,6 @@ public static class IconManager
/// <param name="hIcon">Pointer to icon handle.</param>
/// <returns>N/A</returns>
[DllImport("User32.dll")]
public static extern int DestroyIcon(IntPtr hIcon);
public static extern int DestroyIcon(nint hIcon);
}
}

View File

@@ -31,9 +31,6 @@ using UtfUnknown;
namespace QuickLook.Plugin.CsvViewer;
/// <summary>
/// Interaction logic for CsvViewerPanel.xaml
/// </summary>
public partial class CsvViewerPanel : UserControl
{
public CsvViewerPanel()

View File

@@ -38,9 +38,6 @@ using System.Windows.Threading;
namespace QuickLook.Plugin.ImageViewer;
/// <summary>
/// Interaction logic for ImagePanel.xaml
/// </summary>
public partial class ImagePanel : UserControl, INotifyPropertyChanged, IDisposable
{
private Visibility _backgroundVisibility = Visibility.Visible;

View File

@@ -29,9 +29,6 @@ using System.Windows.Controls;
namespace QuickLook.Plugin.PDFViewer;
/// <summary>
/// Interaction logic for PdfViewer.xaml
/// </summary>
public partial class PdfViewerControl : UserControl, INotifyPropertyChanged, IDisposable
{
private int _changePageDeltaSum;

View File

@@ -8,13 +8,6 @@
FontSize="14"
UseLayoutRounding="True"
mc:Ignorable="d">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/QuickLook.Common;component/Styles/MainWindowStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="15" />

View File

@@ -29,27 +29,16 @@ namespace QuickLook.Plugin.PEViewer;
public partial class PEInfoPanel : UserControl
{
private bool _stop;
public PEInfoPanel()
{
InitializeComponent();
// apply global theme
Resources.MergedDictionaries[0].Clear();
string translationFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Translations.config");
totalSizeTitle.Text = TranslationHelper.Get("TOTAL_SIZE", translationFile);
fileVersionTitle.Text = TranslationHelper.Get("FILE_VERSION", translationFile);
productVersionTitle.Text = TranslationHelper.Get("PRODUCT_VERSION", translationFile);
}
public bool Stop
{
set => _stop = value;
get => _stop;
}
public void DisplayInfo(string path)
{
_ = Task.Run(() =>
@@ -71,8 +60,6 @@ public partial class PEInfoPanel : UserControl
var name = Path.GetFileName(path);
filename.Text = string.IsNullOrEmpty(name) ? path : name;
Stop = false;
_ = Task.Run(() =>
{
if (File.Exists(path))

View File

@@ -44,7 +44,7 @@ internal static class WindowsThumbnailProvider
private static extern int SHCreateItemFromParsingName(
[MarshalAs(UnmanagedType.LPWStr)] string path,
// The following parameter is not used - binding context.
IntPtr pbc,
nint pbc,
ref Guid riid,
[MarshalAs(UnmanagedType.Interface)] out IShellItem shellItem);
@@ -71,7 +71,7 @@ internal static class WindowsThumbnailProvider
}
}
internal static Bitmap GetBitmapFromHBitmap(IntPtr nativeHBitmap)
internal static Bitmap GetBitmapFromHBitmap(nint nativeHBitmap)
{
var bmp = Image.FromHbitmap(nativeHBitmap);
@@ -115,7 +115,7 @@ internal static class WindowsThumbnailProvider
return srcBitmap;
}
private static IntPtr GetHBitmap(string fileName, int width, int height, ThumbnailOptions options)
private static nint GetHBitmap(string fileName, int width, int height, ThumbnailOptions options)
{
var shellItem2Guid = new Guid(IShellItem2Guid);
var retCode =
@@ -142,18 +142,18 @@ internal static class WindowsThumbnailProvider
[Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe")]
internal interface IShellItem
{
void BindToHandler(IntPtr pbc,
public void BindToHandler(nint pbc,
[MarshalAs(UnmanagedType.LPStruct)] Guid bhid,
[MarshalAs(UnmanagedType.LPStruct)] Guid riid,
out IntPtr ppv);
out nint ppv);
void GetParent(out IShellItem ppsi);
public void GetParent(out IShellItem ppsi);
void GetDisplayName(SIGDN sigdnName, out IntPtr ppszName);
public void GetDisplayName(SIGDN sigdnName, out nint ppszName);
void GetAttributes(uint sfgaoMask, out uint psfgaoAttribs);
public void GetAttributes(uint sfgaoMask, out uint psfgaoAttribs);
void Compare(IShellItem psi, uint hint, out int piOrder);
public void Compare(IShellItem psi, uint hint, out int piOrder);
}
internal enum SIGDN : uint
@@ -165,7 +165,7 @@ internal static class WindowsThumbnailProvider
PARENTRELATIVEEDITING = 0x80031001,
DESKTOPABSOLUTEEDITING = 0x8004c000,
FILESYSPATH = 0x80058000,
URL = 0x80068000
URL = 0x80068000,
}
internal enum HResult
@@ -182,7 +182,7 @@ internal static class WindowsThumbnailProvider
Win32ErrorCanceled = 1223,
Canceled = unchecked((int)0x800704C7),
ResourceInUse = unchecked((int)0x800700AA),
AccessDenied = unchecked((int)0x80030005)
AccessDenied = unchecked((int)0x80030005),
}
[ComImport]
@@ -191,10 +191,10 @@ internal static class WindowsThumbnailProvider
internal interface IShellItemImageFactory
{
[PreserveSig]
HResult GetImage(
public HResult GetImage(
[In][MarshalAs(UnmanagedType.Struct)] NativeSize size,
[In] ThumbnailOptions flags,
[Out] out IntPtr phbm);
[Out] out nint phbm);
}
[StructLayout(LayoutKind.Sequential)]

View File

@@ -7,13 +7,6 @@
Height="200"
FontSize="14"
mc:Ignorable="d">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/QuickLook.Common;component/Styles/MainWindowStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid>
<Grid.ColumnDefinitions>

View File

@@ -37,9 +37,6 @@ public partial class PluginInfoPanel : UserControl
{
InitializeComponent();
// apply global theme
Resources.MergedDictionaries[0].Clear();
_path = path;
_context = context;
ReadInfo();

View File

@@ -45,9 +45,6 @@ using WPFMediaKit.DirectShow.MediaPlayers;
namespace QuickLook.Plugin.VideoViewer;
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class ViewerPanel : UserControl, IDisposable, INotifyPropertyChanged
{
private readonly ContextObject _context;

View File

@@ -23,9 +23,6 @@ using QuickLook.Common.Helpers;
namespace QuickLook.Controls.GlassLayer;
/// <summary>
/// Interaction logic for GlassLayer.xaml
/// </summary>
public partial class GlassLayer : UserControl
{
public GlassLayer()

View File

@@ -109,12 +109,12 @@ internal static class DataTransferManagerHelper
private static IDataTransferManagerInterop DataTransferManagerInterop =>
(IDataTransferManagerInterop)WindowsRuntimeMarshal.GetActivationFactory(typeof(DataTransferManager));
public static DataTransferManager GetForWindow(IntPtr hwnd)
public static DataTransferManager GetForWindow(nint hwnd)
{
return DataTransferManagerInterop.GetForWindow(hwnd, DTM_IID);
}
public static void ShowShareUIForWindow(IntPtr hwnd)
public static void ShowShareUIForWindow(nint hwnd)
{
DataTransferManagerInterop.ShowShareUIForWindow(hwnd);
}
@@ -124,8 +124,8 @@ internal static class DataTransferManagerHelper
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
private interface IDataTransferManagerInterop
{
DataTransferManager GetForWindow([In] IntPtr appWindow, [In] ref Guid riid);
public DataTransferManager GetForWindow([In] nint appWindow, [In] ref Guid riid);
void ShowShareUIForWindow(IntPtr appWindow);
public void ShowShareUIForWindow(nint appWindow);
}
}

View File

@@ -110,64 +110,64 @@ internal enum SLR_FLAGS
internal interface IShellLinkW
{
/// <summary>Retrieves the path and file name of a Shell link object</summary>
void GetPath([Out] [MarshalAs(UnmanagedType.LPWStr)]
public void GetPath([Out] [MarshalAs(UnmanagedType.LPWStr)]
StringBuilder pszFile, int cchMaxPath, out WIN32_FIND_DATAW pfd, SLGP_FLAGS fFlags);
/// <summary>Retrieves the list of item identifiers for a Shell link object</summary>
void GetIDList(out IntPtr ppidl);
public void GetIDList(out nint ppidl);
/// <summary>Sets the pointer to an item identifier list (PIDL) for a Shell link object.</summary>
void SetIDList(IntPtr pidl);
public void SetIDList(nint pidl);
/// <summary>Retrieves the description string for a Shell link object</summary>
void GetDescription([Out] [MarshalAs(UnmanagedType.LPWStr)]
public void GetDescription([Out] [MarshalAs(UnmanagedType.LPWStr)]
StringBuilder pszName, int cchMaxName);
/// <summary>Sets the description for a Shell link object. The description can be any application-defined string</summary>
void SetDescription([MarshalAs(UnmanagedType.LPWStr)] string pszName);
public void SetDescription([MarshalAs(UnmanagedType.LPWStr)] string pszName);
/// <summary>Retrieves the name of the working directory for a Shell link object</summary>
void GetWorkingDirectory([Out] [MarshalAs(UnmanagedType.LPWStr)]
public void GetWorkingDirectory([Out] [MarshalAs(UnmanagedType.LPWStr)]
StringBuilder pszDir, int cchMaxPath);
/// <summary>Sets the name of the working directory for a Shell link object</summary>
void SetWorkingDirectory([MarshalAs(UnmanagedType.LPWStr)] string pszDir);
public void SetWorkingDirectory([MarshalAs(UnmanagedType.LPWStr)] string pszDir);
/// <summary>Retrieves the command-line arguments associated with a Shell link object</summary>
void GetArguments([Out] [MarshalAs(UnmanagedType.LPWStr)]
public void GetArguments([Out] [MarshalAs(UnmanagedType.LPWStr)]
StringBuilder pszArgs, int cchMaxPath);
/// <summary>Sets the command-line arguments for a Shell link object</summary>
void SetArguments([MarshalAs(UnmanagedType.LPWStr)] string pszArgs);
public void SetArguments([MarshalAs(UnmanagedType.LPWStr)] string pszArgs);
/// <summary>Retrieves the hot key for a Shell link object</summary>
void GetHotkey(out short pwHotkey);
public void GetHotkey(out short pwHotkey);
/// <summary>Sets a hot key for a Shell link object</summary>
void SetHotkey(short wHotkey);
public void SetHotkey(short wHotkey);
/// <summary>Retrieves the show command for a Shell link object</summary>
void GetShowCmd(out int piShowCmd);
public void GetShowCmd(out int piShowCmd);
/// <summary>Sets the show command for a Shell link object. The show command sets the initial show state of the window.</summary>
void SetShowCmd(int iShowCmd);
public void SetShowCmd(int iShowCmd);
/// <summary>Retrieves the location (path and index) of the icon for a Shell link object</summary>
void GetIconLocation([Out] [MarshalAs(UnmanagedType.LPWStr)]
public void GetIconLocation([Out] [MarshalAs(UnmanagedType.LPWStr)]
StringBuilder pszIconPath,
int cchIconPath, out int piIcon);
/// <summary>Sets the location (path and index) of the icon for a Shell link object</summary>
void SetIconLocation([MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIcon);
public void SetIconLocation([MarshalAs(UnmanagedType.LPWStr)] string pszIconPath, int iIcon);
/// <summary>Sets the relative path to the Shell link object</summary>
void SetRelativePath([MarshalAs(UnmanagedType.LPWStr)] string pszPathRel, int dwReserved);
public void SetRelativePath([MarshalAs(UnmanagedType.LPWStr)] string pszPathRel, int dwReserved);
/// <summary>Attempts to find the target of a Shell link, even if it has been moved or renamed</summary>
void Resolve(IntPtr hwnd, SLR_FLAGS fFlags);
public void Resolve(nint hwnd, SLR_FLAGS fFlags);
/// <summary>Sets the path and file name of a Shell link object</summary>
void SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile);
public void SetPath([MarshalAs(UnmanagedType.LPWStr)] string pszFile);
}
// CLSID_ShellLink from ShlGuid.h

View File

@@ -9,13 +9,6 @@
FontSize="14"
UseLayoutRounding="True"
mc:Ignorable="d">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/QuickLook.Common;component/Styles/MainWindowStyles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="15" />

View File

@@ -25,9 +25,6 @@ using System.Windows.Controls;
namespace QuickLook.Plugin.InfoPanel;
/// <summary>
/// Interaction logic for InfoPanel.xaml
/// </summary>
public partial class InfoPanel : UserControl
{
private bool _stop;
@@ -35,9 +32,6 @@ public partial class InfoPanel : UserControl
public InfoPanel()
{
InitializeComponent();
// apply global theme
Resources.MergedDictionaries[0].Clear();
}
public bool Stop
@@ -48,7 +42,7 @@ public partial class InfoPanel : UserControl
public void DisplayInfo(string path)
{
Task.Run(() =>
_ = Task.Run(() =>
{
var scale = DisplayDeviceHelper.GetCurrentScaleFactor();

View File

@@ -44,13 +44,13 @@ internal static class WindowsThumbnailProvider
private static extern int SHCreateItemFromParsingName(
[MarshalAs(UnmanagedType.LPWStr)] string path,
// The following parameter is not used - binding context.
IntPtr pbc,
nint pbc,
ref Guid riid,
[MarshalAs(UnmanagedType.Interface)] out IShellItem shellItem);
[DllImport("gdi32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
private static extern bool DeleteObject(IntPtr hObject);
private static extern bool DeleteObject(nint hObject);
public static Bitmap GetThumbnail(string fileName, int width, int height, ThumbnailOptions options)
{
@@ -71,7 +71,7 @@ internal static class WindowsThumbnailProvider
}
}
internal static Bitmap GetBitmapFromHBitmap(IntPtr nativeHBitmap)
internal static Bitmap GetBitmapFromHBitmap(nint nativeHBitmap)
{
var bmp = Image.FromHbitmap(nativeHBitmap);
@@ -115,7 +115,7 @@ internal static class WindowsThumbnailProvider
return srcBitmap;
}
private static IntPtr GetHBitmap(string fileName, int width, int height, ThumbnailOptions options)
private static nint GetHBitmap(string fileName, int width, int height, ThumbnailOptions options)
{
var shellItem2Guid = new Guid(IShellItem2Guid);
var retCode =
@@ -142,18 +142,18 @@ internal static class WindowsThumbnailProvider
[Guid("43826d1e-e718-42ee-bc55-a1e261c37bfe")]
internal interface IShellItem
{
void BindToHandler(IntPtr pbc,
public void BindToHandler(nint pbc,
[MarshalAs(UnmanagedType.LPStruct)] Guid bhid,
[MarshalAs(UnmanagedType.LPStruct)] Guid riid,
out IntPtr ppv);
out nint ppv);
void GetParent(out IShellItem ppsi);
public void GetParent(out IShellItem ppsi);
void GetDisplayName(SIGDN sigdnName, out IntPtr ppszName);
public void GetDisplayName(SIGDN sigdnName, out nint ppszName);
void GetAttributes(uint sfgaoMask, out uint psfgaoAttribs);
public void GetAttributes(uint sfgaoMask, out uint psfgaoAttribs);
void Compare(IShellItem psi, uint hint, out int piOrder);
public void Compare(IShellItem psi, uint hint, out int piOrder);
}
internal enum SIGDN : uint
@@ -194,7 +194,7 @@ internal static class WindowsThumbnailProvider
HResult GetImage(
[In][MarshalAs(UnmanagedType.Struct)] NativeSize size,
[In] ThumbnailOptions flags,
[Out] out IntPtr phbm);
[Out] out nint phbm);
}
[StructLayout(LayoutKind.Sequential)]

View File

@@ -31,9 +31,6 @@ using Size = System.Windows.Size;
namespace QuickLook;
/// <summary>
/// Interaction logic for ViewerWindow.xaml
/// </summary>
public partial class ViewerWindow : Window
{
private Size _customWindowSize = Size.Empty;