@@ -583,44 +583,86 @@ public void RefreshAll()
583
583
Task . Run ( RefreshStashes ) ;
584
584
}
585
585
586
- public void OpenInFileManager ( )
586
+ public ContextMenu CreateContextMenuForExternalTools ( )
587
587
{
588
- Native . OS . OpenInFileManager ( _fullpath ) ;
589
- }
588
+ var menu = new ContextMenu ( ) ;
589
+ menu . Placement = PlacementMode . BottomEdgeAlignedLeft ;
590
590
591
- public void OpenInTerminal ( )
592
- {
593
- Native . OS . OpenTerminal ( _fullpath ) ;
594
- }
591
+ RenderOptions . SetBitmapInterpolationMode ( menu , BitmapInterpolationMode . HighQuality ) ;
592
+ RenderOptions . SetEdgeMode ( menu , EdgeMode . Antialias ) ;
593
+ RenderOptions . SetTextRenderingMode ( menu , TextRenderingMode . Antialias ) ;
594
+
595
+ var explore = new MenuItem ( ) ;
596
+ explore . Header = App . Text ( "Repository.Explore" ) ;
597
+ explore . Icon = App . CreateMenuIcon ( "Icons.Explore" ) ;
598
+ explore . Click += ( _ , e ) =>
599
+ {
600
+ Native . OS . OpenInFileManager ( _fullpath ) ;
601
+ e . Handled = true ;
602
+ } ;
603
+
604
+ var terminal = new MenuItem ( ) ;
605
+ terminal . Header = App . Text ( "Repository.Terminal" ) ;
606
+ terminal . Icon = App . CreateMenuIcon ( "Icons.Terminal" ) ;
607
+ terminal . Click += ( _ , e ) =>
608
+ {
609
+ Native . OS . OpenTerminal ( _fullpath ) ;
610
+ e . Handled = true ;
611
+ } ;
612
+
613
+ menu . Items . Add ( explore ) ;
614
+ menu . Items . Add ( terminal ) ;
595
615
596
- public ContextMenu CreateContextMenuForExternalTools ( )
597
- {
598
616
var tools = Native . OS . ExternalTools ;
599
- if ( tools . Count == 0 )
617
+ if ( tools . Count > 0 )
600
618
{
601
- App . RaiseException ( _fullpath , "No available external editors found!" ) ;
602
- return null ;
619
+ menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
620
+
621
+ foreach ( var tool in Native . OS . ExternalTools )
622
+ {
623
+ var dupTool = tool ;
624
+
625
+ var item = new MenuItem ( ) ;
626
+ item . Header = App . Text ( "Repository.OpenIn" , dupTool . Name ) ;
627
+ item . Icon = new Image { Width = 16 , Height = 16 , Source = dupTool . IconImage } ;
628
+ item . Click += ( _ , e ) =>
629
+ {
630
+ dupTool . Open ( _fullpath ) ;
631
+ e . Handled = true ;
632
+ } ;
633
+
634
+ menu . Items . Add ( item ) ;
635
+ }
603
636
}
604
637
605
- var menu = new ContextMenu ( ) ;
606
- menu . Placement = PlacementMode . BottomEdgeAlignedLeft ;
607
- RenderOptions . SetBitmapInterpolationMode ( menu , BitmapInterpolationMode . HighQuality ) ;
638
+ var urls = new Dictionary < string , string > ( ) ;
639
+ foreach ( var r in _remotes )
640
+ {
641
+ if ( r . TryGetVisitURL ( out var visit ) )
642
+ urls . Add ( r . Name , visit ) ;
643
+ }
608
644
609
- foreach ( var tool in tools )
645
+ if ( urls . Count > 0 )
610
646
{
611
- var dupTool = tool ;
647
+ menu . Items . Add ( new MenuItem ( ) { Header = "-" } ) ;
612
648
613
- var item = new MenuItem ( ) ;
614
- item . Header = App . Text ( "Repository.OpenIn" , dupTool . Name ) ;
615
- item . Icon = new Image { Width = 16 , Height = 16 , Source = dupTool . IconImage } ;
616
- item . Click += ( _ , e ) =>
649
+ foreach ( var url in urls )
617
650
{
618
- dupTool . Open ( _fullpath ) ;
619
- e . Handled = true ;
620
- } ;
651
+ var name = url . Key ;
652
+ var addr = url . Value ;
621
653
622
- menu . Items . Add ( item ) ;
623
- }
654
+ var item = new MenuItem ( ) ;
655
+ item . Header = App . Text ( "Repository.Visit" , name ) ;
656
+ item . Icon = App . CreateMenuIcon ( "Icons.Remotes" ) ;
657
+ item . Click += ( _ , e ) =>
658
+ {
659
+ Native . OS . OpenBrowser ( addr ) ;
660
+ e . Handled = true ;
661
+ } ;
662
+
663
+ menu . Items . Add ( item ) ;
664
+ }
665
+ }
624
666
625
667
return menu ;
626
668
}
0 commit comments