diff --git a/src/Consolonia.Themes.TurboVision/Templates/Controls/DataGrid.axaml b/src/Consolonia.Themes.TurboVision/Templates/Controls/DataGrid.axaml index 317b485f..8fc87443 100644 --- a/src/Consolonia.Themes.TurboVision/Templates/Controls/DataGrid.axaml +++ b/src/Consolonia.Themes.TurboVision/Templates/Controls/DataGrid.axaml @@ -72,12 +72,12 @@ - @@ -313,14 +313,23 @@ Background="{TemplateBinding Background}" Margin="0,1" /> + + + diff --git a/src/Consolonia.Themes.TurboVision/Templates/Controls/Helpers/FastLineSeparator.cs b/src/Consolonia.Themes.TurboVision/Templates/Controls/Helpers/FastLineSeparator.cs new file mode 100644 index 00000000..1bb035b1 --- /dev/null +++ b/src/Consolonia.Themes.TurboVision/Templates/Controls/Helpers/FastLineSeparator.cs @@ -0,0 +1,67 @@ +using Avalonia; +using Avalonia.Controls; +using Avalonia.Layout; +using Avalonia.Media; + +namespace Consolonia.Themes.TurboVision.Templates.Controls.Helpers +{ + public class FastLineSeparator : Control + { + public static readonly StyledProperty OrientationProperty = + AvaloniaProperty.Register(nameof(Orientation), Orientation.Horizontal); + + public Orientation Orientation + { + get => GetValue(OrientationProperty); + set => SetValue(OrientationProperty, value); + } + + public static readonly StyledProperty BrushProperty = + AvaloniaProperty.Register(nameof(Brush), Brushes.Black); + + public IBrush Brush + { + get => GetValue(BrushProperty); + set => SetValue(BrushProperty, value); + } + + + public FastLineSeparator() + { + AffectsRender(OrientationProperty); + } + + protected override Size MeasureOverride(Size availableSize) + { + return Orientation == Orientation.Horizontal + ? new Size(0, 1) + : new Size(1, 0); + } + + protected override Size ArrangeOverride(Size finalSize) + { + return finalSize; + } + + public override void Render(DrawingContext context) + { + var pen = new Pen(Brush); + + if (Orientation == Orientation.Horizontal) + { + // Draw a horizontal line across the control's width + var startPoint = new Point(0, Bounds.Height / 2); + var endPoint = new Point(Bounds.Width-1, Bounds.Height / 2); + context.DrawLine(pen, startPoint, endPoint); + } + else + { + // Draw a vertical line across the control's height + var startPoint = new Point(Bounds.Width / 2, 0); + var endPoint = new Point(Bounds.Width / 2, Bounds.Height-1); + context.DrawLine(pen, startPoint, endPoint); + } + } + + } +} \ No newline at end of file