From 7106f3b978c6a8d023f3f54bf1f1a28fbfff2758 Mon Sep 17 00:00:00 2001 From: leo Date: Thu, 7 Jan 2021 00:29:10 +0800 Subject: [PATCH] feature: add ChromeTabShape; new titlebar theme for Launcher --- src/Helpers/ChromeTabShape.cs | 38 +++++++++++++++ src/Resources/Themes/Dark.xaml | 4 +- src/UI/Launcher.xaml | 84 +++++++++++++--------------------- src/UI/Launcher.xaml.cs | 3 +- 4 files changed, 74 insertions(+), 55 deletions(-) create mode 100644 src/Helpers/ChromeTabShape.cs diff --git a/src/Helpers/ChromeTabShape.cs b/src/Helpers/ChromeTabShape.cs new file mode 100644 index 00000000..e9d81c97 --- /dev/null +++ b/src/Helpers/ChromeTabShape.cs @@ -0,0 +1,38 @@ +using System; +using System.Windows; +using System.Windows.Media; +using System.Windows.Shapes; + +namespace SourceGit.Helpers { + + /// + /// Chrome like tab shape + /// + public class ChromeTabShape : Shape { + protected override Geometry DefiningGeometry => MakeGeometry(); + + public ChromeTabShape() { + Stretch = Stretch.None; + StrokeThickness = 0; + } + + private Geometry MakeGeometry() { + var geo = new StreamGeometry(); + var cornerSize = new Size(4, 4); + var cornerAngle = Math.PI / 2; + using (var ctx = geo.Open()) { + ctx.BeginFigure(new Point(-5.1, ActualHeight), true, true); + ctx.ArcTo(new Point(-1.1, ActualHeight - 4), cornerSize, cornerAngle, false, SweepDirection.Counterclockwise, false, true); + ctx.LineTo(new Point(-1.1, 4), false, true); + ctx.ArcTo(new Point(2.9, 0), cornerSize, cornerAngle, false, SweepDirection.Clockwise, false, true); + ctx.LineTo(new Point(ActualWidth - 2.9, 0), false, true); + ctx.ArcTo(new Point(ActualWidth + 1.1, 4), cornerSize, cornerAngle, false, SweepDirection.Clockwise, false, true); + ctx.LineTo(new Point(ActualWidth + 1.1, ActualHeight - 4), false, true); + ctx.ArcTo(new Point(ActualWidth + 5.1, ActualHeight), cornerSize, cornerAngle, false, SweepDirection.Counterclockwise, false, true); + } + + geo.Freeze(); + return geo; + } + } +} diff --git a/src/Resources/Themes/Dark.xaml b/src/Resources/Themes/Dark.xaml index 37748cfc..3ea26cf5 100644 --- a/src/Resources/Themes/Dark.xaml +++ b/src/Resources/Themes/Dark.xaml @@ -3,10 +3,10 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> - + - + diff --git a/src/UI/Launcher.xaml b/src/UI/Launcher.xaml index ca27e7f9..df9fc0a0 100644 --- a/src/UI/Launcher.xaml +++ b/src/UI/Launcher.xaml @@ -6,6 +6,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:source="clr-namespace:SourceGit" xmlns:local="clr-namespace:SourceGit.UI" + xmlns:helpers="clr-namespace:SourceGit.Helpers" xmlns:converters="clr-namespace:SourceGit.Converters" mc:Ignorable="d" MinWidth="800" MinHeight="600" @@ -37,7 +38,7 @@ - + @@ -50,6 +51,12 @@ + + + + + + @@ -58,16 +65,16 @@ - + - - + @@ -90,7 +97,7 @@ - + @@ -163,28 +170,21 @@ - - + + + + + + - - - + - - - + - + - - - - - - - - - - - - - - - - - - - + @@ -241,7 +221,7 @@ - +