6
6
using System . IO ;
7
7
using System . Runtime . CompilerServices ;
8
8
using Windows . ApplicationModel . DataTransfer ;
9
+ using Windows . Foundation . Collections ;
9
10
using Windows . UI . Xaml ;
10
11
using Windows . UI . Xaml . Controls ;
11
12
using Windows . UI . Xaml . Input ;
@@ -76,6 +77,24 @@ public bool ShowEmptyRecycleBin
76
77
}
77
78
}
78
79
80
+ private bool _RecycleBinHasItems ;
81
+
82
+ public bool RecycleBinHasItems
83
+ {
84
+ get
85
+ {
86
+ return _RecycleBinHasItems ;
87
+ }
88
+ set
89
+ {
90
+ if ( value != _RecycleBinHasItems )
91
+ {
92
+ _RecycleBinHasItems = value ;
93
+ NotifyPropertyChanged ( "RecycleBinHasItems" ) ;
94
+ }
95
+ }
96
+ }
97
+
79
98
public event PropertyChangedEventHandler PropertyChanged ;
80
99
81
100
private void NotifyPropertyChanged ( [ CallerMemberName ] string propertyName = "" )
@@ -142,7 +161,7 @@ private void Sidebar_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sende
142
161
App . CurrentInstance . NavigationToolbar . PathControlDisplayText = App . CurrentInstance . FilesystemViewModel . WorkingDirectory ;
143
162
}
144
163
145
- private void NavigationViewLocationItem_RightTapped ( object sender , RightTappedRoutedEventArgs e )
164
+ private async void NavigationViewLocationItem_RightTapped ( object sender , RightTappedRoutedEventArgs e )
146
165
{
147
166
Microsoft . UI . Xaml . Controls . NavigationViewItem sidebarItem = ( Microsoft . UI . Xaml . Controls . NavigationViewItem ) sender ;
148
167
var item = sidebarItem . DataContext as LocationItem ;
@@ -158,6 +177,21 @@ private void NavigationViewLocationItem_RightTapped(object sender, RightTappedRo
158
177
159
178
if ( item . Path . Equals ( App . AppSettings . RecycleBinPath , StringComparison . OrdinalIgnoreCase ) )
160
179
{
180
+ var value = new ValueSet
181
+ {
182
+ { "Arguments" , "RecycleBin" } ,
183
+ { "action" , "Query" }
184
+ } ;
185
+ var response = await App . Connection . SendMessageAsync ( value ) ;
186
+ if ( response . Status == Windows . ApplicationModel . AppService . AppServiceResponseStatus . Success && response . Message . TryGetValue ( "NumItems" , out var numItems ) )
187
+ {
188
+ RecycleBinHasItems = ( long ) numItems > 0 ;
189
+ }
190
+ else
191
+ {
192
+ RecycleBinHasItems = false ;
193
+ }
194
+
161
195
ShowEmptyRecycleBin = true ;
162
196
ShowUnpinItem = true ;
163
197
}
0 commit comments