mirror of
https://github.com/2dust/v2rayN.git
synced 2026-05-30 01:34:08 +00:00
Update OptionSettingWindow.axaml.cs
This commit is contained in:
parent
4ae5c021fd
commit
896938b5e6
1 changed files with 16 additions and 21 deletions
|
|
@ -155,35 +155,30 @@ public partial class OptionSettingWindow : WindowBase<OptionSettingViewModel>
|
||||||
{
|
{
|
||||||
var lstFonts = await GetFonts();
|
var lstFonts = await GetFonts();
|
||||||
|
|
||||||
lstFonts.Add(string.Empty);
|
lstFonts.Insert(0, string.Empty);
|
||||||
cmbcurrentFontFamily.ItemsSource = lstFonts;
|
cmbcurrentFontFamily.ItemsSource = lstFonts;
|
||||||
|
|
||||||
|
if (ViewModel?.CurrentFontFamily.IsNullOrEmpty() == true)
|
||||||
|
{
|
||||||
|
cmbcurrentFontFamily.SelectedIndex = 0;
|
||||||
|
cmbcurrentFontFamily.Text = string.Empty;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<List<string>> GetFonts()
|
private async Task<List<string>> GetFonts()
|
||||||
{
|
{
|
||||||
|
await Task.CompletedTask;
|
||||||
|
|
||||||
var lstFonts = new List<string>();
|
var lstFonts = new List<string>();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (Utils.IsWindows())
|
var lst = Avalonia.Media.FontManager.Current.SystemFonts
|
||||||
{
|
.Select(t => t.Name)
|
||||||
return lstFonts;
|
.Where(t => t.IsNotEmpty())
|
||||||
}
|
.Distinct(StringComparer.OrdinalIgnoreCase)
|
||||||
else if (Utils.IsNonWindows())
|
.OrderBy(t => t)
|
||||||
{
|
.ToList();
|
||||||
var result = await Utils.GetLinuxFontFamily("zh");
|
return lst;
|
||||||
if (result.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
return lstFonts;
|
|
||||||
}
|
|
||||||
|
|
||||||
var lst = result.Split(Environment.NewLine)
|
|
||||||
.Where(t => t.IsNotEmpty())
|
|
||||||
.ToList()
|
|
||||||
.Select(t => t.Split(",").FirstOrDefault() ?? "")
|
|
||||||
.OrderBy(t => t)
|
|
||||||
.ToList();
|
|
||||||
return lst;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue