mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-29 16:14:59 +00:00
feature: allow user to select the chart fill color
This commit is contained in:
parent
de15cb1ff2
commit
c0f59c441b
6 changed files with 88 additions and 13 deletions
|
@ -185,7 +185,25 @@
|
|||
</Grid>
|
||||
|
||||
<!-- Graph -->
|
||||
<lvc:CartesianChart Grid.Column="1" Margin="16" Series="{Binding Series}" XAxes="{Binding XAxes}" YAxes="{Binding YAxes}" ZoomMode="X"/>
|
||||
<Grid Grid.Column="1" RowDefinitions="28,*" Margin="16,0">
|
||||
<Button Grid.Row="0" Background="Transparent" BorderThickness="0" HorizontalAlignment="Center">
|
||||
<Button.Flyout>
|
||||
<Flyout>
|
||||
<Border Padding="8">
|
||||
<v:ColorPicker Value="{Binding #ThisControl.SampleFillColor, Mode=TwoWay}"/>
|
||||
</Border>
|
||||
</Flyout>
|
||||
</Button.Flyout>
|
||||
|
||||
<Path Width="20" Height="20" Data="{StaticResource Icons.ColorPicker}" Fill="{Binding #ThisControl.SampleFillBrush}"/>
|
||||
</Button>
|
||||
|
||||
<lvc:CartesianChart Grid.Row="1"
|
||||
Series="{Binding Series}"
|
||||
XAxes="{Binding XAxes}" YAxes="{Binding YAxes}"
|
||||
ZoomMode="X"
|
||||
DataContextChanged="OnReportChanged"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
|
|
|
@ -1,17 +1,65 @@
|
|||
using Avalonia;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
public partial class Statistics : ChromelessWindow
|
||||
{
|
||||
public static readonly StyledProperty<uint> SampleFillColorProperty =
|
||||
AvaloniaProperty.Register<Statistics, uint>(nameof(SampleFillColor));
|
||||
|
||||
public uint SampleFillColor
|
||||
{
|
||||
get => GetValue(SampleFillColorProperty);
|
||||
set => SetValue(SampleFillColorProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<IBrush> SampleFillBrushProperty =
|
||||
AvaloniaProperty.Register<Statistics, IBrush>(nameof(SampleFillBrush), Brushes.Transparent);
|
||||
|
||||
public IBrush SampleFillBrush
|
||||
{
|
||||
get => GetValue(SampleFillBrushProperty);
|
||||
set => SetValue(SampleFillBrushProperty, value);
|
||||
}
|
||||
|
||||
public Statistics()
|
||||
{
|
||||
SampleFillColor = ViewModels.Preference.Instance.StatisticsSampleColor;
|
||||
SampleFillBrush = new SolidColorBrush(SampleFillColor);
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
|
||||
{
|
||||
base.OnPropertyChanged(change);
|
||||
|
||||
if (change.Property == SampleFillColorProperty)
|
||||
ChangeColor(SampleFillColor);
|
||||
}
|
||||
|
||||
private void BeginMoveWindow(object _, PointerPressedEventArgs e)
|
||||
{
|
||||
BeginMoveDrag(e);
|
||||
}
|
||||
|
||||
private void OnReportChanged(object sender, System.EventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.Statistics { SelectedReport: Models.StatisticsReport report })
|
||||
report.ChangeColor(SampleFillColor);
|
||||
}
|
||||
|
||||
private void ChangeColor(uint color)
|
||||
{
|
||||
if (color != ViewModels.Preference.Instance.StatisticsSampleColor)
|
||||
{
|
||||
ViewModels.Preference.Instance.StatisticsSampleColor = color;
|
||||
SetCurrentValue(SampleFillBrushProperty, new SolidColorBrush(color));
|
||||
|
||||
if (DataContext is ViewModels.Statistics { SelectedReport: Models.StatisticsReport report })
|
||||
report.ChangeColor(color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue