33
44using Microsoft . Extensions . Logging ;
55using Microsoft . UI . Xaml ;
6+ using Microsoft . UI . Xaml . Controls ;
67using Microsoft . UI . Xaml . Input ;
78using System . IO ;
89using System . Runtime . InteropServices ;
@@ -135,7 +136,12 @@ public async Task DragOverAsync(DragEventArgs e)
135136 try
136137 {
137138 e . DragUIOverride . IsCaptionVisible = true ;
138- if ( workingDirectory . StartsWith ( Constants . UserEnvironmentPaths . RecycleBinPath , StringComparison . Ordinal ) )
139+ if ( e . DataView . Properties . TryGetValue ( "Files_ActionBinder" , out var actionBinder ) && actionBinder is "Files_ShelfBinder" )
140+ {
141+ e . DragUIOverride . Caption = string . Format ( Strings . LinkToFolderCaptionText . GetLocalizedResource ( ) , folderName ) ;
142+ e . AcceptedOperation = DataPackageOperation . Link ;
143+ }
144+ else if ( workingDirectory . StartsWith ( Constants . UserEnvironmentPaths . RecycleBinPath , StringComparison . Ordinal ) )
139145 {
140146 e . DragUIOverride . Caption = string . Format ( Strings . MoveToFolderCaptionText . GetLocalizedResource ( ) , folderName ) ;
141147 // Some applications such as Edge can't raise the drop event by the Move flag (#14008), so we set the Copy flag as well.
@@ -192,8 +198,6 @@ x.Item is ZipStorageFile ||
192198 public async Task DropAsync ( DragEventArgs e )
193199 {
194200 e . Handled = true ;
195-
196-
197201 if ( e . DataView . Contains ( StandardDataFormats . Uri ) && await e . DataView . GetUriAsync ( ) is { } uri )
198202 {
199203 if ( GitHelpers . IsValidRepoUrl ( uri . ToString ( ) ) )
@@ -203,24 +207,46 @@ public async Task DropAsync(DragEventArgs e)
203207 }
204208 }
205209
206- if ( FilesystemHelpers . HasDraggedStorageItems ( e . DataView ) )
210+ var deferral = e . GetDeferral ( ) ;
211+ try
207212 {
208- var deferral = e . GetDeferral ( ) ;
213+ if ( ! FilesystemHelpers . HasDraggedStorageItems ( e . DataView ) )
214+ return ;
209215
210- try
216+ if ( e . DataView . Properties . TryGetValue ( "Files_ActionBinder" , out var actionBinder ) && actionBinder is "Files_ShelfBinder" )
211217 {
212- await _associatedInstance . FilesystemHelpers . PerformOperationTypeAsync ( e . AcceptedOperation , e . DataView , _associatedInstance . ShellViewModel . WorkingDirectory , false , true ) ;
213- await _associatedInstance . RefreshIfNoWatcherExistsAsync ( ) ;
218+ if ( e . OriginalSource is not UIElement uiElement )
219+ return ;
220+
221+ var pwd = _associatedInstance . ShellViewModel . WorkingDirectory . TrimPath ( ) ;
222+ var folderName = Path . IsPathRooted ( pwd ) && Path . GetPathRoot ( pwd ) == pwd ? Path . GetPathRoot ( pwd ) : Path . GetFileName ( pwd ) ;
223+ var menuFlyout = new MenuFlyout ( )
224+ {
225+ Items =
226+ {
227+ new MenuFlyoutItem ( ) { Text = string . Format ( Strings . CopyToFolderCaptionText . GetLocalizedResource ( ) , folderName ) , Command = new AsyncRelayCommand ( async ct =>
228+ await _associatedInstance . FilesystemHelpers . PerformOperationTypeAsync ( DataPackageOperation . Copy , e . DataView , _associatedInstance . ShellViewModel . WorkingDirectory , false , true ) ) } ,
229+ new MenuFlyoutItem ( ) { Text = string . Format ( Strings . MoveToFolderCaptionText . GetLocalizedResource ( ) , folderName ) , Command = new AsyncRelayCommand ( async ct =>
230+ await _associatedInstance . FilesystemHelpers . PerformOperationTypeAsync ( DataPackageOperation . Move , e . DataView , _associatedInstance . ShellViewModel . WorkingDirectory , false , true ) ) }
231+ }
232+ } ;
233+
234+ menuFlyout . ShowAt ( uiElement , e . GetPosition ( uiElement ) ) ;
214235 }
215- finally
236+ else
216237 {
217- deferral . Complete ( ) ;
238+ await _associatedInstance . FilesystemHelpers . PerformOperationTypeAsync ( e . AcceptedOperation , e . DataView , _associatedInstance . ShellViewModel . WorkingDirectory , false , true ) ;
239+ await _associatedInstance . RefreshIfNoWatcherExistsAsync ( ) ;
218240 }
219241 }
242+ finally
243+ {
244+ deferral . Complete ( ) ;
245+ }
220246 }
221247
222248 public void Dispose ( )
223249 {
224250 }
225251 }
226- }
252+ }
0 commit comments