Skip to content

Commit

Permalink
修复切换标签页时选择可能出错的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
DearVa committed Jul 16, 2022
1 parent f24b0db commit 093551b
Show file tree
Hide file tree
Showing 24 changed files with 328 additions and 372 deletions.
2 changes: 1 addition & 1 deletion Build.cmd
Original file line number Diff line number Diff line change
@@ -1 +1 @@
dotnet build ./ExplorerEx/ExplorerEx.csproj -c Release
dotnet build ExplorerEx -c Release
1 change: 0 additions & 1 deletion ExplorerEx/App.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:m="clr-namespace:ExplorerEx.Model"
xmlns:e="clr-namespace:ExplorerEx.Model.Enums"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
mc:Ignorable="d">
<Application.Resources>
<ResourceDictionary>
Expand Down
5 changes: 3 additions & 2 deletions ExplorerEx/Command/FileItemCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ public class FileItemCommand : ICommand {
}
var destPaths = filePaths.Select(path => Path.Combine(Folder.FullPath, Path.GetFileName(path))).ToList();
try {
FileUtils.FileOperation(isCut ? FileOpType.Move : FileOpType.Copy, filePaths, destPaths);
await FileUtils.FileOperation(isCut ? FileOpType.Move : FileOpType.Copy, filePaths, destPaths);
FileTabControl.MouseOverTabControl.SelectedTab.FileListView.SelectItems(destPaths);
} catch (Exception e) {
Logger.Exception(e);
}
Expand Down Expand Up @@ -143,7 +144,7 @@ public class FileItemCommand : ICommand {
return;
}
try {
FileUtils.FileOperation(FileOpType.Delete, Items.Where(item => item is FileSystemItem).Select(item => item.FullPath).ToArray());
await FileUtils.FileOperation(FileOpType.Delete, Items.Where(item => item is FileSystemItem).Select(item => item.FullPath).ToArray());
} catch (Exception e) {
Logger.Exception(e);
}
Expand Down
123 changes: 0 additions & 123 deletions ExplorerEx/ExplorerEx - Backup.csproj

This file was deleted.

41 changes: 28 additions & 13 deletions ExplorerEx/Model/CreateFileItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,28 @@ public class CreateFileItem : SimpleNotifyPropertyChanged {
}

/// <summary>
/// 创建该文件,方法会自动枚举文件,防止重名
/// 自动枚举文件获取下一个可以创建的文件
/// </summary>
/// <param name="path">文件夹路径</param>
/// <returns>创建的文件名,不包括路径</returns>
public virtual string Create(string path) {
var fileName = FileUtils.GetNewFileName(path, $"{"New".L()} {Description}{Extension}");
File.Create(Path.Combine(path, fileName)).Dispose();
return fileName;
public virtual string GetCreateName(string path) {
return FileUtils.GetNewFileName(path, $"{"New".L()} {Description}{Extension}");
}

public virtual bool Create(string path, string fileName) {
var filePath = Path.Combine(path, fileName);
if (File.Exists(filePath)) {
return false;
}
File.Create(filePath).Dispose();
return true;
}

public static ObservableCollection<CreateFileItem> Items {
get {
UpdateItems();
if (items.Count == 0) {
UpdateItems();
}
return items;
}
}
Expand All @@ -58,12 +67,11 @@ public class CreateFileItem : SimpleNotifyPropertyChanged {
var newItems = (string[])Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\Discardable\PostSetup\ShellNew")!.GetValue("Classes")!;
items.Clear();
items.Add(new CreateDirectoryItem());
items.Add(new CreateFileLinkItem());
items.Add(new CreateFileItem(".txt"));
// items.Add(new CreateFileLinkItem());
// items.Add(new CreateFileItem(".txt"));
foreach (var item in newItems) {
if (item[0] == '.') {
switch (item) {
case ".txt":
case ".lnk":
case ".library-ms":
continue;
Expand All @@ -85,10 +93,17 @@ internal class CreateDirectoryItem : CreateFileItem {
Description = "Folder".L();
}

public override string Create(string path) {
var folderName = FileUtils.GetNewFileName(path, "New_folder".L());
Directory.CreateDirectory(Path.Combine(path, folderName));
return folderName;
public override string GetCreateName(string path) {
return FileUtils.GetNewFileName(path, "New_folder".L());
}

public override bool Create(string path, string folderName) {
var folderPath = Path.Combine(path, folderName);
if (Directory.Exists(folderPath)) {
return false;
}
Directory.CreateDirectory(folderPath);
return true;
}
}

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 @@ -140,7 +140,7 @@ public abstract class FileListViewItem : SimpleNotifyPropertyChanged {
/// </summary>
/// <param name="list"></param>
/// <param name="token"></param>
/// <param name="useLargeIcon"></param>
/// <param name="options"></param>
/// <returns></returns>
public static async Task LoadDetails(IReadOnlyCollection<FileListViewItem> list, CancellationToken token, LoadDetailsOptions options) {
try {
Expand Down
9 changes: 9 additions & 0 deletions ExplorerEx/Strings/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions ExplorerEx/Strings/Resources.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -542,4 +542,7 @@ For the application to run properly, it's recommanded that you first extract all
<data name="#ErrorExtractFiles" xml:space="preserve">
<value>Error occurs when extracting following files:</value>
</data>
<data name="FileOrFolderAlreadyExist" xml:space="preserve">
<value>File or Folder already exist.</value>
</data>
</root>
3 changes: 3 additions & 0 deletions ExplorerEx/Strings/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -589,4 +589,7 @@ ExplorerEx [-h|--help] [-r|--runInBackground] [-o|--openInNewWindow] [-d|--requi
<data name="FullPath" xml:space="preserve">
<value>完整路径</value>
</data>
<data name="FileOrFolderAlreadyExist" xml:space="preserve">
<value>文件或文件夹已存在。</value>
</data>
</root>
Loading

0 comments on commit 093551b

Please sign in to comment.