@@ -37,6 +37,7 @@ public abstract class BaseLayout : Page, INotifyPropertyChanged
37
37
public CurrentInstanceViewModel InstanceViewModel => App . CurrentInstance . InstanceViewModel ;
38
38
public DirectoryPropertiesViewModel DirectoryPropertiesViewModel { get ; }
39
39
public bool IsQuickLookEnabled { get ; set ; } = false ;
40
+ public MenuFlyout BaseLayoutContextFlyout { get ; set ; }
40
41
public MenuFlyout BaseLayoutItemContextFlyout { get ; set ; }
41
42
42
43
public ItemViewModel AssociatedViewModel = null ;
@@ -155,49 +156,47 @@ public BaseLayout()
155
156
156
157
public abstract void SetSelectedItemsOnUi ( List < ListedItem > selectedItems ) ;
157
158
158
- private void ClearShellContextMenus ( )
159
+ private void ClearShellContextMenus ( MenuFlyout menuFlyout )
159
160
{
160
- var contextMenuItems = BaseLayoutItemContextFlyout . Items . Where ( c => c . Tag != null && ParseContextMenuTag ( c . Tag ) . menuHandle != null ) . ToList ( ) ;
161
+ var contextMenuItems = menuFlyout . Items . Where ( c => c . Tag != null && ParseContextMenuTag ( c . Tag ) . menuHandle != null ) . ToList ( ) ;
161
162
for ( int i = 0 ; i < contextMenuItems . Count ; i ++ )
162
163
{
163
- BaseLayoutItemContextFlyout . Items . RemoveAt ( BaseLayoutItemContextFlyout . Items . IndexOf ( contextMenuItems [ i ] ) ) ;
164
+ menuFlyout . Items . RemoveAt ( menuFlyout . Items . IndexOf ( contextMenuItems [ i ] ) ) ;
164
165
}
165
- if ( BaseLayoutItemContextFlyout . Items [ 0 ] is MenuFlyoutSeparator flyoutSeperator )
166
+ if ( menuFlyout . Items [ 0 ] is MenuFlyoutSeparator flyoutSeperator )
166
167
{
167
- BaseLayoutItemContextFlyout . Items . RemoveAt ( BaseLayoutItemContextFlyout . Items . IndexOf ( flyoutSeperator ) ) ;
168
+ menuFlyout . Items . RemoveAt ( menuFlyout . Items . IndexOf ( flyoutSeperator ) ) ;
168
169
}
169
170
}
170
171
171
- public virtual void SetShellContextmenu ( bool shiftPressed , bool showOpenMenu )
172
+ public virtual void SetShellContextmenu ( MenuFlyout menuFlyout , bool shiftPressed , bool showOpenMenu )
172
173
{
173
- ClearShellContextMenus ( ) ;
174
- if ( _SelectedItems != null && _SelectedItems . Count > 0 )
174
+ ClearShellContextMenus ( menuFlyout ) ;
175
+ var currentBaseLayoutItemCount = menuFlyout . Items . Count ;
176
+ var maxItems = AppSettings . ShowAllContextMenuItems ? int . MaxValue : shiftPressed ? 6 : 4 ;
177
+ if ( App . Connection != null )
175
178
{
176
- var currentBaseLayoutItemCount = BaseLayoutItemContextFlyout . Items . Count ;
177
- var isDirectory = ! _SelectedItems . Any ( c => c . PrimaryItemAttribute == StorageItemTypes . File || c . PrimaryItemAttribute == StorageItemTypes . None ) ;
178
- var maxItems = AppSettings . ShowAllContextMenuItems ? int . MaxValue : shiftPressed ? 6 : 4 ;
179
- if ( App . Connection != null )
180
- {
181
- var response = App . Connection . SendMessageAsync ( new ValueSet ( ) {
179
+ var response = App . Connection . SendMessageAsync ( new ValueSet ( ) {
182
180
{ "Arguments" , "LoadContextMenu" } ,
183
- { "FilePath" , string . Join ( '|' , _SelectedItems . Select ( x => x . ItemPath ) ) } ,
181
+ { "FilePath" , IsItemSelected ?
182
+ string . Join ( '|' , _SelectedItems . Select ( x => x . ItemPath ) ) :
183
+ App . CurrentInstance . FilesystemViewModel . CurrentFolder . ItemPath } ,
184
184
{ "ExtendedMenu" , shiftPressed } ,
185
185
{ "ShowOpenMenu" , showOpenMenu } } ) . AsTask ( ) . Result ;
186
- if ( response . Status == Windows . ApplicationModel . AppService . AppServiceResponseStatus . Success
187
- && response . Message . ContainsKey ( "Handle" ) )
186
+ if ( response . Status == Windows . ApplicationModel . AppService . AppServiceResponseStatus . Success
187
+ && response . Message . ContainsKey ( "Handle" ) )
188
+ {
189
+ var contextMenu = JsonConvert . DeserializeObject < Win32ContextMenu > ( ( string ) response . Message [ "ContextMenu" ] ) ;
190
+ if ( contextMenu != null )
188
191
{
189
- var contextMenu = JsonConvert . DeserializeObject < Win32ContextMenu > ( ( string ) response . Message [ "ContextMenu" ] ) ;
190
- if ( contextMenu != null )
191
- {
192
- LoadMenuFlyoutItem ( BaseLayoutItemContextFlyout . Items , contextMenu . Items , ( string ) response . Message [ "Handle" ] , true , maxItems ) ;
193
- }
192
+ LoadMenuFlyoutItem ( menuFlyout . Items , contextMenu . Items , ( string ) response . Message [ "Handle" ] , true , maxItems ) ;
194
193
}
195
194
}
196
- var totalFlyoutItems = BaseLayoutItemContextFlyout . Items . Count - currentBaseLayoutItemCount ;
197
- if ( totalFlyoutItems > 0 && ! ( BaseLayoutItemContextFlyout . Items [ totalFlyoutItems ] is MenuFlyoutSeparator ) )
198
- {
199
- BaseLayoutItemContextFlyout . Items . Insert ( totalFlyoutItems , new MenuFlyoutSeparator ( ) ) ;
200
- }
195
+ }
196
+ var totalFlyoutItems = menuFlyout . Items . Count - currentBaseLayoutItemCount ;
197
+ if ( totalFlyoutItems > 0 && ! ( menuFlyout . Items [ totalFlyoutItems ] is MenuFlyoutSeparator ) )
198
+ {
199
+ menuFlyout . Items . Insert ( totalFlyoutItems , new MenuFlyoutSeparator ( ) ) ;
201
200
}
202
201
}
203
202
@@ -405,14 +404,20 @@ await App.Connection.SendMessageAsync(new ValueSet() {
405
404
}
406
405
}
407
406
407
+ public void RightClickContextMenu_Opening ( object sender , object e )
408
+ {
409
+ var shiftPressed = Window . Current . CoreWindow . GetKeyState ( VirtualKey . Shift ) . HasFlag ( CoreVirtualKeyStates . Down ) ;
410
+ SetShellContextmenu ( BaseLayoutContextFlyout , shiftPressed , false ) ;
411
+ }
412
+
408
413
public void RightClickItemContextMenu_Opening ( object sender , object e )
409
414
{
410
415
var shiftPressed = Window . Current . CoreWindow . GetKeyState ( VirtualKey . Shift ) . HasFlag ( CoreVirtualKeyStates . Down ) ;
411
416
var showOpenMenu = ( SelectedItems . Count == 1 )
412
417
&& SelectedItem . PrimaryItemAttribute == StorageItemTypes . File
413
418
&& ! string . IsNullOrEmpty ( SelectedItem . FileExtension )
414
419
&& SelectedItem . FileExtension . Equals ( ".msi" , StringComparison . OrdinalIgnoreCase ) ;
415
- SetShellContextmenu ( shiftPressed , showOpenMenu ) ;
420
+ SetShellContextmenu ( BaseLayoutItemContextFlyout , shiftPressed , showOpenMenu ) ;
416
421
417
422
if ( ! AppSettings . ShowCopyLocationOption )
418
423
{
0 commit comments