optimize<CommitGraph>: remove unused polyline mode

This commit is contained in:
leo 2021-10-08 16:46:14 +08:00
parent ade45732f2
commit 7c44c0a840
6 changed files with 20 additions and 88 deletions

View file

@ -254,11 +254,7 @@ namespace SourceGit.Views.Controls {
var bottom = startY + ActualHeight;
// 绘制线
if (Models.Preference.Instance.Window.UsePolylineInGraph) {
DrawPolyLines(dc, top, bottom);
} else {
DrawCurves(dc, top, bottom);
}
DrawCurves(dc, top, bottom);
// 绘制点
var dotFill = FindResource("Brush.Contents") as Brush;
@ -341,51 +337,5 @@ namespace SourceGit.Views.Controls {
dc.DrawGeometry(null, PENS[link.Color], geo);
}
}
private void DrawPolyLines(DrawingContext dc, double top, double bottom) {
foreach (var line in data.Paths) {
var last = line.Points[0];
var size = line.Points.Count;
if (line.Points[size - 1].Y < top) continue;
if (last.Y > bottom) continue;
var geo = new StreamGeometry();
var pen = PENS[line.Color];
using (var ctx = geo.Open()) {
var started = false;
var ended = false;
for (int i = 1; i < size; i++) {
var cur = line.Points[i];
if (cur.Y < top) {
last = cur;
continue;
}
if (!started) {
ctx.BeginFigure(last, false, false);
}
if (cur.Y > bottom) {
cur.Y = bottom;
ended = true;
}
ctx.LineTo(cur, true, false);
if (ended) break;
last = cur;
}
}
geo.Freeze();
dc.DrawGeometry(null, pen, geo);
}
foreach (var link in data.Links) {
if (link.End.Y < top) continue;
if (link.Start.Y > bottom) break;
dc.DrawLine(PENS[link.Color], link.Start, link.End);
}
}
}
}

View file

@ -192,24 +192,16 @@
</Border>
<!-- Right Top Button -->
<StackPanel HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,6,8,0" Orientation="Horizontal">
<ToggleButton
Style="{StaticResource Style.ToggleButton.CommitGraphMode}"
Foreground="{DynamicResource Brush.FG2}"
Width="16" Height="16"
ToolTip="{DynamicResource Text.Histories.GraphMode}"
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=Window.UsePolylineInGraph, Mode=TwoWay}"
Checked="ChangeGraphMode" Unchecked="ChangeGraphMode"/>
<ToggleButton
Style="{StaticResource Style.ToggleButton.SplitDirection}"
Foreground="{DynamicResource Brush.FG2}"
Width="16" Height="16"
Margin="8,0,0,0"
ToolTip="{DynamicResource Text.Histories.DisplayMode}"
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=Window.MoveCommitInfoRight, Mode=TwoWay, Converter={StaticResource InverseBool}}"
Checked="ChangeOrientation" Unchecked="ChangeOrientation"/>
</StackPanel>
<ToggleButton
HorizontalAlignment="Right"
VerticalAlignment="Top"
Style="{StaticResource Style.ToggleButton.SplitDirection}"
Foreground="{DynamicResource Brush.FG2}"
Width="16" Height="16"
Margin="0,6,8,0"
ToolTip="{DynamicResource Text.Histories.DisplayMode}"
IsChecked="{Binding Source={x:Static models:Preference.Instance}, Path=Window.MoveCommitInfoRight, Mode=TwoWay, Converter={StaticResource InverseBool}}"
Checked="ChangeOrientation" Unchecked="ChangeOrientation"/>
</Grid>
</Grid>
</UserControl>

View file

@ -145,11 +145,6 @@ namespace SourceGit.Views.Widgets {
layout.InvalidateArrange();
}
public void ChangeGraphMode(object sender, RoutedEventArgs e) {
graph.InvalidateVisual();
e.Handled = true;
}
#endregion
#region SEARCH_BAR

View file

@ -4,6 +4,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
xmlns:models="clr-namespace:SourceGit.Models"
xmlns:widgets="clr-namespace:SourceGit.Views.Widgets"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
@ -15,11 +16,11 @@
<Grid Grid.Row="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80"/>
<ColumnDefinition Width="48"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="48"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="80"/>
<ColumnDefinition Width="48"/>
</Grid.ColumnDefinitions>
<Border
@ -48,11 +49,11 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" x:Name="txtStartSHA" Foreground="DarkOrange"/>
<TextBlock Grid.Column="1" x:Name="txtStartTime" Foreground="{DynamicResource Brush.FG2}" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="0" x:Name="txtStartSHA" Foreground="DarkOrange" FontFamily="{Binding Source={x:Static models:Preference.Instance}, Path=General.FontFamilyContent, Mode=OneWay}"/>
<TextBlock Grid.Column="1" x:Name="txtStartTime" Foreground="{DynamicResource Brush.FG2}" HorizontalAlignment="Right" FontFamily="{Binding Source={x:Static models:Preference.Instance}, Path=General.FontFamilyContent, Mode=OneWay}"/>
</Grid>
<TextBlock Grid.Row="1" x:Name="txtStartSubject" FontSize="10pt" VerticalAlignment="Bottom"/>
<TextBlock Grid.Row="1" x:Name="txtStartSubject" VerticalAlignment="Bottom" FontFamily="{Binding Source={x:Static models:Preference.Instance}, Path=General.FontFamilyContent, Mode=OneWay}" FontSize="10pt"/>
</Grid>
</Grid>
</Border>
@ -94,11 +95,11 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" x:Name="txtEndSHA" Foreground="DarkOrange"/>
<TextBlock Grid.Column="1" x:Name="txtEndTime" Foreground="{DynamicResource Brush.FG2}" HorizontalAlignment="Right"/>
<TextBlock Grid.Column="0" x:Name="txtEndSHA" Foreground="DarkOrange" FontFamily="{Binding Source={x:Static models:Preference.Instance}, Path=General.FontFamilyContent, Mode=OneWay}" />
<TextBlock Grid.Column="1" x:Name="txtEndTime" Foreground="{DynamicResource Brush.FG2}" HorizontalAlignment="Right" FontFamily="{Binding Source={x:Static models:Preference.Instance}, Path=General.FontFamilyContent, Mode=OneWay}" />
</Grid>
<TextBlock Grid.Row="1" x:Name="txtEndSubject" FontSize="10pt" VerticalAlignment="Bottom"/>
<TextBlock Grid.Row="1" x:Name="txtEndSubject" VerticalAlignment="Bottom" FontFamily="{Binding Source={x:Static models:Preference.Instance}, Path=General.FontFamilyContent, Mode=OneWay}" FontSize="10pt"/>
</Grid>
</Grid>
</Border>