@@ -296,6 +296,85 @@ public Task OpenRevisionFileWithDefaultEditor(string file)
296296 } ) ;
297297 }
298298
299+ public ContextMenu CreateChangeContextMenuByFolder ( ChangeTreeNode node , List < Models . Change > changes )
300+ {
301+ var fullPath = Native . OS . GetAbsPath ( _repo . FullPath , node . FullPath ) ;
302+ var explore = new MenuItem ( ) ;
303+ explore . Header = App . Text ( "RevealFile" ) ;
304+ explore . Icon = App . CreateMenuIcon ( "Icons.Explore" ) ;
305+ explore . IsEnabled = Directory . Exists ( fullPath ) ;
306+ explore . Click += ( _ , ev ) =>
307+ {
308+ Native . OS . OpenInFileManager ( fullPath , true ) ;
309+ ev . Handled = true ;
310+ } ;
311+
312+ var history = new MenuItem ( ) ;
313+ history . Header = App . Text ( "DirHistories" ) ;
314+ history . Icon = App . CreateMenuIcon ( "Icons.Histories" ) ;
315+ history . Click += ( _ , ev ) =>
316+ {
317+ App . ShowWindow ( new DirHistories ( _repo , node . FullPath , _commit . SHA ) , false ) ;
318+ ev . Handled = true ;
319+ } ;
320+
321+ var patch = new MenuItem ( ) ;
322+ patch . Header = App . Text ( "FileCM.SaveAsPatch" ) ;
323+ patch . Icon = App . CreateMenuIcon ( "Icons.Diff" ) ;
324+ patch . Click += async ( _ , e ) =>
325+ {
326+ var storageProvider = App . GetStorageProvider ( ) ;
327+ if ( storageProvider == null )
328+ return ;
329+
330+ var options = new FilePickerSaveOptions ( ) ;
331+ options . Title = App . Text ( "FileCM.SaveAsPatch" ) ;
332+ options . DefaultExtension = ".patch" ;
333+ options . FileTypeChoices = [ new FilePickerFileType ( "Patch File" ) { Patterns = [ "*.patch" ] } ] ;
334+
335+ var baseRevision = _commit . Parents . Count == 0 ? Models . Commit . EmptyTreeSHA1 : _commit . Parents [ 0 ] ;
336+ var storageFile = await storageProvider . SaveFilePickerAsync ( options ) ;
337+ if ( storageFile != null )
338+ {
339+ var saveTo = storageFile . Path . LocalPath ;
340+ var succ = await Task . Run ( ( ) => Commands . SaveChangesAsPatch . ProcessRevisionCompareChanges ( _repo . FullPath , changes , baseRevision , _commit . SHA , saveTo ) ) ;
341+ if ( succ )
342+ App . SendNotification ( _repo . FullPath , App . Text ( "SaveAsPatchSuccess" ) ) ;
343+ }
344+
345+ e . Handled = true ;
346+ } ;
347+
348+ var copyPath = new MenuItem ( ) ;
349+ copyPath . Header = App . Text ( "CopyPath" ) ;
350+ copyPath . Icon = App . CreateMenuIcon ( "Icons.Copy" ) ;
351+ copyPath . Click += ( _ , ev ) =>
352+ {
353+ App . CopyText ( node . FullPath ) ;
354+ ev . Handled = true ;
355+ } ;
356+
357+ var copyFullPath = new MenuItem ( ) ;
358+ copyFullPath . Header = App . Text ( "CopyFullPath" ) ;
359+ copyFullPath . Icon = App . CreateMenuIcon ( "Icons.Copy" ) ;
360+ copyFullPath . Click += ( _ , e ) =>
361+ {
362+ App . CopyText ( fullPath ) ;
363+ e . Handled = true ;
364+ } ;
365+
366+ var menu = new ContextMenu ( ) ;
367+ menu . Items . Add ( explore ) ;
368+ menu . Items . Add ( new MenuItem { Header = "-" } ) ;
369+ menu . Items . Add ( history ) ;
370+ menu . Items . Add ( patch ) ;
371+ menu . Items . Add ( new MenuItem { Header = "-" } ) ;
372+ menu . Items . Add ( copyPath ) ;
373+ menu . Items . Add ( copyFullPath ) ;
374+
375+ return menu ;
376+ }
377+
299378 public ContextMenu CreateChangeContextMenu ( Models . Change change )
300379 {
301380 var diffWithMerger = new MenuItem ( ) ;
@@ -428,8 +507,61 @@ public ContextMenu CreateChangeContextMenu(Models.Change change)
428507 return menu ;
429508 }
430509
510+ public ContextMenu CreateRevisionFileContextMenuByFolder ( string path )
511+ {
512+ var fullPath = Native . OS . GetAbsPath ( _repo . FullPath , path ) ;
513+ var explore = new MenuItem ( ) ;
514+ explore . Header = App . Text ( "RevealFile" ) ;
515+ explore . Icon = App . CreateMenuIcon ( "Icons.Explore" ) ;
516+ explore . IsEnabled = Directory . Exists ( fullPath ) ;
517+ explore . Click += ( _ , ev ) =>
518+ {
519+ Native . OS . OpenInFileManager ( fullPath , true ) ;
520+ ev . Handled = true ;
521+ } ;
522+
523+ var history = new MenuItem ( ) ;
524+ history . Header = App . Text ( "DirHistories" ) ;
525+ history . Icon = App . CreateMenuIcon ( "Icons.Histories" ) ;
526+ history . Click += ( _ , ev ) =>
527+ {
528+ App . ShowWindow ( new DirHistories ( _repo , path , _commit . SHA ) , false ) ;
529+ ev . Handled = true ;
530+ } ;
531+
532+ var copyPath = new MenuItem ( ) ;
533+ copyPath . Header = App . Text ( "CopyPath" ) ;
534+ copyPath . Icon = App . CreateMenuIcon ( "Icons.Copy" ) ;
535+ copyPath . Click += ( _ , ev ) =>
536+ {
537+ App . CopyText ( path ) ;
538+ ev . Handled = true ;
539+ } ;
540+
541+ var copyFullPath = new MenuItem ( ) ;
542+ copyFullPath . Header = App . Text ( "CopyFullPath" ) ;
543+ copyFullPath . Icon = App . CreateMenuIcon ( "Icons.Copy" ) ;
544+ copyFullPath . Click += ( _ , e ) =>
545+ {
546+ App . CopyText ( fullPath ) ;
547+ e . Handled = true ;
548+ } ;
549+
550+ var menu = new ContextMenu ( ) ;
551+ menu . Items . Add ( explore ) ;
552+ menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
553+ menu . Items . Add ( history ) ;
554+ menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
555+ menu . Items . Add ( copyPath ) ;
556+ menu . Items . Add ( copyFullPath ) ;
557+ return menu ;
558+ }
559+
431560 public ContextMenu CreateRevisionFileContextMenu ( Models . Object file )
432561 {
562+ if ( file . Type == Models . ObjectType . Tree )
563+ return CreateRevisionFileContextMenuByFolder ( file . Path ) ;
564+
433565 var menu = new ContextMenu ( ) ;
434566 var fullPath = Native . OS . GetAbsPath ( _repo . FullPath , file . Path ) ;
435567 var explore = new MenuItem ( ) ;
0 commit comments