Skip to content

Commit

Permalink
refactor: 'Breakpoint here' commands CanExecute
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 7, 2024
1 parent 91593a9 commit b2960e3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/Spice86/ViewModels/DisassemblyViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,11 @@ private void MoveCsIpHere() {
UpdateDisassemblyCommand.Execute(null);
}
}

[RelayCommand]

private bool RemoveExecutionBreakpointHereCanExecute() =>
SelectedInstruction is not null && _breakpointsViewModel.HasUserExecutionBreakpoint(SelectedInstruction);

[RelayCommand(CanExecute = nameof(RemoveExecutionBreakpointHereCanExecute))]
private void RemoveExecutionBreakpointHere() {
if (SelectedInstruction is null) {
return;
Expand All @@ -280,7 +283,10 @@ private void RemoveExecutionBreakpointHere() {
SelectedInstruction.HasBreakpoint = _breakpointsViewModel.HasUserExecutionBreakpoint(SelectedInstruction);
}

[RelayCommand]
private bool CreateExecutionBreakpointHereCanExecute() =>
SelectedInstruction is not null && !_breakpointsViewModel.HasUserExecutionBreakpoint(SelectedInstruction);

[RelayCommand(CanExecute = nameof(CreateExecutionBreakpointHereCanExecute))]
private void CreateExecutionBreakpointHere() {
if (SelectedInstruction is null) {
return;
Expand Down
4 changes: 2 additions & 2 deletions src/Spice86/Views/DisassemblyView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@
<DataGrid.ContextMenu>
<ContextMenu>
<MenuItem Header="Copy line" Command="{Binding CopyLineCommand}" />
<MenuItem Header="Create address Breakpoint here" Command="{Binding CreateExecutionBreakpointHereCommand}" />
<MenuItem Header="Remove address BreakPoint here" Command="{Binding RemoveExecutionBreakpointHereCommand}" />
<MenuItem Header="Create execution breakpoint here" Command="{Binding CreateExecutionBreakpointHereCommand}" />
<MenuItem Header="Remove execution breakPoint here" Command="{Binding RemoveExecutionBreakpointHereCommand}" />
<MenuItem Header="Move CS:IP here" Command="{Binding MoveCsIpHereCommand}" />
</ContextMenu>
</DataGrid.ContextMenu>
Expand Down

0 comments on commit b2960e3

Please sign in to comment.