From c0348b73bd1df091489df2fa6569542030028556 Mon Sep 17 00:00:00 2001 From: ghiboz Date: Fri, 5 Jul 2024 14:02:30 +0200 Subject: [PATCH] set pen thickness "General": { "Pen.Thickness": "4.4" } --- src/App.axaml.cs | 17 +++++++++++++++++ src/Models/CommitGraph.cs | 10 ++++++++++ src/Models/CustomColorSchema.cs | 1 + src/Views/Histories.axaml.cs | 2 ++ 4 files changed, 30 insertions(+) diff --git a/src/App.axaml.cs b/src/App.axaml.cs index f989a325..785b511c 100644 --- a/src/App.axaml.cs +++ b/src/App.axaml.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Globalization; using System.IO; using System.Net.Http; using System.Reflection; @@ -188,6 +189,22 @@ namespace SourceGit Models.CommitGraph.SetPenColors(penColors); } + foreach (var kv in schema.General) + { + if (kv.Key.Equals("Pen.Thickness", StringComparison.Ordinal)) + { + double thick = Models.CommitGraph.GetPenThickness(); + try + { + thick = double.Parse(kv.Value, CultureInfo.InvariantCulture); + } + catch + { + } + Models.CommitGraph.SetPenThickness(thick); + } + } + app.Resources.MergedDictionaries.Add(resDic); app._colorOverrides = resDic; } diff --git a/src/Models/CommitGraph.cs b/src/Models/CommitGraph.cs index bc0ea8e1..c0ffe820 100644 --- a/src/Models/CommitGraph.cs +++ b/src/Models/CommitGraph.cs @@ -123,6 +123,15 @@ namespace SourceGit.Models _penCount = colors.Count; } + public static void SetPenThickness(double value) + { + _penThickness = value; + } + public static double GetPenThickness() + { + return _penThickness; + } + public static CommitGraph Parse(List commits) { double UNIT_WIDTH = 12; @@ -268,6 +277,7 @@ namespace SourceGit.Models return temp; } + private static double _penThickness = 1; private static int _penCount = 0; private static readonly List _defaultPenColors = [ Colors.Orange, diff --git a/src/Models/CustomColorSchema.cs b/src/Models/CustomColorSchema.cs index 4266b98e..943b916e 100644 --- a/src/Models/CustomColorSchema.cs +++ b/src/Models/CustomColorSchema.cs @@ -6,5 +6,6 @@ namespace SourceGit.Models { public Dictionary Basic { get; set; } = new Dictionary(); public List Graph { get; set; } = new List(); + public Dictionary General { get; set; } = new Dictionary(); } } diff --git a/src/Views/Histories.axaml.cs b/src/Views/Histories.axaml.cs index 37ad441d..6ac67d0b 100644 --- a/src/Views/Histories.axaml.cs +++ b/src/Views/Histories.axaml.cs @@ -158,6 +158,8 @@ namespace SourceGit.Views var geo = new StreamGeometry(); var pen = Models.CommitGraph.Pens[line.Color]; + pen.Thickness = Models.CommitGraph.GetPenThickness(); + using (var ctx = geo.Open()) { var started = false;