mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-24 20:57:19 -08:00
optimize<CommitGraph>: create pen as static resources; change style of dot point in CommitGraph
This commit is contained in:
parent
bfade2e69b
commit
0159dae85f
1 changed files with 14 additions and 15 deletions
|
@ -10,15 +10,15 @@ namespace SourceGit.Views.Controls {
|
||||||
/// 提交线路图
|
/// 提交线路图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CommitGraph : FrameworkElement {
|
public class CommitGraph : FrameworkElement {
|
||||||
public static readonly Brush[] COLORS = new Brush[] {
|
public static readonly Pen[] PENS = new Pen[] {
|
||||||
Brushes.Orange,
|
new Pen(Brushes.Orange, 2),
|
||||||
Brushes.ForestGreen,
|
new Pen(Brushes.ForestGreen, 2),
|
||||||
Brushes.Gold,
|
new Pen(Brushes.Gold, 2),
|
||||||
Brushes.Magenta,
|
new Pen(Brushes.Magenta, 2),
|
||||||
Brushes.Red,
|
new Pen(Brushes.Red, 2),
|
||||||
Brushes.Gray,
|
new Pen(Brushes.Gray, 2),
|
||||||
Brushes.Turquoise,
|
new Pen(Brushes.Turquoise, 2),
|
||||||
Brushes.Olive,
|
new Pen(Brushes.Olive, 2),
|
||||||
};
|
};
|
||||||
|
|
||||||
public static readonly double UNIT_WIDTH = 12;
|
public static readonly double UNIT_WIDTH = 12;
|
||||||
|
@ -45,7 +45,7 @@ namespace SourceGit.Views.Controls {
|
||||||
LastY = start.Y;
|
LastY = start.Y;
|
||||||
|
|
||||||
Line = new Line();
|
Line = new Line();
|
||||||
Line.Color = color % COLORS.Length;
|
Line.Color = color % PENS.Length;
|
||||||
Line.Points.Add(start);
|
Line.Points.Add(start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ namespace SourceGit.Views.Controls {
|
||||||
if (last.Y > bottom) continue;
|
if (last.Y > bottom) continue;
|
||||||
|
|
||||||
var geo = new StreamGeometry();
|
var geo = new StreamGeometry();
|
||||||
var pen = new Pen(COLORS[line.Color], 2);
|
var pen = PENS[line.Color];
|
||||||
using (var ctx = geo.Open()) {
|
using (var ctx = geo.Open()) {
|
||||||
ctx.BeginFigure(last, false, false);
|
ctx.BeginFigure(last, false, false);
|
||||||
|
|
||||||
|
@ -289,23 +289,22 @@ namespace SourceGit.Views.Controls {
|
||||||
if (link.Start.Y > bottom) break;
|
if (link.Start.Y > bottom) break;
|
||||||
|
|
||||||
var geo = new StreamGeometry();
|
var geo = new StreamGeometry();
|
||||||
var pen = new Pen(COLORS[link.Color], 2);
|
|
||||||
|
|
||||||
using (var ctx = geo.Open()) {
|
using (var ctx = geo.Open()) {
|
||||||
ctx.BeginFigure(link.Start, false, false);
|
ctx.BeginFigure(link.Start, false, false);
|
||||||
ctx.QuadraticBezierTo(link.Control, link.End, true, false);
|
ctx.QuadraticBezierTo(link.Control, link.End, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
geo.Freeze();
|
geo.Freeze();
|
||||||
dc.DrawGeometry(null, pen, geo);
|
dc.DrawGeometry(null, PENS[link.Color], geo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 绘制点
|
// 绘制点
|
||||||
|
var dotFill = FindResource("Brush.Contents") as Brush;
|
||||||
foreach (var dot in data.Dots) {
|
foreach (var dot in data.Dots) {
|
||||||
if (dot.Center.Y < top) continue;
|
if (dot.Center.Y < top) continue;
|
||||||
if (dot.Center.Y > bottom) break;
|
if (dot.Center.Y > bottom) break;
|
||||||
|
|
||||||
dc.DrawEllipse(COLORS[dot.Color], null, dot.Center, 3, 3);
|
dc.DrawEllipse(dotFill, PENS[dot.Color], dot.Center, 3, 3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue