Skip to content

Commit

Permalink
修复了右键菜单打开文件夹会在win自带资源管理器打开的bug;修复地址栏不显示下划线的bug;封装ContentDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
DearVa committed Jul 23, 2022
1 parent 216272f commit 67c3dd8
Show file tree
Hide file tree
Showing 15 changed files with 570 additions and 282 deletions.
10 changes: 8 additions & 2 deletions ExplorerEx/Command/FileItemCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,11 @@ public class FileItemCommand : ICommand {
/// <param name="item"></param>
/// <param name="runAs">是否以管理员方式执行,仅对可执行文件有效</param>
public static void OpenFile(FileListViewItem item, bool runAs) {
if (item is ZipFileItem zipFile) {
switch (item) {
case FolderItem folder:
_ = FileTabControl.MouseOverTabControl.SelectedTab.LoadDirectoryAsync(folder.FullPath);
break;
case ZipFileItem zipFile:
var zipArchive = zipFile.ZipArchive;
if (zipFile.IsExecutable && zipArchive.Entries.Count > 1) {
var result = hc.MessageBox.Show(new MessageBoxInfo {
Expand All @@ -255,8 +259,10 @@ public class FileItemCommand : ICommand {
var tempPath = FolderUtils.GetRandomFolderInTemp(Path.GetFileName(zipFile.ZipPath));
OpenFile(zipFile.Extract(tempPath, false), runAs);
});
} else {
break;
default:
OpenFile(item.FullPath, runAs);
break;
}
}

Expand Down
16 changes: 12 additions & 4 deletions ExplorerEx/Model/CreateFileItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ namespace ExplorerEx.Model;
/// 新建 一个文件
/// </summary>
public class CreateFileItem : SimpleNotifyPropertyChanged {
public static CreateFileItem NoExtension { get; } = new(string.Empty, false) {
Description = "File".L()
};

public ImageSource Icon { get; protected set; }

public string Description { get; protected set; }
Expand Down Expand Up @@ -66,12 +70,14 @@ public class CreateFileItem : SimpleNotifyPropertyChanged {
public static void UpdateItems() {
var newItems = (string[])Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\Discardable\PostSetup\ShellNew")!.GetValue("Classes")!;
items.Clear();
items.Add(new CreateDirectoryItem());
items.Add(CreateFolderItem.Singleton);
// items.Add(new CreateFileLinkItem());
// items.Add(new CreateFileItem(".txt"));
items.Add(NoExtension);
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 @@ -87,8 +93,10 @@ public class CreateFileItem : SimpleNotifyPropertyChanged {
/// <summary>
/// 新建文件夹
/// </summary>
internal class CreateDirectoryItem : CreateFileItem {
public CreateDirectoryItem() : base(null, false) {
internal class CreateFolderItem : CreateFileItem {
public static CreateFolderItem Singleton { get; } = new();

private CreateFolderItem() : base(null, false) {
Icon = EmptyFolderDrawingImage;
Description = "Folder".L();
}
Expand Down
18 changes: 18 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.

6 changes: 6 additions & 0 deletions ExplorerEx/Strings/Resources.en.resx
Original file line number Diff line number Diff line change
Expand Up @@ -551,4 +551,10 @@ For the application to run properly, it's recommanded that you first extract all
<data name="FatalError" xml:space="preserve">
<value>Fatal error</value>
</data>
<data name="Create" xml:space="preserve">
<value>Create</value>
</data>
<data name="File" xml:space="preserve">
<value>File</value>
</data>
</root>
6 changes: 6 additions & 0 deletions ExplorerEx/Strings/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -598,4 +598,10 @@ ExplorerEx [-h|--help] [-r|--runInBackground] [-o|--openInNewWindow] [-d|--requi
<data name="FatalError" xml:space="preserve">
<value>致命错误</value>
</data>
<data name="Create" xml:space="preserve">
<value>创建</value>
</data>
<data name="File" xml:space="preserve">
<value>文件</value>
</data>
</root>
46 changes: 46 additions & 0 deletions ExplorerEx/View/Controls/ContentDialog.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<Border x:Class="ExplorerEx.View.Controls.ContentDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ct="clr-namespace:ExplorerEx.View.Controls"
mc:Ignorable="d" KeyboardNavigation.TabNavigation="Cycle"
Background="#44000000" SnapsToDevicePixels="True" UseLayoutRounding="True" Opacity="0"
d:DataContext="{d:DesignInstance ct:ContentDialog}">
<Border BorderBrush="{DynamicResource PrimaryTextBrush}" CornerRadius="8"
HorizontalAlignment="Center" VerticalAlignment="Center" MinWidth="350" MinHeight="160"
Effect="{StaticResource EffectShadow4}">
<Border.RenderTransformOrigin>0.5,0.5</Border.RenderTransformOrigin>
<Border.RenderTransform>
<ScaleTransform x:Name="ScaleTf"/>
</Border.RenderTransform>
<ct:ClippingBorder CornerRadius="8" Background="{DynamicResource RegionBrush}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>

<TextBlock Grid.Row="0" Text="{Binding Title, Mode=OneWay}" FontSize="20" Margin="26,26,26,20"/>

<ContentPresenter x:Name="ContentPresenter" Grid.Row="1" Content="{Binding Content, Mode=OneWay}" Margin="26,0,26,20"/>

<Border Grid.Row="2" Background="{DynamicResource BorderBrush}" BorderBrush="{DynamicResource SecondaryBorderBrush}" BorderThickness="0,1,0,0">
<DockPanel HorizontalAlignment="Stretch" Margin="25,10">
<Button x:Name="PrimaryButton" TabIndex="0" Content="{Binding PrimaryButtonText, Mode=OneWay}" MinWidth="100" MaxWidth="200"
Visibility="{Binding PrimaryButtonText, Converter={StaticResource Object2VisibilityConverter}, Mode=OneWay}"
IsEnabled="{Binding IsPrimaryButtonEnabled, Mode=OneWay}" Command="{Binding PrimaryButtonCommand, Mode=OneWay}"
DockPanel.Dock="Left" Style="{StaticResource ButtonPrimary}" Click="ContentDialogPrimaryButton_OnClick"/>
<Button x:Name="SecondaryButton" TabIndex="1" Content="{Binding SecondaryButtonText, Mode=OneWay}" MinWidth="100" MaxWidth="200"
Visibility="{Binding SecondaryButtonText, Converter={StaticResource Object2VisibilityConverter}, Mode=OneWay}"
Command="{Binding SecondaryButtonCommand, Mode=OneWay}" Click="ContentDialogSecondaryButton_OnClick"/>
<Button TabIndex="2" Content="{Binding CancelButtonText, Mode=OneWay}" MinWidth="100" MaxWidth="200"
Visibility="{Binding CancelButtonText, Converter={StaticResource Object2VisibilityConverter}, Mode=OneWay}"
DockPanel.Dock="Right" HorizontalAlignment="Right" Command="{Binding CancelButtonCommand, Mode=OneWay}" Click="ContentDialogCancelButton_OnClick"/>
</DockPanel>
</Border>
</Grid>
</ct:ClippingBorder>
</Border>
</Border>

0 comments on commit 67c3dd8

Please sign in to comment.