@@ -14,8 +14,8 @@ namespace Flow.Launcher.ViewModel
14
14
{
15
15
public class ResultViewModel : BaseModel
16
16
{
17
- private static readonly PrivateFontCollection fontCollection = new ( ) ;
18
- private static readonly Dictionary < string , string > fonts = new ( ) ;
17
+ private static readonly PrivateFontCollection FontCollection = new ( ) ;
18
+ private static readonly Dictionary < string , string > Fonts = new ( ) ;
19
19
20
20
public ResultViewModel ( Result result , Settings settings )
21
21
{
@@ -37,7 +37,7 @@ public ResultViewModel(Result result, Settings settings)
37
37
fontFamilyPath = Path . Combine ( Result . PluginDirectory , fontFamilyPath ) ;
38
38
}
39
39
40
- if ( fonts . TryGetValue ( fontFamilyPath , out var value ) )
40
+ if ( Fonts . TryGetValue ( fontFamilyPath , out var value ) )
41
41
{
42
42
Glyph = glyph with
43
43
{
@@ -46,11 +46,11 @@ public ResultViewModel(Result result, Settings settings)
46
46
}
47
47
else
48
48
{
49
- fontCollection . AddFontFile ( fontFamilyPath ) ;
50
- fonts [ fontFamilyPath ] = $ "{ Path . GetDirectoryName ( fontFamilyPath ) } /#{ fontCollection . Families [ ^ 1 ] . Name } ";
49
+ FontCollection . AddFontFile ( fontFamilyPath ) ;
50
+ Fonts [ fontFamilyPath ] = $ "{ Path . GetDirectoryName ( fontFamilyPath ) } /#{ FontCollection . Families [ ^ 1 ] . Name } ";
51
51
Glyph = glyph with
52
52
{
53
- FontFamily = fonts [ fontFamilyPath ]
53
+ FontFamily = Fonts [ fontFamilyPath ]
54
54
} ;
55
55
}
56
56
}
@@ -92,14 +92,10 @@ public Visibility ShowPreviewImage
92
92
get
93
93
{
94
94
if ( PreviewImageAvailable )
95
- {
96
95
return Visibility . Visible ;
97
- }
98
- else
99
- {
100
- // Fall back to icon
101
- return ShowIcon ;
102
- }
96
+
97
+ // Fall back to icon
98
+ return ShowIcon ;
103
99
}
104
100
}
105
101
@@ -108,9 +104,8 @@ public double IconRadius
108
104
get
109
105
{
110
106
if ( Result . RoundedIcon )
111
- {
112
107
return IconXY / 2 ;
113
- }
108
+
114
109
return IconXY ;
115
110
}
116
111
@@ -145,40 +140,40 @@ public Visibility ShowGlyph
145
140
? Result . SubTitle
146
141
: Result . SubTitleToolTip ;
147
142
148
- private volatile bool ImageLoaded ;
149
- private volatile bool PreviewImageLoaded ;
143
+ private volatile bool _imageLoaded ;
144
+ private volatile bool _previewImageLoaded ;
150
145
151
- private ImageSource image = ImageLoader . LoadingImage ;
152
- private ImageSource previewImage = ImageLoader . LoadingImage ;
146
+ private ImageSource _image = ImageLoader . LoadingImage ;
147
+ private ImageSource _previewImage = ImageLoader . LoadingImage ;
153
148
154
149
public ImageSource Image
155
150
{
156
151
get
157
152
{
158
- if ( ! ImageLoaded )
153
+ if ( ! _imageLoaded )
159
154
{
160
- ImageLoaded = true ;
155
+ _imageLoaded = true ;
161
156
_ = LoadImageAsync ( ) ;
162
157
}
163
158
164
- return image ;
159
+ return _image ;
165
160
}
166
- private set => image = value ;
161
+ private set => _image = value ;
167
162
}
168
163
169
164
public ImageSource PreviewImage
170
165
{
171
166
get
172
167
{
173
- if ( ! PreviewImageLoaded )
168
+ if ( ! _previewImageLoaded )
174
169
{
175
- PreviewImageLoaded = true ;
170
+ _previewImageLoaded = true ;
176
171
_ = LoadPreviewImageAsync ( ) ;
177
172
}
178
173
179
- return previewImage ;
174
+ return _previewImage ;
180
175
}
181
- private set => previewImage = value ;
176
+ private set => _previewImage = value ;
182
177
}
183
178
184
179
/// <summary>
@@ -194,8 +189,7 @@ private async Task<ImageSource> LoadImageInternalAsync(string imagePath, Result.
194
189
{
195
190
try
196
191
{
197
- var image = icon ( ) ;
198
- return image ;
192
+ return icon ( ) ;
199
193
}
200
194
catch ( Exception e )
201
195
{
@@ -214,7 +208,7 @@ private async Task LoadImageAsync()
214
208
var iconDelegate = Result . Icon ;
215
209
if ( ImageLoader . TryGetValue ( imagePath , false , out ImageSource img ) )
216
210
{
217
- image = img ;
211
+ _image = img ;
218
212
}
219
213
else
220
214
{
@@ -229,7 +223,7 @@ private async Task LoadPreviewImageAsync()
229
223
var iconDelegate = Result . Preview . PreviewDelegate ?? Result . Icon ;
230
224
if ( ImageLoader . TryGetValue ( imagePath , true , out ImageSource img ) )
231
225
{
232
- previewImage = img ;
226
+ _previewImage = img ;
233
227
}
234
228
else
235
229
{
@@ -240,13 +234,10 @@ private async Task LoadPreviewImageAsync()
240
234
241
235
public void LoadPreviewImage ( )
242
236
{
243
- if ( ShowDefaultPreview == Visibility . Visible )
237
+ if ( ShowDefaultPreview == Visibility . Visible && ! _previewImageLoaded && ShowPreviewImage == Visibility . Visible )
244
238
{
245
- if ( ! PreviewImageLoaded && ShowPreviewImage == Visibility . Visible )
246
- {
247
- PreviewImageLoaded = true ;
248
- _ = LoadPreviewImageAsync ( ) ;
249
- }
239
+ _previewImageLoaded = true ;
240
+ _ = LoadPreviewImageAsync ( ) ;
250
241
}
251
242
}
252
243
0 commit comments