mirror of
				https://github.com/2dust/v2rayN.git
				synced 2025-10-27 02:34:41 +00:00 
			
		
		
		
	asynchronous font loading
This commit is contained in:
		
							parent
							
								
									d748e6eff4
								
							
						
					
					
						commit
						c1ace6bf4a
					
				
					 1 changed files with 24 additions and 5 deletions
				
			
		|  | @ -30,7 +30,6 @@ namespace v2rayN.Views | ||||||
| 
 | 
 | ||||||
|             this.Owner = Application.Current.MainWindow; |             this.Owner = Application.Current.MainWindow; | ||||||
|             _config = LazyConfig.Instance.GetConfig(); |             _config = LazyConfig.Instance.GetConfig(); | ||||||
|             var lstFonts = GetFonts(Utils.GetFontsPath()); |  | ||||||
| 
 | 
 | ||||||
|             ViewModel = new OptionSettingViewModel(this); |             ViewModel = new OptionSettingViewModel(this); | ||||||
| 
 | 
 | ||||||
|  | @ -99,8 +98,7 @@ namespace v2rayN.Views | ||||||
|                 cmbSubConvertUrl.Items.Add(it); |                 cmbSubConvertUrl.Items.Add(it); | ||||||
|             }); |             }); | ||||||
| 
 | 
 | ||||||
|             lstFonts.ForEach(it => { cmbcurrentFontFamily.Items.Add(it); }); |             cmbcurrentFontFamily.Items.Add("默认字体"); | ||||||
|             cmbcurrentFontFamily.Items.Add(string.Empty); |  | ||||||
| 
 | 
 | ||||||
|             this.WhenActivated(disposables => |             this.WhenActivated(disposables => | ||||||
|             { |             { | ||||||
|  | @ -147,7 +145,8 @@ namespace v2rayN.Views | ||||||
|                 this.Bind(ViewModel, vm => vm.DoubleClick2Activate, v => v.togDoubleClick2Activate.IsChecked).DisposeWith(disposables); |                 this.Bind(ViewModel, vm => vm.DoubleClick2Activate, v => v.togDoubleClick2Activate.IsChecked).DisposeWith(disposables); | ||||||
|                 this.Bind(ViewModel, vm => vm.AutoUpdateInterval, v => v.txtautoUpdateInterval.Text).DisposeWith(disposables); |                 this.Bind(ViewModel, vm => vm.AutoUpdateInterval, v => v.txtautoUpdateInterval.Text).DisposeWith(disposables); | ||||||
|                 this.Bind(ViewModel, vm => vm.TrayMenuServersLimit, v => v.txttrayMenuServersLimit.Text).DisposeWith(disposables); |                 this.Bind(ViewModel, vm => vm.TrayMenuServersLimit, v => v.txttrayMenuServersLimit.Text).DisposeWith(disposables); | ||||||
|                 this.Bind(ViewModel, vm => vm.CurrentFontFamily, v => v.cmbcurrentFontFamily.Text).DisposeWith(disposables); |                 // this.Bind(ViewModel, vm => vm.CurrentFontFamily, v => v.cmbcurrentFontFamily.Text).DisposeWith(disposables); | ||||||
|  |                 LoadFontsAsync(disposables); | ||||||
|                 this.Bind(ViewModel, vm => vm.SpeedTestTimeout, v => v.cmbSpeedTestTimeout.Text).DisposeWith(disposables); |                 this.Bind(ViewModel, vm => vm.SpeedTestTimeout, v => v.cmbSpeedTestTimeout.Text).DisposeWith(disposables); | ||||||
|                 this.Bind(ViewModel, vm => vm.SpeedTestUrl, v => v.cmbSpeedTestUrl.Text).DisposeWith(disposables); |                 this.Bind(ViewModel, vm => vm.SpeedTestUrl, v => v.cmbSpeedTestUrl.Text).DisposeWith(disposables); | ||||||
|                 this.Bind(ViewModel, vm => vm.SpeedPingTestUrl, v => v.cmbSpeedPingTestUrl.Text).DisposeWith(disposables); |                 this.Bind(ViewModel, vm => vm.SpeedPingTestUrl, v => v.cmbSpeedPingTestUrl.Text).DisposeWith(disposables); | ||||||
|  | @ -227,5 +226,25 @@ namespace v2rayN.Views | ||||||
|         { |         { | ||||||
|             ViewModel.destOverride = clbdestOverride.SelectedItems.Cast<string>().ToList(); |             ViewModel.destOverride = clbdestOverride.SelectedItems.Cast<string>().ToList(); | ||||||
|         } |         } | ||||||
|  | 
 | ||||||
|  |         private async void LoadFontsAsync(CompositeDisposable disposables) | ||||||
|  |         { | ||||||
|  |             try | ||||||
|  |             { | ||||||
|  |                 var fonts = await Task.Run(() => GetFonts(Utils.GetFontsPath())); | ||||||
|  |                 Dispatcher.Invoke(() => | ||||||
|  |                 { | ||||||
|  |                     foreach (var font in fonts) | ||||||
|  |                     { | ||||||
|  |                         cmbcurrentFontFamily.Items.Add(font); | ||||||
|  |                     } | ||||||
|  |                     this.Bind(ViewModel, vm => vm.CurrentFontFamily, v => v.cmbcurrentFontFamily.Text).DisposeWith(disposables); | ||||||
|  |                 }); | ||||||
|  |             } | ||||||
|  |             catch (Exception e) | ||||||
|  |             { | ||||||
|  |                 Logging.SaveLog("Async font loading error", e); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
		Loading…
	
		Reference in a new issue
	
	 sincere liu
						sincere liu