Skip to content

Commit

Permalink
feat: IsCsIp signaled by FontWeight, not column
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilien Noal <noal.maximilien@gmail.com>
  • Loading branch information
maximilien-noal committed Nov 17, 2024
1 parent 269f3d3 commit 7dbf321
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
22 changes: 22 additions & 0 deletions src/Spice86/Converters/BoolToFontWeightConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
namespace Spice86.Converters;

using Avalonia.Data;
using Avalonia.Data.Converters;
using Avalonia.Media;

using System;
using System.Globalization;
using System.Reflection;

internal class BoolToFontWeightConverter : IValueConverter {
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) {
if(value is bool source) {
return source ? FontWeight.Bold : FontWeight.Normal;
}
return BindingOperations.DoNothing;
}

public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) {
return BindingOperations.DoNothing;
}
}
11 changes: 9 additions & 2 deletions src/Spice86/Views/DisassemblyView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<UserControl.Resources>
<converters:InstructionToStringConverter x:Key="InstructionToStringConverter" />
<converters:SegmentedAddressConverter x:Key="SegmentedAddressConverter" />
<converters:BoolToFontWeightConverter x:Key="BoolToFontWeightConverter" />
</UserControl.Resources>
<Grid RowDefinitions="Auto,*">
<Grid ColumnDefinitions="Auto,Auto,Auto,Auto,*,Auto" Grid.Row="0"
Expand Down Expand Up @@ -81,8 +82,14 @@
ItemsSource="{Binding Instructions}">
<DataGrid.Columns>
<DataGridCheckBoxColumn Binding="{Binding HasBreakpoint}" Header="Breakpoint" />
<DataGridTextColumn Binding="{Binding AddressInformation}" Header="Address (CS:IP+offset)" />
<DataGridCheckBoxColumn Binding="{Binding IsCsIp}" Header="Is CS:IP" />
<DataGridTextColumn
Binding="{Binding Address}">
<DataGridTextColumn.CellTheme>
<ControlTheme TargetType="DataGridCell" BasedOn="{StaticResource {x:Type DataGridCell}}">
<Setter Property="FontWeight" Value="{ReflectionBinding IsCsIp, Converter={StaticResource BoolToFontWeightConverter}}" />
</ControlTheme>
</DataGridTextColumn.CellTheme>
</DataGridTextColumn>
<DataGridTextColumn MaxWidth="300"
Binding="{Binding Converter={StaticResource InstructionToStringConverter}}"
Header="MASM" />
Expand Down

0 comments on commit 7dbf321

Please sign in to comment.