Files
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

51 lines
1.2 KiB
C#

using Avalonia.Controls;
using Avalonia.Controls.Primitives;
using Avalonia.Controls.Shapes;
using Avalonia.Styling;
using DataBoxControl.Primitives;
using System;
namespace DataBoxControl;
public class DataBoxRow : ListBoxItem
{
private Rectangle? _bottomGridLine;
protected override Type StyleKeyOverride => typeof(DataBoxRow);
internal DataBox? DataBox { get; set; }
internal DataBoxCellsPresenter? CellsPresenter { get; set; }
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
base.OnApplyTemplate(e);
_bottomGridLine = e.NameScope.Find<Rectangle>("PART_BottomGridLine");
InvalidateBottomGridLine();
CellsPresenter = e.NameScope.Find<DataBoxCellsPresenter>("PART_CellsPresenter");
if(CellsPresenter is { }) {
CellsPresenter.DataBox = DataBox;
CellsPresenter.Attach();
}
}
private void InvalidateBottomGridLine()
{
if(_bottomGridLine is { } && DataBox is { }) {
bool newVisibility =
DataBox.GridLinesVisibility == DataBoxGridLinesVisibility.Horizontal
|| DataBox.GridLinesVisibility == DataBoxGridLinesVisibility.All;
if(newVisibility != _bottomGridLine.IsVisible) {
_bottomGridLine.IsVisible = newVisibility;
}
_bottomGridLine.Fill = DataBox.HorizontalGridLinesBrush;
}
}
}