mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-10-31 13:03:20 -07:00
ux: new theme for statistics
This commit is contained in:
parent
3d205378d8
commit
a472d07544
2 changed files with 28 additions and 27 deletions
|
@ -76,8 +76,13 @@
|
|||
<Setter Property="Background" Value="Transparent"/>
|
||||
</Style>
|
||||
|
||||
<Style Selector="ListBoxItem Border.switcher_bg">
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Border2}"/>
|
||||
</Style>
|
||||
|
||||
<Style Selector="ListBoxItem:selected Border.switcher_bg">
|
||||
<Setter Property="Background" Value="{DynamicResource Brush.Accent}"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Accent}"/>
|
||||
</Style>
|
||||
|
||||
<Style Selector="TextBlock.view_mode_switcher">
|
||||
|
@ -91,19 +96,19 @@
|
|||
</ListBox.Styles>
|
||||
|
||||
<ListBoxItem>
|
||||
<Border Classes="switcher_bg" Height="28" Padding="16,0" BorderThickness="1,1,0,1" BorderBrush="{DynamicResource Brush.Border1}" CornerRadius="14,0,0,14">
|
||||
<Border Classes="switcher_bg" Height="28" Padding="16,0" BorderThickness="1,1,0,1" CornerRadius="14,0,0,14">
|
||||
<TextBlock Classes="view_mode_switcher" Text="{DynamicResource Text.Statistics.ThisYear}"/>
|
||||
</Border>
|
||||
</ListBoxItem>
|
||||
|
||||
<ListBoxItem>
|
||||
<Border Classes="switcher_bg" Height="28" Padding="16,0" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}">
|
||||
<Border Classes="switcher_bg" Height="28" Padding="16,0" BorderThickness="1">
|
||||
<TextBlock Classes="view_mode_switcher" Text="{DynamicResource Text.Statistics.ThisMonth}"/>
|
||||
</Border>
|
||||
</ListBoxItem>
|
||||
|
||||
<ListBoxItem>
|
||||
<Border Classes="switcher_bg" Height="28" Padding="16,0" BorderThickness="0,1,1,1" BorderBrush="{DynamicResource Brush.Border1}" CornerRadius="0,14,14,0">
|
||||
<Border Classes="switcher_bg" Height="28" Padding="16,0" BorderThickness="0,1,1,1" CornerRadius="0,14,14,0">
|
||||
<TextBlock Classes="view_mode_switcher" Text="{DynamicResource Text.Statistics.ThisWeek}"/>
|
||||
</Border>
|
||||
</ListBoxItem>
|
||||
|
@ -125,10 +130,10 @@
|
|||
HeadersVisibility="Column"
|
||||
GridLinesVisibility="All"
|
||||
BorderThickness="1"
|
||||
BorderBrush="{DynamicResource Brush.Border1}"
|
||||
BorderBrush="{DynamicResource Brush.Border2}"
|
||||
Background="{DynamicResource Brush.Contents}"
|
||||
HorizontalGridLinesBrush="{DynamicResource Brush.Border1}"
|
||||
VerticalGridLinesBrush="{DynamicResource Brush.Border1}"
|
||||
HorizontalGridLinesBrush="{DynamicResource Brush.Border2}"
|
||||
VerticalGridLinesBrush="{DynamicResource Brush.Border2}"
|
||||
IsReadOnly="True"
|
||||
RowHeight="26"
|
||||
HorizontalScrollBarVisibility="Disabled"
|
||||
|
@ -138,8 +143,8 @@
|
|||
<Setter Property="Background" Value="{DynamicResource Brush.Window}"/>
|
||||
<Setter Property="Padding" Value="8,0,0,0"/>
|
||||
<Setter Property="BorderThickness" Value="0,0,0,1"/>
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Border1}"/>
|
||||
<Setter Property="SeparatorBrush" Value="{DynamicResource Brush.Border1}" />
|
||||
<Setter Property="BorderBrush" Value="{DynamicResource Brush.Border2}"/>
|
||||
<Setter Property="SeparatorBrush" Value="{DynamicResource Brush.Border2}" />
|
||||
|
||||
<Style Selector="^:pointerover /template/ Grid#PART_ColumnHeaderRoot">
|
||||
<Setter Property="Background" Value="{DynamicResource Brush.Window}"/>
|
||||
|
@ -176,7 +181,8 @@
|
|||
<!-- Graph -->
|
||||
<v:Chart Grid.Column="1"
|
||||
Margin="16,0,0,0"
|
||||
LineBrush="{DynamicResource Brush.Border1}"
|
||||
LabelBrush="{DynamicResource Brush.FG1}"
|
||||
LineBrush="{DynamicResource Brush.Border2}"
|
||||
ShapeBrush="{DynamicResource Brush.Accent}"
|
||||
Samples="{Binding Samples}"/>
|
||||
</Grid>
|
||||
|
|
|
@ -12,6 +12,15 @@ namespace SourceGit.Views
|
|||
{
|
||||
public class Chart : Control
|
||||
{
|
||||
public static readonly StyledProperty<IBrush> LabelBrushProperty =
|
||||
AvaloniaProperty.Register<Chart, IBrush>(nameof(LabelBrush), Brushes.Black);
|
||||
|
||||
public IBrush LabelBrush
|
||||
{
|
||||
get => GetValue(LabelBrushProperty);
|
||||
set => SetValue(LabelBrushProperty, value);
|
||||
}
|
||||
|
||||
public static readonly StyledProperty<IBrush> LineBrushProperty =
|
||||
AvaloniaProperty.Register<Chart, IBrush>(nameof(LineBrush), Brushes.Gray);
|
||||
|
||||
|
@ -63,33 +72,19 @@ namespace SourceGit.Views
|
|||
}
|
||||
|
||||
if (maxV < 5)
|
||||
{
|
||||
maxV = 5;
|
||||
}
|
||||
else if (maxV < 10)
|
||||
{
|
||||
maxV = 10;
|
||||
}
|
||||
else if (maxV < 50)
|
||||
{
|
||||
maxV = 50;
|
||||
}
|
||||
else if (maxV < 100)
|
||||
{
|
||||
maxV = 100;
|
||||
}
|
||||
else if (maxV < 200)
|
||||
{
|
||||
maxV = 200;
|
||||
}
|
||||
else if (maxV < 500)
|
||||
{
|
||||
maxV = 500;
|
||||
}
|
||||
else
|
||||
{
|
||||
maxV = (int)Math.Ceiling(maxV / 500.0) * 500;
|
||||
}
|
||||
|
||||
var typeface = new Typeface("fonts:SourceGit#JetBrains Mono");
|
||||
var pen = new Pen(LineBrush, 1);
|
||||
|
@ -100,7 +95,7 @@ namespace SourceGit.Views
|
|||
context.DrawRectangle(Brushes.Transparent, null, new Rect(0, 0, width, height));
|
||||
|
||||
// Draw coordinate
|
||||
var maxLabel = new FormattedText($"{maxV}", CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 12.0, LineBrush);
|
||||
var maxLabel = new FormattedText($"{maxV}", CultureInfo.CurrentCulture, FlowDirection.LeftToRight, typeface, 12.0, LabelBrush);
|
||||
var horizonStart = maxLabel.Width + 8;
|
||||
var labelHeight = maxLabel.Height;
|
||||
context.DrawText(maxLabel, new Point(0, -maxLabel.Height * 0.5));
|
||||
|
@ -122,7 +117,7 @@ namespace SourceGit.Views
|
|||
FlowDirection.LeftToRight,
|
||||
typeface,
|
||||
12.0,
|
||||
LineBrush);
|
||||
LabelBrush);
|
||||
|
||||
var dashHeight = i * stepV;
|
||||
var vy = Math.Max(0, dashHeight - vLabel.Height * 0.5);
|
||||
|
@ -155,7 +150,7 @@ namespace SourceGit.Views
|
|||
FlowDirection.LeftToRight,
|
||||
typeface,
|
||||
10.0,
|
||||
LineBrush);
|
||||
LabelBrush);
|
||||
var rect = _hitBoxes[i];
|
||||
var xLabel = rect.X - (hLabel.Width - rect.Width) * 0.5;
|
||||
var yLabel = height - labelHeight + 4;
|
||||
|
@ -188,7 +183,7 @@ namespace SourceGit.Views
|
|||
FlowDirection.LeftToRight,
|
||||
typeface,
|
||||
12.0,
|
||||
LineBrush);
|
||||
LabelBrush);
|
||||
|
||||
var tx = rect.X - (tooltip.Width - rect.Width) * 0.5;
|
||||
var ty = rect.Y - tooltip.Height - 4;
|
||||
|
|
Loading…
Reference in a new issue