diff --git a/src/Resources/Icons.xaml b/src/Resources/Icons.xaml
index 2389a263..f6e198ac 100644
--- a/src/Resources/Icons.xaml
+++ b/src/Resources/Icons.xaml
@@ -5,7 +5,6 @@
M491 256h469c13 0 21-9 21-21v-171c0-13-9-21-21-21h-469c-13 0-21 9-21 21V128H256V64c0-13-9-21-21-21h-171c-13 0-21 9-21 21v171c0 13 9 21 21 21H128v597h341v64c0 13 9 21 21 21h469c13 0 21-9 21-21v-171c0-13-9-21-21-21h-469c-13 0-21 9-21 21V811H171v-299h299v64c0 13 9 21 21 21h469c13 0 21-9 21-21v-171c0-13-9-21-21-21h-469c-13 0-21 9-21 21V469H171V256h64c13 0 21-9 21-21V171h213v64c0 13 9 21 21 21z
M170 470l0 84 86 0 0-84-86 0zM86 598l0-172 852 0 0 172-852 0zM256 298l0-84-86 0 0 84 86 0zM86 170l852 0 0 172-852 0 0-172zM170 726l0 84 86 0 0-84-86 0zM86 854l0-172 852 0 0 172-852 0z
M853.3 960H170.7V64h469.3l213.3 213.3zM821.3 298.7H618.7V96z
- M192 0l0 1024 320-320 320 320 0-1024z
M888.8 0H135.2c-32.3 0-58.9 26.1-58.9 58.9v906.2c0 32.3 26.1 58.9 58.9 58.9h753.2c32.3 0 58.9-26.1 58.9-58.9v-906.2c.5-32.8-26.1-58.9-58.4-58.9zm-164.9 176.6c30.7 0 55.8 25.1 55.8 55.8s-25.1 55.8-55.8 55.8s-55.8-25.1-55.8-55.8s24.6-55.8 55.8-55.8zm-212 0c30.7 0 55.8 25.1 55.8 55.8S542.7 288.3 512 288.3s-55.8-25.1-55.8-55.8S481.3 176.6 512 176.6zm-212 0c30.7 0 55.8 25.1 55.8 55.8s-25.1 55.8-55.8 55.8s-55.8-25.1-55.8-55.8s25.1-55.8 55.8-55.8zm208.9 606.2H285.2c-24.6 0-44-20-44-44c0-24.6 20-44 44-44h223.7c24.6 0 44 20 44 44c0 24.1-19.5 44-44 44zm229.9-212H285.2c-24.6 0-44-20-44-44c0-24.6 20-44 44-44h453.1c24.6 0 44 20 44 44c.5 24.1-19.5 44-43.5 44z
M1024 427H597V0h-171v427H0v171h427V1024h171V597H1024z
M682.7 42.7H85.3v682.7h85.3V128h512V42.7zM256 213.3l4.5 768H896V213.3H256zm554.7 682.7H341.3V298.7h469.3v597.3z
diff --git a/src/Resources/Locales/en_US.xaml b/src/Resources/Locales/en_US.xaml
index 04f63e3b..208f076f 100644
--- a/src/Resources/Locales/en_US.xaml
+++ b/src/Resources/Locales/en_US.xaml
@@ -299,9 +299,9 @@
Merge Option :
Free & open source GUI for git users
- Open local repository
- Open terminal
- Clone remote repository
+ Open Repository
+ Open Terminal
+ Clone Repository
DROP FOLDER HERE
START
RECENT OPENED
diff --git a/src/Views/Controls/Bookmark.cs b/src/Views/Controls/Bookmark.cs
index 9250b705..20d80fca 100644
--- a/src/Views/Controls/Bookmark.cs
+++ b/src/Views/Controls/Bookmark.cs
@@ -1,66 +1,64 @@
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Media;
-using System.Windows.Shapes;
-
-namespace SourceGit.Views.Controls {
-
- ///
- /// 标签页图标
- ///
- public class Bookmark : Border {
- private Path icon = null;
-
- public static readonly Brush[] COLORS = new Brush[] {
- Brushes.Transparent,
- Brushes.White,
- Brushes.Red,
- Brushes.Orange,
- Brushes.Yellow,
- Brushes.ForestGreen,
- Brushes.Purple,
- Brushes.DeepSkyBlue,
- Brushes.Magenta,
- };
-
- public static readonly DependencyProperty ColorProperty =
- DependencyProperty.Register("Color", typeof(int), typeof(Bookmark), new PropertyMetadata(0, UpdateBookmark));
-
- public int Color {
- get { return (int)GetValue(ColorProperty); }
- set { SetValue(ColorProperty, value); }
- }
-
- public static readonly DependencyProperty IsNewPageProperty =
- DependencyProperty.Register("IsNewPage", typeof(bool), typeof(Bookmark), new PropertyMetadata(false, UpdateBookmark));
-
- public bool IsNewPage {
- get { return (bool)GetValue(IsNewPageProperty); }
- set { SetValue(IsNewPageProperty, value); }
- }
-
- public Bookmark() {
- icon = new Path();
- Child = icon;
- UpdateBookmark(this, new DependencyPropertyChangedEventArgs());
- }
-
- private static void UpdateBookmark(DependencyObject d, DependencyPropertyChangedEventArgs e) {
- var mark = d as Bookmark;
- if (mark == null) return;
-
- if (!mark.IsNewPage) {
- if (mark.Color == 0) {
- mark.icon.SetResourceReference(Path.FillProperty, "Brush.FG1");
- mark.icon.Data = mark.FindResource("Icon.Git") as Geometry;
- } else {
- mark.icon.Fill = COLORS[mark.Color % COLORS.Length];
- mark.icon.Data = mark.FindResource("Icon.Bookmark") as Geometry;
- }
- } else {
- mark.icon.SetResourceReference(Path.FillProperty, "Brush.FG1");
- mark.icon.Data = mark.FindResource("Icon.WelcomePage") as Geometry;
- }
- }
- }
-}
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+using System.Windows.Shapes;
+
+namespace SourceGit.Views.Controls {
+
+ ///
+ /// 标签页图标
+ ///
+ public class Bookmark : Border {
+ private Path icon = null;
+
+ public static readonly Brush[] COLORS = new Brush[] {
+ Brushes.Transparent,
+ Brushes.Red,
+ Brushes.Orange,
+ Brushes.Yellow,
+ Brushes.ForestGreen,
+ Brushes.Purple,
+ Brushes.DeepSkyBlue,
+ Brushes.Magenta,
+ };
+
+ public static readonly DependencyProperty ColorProperty =
+ DependencyProperty.Register("Color", typeof(int), typeof(Bookmark), new PropertyMetadata(0, UpdateBookmark));
+
+ public int Color {
+ get { return (int)GetValue(ColorProperty); }
+ set { SetValue(ColorProperty, value); }
+ }
+
+ public static readonly DependencyProperty IsNewPageProperty =
+ DependencyProperty.Register("IsNewPage", typeof(bool), typeof(Bookmark), new PropertyMetadata(false, UpdateBookmark));
+
+ public bool IsNewPage {
+ get { return (bool)GetValue(IsNewPageProperty); }
+ set { SetValue(IsNewPageProperty, value); }
+ }
+
+ public Bookmark() {
+ icon = new Path();
+ Child = icon;
+ UpdateBookmark(this, new DependencyPropertyChangedEventArgs());
+ }
+
+ private static void UpdateBookmark(DependencyObject d, DependencyPropertyChangedEventArgs e) {
+ var mark = d as Bookmark;
+ if (mark == null) return;
+
+ if (!mark.IsNewPage) {
+ mark.icon.Data = mark.FindResource("Icon.Git") as Geometry;
+ if (mark.Color == 0) {
+ mark.icon.SetResourceReference(Path.FillProperty, "Brush.FG1");
+ } else {
+ mark.icon.Fill = COLORS[mark.Color % COLORS.Length];
+ }
+ } else {
+ mark.icon.SetResourceReference(Path.FillProperty, "Brush.FG1");
+ mark.icon.Data = mark.FindResource("Icon.WelcomePage") as Geometry;
+ }
+ }
+ }
+}
diff --git a/src/Views/Widgets/PageTabBar.xaml.cs b/src/Views/Widgets/PageTabBar.xaml.cs
index f8519dc4..43da4f21 100644
--- a/src/Views/Widgets/PageTabBar.xaml.cs
+++ b/src/Views/Widgets/PageTabBar.xaml.cs
@@ -1,353 +1,353 @@
-using System;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Input;
-using System.Windows.Media;
-
-namespace SourceGit.Views.Widgets {
-
- ///
- /// 主窗体标题栏的标签页容器控件
- ///
- public partial class PageTabBar : UserControl {
-
- ///
- /// 标签数据
- ///
- public class Tab : Controls.BindableBase {
- public string Id { get; set; }
- public bool IsWelcomePage { get; set; }
-
- private string title;
- public string Title {
- get => title;
- set => SetProperty(ref title, value);
- }
-
- public string Tooltip { get; set; }
-
- private int bookmark = 0;
- public int Bookmark {
- get => bookmark;
- set => SetProperty(ref bookmark, value);
- }
- }
-
- ///
- /// 仓库标签页编辑事件参数
- ///
- public event Action OnTabEdited;
-
- ///
- /// 标签相关事件参数
- ///
- public class TabEventArgs : RoutedEventArgs {
- public string TabId { get; set; }
- public TabEventArgs(RoutedEvent e, object o, string id) : base(e, o) { TabId = id; }
- }
-
- public static readonly RoutedEvent TabAddEvent = EventManager.RegisterRoutedEvent(
- "TabAdd",
- RoutingStrategy.Bubble,
- typeof(EventHandler),
- typeof(PageTabBar));
-
- public event RoutedEventHandler TabAdd {
- add { AddHandler(TabAddEvent, value); }
- remove { RemoveHandler(TabAddEvent, value); }
- }
-
- public static readonly RoutedEvent TabSelectedEvent = EventManager.RegisterRoutedEvent(
- "TabSelected",
- RoutingStrategy.Bubble,
- typeof(EventHandler),
- typeof(PageTabBar));
-
- public event RoutedEventHandler TabSelected {
- add { AddHandler(TabSelectedEvent, value); }
- remove { RemoveHandler(TabSelectedEvent, value); }
- }
-
- public static readonly RoutedEvent TabClosedEvent = EventManager.RegisterRoutedEvent(
- "TabClosed",
- RoutingStrategy.Bubble,
- typeof(EventHandler),
- typeof(PageTabBar));
-
- public event RoutedEventHandler TabClosed {
- add { AddHandler(TabClosedEvent, value); }
- remove { RemoveHandler(TabClosedEvent, value); }
- }
-
- public ObservableCollection Tabs {
- get;
- private set;
- }
-
- public string Current {
- get { return (container.SelectedItem as Tab).Id; }
- }
-
- public PageTabBar() {
- Tabs = new ObservableCollection();
- InitializeComponent();
- }
-
- public void Add() {
- NewTab(null, null);
- }
-
- public void Add(string title, string repo, int bookmark) {
- var tab = new Tab() {
- Id = repo,
- IsWelcomePage = false,
- Title = title,
- Tooltip = repo,
- Bookmark = bookmark,
- };
-
- Tabs.Add(tab);
- container.SelectedItem = tab;
- }
-
- public void Replace(string id, string title, string repo, int bookmark) {
- var tab = null as Tab;
- var curTab = container.SelectedItem as Tab;
-
- foreach (var one in Tabs) {
- if (one.Id == id) {
- tab = one;
- break;
- }
- }
-
- if (tab == null) return;
-
- var idx = Tabs.IndexOf(tab);
- Tabs.RemoveAt(idx);
- RaiseEvent(new TabEventArgs(TabClosedEvent, this, tab.Id));
-
- var replaced = new Tab() {
- Id = repo,
- IsWelcomePage = false,
- Title = title,
- Tooltip = repo,
- Bookmark = bookmark,
- };
-
- Tabs.Insert(idx, replaced);
- if (curTab.Id == id) container.SelectedItem = replaced;
- }
-
- public void Update(string id, int bookmark, string title) {
- foreach (var one in Tabs) {
- if (one.Id == id) {
- one.Bookmark = bookmark;
- one.Title = title;
- break;
- }
- }
- }
-
- public bool Goto(string id) {
- foreach (var tab in Tabs) {
- if (tab.Id == id) {
- container.SelectedItem = tab;
- return true;
- }
- }
-
- return false;
- }
-
- public void Next() {
- container.SelectedIndex = (container.SelectedIndex + 1) % Tabs.Count;
- }
-
- public void CloseCurrent() {
- var curTab = container.SelectedItem as Tab;
- var idx = container.SelectedIndex;
- Tabs.Remove(curTab);
- if (Tabs.Count == 0) {
- Application.Current.Shutdown();
- } else {
- var last = Tabs.Count - 1;
- var next = idx > last ? Tabs[last] : Tabs[idx];
- container.SelectedItem = next;
- RaiseEvent(new TabEventArgs(TabClosedEvent, this, curTab.Id));
- RaiseEvent(new TabEventArgs(TabSelectedEvent, this, next.Id));
- }
- }
-
- private void CalcScrollerVisibilty(object sender, SizeChangedEventArgs e) {
- if ((sender as StackPanel).ActualWidth > scroller.ActualWidth) {
- leftScroller.Visibility = Visibility.Visible;
- rightScroller.Visibility = Visibility.Visible;
- } else {
- leftScroller.Visibility = Visibility.Collapsed;
- rightScroller.Visibility = Visibility.Collapsed;
- }
- }
-
- private void NewTab(object sender, RoutedEventArgs e) {
- var id = Guid.NewGuid().ToString();
- var tab = new Tab() {
- Id = id,
- IsWelcomePage = true,
- Title = App.Text("PageTabBar.Welcome.Title"),
- Tooltip = App.Text("PageTabBar.Welcome.Tip"),
- Bookmark = 0,
- };
-
- Tabs.Add(tab);
- RaiseEvent(new TabEventArgs(TabAddEvent, this, id));
- container.SelectedItem = tab;
- }
-
- private void ScrollLeft(object sender, RoutedEventArgs e) {
- scroller.LineLeft();
- }
-
- private void ScrollRight(object sender, RoutedEventArgs e) {
- scroller.LineRight();
- }
-
- private void SelectionChanged(object sender, SelectionChangedEventArgs e) {
- var tab = container.SelectedItem as Tab;
- if (tab == null) return;
- RaiseEvent(new TabEventArgs(TabSelectedEvent, this, tab.Id));
- }
-
- private void CloseTab(object sender, RoutedEventArgs e) {
- var tab = (sender as Button).DataContext as Tab;
- if (tab == null) return;
- CloseTab(tab);
- }
-
- private void CloseTab(Tab tab) {
- var curTab = container.SelectedItem as Tab;
- if (curTab != null && tab.Id == curTab.Id) {
- var idx = Tabs.IndexOf(tab);
- Tabs.Remove(tab);
-
- if (Tabs.Count == 0) {
- Application.Current.Shutdown();
- return;
- }
-
- var last = Tabs.Count - 1;
- var next = idx > last ? Tabs[last] : Tabs[idx];
- container.SelectedItem = next;
- RaiseEvent(new TabEventArgs(TabSelectedEvent, this, next.Id));
- } else {
- Tabs.Remove(tab);
- }
- RaiseEvent(new TabEventArgs(TabClosedEvent, this, tab.Id));
- }
-
- private void OnMouseMove(object sender, MouseEventArgs e) {
- var item = sender as ListBoxItem;
- if (item == null) return;
-
- var tab = item.DataContext as Tab;
- if (tab == null || tab != container.SelectedItem) return;
-
- if (e.LeftButton == MouseButtonState.Pressed) {
- var dragging = new Controls.DragDropAdorner(item);
- DragDrop.DoDragDrop(item, item.DataContext, DragDropEffects.Move);
- dragging.Remove();
- }
- }
-
- private void OnDrop(object sender, DragEventArgs e) {
- var tabSrc = e.Data.GetData(typeof(Tab)) as Tab;
- if (tabSrc == null) return;
-
- var dst = e.Source as FrameworkElement;
- if (dst == null) return;
-
- var tabDst = dst.DataContext as Tab;
- if (tabSrc.Id == tabDst.Id) return;
-
- int dstIdx = Tabs.IndexOf(tabDst);
- Tabs.Remove(tabSrc);
- Tabs.Insert(dstIdx, tabSrc);
- container.SelectedItem = tabSrc;
- e.Handled = true;
- }
-
- private void OnTabContextMenuOpening(object sender, ContextMenuEventArgs e) {
- var tab = (sender as ListBoxItem).DataContext as Tab;
- if (tab == null) return;
-
- var menu = new ContextMenu();
-
- var close = new MenuItem();
- close.Header = App.Text("PageTabBar.Tab.Close");
- close.Click += (_, __) => {
- CloseTab(tab);
- };
-
- var closeOther = new MenuItem();
- closeOther.Header = App.Text("PageTabBar.Tab.CloseOther");
- closeOther.Click += (_, __) => {
- Tabs.ToList().ForEach(t => { if (tab != t) CloseTab(t); });
- };
-
- var closeRight = new MenuItem();
- closeRight.Header = App.Text("PageTabBar.Tab.CloseRight");
- closeRight.Click += (_, __) => {
- var tabs = Tabs.ToList();
- tabs.RemoveRange(0, tabs.IndexOf(tab) + 1);
- tabs.ForEach(t => CloseTab(t));
- };
-
- menu.Items.Add(close);
- menu.Items.Add(closeOther);
- menu.Items.Add(closeRight);
-
- if (!tab.IsWelcomePage) {
- var iconBookmark = FindResource("Icon.Bookmark") as Geometry;
- var bookmark = new MenuItem();
- bookmark.Header = App.Text("PageTabBar.Tab.Bookmark");
- for (int i = 0; i < Controls.Bookmark.COLORS.Length; i++) {
- var icon = new System.Windows.Shapes.Path();
- icon.Data = iconBookmark;
- icon.Fill = Controls.Bookmark.COLORS[i];
- icon.Width = 8;
-
- var mark = new MenuItem();
- mark.Icon = icon;
- mark.Header = $"{i}";
-
- var refIdx = i;
- mark.Click += (o, ev) => {
- var repo = Models.Preference.Instance.FindRepository(tab.Id);
- if (repo != null) {
- repo.Bookmark = refIdx;
- tab.Bookmark = refIdx;
- OnTabEdited?.Invoke(tab);
- }
- ev.Handled = true;
- };
- bookmark.Items.Add(mark);
- }
- menu.Items.Add(new Separator());
- menu.Items.Add(bookmark);
-
- var copyPath = new MenuItem();
- copyPath.Header = App.Text("PageTabBar.Tab.CopyPath");
- copyPath.Click += (_, __) => {
- Clipboard.SetDataObject(tab.Id);
- };
- menu.Items.Add(new Separator());
- menu.Items.Add(copyPath);
- }
-
- menu.IsOpen = true;
- e.Handled = true;
- }
- }
-}
+using System;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+using System.Windows.Media;
+
+namespace SourceGit.Views.Widgets {
+
+ ///
+ /// 主窗体标题栏的标签页容器控件
+ ///
+ public partial class PageTabBar : UserControl {
+
+ ///
+ /// 标签数据
+ ///
+ public class Tab : Controls.BindableBase {
+ public string Id { get; set; }
+ public bool IsWelcomePage { get; set; }
+
+ private string title;
+ public string Title {
+ get => title;
+ set => SetProperty(ref title, value);
+ }
+
+ public string Tooltip { get; set; }
+
+ private int bookmark = 0;
+ public int Bookmark {
+ get => bookmark;
+ set => SetProperty(ref bookmark, value);
+ }
+ }
+
+ ///
+ /// 仓库标签页编辑事件参数
+ ///
+ public event Action OnTabEdited;
+
+ ///
+ /// 标签相关事件参数
+ ///
+ public class TabEventArgs : RoutedEventArgs {
+ public string TabId { get; set; }
+ public TabEventArgs(RoutedEvent e, object o, string id) : base(e, o) { TabId = id; }
+ }
+
+ public static readonly RoutedEvent TabAddEvent = EventManager.RegisterRoutedEvent(
+ "TabAdd",
+ RoutingStrategy.Bubble,
+ typeof(EventHandler),
+ typeof(PageTabBar));
+
+ public event RoutedEventHandler TabAdd {
+ add { AddHandler(TabAddEvent, value); }
+ remove { RemoveHandler(TabAddEvent, value); }
+ }
+
+ public static readonly RoutedEvent TabSelectedEvent = EventManager.RegisterRoutedEvent(
+ "TabSelected",
+ RoutingStrategy.Bubble,
+ typeof(EventHandler),
+ typeof(PageTabBar));
+
+ public event RoutedEventHandler TabSelected {
+ add { AddHandler(TabSelectedEvent, value); }
+ remove { RemoveHandler(TabSelectedEvent, value); }
+ }
+
+ public static readonly RoutedEvent TabClosedEvent = EventManager.RegisterRoutedEvent(
+ "TabClosed",
+ RoutingStrategy.Bubble,
+ typeof(EventHandler),
+ typeof(PageTabBar));
+
+ public event RoutedEventHandler TabClosed {
+ add { AddHandler(TabClosedEvent, value); }
+ remove { RemoveHandler(TabClosedEvent, value); }
+ }
+
+ public ObservableCollection Tabs {
+ get;
+ private set;
+ }
+
+ public string Current {
+ get { return (container.SelectedItem as Tab).Id; }
+ }
+
+ public PageTabBar() {
+ Tabs = new ObservableCollection();
+ InitializeComponent();
+ }
+
+ public void Add() {
+ NewTab(null, null);
+ }
+
+ public void Add(string title, string repo, int bookmark) {
+ var tab = new Tab() {
+ Id = repo,
+ IsWelcomePage = false,
+ Title = title,
+ Tooltip = repo,
+ Bookmark = bookmark,
+ };
+
+ Tabs.Add(tab);
+ container.SelectedItem = tab;
+ }
+
+ public void Replace(string id, string title, string repo, int bookmark) {
+ var tab = null as Tab;
+ var curTab = container.SelectedItem as Tab;
+
+ foreach (var one in Tabs) {
+ if (one.Id == id) {
+ tab = one;
+ break;
+ }
+ }
+
+ if (tab == null) return;
+
+ var idx = Tabs.IndexOf(tab);
+ Tabs.RemoveAt(idx);
+ RaiseEvent(new TabEventArgs(TabClosedEvent, this, tab.Id));
+
+ var replaced = new Tab() {
+ Id = repo,
+ IsWelcomePage = false,
+ Title = title,
+ Tooltip = repo,
+ Bookmark = bookmark,
+ };
+
+ Tabs.Insert(idx, replaced);
+ if (curTab.Id == id) container.SelectedItem = replaced;
+ }
+
+ public void Update(string id, int bookmark, string title) {
+ foreach (var one in Tabs) {
+ if (one.Id == id) {
+ one.Bookmark = bookmark;
+ one.Title = title;
+ break;
+ }
+ }
+ }
+
+ public bool Goto(string id) {
+ foreach (var tab in Tabs) {
+ if (tab.Id == id) {
+ container.SelectedItem = tab;
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public void Next() {
+ container.SelectedIndex = (container.SelectedIndex + 1) % Tabs.Count;
+ }
+
+ public void CloseCurrent() {
+ var curTab = container.SelectedItem as Tab;
+ var idx = container.SelectedIndex;
+ Tabs.Remove(curTab);
+ if (Tabs.Count == 0) {
+ Application.Current.Shutdown();
+ } else {
+ var last = Tabs.Count - 1;
+ var next = idx > last ? Tabs[last] : Tabs[idx];
+ container.SelectedItem = next;
+ RaiseEvent(new TabEventArgs(TabClosedEvent, this, curTab.Id));
+ RaiseEvent(new TabEventArgs(TabSelectedEvent, this, next.Id));
+ }
+ }
+
+ private void CalcScrollerVisibilty(object sender, SizeChangedEventArgs e) {
+ if ((sender as StackPanel).ActualWidth > scroller.ActualWidth) {
+ leftScroller.Visibility = Visibility.Visible;
+ rightScroller.Visibility = Visibility.Visible;
+ } else {
+ leftScroller.Visibility = Visibility.Collapsed;
+ rightScroller.Visibility = Visibility.Collapsed;
+ }
+ }
+
+ private void NewTab(object sender, RoutedEventArgs e) {
+ var id = Guid.NewGuid().ToString();
+ var tab = new Tab() {
+ Id = id,
+ IsWelcomePage = true,
+ Title = App.Text("PageTabBar.Welcome.Title"),
+ Tooltip = App.Text("PageTabBar.Welcome.Tip"),
+ Bookmark = 0,
+ };
+
+ Tabs.Add(tab);
+ RaiseEvent(new TabEventArgs(TabAddEvent, this, id));
+ container.SelectedItem = tab;
+ }
+
+ private void ScrollLeft(object sender, RoutedEventArgs e) {
+ scroller.LineLeft();
+ }
+
+ private void ScrollRight(object sender, RoutedEventArgs e) {
+ scroller.LineRight();
+ }
+
+ private void SelectionChanged(object sender, SelectionChangedEventArgs e) {
+ var tab = container.SelectedItem as Tab;
+ if (tab == null) return;
+ RaiseEvent(new TabEventArgs(TabSelectedEvent, this, tab.Id));
+ }
+
+ private void CloseTab(object sender, RoutedEventArgs e) {
+ var tab = (sender as Button).DataContext as Tab;
+ if (tab == null) return;
+ CloseTab(tab);
+ }
+
+ private void CloseTab(Tab tab) {
+ var curTab = container.SelectedItem as Tab;
+ if (curTab != null && tab.Id == curTab.Id) {
+ var idx = Tabs.IndexOf(tab);
+ Tabs.Remove(tab);
+
+ if (Tabs.Count == 0) {
+ Application.Current.Shutdown();
+ return;
+ }
+
+ var last = Tabs.Count - 1;
+ var next = idx > last ? Tabs[last] : Tabs[idx];
+ container.SelectedItem = next;
+ RaiseEvent(new TabEventArgs(TabSelectedEvent, this, next.Id));
+ } else {
+ Tabs.Remove(tab);
+ }
+ RaiseEvent(new TabEventArgs(TabClosedEvent, this, tab.Id));
+ }
+
+ private void OnMouseMove(object sender, MouseEventArgs e) {
+ var item = sender as ListBoxItem;
+ if (item == null) return;
+
+ var tab = item.DataContext as Tab;
+ if (tab == null || tab != container.SelectedItem) return;
+
+ if (e.LeftButton == MouseButtonState.Pressed) {
+ var dragging = new Controls.DragDropAdorner(item);
+ DragDrop.DoDragDrop(item, item.DataContext, DragDropEffects.Move);
+ dragging.Remove();
+ }
+ }
+
+ private void OnDrop(object sender, DragEventArgs e) {
+ var tabSrc = e.Data.GetData(typeof(Tab)) as Tab;
+ if (tabSrc == null) return;
+
+ var dst = e.Source as FrameworkElement;
+ if (dst == null) return;
+
+ var tabDst = dst.DataContext as Tab;
+ if (tabSrc.Id == tabDst.Id) return;
+
+ int dstIdx = Tabs.IndexOf(tabDst);
+ Tabs.Remove(tabSrc);
+ Tabs.Insert(dstIdx, tabSrc);
+ container.SelectedItem = tabSrc;
+ e.Handled = true;
+ }
+
+ private void OnTabContextMenuOpening(object sender, ContextMenuEventArgs e) {
+ var tab = (sender as ListBoxItem).DataContext as Tab;
+ if (tab == null) return;
+
+ var menu = new ContextMenu();
+
+ var close = new MenuItem();
+ close.Header = App.Text("PageTabBar.Tab.Close");
+ close.Click += (_, __) => {
+ CloseTab(tab);
+ };
+
+ var closeOther = new MenuItem();
+ closeOther.Header = App.Text("PageTabBar.Tab.CloseOther");
+ closeOther.Click += (_, __) => {
+ Tabs.ToList().ForEach(t => { if (tab != t) CloseTab(t); });
+ };
+
+ var closeRight = new MenuItem();
+ closeRight.Header = App.Text("PageTabBar.Tab.CloseRight");
+ closeRight.Click += (_, __) => {
+ var tabs = Tabs.ToList();
+ tabs.RemoveRange(0, tabs.IndexOf(tab) + 1);
+ tabs.ForEach(t => CloseTab(t));
+ };
+
+ menu.Items.Add(close);
+ menu.Items.Add(closeOther);
+ menu.Items.Add(closeRight);
+
+ if (!tab.IsWelcomePage) {
+ var iconBookmark = FindResource("Icon.Git") as Geometry;
+ var bookmark = new MenuItem();
+ bookmark.Header = App.Text("PageTabBar.Tab.Bookmark");
+ for (int i = 0; i < Controls.Bookmark.COLORS.Length; i++) {
+ var icon = new System.Windows.Shapes.Path();
+ icon.Data = iconBookmark;
+ icon.Fill = i == 0 ? (FindResource("Brush.FG1") as Brush) : Controls.Bookmark.COLORS[i];
+ icon.Width = 12;
+
+ var mark = new MenuItem();
+ mark.Icon = icon;
+ mark.Header = $"{i}";
+
+ var refIdx = i;
+ mark.Click += (o, ev) => {
+ var repo = Models.Preference.Instance.FindRepository(tab.Id);
+ if (repo != null) {
+ repo.Bookmark = refIdx;
+ tab.Bookmark = refIdx;
+ OnTabEdited?.Invoke(tab);
+ }
+ ev.Handled = true;
+ };
+ bookmark.Items.Add(mark);
+ }
+ menu.Items.Add(new Separator());
+ menu.Items.Add(bookmark);
+
+ var copyPath = new MenuItem();
+ copyPath.Header = App.Text("PageTabBar.Tab.CopyPath");
+ copyPath.Click += (_, __) => {
+ Clipboard.SetDataObject(tab.Id);
+ };
+ menu.Items.Add(new Separator());
+ menu.Items.Add(copyPath);
+ }
+
+ menu.IsOpen = true;
+ e.Handled = true;
+ }
+ }
+}
diff --git a/src/Views/Widgets/Welcome.xaml b/src/Views/Widgets/Welcome.xaml
index 3ddd3268..906395e7 100644
--- a/src/Views/Widgets/Welcome.xaml
+++ b/src/Views/Widgets/Welcome.xaml
@@ -1,274 +1,274 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Views/Widgets/Welcome.xaml.cs b/src/Views/Widgets/Welcome.xaml.cs
index 5d880d59..dfddc654 100644
--- a/src/Views/Widgets/Welcome.xaml.cs
+++ b/src/Views/Widgets/Welcome.xaml.cs
@@ -188,14 +188,14 @@ namespace SourceGit.Views.Widgets {
ev.Handled = true;
};
- var iconBookmark = FindResource("Icon.Bookmark") as Geometry;
+ var iconBookmark = FindResource("Icon.Git") as Geometry;
var bookmark = new MenuItem();
bookmark.Header = App.Text("RepoCM.Bookmark");
for (int i = 0; i < Controls.Bookmark.COLORS.Length; i++) {
var icon = new System.Windows.Shapes.Path();
icon.Data = iconBookmark;
- icon.Fill = Controls.Bookmark.COLORS[i];
- icon.Width = 8;
+ icon.Fill = i == 0 ? (FindResource("Brush.FG1") as Brush) : Controls.Bookmark.COLORS[i];
+ icon.Width = 12;
var mark = new MenuItem();
mark.Icon = icon;