Skip to content

Commit

Permalink
优化文件夹右键菜单项,添加粘贴按钮;更新部分图标为Fluent样式;修复exe文件不显示缩略图的bug;修复新建文件菜单不显示的bug;修…
Browse files Browse the repository at this point in the history
…复右键菜单无法新建文件的bug
  • Loading branch information
DearVa committed Aug 13, 2022
1 parent 92d1713 commit 641f1c5
Show file tree
Hide file tree
Showing 17 changed files with 132 additions and 161 deletions.
10 changes: 7 additions & 3 deletions ExplorerEx/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:m="clr-namespace:ExplorerEx.Model"
xmlns:e="clr-namespace:ExplorerEx.Model.Enums"
xmlns:u="clr-namespace:ExplorerEx.Utils"
mc:Ignorable="d">
Expand All @@ -27,6 +26,11 @@
<c:Bytes2StringConverter x:Key="Bytes2StringConverter"/>
<u:LangConverter x:Key="LangConverter"/>

<Style TargetType="Separator">
<Setter Property="Background" Value="{DynamicResource SecondaryBorderBrush}" />
<Setter Property="Margin" Value="-30,3,0,3" />
</Style>

<Style x:Key="ButtonLikeMenuItem" TargetType="MenuItem">
<Setter Property="Width" Value="38"/>
<Setter Property="Height" Value="34"/>
Expand Down Expand Up @@ -107,8 +111,8 @@

<Style x:Key="CreateMenuItemContainerStyle" TargetType="MenuItem"
BasedOn="{StaticResource MenuItemBaseStyle}">
<Setter Property="Icon" Value="{Binding (m:CreateFileItem.Icon)}"/>
<Setter Property="Header" Value="{Binding (m:CreateFileItem.Description)}"/>
<Setter Property="Icon" Value="{Binding Icon}"/>
<Setter Property="Header" Value="{Binding Description}"/>
<Setter Property="CommandParameter" Value="{Binding}"/>
</Style>

Expand Down
3 changes: 1 addition & 2 deletions ExplorerEx/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,8 @@ public partial class App {
}.Start();

ProcessorCount = Environment.ProcessorCount;

Shell32Interop.Initizlize();
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
IconHelper.InitializeDefaultIcons(Resources);
Settings.Current.LoadSettings();
ChangeTheme(((SolidColorBrush)SystemParameters.WindowGlassBrush).Color, false);

Expand Down
129 changes: 40 additions & 89 deletions ExplorerEx/Assets/Geometries.xaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion ExplorerEx/Assets/Svg/Copy.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ExplorerEx/Assets/Svg/Delete.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ExplorerEx/Assets/Svg/Paste.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ExplorerEx/Assets/Svg/Properties.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion ExplorerEx/Assets/Svg/Share.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion ExplorerEx/Model/CreateFileItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ namespace ExplorerEx.Model;
/// </summary>
public class CreateFileItem : NotifyPropertyChangedBase {
public static CreateFileItem NoExtension { get; } = new(string.Empty, false) {
Description = "File".L()
Description = "File".L(),
Icon = UnknownFileDrawingImage
};

public ImageSource? Icon { get; protected set; }
Expand Down
2 changes: 1 addition & 1 deletion ExplorerEx/Model/FileItem/Bookmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public class BookmarkItem : FileListViewItem, IFilterable {
public override void LoadIcon(LoadDetailsOptions options) {
if (FullPath.Length == 3) {
IsFolder = true;
Icon = GetPathThumbnail(FullPath);
Icon = GetDriveThumbnail(FullPath);
} else if (Directory.Exists(FullPath)) {
IsFolder = true;
Icon = FolderUtils.IsEmptyFolder(FullPath) ? EmptyFolderDrawingImage : FolderDrawingImage;
Expand Down
2 changes: 1 addition & 1 deletion ExplorerEx/Model/FileItem/DiskDriveItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public sealed class DiskDriveItem : FolderItem {
}

public override void LoadIcon(LoadDetailsOptions options) {
Icon = IconHelper.GetPathThumbnail(Drive.Name);
Icon = IconHelper.GetDriveThumbnail(Drive.Name);
}

public Task<List<FileListViewItem>> EnumerateItems() {
Expand Down
2 changes: 1 addition & 1 deletion ExplorerEx/Model/FileItem/FileListViewItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public class LoadDetailsOptions {
public bool UseLargeIcon { get; set; }

public void SetPreLoadIconByItemCount(int count) {
PreLoadIcon = count / App.ProcessorCount < 20;
PreLoadIcon = count < 20 * App.ProcessorCount;
}
}

Expand Down
2 changes: 1 addition & 1 deletion ExplorerEx/Model/FileItem/FolderOnlyItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ internal sealed class FolderOnlyItem : FileListViewItem {
if (driveInfo.IsReady) {
InitializeChildren();
}
Icon = IconHelper.GetPathThumbnail(driveInfo.Name);
Icon = IconHelper.GetDriveThumbnail(driveInfo.Name);
}

private void InitializeChildren() {
Expand Down
14 changes: 8 additions & 6 deletions ExplorerEx/Shell32/Shell32Interop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
using ExplorerEx.Command;
using ExplorerEx.Model;
using ExplorerEx.Utils;
using ExplorerEx.Win32;
using static ExplorerEx.Win32.Win32Interop;

namespace ExplorerEx.Shell32;
Expand Down Expand Up @@ -132,9 +131,9 @@ public struct OpenAsInfo {
/// Apparently (and hopefully) ordinal 727 isn't going to change.
///
[DllImport(Shell32, EntryPoint = "#727")]
public static extern int SHGetImageList(SHIL iImageList, [In] ref Guid riid, out IImageList ppv);
public static extern int SHGetImageList(SHIL iImageList, [In] ref Guid riid, out IntPtr ppv);

[DllImport(Shell32, CharSet = CharSet.Ansi)]
[DllImport(Shell32, CharSet = CharSet.Unicode)]
public static extern int SHGetFileInfo(string pszPath, FileAttribute dwFileAttributes, ref ShFileInfo psfi, int cbFileInfo, SHGFI uFlags);

[DllImport(Shell32)]
Expand Down Expand Up @@ -165,7 +164,7 @@ public struct OpenAsInfo {
public static extern int SHGetKnownFolderPath([MarshalAs(UnmanagedType.LPStruct)] Guid rfid, uint dwFlags, IntPtr hToken, out IntPtr pszPath);

[DllImport("ole32.dll")]
public static extern int CoCreateInstance(ref Guid clsid, [MarshalAs(UnmanagedType.IUnknown)] object inner, uint context, ref Guid uuid, out IntPtr rReturnedComObject);
public static extern int CoCreateInstance(ref Guid clsid, [MarshalAs(UnmanagedType.IUnknown)] object? inner, uint context, ref Guid uuid, out IntPtr rReturnedComObject);

[DllImport(Shell32, CharSet = CharSet.Unicode)]
public static extern int SHAssocEnumHandlers(string pszExtra, AssocFilter afFilter, out IEnumAssocHandlers ppEnumHandler);
Expand Down Expand Up @@ -242,7 +241,7 @@ public enum EmptyRecycleBinFlags {
/// <param name="lnkPath"></param>
/// <param name="description"></param>
/// <param name="iconPath"></param>
public static void CreateLnk(string targetPath, string lnkPath, string description = null, string iconPath = null) {
public static void CreateLnk(string targetPath, string lnkPath, string? description = null, string? iconPath = null) {
Marshal.ThrowExceptionForHR(CoCreateInstance(ref CLSID_ShellLink, null, 1, ref GUID_IShellLink, out var pShellLink));
var shellLink = GetTypedObjectForIUnknown<IShellLinkW>(pShellLink);
shellLink.SetPath(targetPath);
Expand Down Expand Up @@ -324,6 +323,8 @@ public enum EmptyRecycleBinFlags {
loadIconThread.Start();
}

public static void Initizlize() { }

private record LoadIconParameters(int index, ILD flags, IntPtr pIcon) {
public readonly int index = index;
public readonly ILD flags = flags;
Expand All @@ -333,7 +334,8 @@ private record LoadIconParameters(int index, ILD flags, IntPtr pIcon) {
}

private static void LoadIconThreadWork() {
Marshal.ThrowExceptionForHR(SHGetImageList(SHIL.Jumbo, ref GUID_IImageList, out var jumboImageList));
Marshal.ThrowExceptionForHR(SHGetImageList(SHIL.Jumbo, ref GUID_IImageList, out var pJumboImageList));
var jumboImageList = (IImageList)Marshal.GetTypedObjectForIUnknown(pJumboImageList, typeof(IImageList));

while (true) {
loadIconEvent.WaitOne();
Expand Down

0 comments on commit 641f1c5

Please sign in to comment.