@@ -12,34 +12,23 @@ namespace SourceGit.Models
12
12
{
13
13
public class ExternalTool
14
14
{
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 ;
19
19
20
- public Bitmap IconImage
20
+ public ExternalTool ( string name , string icon , string executable , string openCmdArgs )
21
21
{
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 ;
40
25
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 ) ;
42
30
}
31
+ catch { }
43
32
}
44
33
45
34
public void Open ( string repo )
@@ -52,9 +41,6 @@ public void Open(string repo)
52
41
UseShellExecute = false ,
53
42
} ) ;
54
43
}
55
-
56
- private bool _isFirstTimeGetIcon = true ;
57
- private Bitmap _iconImage = null ;
58
44
}
59
45
60
46
public class JetBrainsState
@@ -107,13 +93,7 @@ public void TryAdd(string name, string icon, string args, string env, Func<strin
107
93
return ;
108
94
}
109
95
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 ) ) ;
117
97
}
118
98
119
99
public void VSCode ( Func < string > platformFinder )
@@ -154,13 +134,11 @@ public void FindJetBrainsFromToolbox(Func<string> platformFinder)
154
134
if ( exclude . Contains ( tool . ToolId . ToLowerInvariant ( ) ) )
155
135
continue ;
156
136
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}\" " ) ) ;
164
142
}
165
143
}
166
144
}
0 commit comments