mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
refactor: using a new DotBrushProperty instead of calling Application.TryGetResource
This commit is contained in:
parent
3a3c0e717f
commit
1e3711e569
2 changed files with 10 additions and 14 deletions
|
@ -131,6 +131,7 @@
|
||||||
<v:CommitGraph x:Name="commitGraph"
|
<v:CommitGraph x:Name="commitGraph"
|
||||||
BindingDataGrid="{Binding #commitDataGrid}"
|
BindingDataGrid="{Binding #commitDataGrid}"
|
||||||
Graph="{Binding Graph}"
|
Graph="{Binding Graph}"
|
||||||
|
DotBrush="{DynamicResource Brush.Contents}"
|
||||||
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
|
||||||
IsHitTestVisible="False"
|
IsHitTestVisible="False"
|
||||||
ClipToBounds="True"/>
|
ClipToBounds="True"/>
|
||||||
|
|
|
@ -99,19 +99,18 @@ namespace SourceGit.Views
|
||||||
set => SetValue(BindingDataGridProperty, value);
|
set => SetValue(BindingDataGridProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static readonly StyledProperty<IBrush> DotBrushProperty =
|
||||||
|
AvaloniaProperty.Register<CommitGraph, IBrush>(nameof(DotBrush), Brushes.Transparent);
|
||||||
|
|
||||||
|
public IBrush DotBrush
|
||||||
|
{
|
||||||
|
get => GetValue(DotBrushProperty);
|
||||||
|
set => SetValue(DotBrushProperty, value);
|
||||||
|
}
|
||||||
|
|
||||||
static CommitGraph()
|
static CommitGraph()
|
||||||
{
|
{
|
||||||
AffectsRender<CommitGraph>(BindingDataGridProperty, GraphProperty);
|
AffectsRender<CommitGraph>(BindingDataGridProperty, GraphProperty, DotBrushProperty);
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
|
|
||||||
{
|
|
||||||
base.OnPropertyChanged(change);
|
|
||||||
|
|
||||||
if (change.Property.Name == "ActualThemeVariant")
|
|
||||||
{
|
|
||||||
InvalidateVisual();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Render(DrawingContext context)
|
public override void Render(DrawingContext context)
|
||||||
|
@ -153,11 +152,7 @@ namespace SourceGit.Views
|
||||||
DrawCurves(context, top, bottom);
|
DrawCurves(context, top, bottom);
|
||||||
|
|
||||||
// Draw connect dots
|
// Draw connect dots
|
||||||
Brush dotFill = null;
|
IBrush dotFill = DotBrush;
|
||||||
if (App.Current.TryGetResource("Brush.Contents", App.Current.ActualThemeVariant, out object res) && res is SolidColorBrush)
|
|
||||||
{
|
|
||||||
dotFill = res as SolidColorBrush;
|
|
||||||
}
|
|
||||||
foreach (var dot in graph.Dots)
|
foreach (var dot in graph.Dots)
|
||||||
{
|
{
|
||||||
if (dot.Center.Y < top)
|
if (dot.Center.Y < top)
|
||||||
|
|
Loading…
Reference in a new issue