@@ -30,7 +30,6 @@ public OptionSettingWindow()
30
30
31
31
this . Owner = Application . Current . MainWindow ;
32
32
_config = LazyConfig . Instance . GetConfig ( ) ;
33
- var lstFonts = GetFonts ( Utils . GetFontsPath ( ) ) ;
34
33
35
34
ViewModel = new OptionSettingViewModel ( this ) ;
36
35
@@ -42,7 +41,7 @@ public OptionSettingWindow()
42
41
_config . inbound [ 0 ] . destOverride ? . ForEach ( it =>
43
42
{
44
43
clbdestOverride . SelectedItems . Add ( it ) ;
45
- } ) ;
44
+ } ) ;
46
45
Global . IEProxyProtocols . ForEach ( it =>
47
46
{
48
47
cmbsystemProxyAdvancedProtocol . Items . Add ( it ) ;
@@ -99,8 +98,7 @@ public OptionSettingWindow()
99
98
cmbSubConvertUrl . Items . Add ( it ) ;
100
99
} ) ;
101
100
102
- lstFonts . ForEach ( it => { cmbcurrentFontFamily . Items . Add ( it ) ; } ) ;
103
- cmbcurrentFontFamily . Items . Add ( string . Empty ) ;
101
+ cmbcurrentFontFamily . Items . Add ( "默认字体" ) ;
104
102
105
103
this . WhenActivated ( disposables =>
106
104
{
@@ -147,7 +145,8 @@ public OptionSettingWindow()
147
145
this . Bind ( ViewModel , vm => vm . DoubleClick2Activate , v => v . togDoubleClick2Activate . IsChecked ) . DisposeWith ( disposables ) ;
148
146
this . Bind ( ViewModel , vm => vm . AutoUpdateInterval , v => v . txtautoUpdateInterval . Text ) . DisposeWith ( disposables ) ;
149
147
this . Bind ( ViewModel , vm => vm . TrayMenuServersLimit , v => v . txttrayMenuServersLimit . Text ) . DisposeWith ( disposables ) ;
150
- this . Bind ( ViewModel , vm => vm . CurrentFontFamily , v => v . cmbcurrentFontFamily . Text ) . DisposeWith ( disposables ) ;
148
+ // this.Bind(ViewModel, vm => vm.CurrentFontFamily, v => v.cmbcurrentFontFamily.Text).DisposeWith(disposables);
149
+ LoadFontsAsync ( disposables ) ;
151
150
this . Bind ( ViewModel , vm => vm . SpeedTestTimeout , v => v . cmbSpeedTestTimeout . Text ) . DisposeWith ( disposables ) ;
152
151
this . Bind ( ViewModel , vm => vm . SpeedTestUrl , v => v . cmbSpeedTestUrl . Text ) . DisposeWith ( disposables ) ;
153
152
this . Bind ( ViewModel , vm => vm . SpeedPingTestUrl , v => v . cmbSpeedPingTestUrl . Text ) . DisposeWith ( disposables ) ;
@@ -227,5 +226,25 @@ private void ClbdestOverride_SelectionChanged(object sender, System.Windows.Cont
227
226
{
228
227
ViewModel . destOverride = clbdestOverride . SelectedItems . Cast < string > ( ) . ToList ( ) ;
229
228
}
229
+
230
+ private async void LoadFontsAsync ( CompositeDisposable disposables )
231
+ {
232
+ try
233
+ {
234
+ var fonts = await Task . Run ( ( ) => GetFonts ( Utils . GetFontsPath ( ) ) ) ;
235
+ Dispatcher . Invoke ( ( ) =>
236
+ {
237
+ foreach ( var font in fonts )
238
+ {
239
+ cmbcurrentFontFamily . Items . Add ( font ) ;
240
+ }
241
+ this . Bind ( ViewModel , vm => vm . CurrentFontFamily , v => v . cmbcurrentFontFamily . Text ) . DisposeWith ( disposables ) ;
242
+ } ) ;
243
+ }
244
+ catch ( Exception e )
245
+ {
246
+ Logging . SaveLog ( "Async font loading error" , e ) ;
247
+ }
248
+ }
230
249
}
231
250
}
0 commit comments