This commit is contained in:
intervinn 2025-03-30 20:02:08 +08:00 committed by GitHub
commit 637bdf77fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 3 deletions

View File

@ -26,7 +26,8 @@
public static string Application { get; private set; } = "";
public static string CustomFont => Path.Combine(Modifications, "content\\fonts\\CustomFont.ttf");
public static string Fonts => Path.Combine("content\\fonts");
public static string CustomFont => Path.Combine(Fonts, "CustomFont.ttf");
public static bool Initialized => !String.IsNullOrEmpty(Base);

View File

@ -99,7 +99,7 @@
Description="{x:Static resources:Strings.Menu_Mods_Misc_CustomFont_Description}">
<StackPanel>
<ui:Button Icon="DocumentAdd16" Content="{x:Static resources:Strings.Menu_Mods_Misc_CustomFont_Choose}" Command="{Binding ManageCustomFontCommand}" Visibility="{Binding ChooseCustomFontVisibility, Mode=OneWay}" />
<ui:Button Icon="Delete16" Content="{x:Static resources:Strings.Menu_Mods_Misc_CustomFont_Remove}" Appearance="Danger" Command="{Binding ManageCustomFontCommand}" Visibility="{Binding DeleteCustomFontVisibility, Mode=OneWay}" />
<ui:Button Icon="Delete16" FontFamily="{Binding DeleteCustomFontFontFamily}" Content="{x:Static resources:Strings.Menu_Mods_Misc_CustomFont_Remove}" Appearance="Danger" Command="{Binding ManageCustomFontCommand}" Visibility="{Binding DeleteCustomFontVisibility, Mode=OneWay}" />
</StackPanel>
</controls:OptionControl>
</StackPanel>

View File

@ -9,8 +9,10 @@ using Windows.Win32.Foundation;
using CommunityToolkit.Mvvm.Input;
using Bloxstrap.Models.SettingTasks;
using Bloxstrap.AppData;
using System.Drawing.Text;
using Wpf.Ui.Controls;
using System.Windows.Media;
namespace Bloxstrap.UI.ViewModels.Settings
{
@ -53,8 +55,11 @@ namespace Bloxstrap.UI.ViewModels.Settings
TextFontTask.NewState = dialog.FileName;
}
OnPropertyChanged(nameof(ChooseCustomFontVisibility));
OnPropertyChanged(nameof(DeleteCustomFontVisibility));
OnPropertyChanged(nameof(CustomFontName));
OnPropertyChanged(nameof(DeleteCustomFontFontFamily));
}
public ICommand OpenModsFolderCommand => new RelayCommand(OpenModsFolder);
@ -63,6 +68,18 @@ namespace Bloxstrap.UI.ViewModels.Settings
public Visibility DeleteCustomFontVisibility => !String.IsNullOrEmpty(TextFontTask.NewState) ? Visibility.Visible : Visibility.Collapsed;
public System.Windows.Media.FontFamily DeleteCustomFontFontFamily => new System.Windows.Media.FontFamily($"{TextFontTask.NewState}#{CustomFontName}");
public string CustomFontName
{
get
{
var families = Fonts.GetFontFamilies(TextFontTask.NewState);
var first = families.ElementAt(0);
return first.ToString().Split("#").ElementAt(first.ToString().Split("#").Count() - 1);
}
}
public ICommand ManageCustomFontCommand => new RelayCommand(ManageCustomFont);
public ICommand OpenCompatSettingsCommand => new RelayCommand(OpenCompatSettings);