mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-24 13:45:00 +00:00
enhance: use custom JsonConverter instead of converting string to FontFamily in each control
This commit is contained in:
parent
0fadab2ca2
commit
56f5f3b4a7
10 changed files with 49 additions and 49 deletions
|
@ -72,7 +72,7 @@
|
|||
BorderThickness="1"
|
||||
Background="{DynamicResource Brush.Contents}"
|
||||
Foreground="{DynamicResource Brush.FG1}"
|
||||
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont, Converter={x:Static c:StringConverters.ToFontFamily}}"
|
||||
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"
|
||||
FontSize="12"
|
||||
BlameData="{Binding Data}"/>
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<Grid RowDefinitions="24,Auto,Auto,Auto" ColumnDefinitions="96,*">
|
||||
<!-- SHA -->
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.SHA}" />
|
||||
<SelectableTextBlock Grid.Row="0" Grid.Column="1" Text="{Binding SHA}" Margin="12,0,0,0" FontSize="12" VerticalAlignment="Center" FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont, Converter={x:Static c:StringConverters.ToFontFamily}}"/>
|
||||
<SelectableTextBlock Grid.Row="0" Grid.Column="1" Text="{Binding SHA}" Margin="12,0,0,0" FontSize="12" VerticalAlignment="Center" FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"/>
|
||||
|
||||
<!-- PARENTS -->
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Parents}" IsVisible="{Binding Parents.Count, Converter={x:Static c:IntConverters.IsGreaterThanZero}}"/>
|
||||
|
@ -95,7 +95,7 @@
|
|||
<!-- Messages -->
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" Classes="info_label" Text="{DynamicResource Text.CommitDetail.Info.Message}" VerticalAlignment="Top" Margin="0,4,0,0" />
|
||||
<ScrollViewer Grid.Row="3" Grid.Column="1" Margin="12,5,0,0" MaxHeight="100" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
|
||||
<SelectableTextBlock Text="{Binding FullMessage}" FontSize="12" FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont, Converter={x:Static c:StringConverters.ToFontFamily}}" TextWrapping="Wrap"/>
|
||||
<SelectableTextBlock Text="{Binding FullMessage}" FontSize="12" FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}" TextWrapping="Wrap"/>
|
||||
</ScrollViewer>
|
||||
</Grid>
|
||||
|
||||
|
|
|
@ -121,7 +121,7 @@
|
|||
Padding="8,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
ItemsSource="{Binding #me.InstalledFonts}"
|
||||
SelectedItem="{Binding DefaultFont, Converter={x:Static c:StringConverters.ToFontFamily}, Mode=TwoWay}">
|
||||
SelectedItem="{Binding DefaultFont, Mode=TwoWay}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate DataType="FontFamily">
|
||||
<Border Height="24">
|
||||
|
@ -140,7 +140,7 @@
|
|||
Padding="8,0"
|
||||
HorizontalAlignment="Stretch"
|
||||
ItemsSource="{Binding #me.InstalledMonospaceFonts}"
|
||||
SelectedItem="{Binding MonospaceFont, Converter={x:Static c:StringConverters.ToFontFamily}, Mode=TwoWay}">
|
||||
SelectedItem="{Binding MonospaceFont, Mode=TwoWay}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate DataType="FontFamily">
|
||||
<Border Height="24">
|
||||
|
|
|
@ -69,17 +69,19 @@ namespace SourceGit.Views
|
|||
var pref = ViewModels.Preference.Instance;
|
||||
DataContext = pref;
|
||||
|
||||
var builtInMono = new FontFamily("fonts:SourceGit#JetBrains Mono");
|
||||
|
||||
InstalledFonts = new AvaloniaList<FontFamily>();
|
||||
InstalledFonts.Add(new FontFamily("fonts:SourceGit#JetBrains Mono"));
|
||||
InstalledFonts.Add(builtInMono);
|
||||
InstalledFonts.AddRange(FontManager.Current.SystemFonts);
|
||||
|
||||
InstalledMonospaceFonts = new AvaloniaList<FontFamily>();
|
||||
InstalledMonospaceFonts.Add(new FontFamily("fonts:SourceGit#JetBrains Mono"));
|
||||
InstalledMonospaceFonts.Add(builtInMono);
|
||||
|
||||
var curMonoFont = pref.MonospaceFont;
|
||||
if (!string.IsNullOrEmpty(curMonoFont) && curMonoFont != "fonts:SourceGit#JetBrains Mono")
|
||||
if (curMonoFont != builtInMono)
|
||||
{
|
||||
InstalledMonospaceFonts.Add(new FontFamily(curMonoFont));
|
||||
InstalledMonospaceFonts.Add(curMonoFont);
|
||||
}
|
||||
|
||||
Task.Run(() =>
|
||||
|
@ -87,7 +89,7 @@ namespace SourceGit.Views
|
|||
var sysMonoFonts = new List<FontFamily>();
|
||||
foreach (var font in FontManager.Current.SystemFonts)
|
||||
{
|
||||
if (font.ToString() == curMonoFont) continue;
|
||||
if (font == curMonoFont) continue;
|
||||
|
||||
var typeface = new Typeface(font);
|
||||
var testI = new FormattedText(
|
||||
|
|
|
@ -89,7 +89,7 @@
|
|||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="m:RevisionTextFile">
|
||||
<v:RevisionTextFileView FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont, Converter={x:Static c:StringConverters.ToFontFamily}}" FontSize="12" Background="{DynamicResource Brush.Contents}"/>
|
||||
<v:RevisionTextFileView FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}" FontSize="12" Background="{DynamicResource Brush.Contents}"/>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="m:RevisionLFSObject">
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
BorderThickness="0"
|
||||
Foreground="{DynamicResource Brush.FG1}"
|
||||
SecondaryFG="{DynamicResource Brush.FG2}"
|
||||
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont, Converter={x:Static c:StringConverters.ToFontFamily}}"
|
||||
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"
|
||||
FontSize="12"
|
||||
DiffData="{Binding}"
|
||||
SyncScrollOffset="{Binding $parent[v:DiffView].DataContext.(vm:DiffContext).SyncScrollOffset, Mode=TwoWay}"
|
||||
|
@ -36,7 +36,7 @@
|
|||
BorderThickness="0"
|
||||
Foreground="{DynamicResource Brush.FG1}"
|
||||
SecondaryFG="{DynamicResource Brush.FG2}"
|
||||
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont, Converter={x:Static c:StringConverters.ToFontFamily}}"
|
||||
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"
|
||||
FontSize="12"
|
||||
DiffData="{Binding}"/>
|
||||
|
||||
|
@ -52,7 +52,7 @@
|
|||
BorderThickness="0"
|
||||
Foreground="{DynamicResource Brush.FG1}"
|
||||
SecondaryFG="{DynamicResource Brush.FG2}"
|
||||
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont, Converter={x:Static c:StringConverters.ToFontFamily}}"
|
||||
FontFamily="{Binding Source={x:Static vm:Preference.Instance}, Path=MonospaceFont}"
|
||||
FontSize="12"
|
||||
DiffData="{Binding}"/>
|
||||
</Grid>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue