ux: new style for statistics page

This commit is contained in:
leo 2024-04-03 17:34:06 +08:00
parent 3d5a9f9d8b
commit bcb83af576
6 changed files with 52 additions and 48 deletions

View file

@ -3607,7 +3607,7 @@ namespace SourceGit.Resources {
}
/// <summary>
/// Looks up a localized string similar to Total Commits.
/// Looks up a localized string similar to COMMITS: .
/// </summary>
public static string Text_Statistics_TotalCommits {
get {
@ -3616,7 +3616,7 @@ namespace SourceGit.Resources {
}
/// <summary>
/// Looks up a localized string similar to Total Committers.
/// Looks up a localized string similar to COMMITTERS: .
/// </summary>
public static string Text_Statistics_TotalCommitters {
get {

View file

@ -1201,10 +1201,10 @@
<value>YEAR</value>
</data>
<data xml:space="preserve" name="Text.Statistics.TotalCommitters">
<value>Total Committers</value>
<value>COMMITTERS: </value>
</data>
<data xml:space="preserve" name="Text.Statistics.TotalCommits">
<value>Total Commits</value>
<value>COMMITS: </value>
</data>
<data xml:space="preserve" name="Text.Statistics.Committer">
<value>COMMITTER</value>

View file

@ -1201,10 +1201,10 @@
<value>YEAR</value>
</data>
<data xml:space="preserve" name="Text.Statistics.TotalCommitters">
<value>Total Committers</value>
<value>COMMITTERS: </value>
</data>
<data xml:space="preserve" name="Text.Statistics.TotalCommits">
<value>Total Commits</value>
<value>COMMITS: </value>
</data>
<data xml:space="preserve" name="Text.Statistics.Committer">
<value>COMMITTER</value>

View file

@ -1198,10 +1198,10 @@
<value>本年</value>
</data>
<data xml:space="preserve" name="Text.Statistics.TotalCommitters">
<value>提交者人数</value>
<value>提交者: </value>
</data>
<data xml:space="preserve" name="Text.Statistics.TotalCommits">
<value>总计提交次数</value>
<value>提交次数: </value>
</data>
<data xml:space="preserve" name="Text.Statistics.Committer">
<value>提交者</value>

View file

@ -128,9 +128,10 @@
<ContentControl Grid.Row="2" Content="{Binding SelectedReport, Mode=OneWay}">
<ContentControl.DataTemplates>
<DataTemplate DataType="m:StatisticsReport">
<Grid RowDefinitions="*,32" ColumnDefinitions="256,*" Margin="8">
<Grid ColumnDefinitions="256,*" Margin="8,8,8,16">
<Grid Grid.Column="0" RowDefinitions="*,16">
<!-- Table By Committer -->
<DataGrid Grid.Row="0" Grid.Column="0"
<DataGrid Grid.Row="0"
ItemsSource="{Binding ByCommitter}"
SelectionMode="Single"
CanUserReorderColumns="False"
@ -151,25 +152,29 @@
</DataGrid.Columns>
</DataGrid>
<!-- Summary -->
<Grid Grid.Row="1" ColumnDefinitions="*,*">
<!-- Total Committers -->
<StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal">
<TextBlock Text="{DynamicResource Text.Statistics.TotalCommitters}" Foreground="{DynamicResource Brush.FG2}" FontWeight="Bold"/>
<TextBlock Text="{Binding ByCommitter.Count}" Margin="4,0,0,0"/>
<StackPanel Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Bottom">
<TextBlock Classes="monospace" Text="{DynamicResource Text.Statistics.TotalCommitters}" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
<TextBlock Classes="monospace" Text="{Binding ByCommitter.Count}" FontSize="11" Margin="4,0,0,0"/>
</StackPanel>
<!-- Graph -->
<v:Chart Grid.Row="0" Grid.Column="1"
Margin="16,8,0,0"
LineBrush="{DynamicResource Brush.FG1}"
ShapeBrush="{DynamicResource Brush.Accent1}"
Samples="{Binding Samples}"/>
<!-- Total Commits -->
<StackPanel Grid.Row="1" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right">
<TextBlock Text="{DynamicResource Text.Statistics.TotalCommits}" Foreground="{DynamicResource Brush.FG2}" FontWeight="Bold"/>
<TextBlock Text="{Binding Total}" Margin="4,0,0,0"/>
<StackPanel Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" VerticalAlignment="Bottom">
<TextBlock Classes="monospace" Text="{DynamicResource Text.Statistics.TotalCommits}" FontSize="11" Foreground="{DynamicResource Brush.FG2}"/>
<TextBlock Classes="monospace" Text="{Binding Total}" FontSize="11" Margin="4,0,0,0"/>
</StackPanel>
</Grid>
</Grid>
<!-- Graph -->
<v:Chart Grid.Column="1"
Margin="16,0,0,0"
LineBrush="{DynamicResource Brush.Border1}"
ShapeBrush="{DynamicResource Brush.Accent1}"
Samples="{Binding Samples}"/>
</Grid>
</DataTemplate>
</ContentControl.DataTemplates>
</ContentControl>

View file

@ -104,8 +104,7 @@ namespace SourceGit.Views
var horizonStart = maxLabel.Width + 8;
var labelHeight = maxLabel.Height;
context.DrawText(maxLabel, new Point(0, -maxLabel.Height * 0.5));
context.DrawLine(pen, new Point(horizonStart, 0), new Point(horizonStart, height - labelHeight));
context.DrawLine(pen, new Point(horizonStart, height - labelHeight), new Point(width, height - labelHeight));
context.DrawRectangle(pen, new Rect(horizonStart, 0, width - horizonStart, height - labelHeight));
if (samples.Count == 0)
return;
@ -114,7 +113,7 @@ namespace SourceGit.Views
var stepX = (width - horizonStart) / samples.Count;
var stepV = (height - labelHeight) / 5;
var labelStepV = maxV / 5;
var gridPen = new Pen(LineBrush, 1, new DashStyle());
var gridPen = new Pen(LineBrush, 1, new DashStyle() { Dashes = [2, 2, 0, 2], Offset = 1 });
for (int i = 1; i < 5; i++)
{
var vLabel = new FormattedText(