@@ -12,34 +12,23 @@ namespace SourceGit.Models
1212{
1313 public class ExternalTool
1414 {
15- public string Name { get ; set ; } = string . Empty ;
16- public string Icon { get ; set ; } = string . Empty ;
17- public string Executable { get ; set ; } = string . Empty ;
18- public string OpenCmdArgs { get ; set ; } = string . Empty ;
15+ public string Name { get ; private set ; } = string . Empty ;
16+ public string Executable { get ; private set ; } = string . Empty ;
17+ public string OpenCmdArgs { get ; private set ; } = string . Empty ;
18+ public Bitmap IconImage { get ; private set ; } = null ;
1919
20- public Bitmap IconImage
20+ public ExternalTool ( string name , string icon , string executable , string openCmdArgs )
2121 {
22- get
23- {
24- if ( _isFirstTimeGetIcon )
25- {
26- _isFirstTimeGetIcon = false ;
27-
28- if ( ! string . IsNullOrWhiteSpace ( Icon ) )
29- {
30- try
31- {
32- var icon = AssetLoader . Open ( new Uri ( $ "avares://SourceGit/Resources/ExternalToolIcons/{ Icon } .png", UriKind . RelativeOrAbsolute ) ) ;
33- _iconImage = new Bitmap ( icon ) ;
34- }
35- catch
36- {
37- }
38- }
39- }
22+ Name = name ;
23+ Executable = executable ;
24+ OpenCmdArgs = openCmdArgs ;
4025
41- return _iconImage ;
26+ try
27+ {
28+ var asset = AssetLoader . Open ( new Uri ( $ "avares://SourceGit/Resources/ExternalToolIcons/{ icon } .png", UriKind . RelativeOrAbsolute ) ) ;
29+ IconImage = new Bitmap ( asset ) ;
4230 }
31+ catch { }
4332 }
4433
4534 public void Open ( string repo )
@@ -52,9 +41,6 @@ public void Open(string repo)
5241 UseShellExecute = false ,
5342 } ) ;
5443 }
55-
56- private bool _isFirstTimeGetIcon = true ;
57- private Bitmap _iconImage = null ;
5844 }
5945
6046 public class JetBrainsState
@@ -107,13 +93,7 @@ public void TryAdd(string name, string icon, string args, string env, Func<strin
10793 return ;
10894 }
10995
110- Founded . Add ( new ExternalTool
111- {
112- Name = name ,
113- Icon = icon ,
114- OpenCmdArgs = args ,
115- Executable = path
116- } ) ;
96+ Founded . Add ( new ExternalTool ( name , icon , path , args ) ) ;
11797 }
11898
11999 public void VSCode ( Func < string > platformFinder )
@@ -154,13 +134,11 @@ public void FindJetBrainsFromToolbox(Func<string> platformFinder)
154134 if ( exclude . Contains ( tool . ToolId . ToLowerInvariant ( ) ) )
155135 continue ;
156136
157- Founded . Add ( new ExternalTool
158- {
159- Name = $ "{ tool . DisplayName } { tool . DisplayVersion } ",
160- Icon = supported_icons . Contains ( tool . ProductCode ) ? $ "JetBrains/{ tool . ProductCode } " : $ "JetBrains/JB",
161- OpenCmdArgs = "\" {0}\" " ,
162- Executable = Path . Combine ( tool . InstallLocation , tool . LaunchCommand ) ,
163- } ) ;
137+ Founded . Add ( new ExternalTool (
138+ $ "{ tool . DisplayName } { tool . DisplayVersion } ",
139+ supported_icons . Contains ( tool . ProductCode ) ? $ "JetBrains/{ tool . ProductCode } " : "JetBrains/JB" ,
140+ Path . Combine ( tool . InstallLocation , tool . LaunchCommand ) ,
141+ "\" {0}\" " ) ) ;
164142 }
165143 }
166144 }
0 commit comments