Files
MesenCE/UI/Debugger/Views/BreakpointListView.axaml.cs
SourMesen e391fd8f9a Code: Add auto-formatting rules for C++ (clang-format) and enforce in CI via "clang-format" and "dotnet format" (#78)
* Code: Add auto-formatting rules for C++ projects (clang-format) and enforce code style via "clang-format" and "dotnet format"

* fix ui format warnings
2026-04-30 06:03:55 -07:00

74 lines
1.8 KiB
C#

using Avalonia;
using Avalonia.Controls;
using Avalonia.Input;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using DataBoxControl;
using Mesen.Config;
using Mesen.Debugger;
using Mesen.Debugger.Utilities;
using Mesen.Debugger.ViewModels;
using Mesen.Debugger.Windows;
using Mesen.Utilities;
using Mesen.ViewModels;
using System;
using System.Linq;
using static Mesen.Debugger.ViewModels.BreakpointListViewModel;
namespace Mesen.Debugger.Views
{
public class BreakpointListView : UserControl
{
public BreakpointListView()
{
InitializeComponent();
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
}
protected override void OnDataContextChanged(EventArgs e)
{
if(DataContext is BreakpointListViewModel vm) {
vm.InitContextMenu(this);
}
base.OnDataContextChanged(e);
}
private void OnCellClick(DataBoxCell cell)
{
if(DataContext is BreakpointListViewModel bpList && cell.DataContext is BreakpointViewModel) {
string? header = cell.Column?.Header?.ToString() ?? "";
if(header == "E" || header == "M") {
bool isEnabledColumn = header == "E";
bool newValue = !bpList.Selection.SelectedItems.Any(bp => (isEnabledColumn ? bp?.Breakpoint.Enabled : bp?.Breakpoint.MarkEvent) == true);
foreach(BreakpointViewModel? bp in bpList.Selection.SelectedItems) {
if(bp != null) {
if(isEnabledColumn) {
bp.Breakpoint.Enabled = newValue;
} else {
if(!bp.Breakpoint.Forbid) {
bp.Breakpoint.MarkEvent = newValue;
}
}
}
}
DebugWorkspaceManager.AutoSave();
BreakpointManager.RefreshBreakpoints();
}
}
}
private void OnCellDoubleClick(DataBoxCell cell)
{
if(cell.DataContext is BreakpointViewModel vm) {
BreakpointEditWindow.EditBreakpoint(vm.Breakpoint, this);
}
}
}
}