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

View file

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

View file

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

View file

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

View file

@ -128,47 +128,52 @@
<ContentControl Grid.Row="2" Content="{Binding SelectedReport, Mode=OneWay}"> <ContentControl Grid.Row="2" Content="{Binding SelectedReport, Mode=OneWay}">
<ContentControl.DataTemplates> <ContentControl.DataTemplates>
<DataTemplate DataType="m:StatisticsReport"> <DataTemplate DataType="m:StatisticsReport">
<Grid RowDefinitions="*,32" ColumnDefinitions="256,*" Margin="8"> <Grid ColumnDefinitions="256,*" Margin="8,8,8,16">
<!-- Table By Committer --> <Grid Grid.Column="0" RowDefinitions="*,16">
<DataGrid Grid.Row="0" Grid.Column="0" <!-- Table By Committer -->
ItemsSource="{Binding ByCommitter}" <DataGrid Grid.Row="0"
SelectionMode="Single" ItemsSource="{Binding ByCommitter}"
CanUserReorderColumns="False" SelectionMode="Single"
CanUserResizeColumns="False" CanUserReorderColumns="False"
CanUserSortColumns="False" CanUserResizeColumns="False"
HeadersVisibility="Column" CanUserSortColumns="False"
GridLinesVisibility="All" HeadersVisibility="Column"
BorderThickness="1" GridLinesVisibility="All"
BorderBrush="{DynamicResource Brush.Border1}" BorderThickness="1"
Background="{DynamicResource Brush.Contents}" BorderBrush="{DynamicResource Brush.Border1}"
IsReadOnly="True" Background="{DynamicResource Brush.Contents}"
RowHeight="26" IsReadOnly="True"
HorizontalScrollBarVisibility="Disabled" RowHeight="26"
VerticalScrollBarVisibility="Auto"> HorizontalScrollBarVisibility="Disabled"
<DataGrid.Columns> VerticalScrollBarVisibility="Auto">
<DataGridTextColumn Width="150" Header="{DynamicResource Text.Statistics.Committer}" Binding="{Binding Name}"/> <DataGrid.Columns>
<DataGridTextColumn Width="*" Header="{DynamicResource Text.Statistics.CommitAmount}" Binding="{Binding Count}"/> <DataGridTextColumn Width="150" Header="{DynamicResource Text.Statistics.Committer}" Binding="{Binding Name}"/>
</DataGrid.Columns> <DataGridTextColumn Width="*" Header="{DynamicResource Text.Statistics.CommitAmount}" Binding="{Binding Count}"/>
</DataGrid> </DataGrid.Columns>
</DataGrid>
<!-- Total Committers --> <!-- Summary -->
<StackPanel Grid.Row="1" Grid.Column="0" Orientation="Horizontal"> <Grid Grid.Row="1" ColumnDefinitions="*,*">
<TextBlock Text="{DynamicResource Text.Statistics.TotalCommitters}" Foreground="{DynamicResource Brush.FG2}" FontWeight="Bold"/> <!-- Total Committers -->
<TextBlock Text="{Binding ByCommitter.Count}" Margin="4,0,0,0"/> <StackPanel Grid.Column="0" Orientation="Horizontal" VerticalAlignment="Bottom">
</StackPanel> <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>
<!-- Total Commits -->
<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 --> <!-- Graph -->
<v:Chart Grid.Row="0" Grid.Column="1" <v:Chart Grid.Column="1"
Margin="16,8,0,0" Margin="16,0,0,0"
LineBrush="{DynamicResource Brush.FG1}" LineBrush="{DynamicResource Brush.Border1}"
ShapeBrush="{DynamicResource Brush.Accent1}" ShapeBrush="{DynamicResource Brush.Accent1}"
Samples="{Binding Samples}"/> 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> </Grid>
</DataTemplate> </DataTemplate>
</ContentControl.DataTemplates> </ContentControl.DataTemplates>

View file

@ -104,8 +104,7 @@ namespace SourceGit.Views
var horizonStart = maxLabel.Width + 8; var horizonStart = maxLabel.Width + 8;
var labelHeight = maxLabel.Height; var labelHeight = maxLabel.Height;
context.DrawText(maxLabel, new Point(0, -maxLabel.Height * 0.5)); context.DrawText(maxLabel, new Point(0, -maxLabel.Height * 0.5));
context.DrawLine(pen, new Point(horizonStart, 0), new Point(horizonStart, height - labelHeight)); context.DrawRectangle(pen, new Rect(horizonStart, 0, width - horizonStart, height - labelHeight));
context.DrawLine(pen, new Point(horizonStart, height - labelHeight), new Point(width, height - labelHeight));
if (samples.Count == 0) if (samples.Count == 0)
return; return;
@ -114,7 +113,7 @@ namespace SourceGit.Views
var stepX = (width - horizonStart) / samples.Count; var stepX = (width - horizonStart) / samples.Count;
var stepV = (height - labelHeight) / 5; var stepV = (height - labelHeight) / 5;
var labelStepV = maxV / 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++) for (int i = 1; i < 5; i++)
{ {
var vLabel = new FormattedText( var vLabel = new FormattedText(