diff --git a/src/Converters/IntToRepoColor.cs b/src/Converters/IntToRepoColor.cs index 8a328224..338f5403 100644 --- a/src/Converters/IntToRepoColor.cs +++ b/src/Converters/IntToRepoColor.cs @@ -15,6 +15,7 @@ namespace SourceGit.Converters { /// All supported colors. /// public static Brush[] Colors = new Brush[] { + Brushes.Transparent, Brushes.White, Brushes.Red, Brushes.Orange, diff --git a/src/UI/Launcher.xaml b/src/UI/Launcher.xaml index 03bbb580..629b3983 100644 --- a/src/UI/Launcher.xaml +++ b/src/UI/Launcher.xaml @@ -88,6 +88,7 @@ + + + + diff --git a/src/UI/Launcher.xaml.cs b/src/UI/Launcher.xaml.cs index bbbd7ec2..c13c1d12 100644 --- a/src/UI/Launcher.xaml.cs +++ b/src/UI/Launcher.xaml.cs @@ -188,18 +188,19 @@ namespace SourceGit.UI { e.Handled = true; }; + var iconBookmark = FindResource("Icon.Bookmark") as Geometry; var bookmark = new MenuItem(); bookmark.Header = "Bookmark"; for (int i = 0; i < Converters.IntToRepoColor.Colors.Length; i++) { var icon = new System.Windows.Shapes.Path(); icon.Style = FindResource("Style.Icon") as Style; - icon.Data = Geometry.Parse("M 0,0 A 180,180 180 1 1 1,1 Z"); + icon.Data = iconBookmark; icon.Fill = Converters.IntToRepoColor.Colors[i]; - icon.Width = 12; + icon.Width = 8; var mark = new MenuItem(); mark.Icon = icon; - mark.Header = $"{i + 1}"; + mark.Header = $"{i}"; var refIdx = i; mark.Click += (o, e) => { diff --git a/src/UI/Manager.xaml b/src/UI/Manager.xaml index 8f462b22..6ab395c6 100644 --- a/src/UI/Manager.xaml +++ b/src/UI/Manager.xaml @@ -6,8 +6,15 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:SourceGit.UI" xmlns:git="clr-namespace:SourceGit.Git" + xmlns:converters="clr-namespace:SourceGit.Converters" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"> + + + + + + @@ -48,11 +55,27 @@ - - - - - + + + + + + + + + + + + + + + + @@ -71,7 +94,7 @@ - @@ -82,6 +105,7 @@ Padding="0" AllowDrop="True" ContextMenuOpening="TreeContextMenuOpening" + ScrollViewer.HorizontalScrollBarVisibility="Disabled" Drop="TreeDrop" GotFocus="TreeGotFocus" MouseMove="TreeMouseMove"> @@ -105,12 +129,44 @@ - + + - - - + + + + + + + + diff --git a/src/UI/Manager.xaml.cs b/src/UI/Manager.xaml.cs index 0071020c..6609410b 100644 --- a/src/UI/Manager.xaml.cs +++ b/src/UI/Manager.xaml.cs @@ -6,6 +6,7 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Input; +using System.Windows.Media; namespace SourceGit.UI { @@ -25,6 +26,7 @@ namespace SourceGit.UI { public bool IsRepo { get; set; } public bool IsExpended { get; set; } public bool IsEditing { get; set; } + public int Color { get; set; } public List Children { get; set; } = new List(); } @@ -100,6 +102,31 @@ namespace SourceGit.UI { ev.Handled = true; }; + var iconBookmark = FindResource("Icon.Bookmark") as Geometry; + var bookmark = new MenuItem(); + bookmark.Header = "Bookmark"; + for (int i = 0; i < Converters.IntToRepoColor.Colors.Length; i++) { + var icon = new System.Windows.Shapes.Path(); + icon.Style = FindResource("Style.Icon") as Style; + icon.Data = iconBookmark; + icon.Fill = Converters.IntToRepoColor.Colors[i]; + icon.Width = 8; + + var mark = new MenuItem(); + mark.Icon = icon; + mark.Header = $"{i}"; + + var refIdx = i; + mark.Click += (o, e) => { + repo.Color = refIdx; + UpdateRecentOpened(); + UpdateTree(); + e.Handled = true; + }; + + bookmark.Items.Add(mark); + } + var delete = new MenuItem(); delete.Header = "Delete"; delete.Click += (o, ev) => { @@ -113,6 +140,7 @@ namespace SourceGit.UI { var menu = new ContextMenu(); menu.Items.Add(open); menu.Items.Add(explore); + menu.Items.Add(bookmark); menu.Items.Add(delete); menu.IsOpen = true; e.Handled = true; @@ -301,8 +329,37 @@ namespace SourceGit.UI { ev.Handled = true; }; + var iconBookmark = FindResource("Icon.Bookmark") as Geometry; + var bookmark = new MenuItem(); + bookmark.Header = "Bookmark"; + for (int i = 0; i < Converters.IntToRepoColor.Colors.Length; i++) { + var icon = new System.Windows.Shapes.Path(); + icon.Style = FindResource("Style.Icon") as Style; + icon.Data = iconBookmark; + icon.Fill = Converters.IntToRepoColor.Colors[i]; + icon.Width = 8; + + var mark = new MenuItem(); + mark.Icon = icon; + mark.Header = $"{i}"; + + var refIdx = i; + mark.Click += (o, e) => { + var repo = App.Preference.FindRepository(node.Id); + if (repo != null) { + repo.Color = refIdx; + UpdateRecentOpened(); + UpdateTree(); + } + e.Handled = true; + }; + + bookmark.Items.Add(mark); + } + menu.Items.Add(open); menu.Items.Add(explore); + menu.Items.Add(bookmark); } else { var addSubFolder = new MenuItem(); addSubFolder.Header = "Add Sub-Folder"; @@ -463,6 +520,7 @@ namespace SourceGit.UI { IsRepo = false, IsExpended = group.IsExpended, IsEditing = group.Id == editingNodeId, + Color = 0, }; groupNodes.Add(node.Id, node); @@ -486,6 +544,7 @@ namespace SourceGit.UI { IsRepo = true, IsExpended = false, IsEditing = repo.Path == editingNodeId, + Color = repo.Color, }; if (groupNodes.ContainsKey(repo.GroupId)) {