Skip to content

Commit 5248d91

Browse files
authored
Disable Clear recycle bin context menu when it is empty (#1358)
1 parent 7634b1e commit 5248d91

File tree

4 files changed

+157
-40
lines changed

4 files changed

+157
-40
lines changed

Files/Strings/zh-Hans/Resources.resw

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,115 @@
600600
<data name="TabStripAddNewTab.ToolTipService.ToolTip" xml:space="preserve">
601601
<value>新标签页(Ctrl+T)</value>
602602
</data>
603+
<data name="ItemSelected.Text" xml:space="preserve">
604+
<value>已选</value>
605+
</data>
606+
<data name="ItemsSelected.Text" xml:space="preserve">
607+
<value>已选</value>
608+
</data>
609+
<data name="ItemCount.Text" xml:space="preserve">
610+
<value>项目</value>
611+
</data>
612+
<data name="ItemsCount.Text" xml:space="preserve">
613+
<value>项目</value>
614+
</data>
615+
<data name="BaseLayoutContextFlyoutPinDirectoryToSidebar.Text" xml:space="preserve">
616+
<value>固定到侧边栏</value>
617+
</data>
618+
<data name="PropertiesAccessed.Text" xml:space="preserve">
619+
<value>访问:</value>
620+
</data>
621+
<data name="PropertiesOwner.Text" xml:space="preserve">
622+
<value>所有者:</value>
623+
</data>
624+
<data name="SettingsShowFileOwnerInProperties.Text" xml:space="preserve">
625+
<value>在属性中显示所有者</value>
626+
</data>
627+
<data name="ConfirmEmptyBinDialog.SecondaryButtonText" xml:space="preserve">
628+
<value>取消</value>
629+
</data>
630+
<data name="ConfirmEmptyBinDialogContent" xml:space="preserve">
631+
<value>是否确实要删除所有项目?</value>
632+
</data>
633+
<data name="ConfirmEmptyBinDialogTitle" xml:space="preserve">
634+
<value>空回收站</value>
635+
</data>
636+
<data name="ConfirmEmptyBinDialog.PrimaryButtonText" xml:space="preserve">
637+
<value>确定</value>
638+
</data>
639+
<data name="ItemSizeBytes" xml:space="preserve">
640+
<value>字节</value>
641+
</data>
642+
<data name="KiloByteSymbol" xml:space="preserve">
643+
<value>千字节(KB)</value>
644+
</data>
645+
<data name="MegaByteSymbol" xml:space="preserve">
646+
<value>兆字节(MB)</value>
647+
</data>
648+
<data name="GigaByteSymbol" xml:space="preserve">
649+
<value>吉字节(GB)</value>
650+
</data>
651+
<data name="TeraByteSymbol" xml:space="preserve">
652+
<value>太字节(TB)</value>
653+
</data>
654+
<data name="PetaByteSymbol" xml:space="preserve">
655+
<value>派字节(PB)</value>
656+
</data>
657+
<data name="ByteSymbol" xml:space="preserve">
658+
<value>字节(B)</value>
659+
</data>
660+
<data name="SettingsAppearanceDateFormatsTip.ToolTipService.ToolTip" xml:space="preserve">
661+
<value>了解日期格式相关信息</value>
662+
</data>
663+
<data name="BitlockerDialog.PrimaryButtonText" xml:space="preserve">
664+
<value>解锁</value>
665+
</data>
666+
<data name="BitlockerDialog.SecondaryButtonText" xml:space="preserve">
667+
<value>取消</value>
668+
</data>
669+
<data name="BitlockerDialog.Title" xml:space="preserve">
670+
<value>输入密码解锁驱动器</value>
671+
</data>
672+
<data name="BitlockerDialogInputText.PlaceholderText" xml:space="preserve">
673+
<value>密码</value>
674+
</data>
675+
<data name="BitlockerInvalidPwDialog.Text" xml:space="preserve">
676+
<value>请检查密码,然后重试。</value>
677+
</data>
678+
<data name="BitlockerInvalidPwDialog.Title" xml:space="preserve">
679+
<value>BitLocker 错误</value>
680+
</data>
681+
<data name="PropertiesFilesAndFoldersCount.Text" xml:space="preserve">
682+
<value>包含:</value>
683+
</data>
684+
<data name="PropertiesFilesAndFoldersCountString" xml:space="preserve">
685+
<value>{0:#,##0} 个文件, {1:#,##0} 个文件夹</value>
686+
</data>
687+
<data name="BaseLayoutContextFlyoutRunAsAdmin.Text" xml:space="preserve">
688+
<value>以管理员身份运行</value>
689+
</data>
690+
<data name="BaseLayoutContextFlyoutRunAsAnotherUser.Text" xml:space="preserve">
691+
<value>以其他身份运行</value>
692+
</data>
693+
<data name="PropertiesDriveItemTypesEquals" xml:space="preserve">
694+
<value>所有类型中 {0}</value>
695+
</data>
696+
<data name="PropertiesDriveItemTypeDifferent" xml:space="preserve">
697+
<value>不同类型</value>
698+
</data>
699+
<data name="PropertiesCombinedItemPath" xml:space="preserve">
700+
<value>全部中 {0}</value>
701+
</data>
702+
<data name="PropertiesDriveUsedSpace.Text" xml:space="preserve">
703+
<value>已用空间:</value>
704+
</data>
705+
<data name="PropertiesDriveFreeSpace.Text" xml:space="preserve">
706+
<value>可用空间:</value>
707+
</data>
708+
<data name="PropertiesDriveCapacity.Text" xml:space="preserve">
709+
<value>权限:</value>
710+
</data>
711+
<data name="PropertiesDriveFileSystem.Text" xml:space="preserve">
712+
<value>文件系统:</value>
713+
</data>
603714
</root>

Files/View Models/ItemViewModel.cs

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,44 +1036,44 @@ private void WatchForDirectoryChanges(string path)
10361036

10371037
uint action = notifyInfo.Action;
10381038

1039-
Debug.WriteLine("action: {0}", action);
1040-
try
1041-
{
1042-
switch (action)
1043-
{
1044-
case FILE_ACTION_ADDED:
1045-
AddFileOrFolder(FileName);
1046-
Debug.WriteLine("File " + FileName + " added to working directory.");
1047-
break;
1048-
1049-
case FILE_ACTION_REMOVED:
1050-
RemoveFileOrFolder(FilesAndFolders.ToList().First(x => x.ItemPath.Equals(FileName)));
1051-
Debug.WriteLine("File " + FileName + " removed from working directory.");
1052-
break;
1053-
1054-
case FILE_ACTION_MODIFIED:
1055-
Debug.WriteLine("File " + FileName + " had attributes modified in the working directory.");
1056-
break;
1057-
1058-
case FILE_ACTION_RENAMED_OLD_NAME:
1059-
RemoveFileOrFolder(FilesAndFolders.ToList().First(x => x.ItemPath.Equals(FileName)));
1060-
Debug.WriteLine("File " + FileName + " will be renamed in the working directory.");
1061-
break;
1062-
1063-
case FILE_ACTION_RENAMED_NEW_NAME:
1064-
AddFileOrFolder(FileName);
1065-
Debug.WriteLine("File " + FileName + " was renamed in the working directory.");
1066-
break;
1067-
1068-
default:
1069-
Debug.WriteLine("File " + FileName + " performed an action in the working directory.");
1070-
break;
1071-
}
1072-
}
1073-
catch (Exception)
1074-
{
1075-
// Prevent invalid operations
1076-
}
1039+
Debug.WriteLine("action: {0}", action);
1040+
try
1041+
{
1042+
switch (action)
1043+
{
1044+
case FILE_ACTION_ADDED:
1045+
AddFileOrFolder(FileName);
1046+
Debug.WriteLine("File " + FileName + " added to working directory.");
1047+
break;
1048+
1049+
case FILE_ACTION_REMOVED:
1050+
RemoveFileOrFolder(FilesAndFolders.ToList().First(x => x.ItemPath.Equals(FileName)));
1051+
Debug.WriteLine("File " + FileName + " removed from working directory.");
1052+
break;
1053+
1054+
case FILE_ACTION_MODIFIED:
1055+
Debug.WriteLine("File " + FileName + " had attributes modified in the working directory.");
1056+
break;
1057+
1058+
case FILE_ACTION_RENAMED_OLD_NAME:
1059+
RemoveFileOrFolder(FilesAndFolders.ToList().First(x => x.ItemPath.Equals(FileName)));
1060+
Debug.WriteLine("File " + FileName + " will be renamed in the working directory.");
1061+
break;
1062+
1063+
case FILE_ACTION_RENAMED_NEW_NAME:
1064+
AddFileOrFolder(FileName);
1065+
Debug.WriteLine("File " + FileName + " was renamed in the working directory.");
1066+
break;
1067+
1068+
default:
1069+
Debug.WriteLine("File " + FileName + " performed an action in the working directory.");
1070+
break;
1071+
}
1072+
}
1073+
catch (Exception)
1074+
{
1075+
// Prevent invalid operations
1076+
}
10771077

10781078
offset += notifyInfo.NextEntryOffset;
10791079

Files/Views/LayoutModes/GenericFileBrowser.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
xmlns:Interactivity="using:Microsoft.Xaml.Interactivity"
77
xmlns:behaviors="using:Microsoft.Toolkit.Uwp.UI.Behaviors"
88
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
9+
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
910
xmlns:controlsprimitives="using:Microsoft.Toolkit.Uwp.UI.Controls.Primitives"
1011
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
1112
xmlns:local="using:Files"
@@ -19,6 +20,8 @@
1920
mc:Ignorable="d">
2021

2122
<local:BaseLayout.Resources>
23+
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />
24+
2225
<MenuFlyout x:Key="BaseLayoutContextFlyout">
2326
<MenuFlyoutSubItem
2427
x:Name="SortByEmptySpace"
@@ -204,7 +207,7 @@
204207
x:Name="EmptyRecycleBin"
205208
x:Uid="BaseLayoutContextFlyoutEmptyRecycleBin"
206209
Click="{x:Bind local:App.CurrentInstance.InteractionOperations.EmptyRecycleBin_ClickAsync}"
207-
IsEnabled="True"
210+
IsEnabled="{x:Bind AssociatedViewModel.IsFolderEmptyTextDisplayed, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}"
208211
Text="Empty recycle bin">
209212
<MenuFlyoutItem.Icon>
210213
<FontIcon FontFamily="{StaticResource RecycleBinIcons}" Glyph="&#xEF88;" />

Files/Views/LayoutModes/GridViewBrowser.xaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,15 @@
99
xmlns:local2="using:Files.Filesystem"
1010
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
1111
xmlns:muxc="using:Microsoft.UI.Xaml.Controls"
12+
xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters"
1213
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
1314
NavigationCacheMode="Required"
1415
PointerPressed="GridViewBrowserViewer_PointerPressed"
1516
PointerWheelChanged="BaseLayout_PointerWheelChanged"
1617
mc:Ignorable="d">
1718
<local:BaseLayout.Resources>
19+
<converters:BoolNegationConverter x:Key="BoolNegationConverter" />
20+
1821
<MenuFlyout x:Key="BaseLayoutContextFlyout">
1922
<MenuFlyoutSubItem
2023
x:Name="SortByEmptySpace"
@@ -200,7 +203,7 @@
200203
x:Name="EmptyRecycleBin"
201204
x:Uid="BaseLayoutContextFlyoutEmptyRecycleBin"
202205
Click="{x:Bind local:App.CurrentInstance.InteractionOperations.EmptyRecycleBin_ClickAsync}"
203-
IsEnabled="True"
206+
IsEnabled="{x:Bind AssociatedViewModel.IsFolderEmptyTextDisplayed, Mode=OneWay, Converter={StaticResource BoolNegationConverter}}"
204207
Text="Empty recycle bin">
205208
<MenuFlyoutItem.Icon>
206209
<FontIcon FontFamily="{StaticResource RecycleBinIcons}" Glyph="&#xEF88;" />

0 commit comments

Comments
 (0)