style<Bookmark>: unify icons for repository

This commit is contained in:
leo 2022-05-20 16:57:36 +08:00
parent bc9f9dc2c6
commit fec14eb04a
6 changed files with 697 additions and 700 deletions

View file

@ -5,7 +5,6 @@
<Geometry x:Key="Icon.SubTree">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</Geometry> <Geometry x:Key="Icon.SubTree">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</Geometry>
<Geometry x:Key="Icon.LFS">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</Geometry> <Geometry x:Key="Icon.LFS">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</Geometry>
<Geometry x:Key="Icon.WelcomePage">M853.3 960H170.7V64h469.3l213.3 213.3zM821.3 298.7H618.7V96z</Geometry> <Geometry x:Key="Icon.WelcomePage">M853.3 960H170.7V64h469.3l213.3 213.3zM821.3 298.7H618.7V96z</Geometry>
<Geometry x:Key="Icon.Bookmark">M192 0l0 1024 320-320 320 320 0-1024z</Geometry>
<Geometry x:Key="Icon.Detail">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</Geometry> <Geometry x:Key="Icon.Detail">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</Geometry>
<Geometry x:Key="Icon.NewTab">M1024 427H597V0h-171v427H0v171h427V1024h171V597H1024z</Geometry> <Geometry x:Key="Icon.NewTab">M1024 427H597V0h-171v427H0v171h427V1024h171V597H1024z</Geometry>
<Geometry x:Key="Icon.Copy">M682.7 42.7H85.3v682.7h85.3V128h512V42.7zM256 213.3l4.5 768H896V213.3H256zm554.7 682.7H341.3V298.7h469.3v597.3z</Geometry> <Geometry x:Key="Icon.Copy">M682.7 42.7H85.3v682.7h85.3V128h512V42.7zM256 213.3l4.5 768H896V213.3H256zm554.7 682.7H341.3V298.7h469.3v597.3z</Geometry>

View file

@ -299,9 +299,9 @@
<sys:String x:Key="Text.Merge.Mode">Merge Option :</sys:String> <sys:String x:Key="Text.Merge.Mode">Merge Option :</sys:String>
<sys:String x:Key="Text.Welcome.Title">Free &amp; open source GUI for git users</sys:String> <sys:String x:Key="Text.Welcome.Title">Free &amp; open source GUI for git users</sys:String>
<sys:String x:Key="Text.Welcome.OpenOrInit">Open local repository</sys:String> <sys:String x:Key="Text.Welcome.OpenOrInit">Open Repository</sys:String>
<sys:String x:Key="Text.Welcome.OpenTerminal">Open terminal</sys:String> <sys:String x:Key="Text.Welcome.OpenTerminal">Open Terminal</sys:String>
<sys:String x:Key="Text.Welcome.Clone">Clone remote repository</sys:String> <sys:String x:Key="Text.Welcome.Clone">Clone Repository</sys:String>
<sys:String x:Key="Text.Welcome.DragDrop">DROP FOLDER HERE</sys:String> <sys:String x:Key="Text.Welcome.DragDrop">DROP FOLDER HERE</sys:String>
<sys:String x:Key="Text.Welcome.Start">START</sys:String> <sys:String x:Key="Text.Welcome.Start">START</sys:String>
<sys:String x:Key="Text.Welcome.Recent">RECENT OPENED</sys:String> <sys:String x:Key="Text.Welcome.Recent">RECENT OPENED</sys:String>

View file

@ -1,66 +1,64 @@
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Shapes; using System.Windows.Shapes;
namespace SourceGit.Views.Controls { namespace SourceGit.Views.Controls {
/// <summary> /// <summary>
/// 标签页图标 /// 标签页图标
/// </summary> /// </summary>
public class Bookmark : Border { public class Bookmark : Border {
private Path icon = null; private Path icon = null;
public static readonly Brush[] COLORS = new Brush[] { public static readonly Brush[] COLORS = new Brush[] {
Brushes.Transparent, Brushes.Transparent,
Brushes.White, Brushes.Red,
Brushes.Red, Brushes.Orange,
Brushes.Orange, Brushes.Yellow,
Brushes.Yellow, Brushes.ForestGreen,
Brushes.ForestGreen, Brushes.Purple,
Brushes.Purple, Brushes.DeepSkyBlue,
Brushes.DeepSkyBlue, Brushes.Magenta,
Brushes.Magenta, };
};
public static readonly DependencyProperty ColorProperty =
public static readonly DependencyProperty ColorProperty = DependencyProperty.Register("Color", typeof(int), typeof(Bookmark), new PropertyMetadata(0, UpdateBookmark));
DependencyProperty.Register("Color", typeof(int), typeof(Bookmark), new PropertyMetadata(0, UpdateBookmark));
public int Color {
public int Color { get { return (int)GetValue(ColorProperty); }
get { return (int)GetValue(ColorProperty); } set { SetValue(ColorProperty, value); }
set { SetValue(ColorProperty, value); } }
}
public static readonly DependencyProperty IsNewPageProperty =
public static readonly DependencyProperty IsNewPageProperty = DependencyProperty.Register("IsNewPage", typeof(bool), typeof(Bookmark), new PropertyMetadata(false, UpdateBookmark));
DependencyProperty.Register("IsNewPage", typeof(bool), typeof(Bookmark), new PropertyMetadata(false, UpdateBookmark));
public bool IsNewPage {
public bool IsNewPage { get { return (bool)GetValue(IsNewPageProperty); }
get { return (bool)GetValue(IsNewPageProperty); } set { SetValue(IsNewPageProperty, value); }
set { SetValue(IsNewPageProperty, value); } }
}
public Bookmark() {
public Bookmark() { icon = new Path();
icon = new Path(); Child = icon;
Child = icon; UpdateBookmark(this, new DependencyPropertyChangedEventArgs());
UpdateBookmark(this, new DependencyPropertyChangedEventArgs()); }
}
private static void UpdateBookmark(DependencyObject d, DependencyPropertyChangedEventArgs e) {
private static void UpdateBookmark(DependencyObject d, DependencyPropertyChangedEventArgs e) { var mark = d as Bookmark;
var mark = d as Bookmark; if (mark == null) return;
if (mark == null) return;
if (!mark.IsNewPage) {
if (!mark.IsNewPage) { mark.icon.Data = mark.FindResource("Icon.Git") as Geometry;
if (mark.Color == 0) { if (mark.Color == 0) {
mark.icon.SetResourceReference(Path.FillProperty, "Brush.FG1"); mark.icon.SetResourceReference(Path.FillProperty, "Brush.FG1");
mark.icon.Data = mark.FindResource("Icon.Git") as Geometry; } else {
} else { mark.icon.Fill = COLORS[mark.Color % COLORS.Length];
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");
} else { mark.icon.Data = mark.FindResource("Icon.WelcomePage") as Geometry;
mark.icon.SetResourceReference(Path.FillProperty, "Brush.FG1"); }
mark.icon.Data = mark.FindResource("Icon.WelcomePage") as Geometry; }
} }
} }
}
}

View file

@ -1,353 +1,353 @@
using System; using System;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Input; using System.Windows.Input;
using System.Windows.Media; using System.Windows.Media;
namespace SourceGit.Views.Widgets { namespace SourceGit.Views.Widgets {
/// <summary> /// <summary>
/// 主窗体标题栏的标签页容器控件 /// 主窗体标题栏的标签页容器控件
/// </summary> /// </summary>
public partial class PageTabBar : UserControl { public partial class PageTabBar : UserControl {
/// <summary> /// <summary>
/// 标签数据 /// 标签数据
/// </summary> /// </summary>
public class Tab : Controls.BindableBase { public class Tab : Controls.BindableBase {
public string Id { get; set; } public string Id { get; set; }
public bool IsWelcomePage { get; set; } public bool IsWelcomePage { get; set; }
private string title; private string title;
public string Title { public string Title {
get => title; get => title;
set => SetProperty(ref title, value); set => SetProperty(ref title, value);
} }
public string Tooltip { get; set; } public string Tooltip { get; set; }
private int bookmark = 0; private int bookmark = 0;
public int Bookmark { public int Bookmark {
get => bookmark; get => bookmark;
set => SetProperty(ref bookmark, value); set => SetProperty(ref bookmark, value);
} }
} }
/// <summary> /// <summary>
/// 仓库标签页编辑事件参数 /// 仓库标签页编辑事件参数
/// </summary> /// </summary>
public event Action<Tab> OnTabEdited; public event Action<Tab> OnTabEdited;
/// <summary> /// <summary>
/// 标签相关事件参数 /// 标签相关事件参数
/// </summary> /// </summary>
public class TabEventArgs : RoutedEventArgs { public class TabEventArgs : RoutedEventArgs {
public string TabId { get; set; } public string TabId { get; set; }
public TabEventArgs(RoutedEvent e, object o, string id) : base(e, o) { TabId = id; } public TabEventArgs(RoutedEvent e, object o, string id) : base(e, o) { TabId = id; }
} }
public static readonly RoutedEvent TabAddEvent = EventManager.RegisterRoutedEvent( public static readonly RoutedEvent TabAddEvent = EventManager.RegisterRoutedEvent(
"TabAdd", "TabAdd",
RoutingStrategy.Bubble, RoutingStrategy.Bubble,
typeof(EventHandler<TabEventArgs>), typeof(EventHandler<TabEventArgs>),
typeof(PageTabBar)); typeof(PageTabBar));
public event RoutedEventHandler TabAdd { public event RoutedEventHandler TabAdd {
add { AddHandler(TabAddEvent, value); } add { AddHandler(TabAddEvent, value); }
remove { RemoveHandler(TabAddEvent, value); } remove { RemoveHandler(TabAddEvent, value); }
} }
public static readonly RoutedEvent TabSelectedEvent = EventManager.RegisterRoutedEvent( public static readonly RoutedEvent TabSelectedEvent = EventManager.RegisterRoutedEvent(
"TabSelected", "TabSelected",
RoutingStrategy.Bubble, RoutingStrategy.Bubble,
typeof(EventHandler<TabEventArgs>), typeof(EventHandler<TabEventArgs>),
typeof(PageTabBar)); typeof(PageTabBar));
public event RoutedEventHandler TabSelected { public event RoutedEventHandler TabSelected {
add { AddHandler(TabSelectedEvent, value); } add { AddHandler(TabSelectedEvent, value); }
remove { RemoveHandler(TabSelectedEvent, value); } remove { RemoveHandler(TabSelectedEvent, value); }
} }
public static readonly RoutedEvent TabClosedEvent = EventManager.RegisterRoutedEvent( public static readonly RoutedEvent TabClosedEvent = EventManager.RegisterRoutedEvent(
"TabClosed", "TabClosed",
RoutingStrategy.Bubble, RoutingStrategy.Bubble,
typeof(EventHandler<TabEventArgs>), typeof(EventHandler<TabEventArgs>),
typeof(PageTabBar)); typeof(PageTabBar));
public event RoutedEventHandler TabClosed { public event RoutedEventHandler TabClosed {
add { AddHandler(TabClosedEvent, value); } add { AddHandler(TabClosedEvent, value); }
remove { RemoveHandler(TabClosedEvent, value); } remove { RemoveHandler(TabClosedEvent, value); }
} }
public ObservableCollection<Tab> Tabs { public ObservableCollection<Tab> Tabs {
get; get;
private set; private set;
} }
public string Current { public string Current {
get { return (container.SelectedItem as Tab).Id; } get { return (container.SelectedItem as Tab).Id; }
} }
public PageTabBar() { public PageTabBar() {
Tabs = new ObservableCollection<Tab>(); Tabs = new ObservableCollection<Tab>();
InitializeComponent(); InitializeComponent();
} }
public void Add() { public void Add() {
NewTab(null, null); NewTab(null, null);
} }
public void Add(string title, string repo, int bookmark) { public void Add(string title, string repo, int bookmark) {
var tab = new Tab() { var tab = new Tab() {
Id = repo, Id = repo,
IsWelcomePage = false, IsWelcomePage = false,
Title = title, Title = title,
Tooltip = repo, Tooltip = repo,
Bookmark = bookmark, Bookmark = bookmark,
}; };
Tabs.Add(tab); Tabs.Add(tab);
container.SelectedItem = tab; container.SelectedItem = tab;
} }
public void Replace(string id, string title, string repo, int bookmark) { public void Replace(string id, string title, string repo, int bookmark) {
var tab = null as Tab; var tab = null as Tab;
var curTab = container.SelectedItem as Tab; var curTab = container.SelectedItem as Tab;
foreach (var one in Tabs) { foreach (var one in Tabs) {
if (one.Id == id) { if (one.Id == id) {
tab = one; tab = one;
break; break;
} }
} }
if (tab == null) return; if (tab == null) return;
var idx = Tabs.IndexOf(tab); var idx = Tabs.IndexOf(tab);
Tabs.RemoveAt(idx); Tabs.RemoveAt(idx);
RaiseEvent(new TabEventArgs(TabClosedEvent, this, tab.Id)); RaiseEvent(new TabEventArgs(TabClosedEvent, this, tab.Id));
var replaced = new Tab() { var replaced = new Tab() {
Id = repo, Id = repo,
IsWelcomePage = false, IsWelcomePage = false,
Title = title, Title = title,
Tooltip = repo, Tooltip = repo,
Bookmark = bookmark, Bookmark = bookmark,
}; };
Tabs.Insert(idx, replaced); Tabs.Insert(idx, replaced);
if (curTab.Id == id) container.SelectedItem = replaced; if (curTab.Id == id) container.SelectedItem = replaced;
} }
public void Update(string id, int bookmark, string title) { public void Update(string id, int bookmark, string title) {
foreach (var one in Tabs) { foreach (var one in Tabs) {
if (one.Id == id) { if (one.Id == id) {
one.Bookmark = bookmark; one.Bookmark = bookmark;
one.Title = title; one.Title = title;
break; break;
} }
} }
} }
public bool Goto(string id) { public bool Goto(string id) {
foreach (var tab in Tabs) { foreach (var tab in Tabs) {
if (tab.Id == id) { if (tab.Id == id) {
container.SelectedItem = tab; container.SelectedItem = tab;
return true; return true;
} }
} }
return false; return false;
} }
public void Next() { public void Next() {
container.SelectedIndex = (container.SelectedIndex + 1) % Tabs.Count; container.SelectedIndex = (container.SelectedIndex + 1) % Tabs.Count;
} }
public void CloseCurrent() { public void CloseCurrent() {
var curTab = container.SelectedItem as Tab; var curTab = container.SelectedItem as Tab;
var idx = container.SelectedIndex; var idx = container.SelectedIndex;
Tabs.Remove(curTab); Tabs.Remove(curTab);
if (Tabs.Count == 0) { if (Tabs.Count == 0) {
Application.Current.Shutdown(); Application.Current.Shutdown();
} else { } else {
var last = Tabs.Count - 1; var last = Tabs.Count - 1;
var next = idx > last ? Tabs[last] : Tabs[idx]; var next = idx > last ? Tabs[last] : Tabs[idx];
container.SelectedItem = next; container.SelectedItem = next;
RaiseEvent(new TabEventArgs(TabClosedEvent, this, curTab.Id)); RaiseEvent(new TabEventArgs(TabClosedEvent, this, curTab.Id));
RaiseEvent(new TabEventArgs(TabSelectedEvent, this, next.Id)); RaiseEvent(new TabEventArgs(TabSelectedEvent, this, next.Id));
} }
} }
private void CalcScrollerVisibilty(object sender, SizeChangedEventArgs e) { private void CalcScrollerVisibilty(object sender, SizeChangedEventArgs e) {
if ((sender as StackPanel).ActualWidth > scroller.ActualWidth) { if ((sender as StackPanel).ActualWidth > scroller.ActualWidth) {
leftScroller.Visibility = Visibility.Visible; leftScroller.Visibility = Visibility.Visible;
rightScroller.Visibility = Visibility.Visible; rightScroller.Visibility = Visibility.Visible;
} else { } else {
leftScroller.Visibility = Visibility.Collapsed; leftScroller.Visibility = Visibility.Collapsed;
rightScroller.Visibility = Visibility.Collapsed; rightScroller.Visibility = Visibility.Collapsed;
} }
} }
private void NewTab(object sender, RoutedEventArgs e) { private void NewTab(object sender, RoutedEventArgs e) {
var id = Guid.NewGuid().ToString(); var id = Guid.NewGuid().ToString();
var tab = new Tab() { var tab = new Tab() {
Id = id, Id = id,
IsWelcomePage = true, IsWelcomePage = true,
Title = App.Text("PageTabBar.Welcome.Title"), Title = App.Text("PageTabBar.Welcome.Title"),
Tooltip = App.Text("PageTabBar.Welcome.Tip"), Tooltip = App.Text("PageTabBar.Welcome.Tip"),
Bookmark = 0, Bookmark = 0,
}; };
Tabs.Add(tab); Tabs.Add(tab);
RaiseEvent(new TabEventArgs(TabAddEvent, this, id)); RaiseEvent(new TabEventArgs(TabAddEvent, this, id));
container.SelectedItem = tab; container.SelectedItem = tab;
} }
private void ScrollLeft(object sender, RoutedEventArgs e) { private void ScrollLeft(object sender, RoutedEventArgs e) {
scroller.LineLeft(); scroller.LineLeft();
} }
private void ScrollRight(object sender, RoutedEventArgs e) { private void ScrollRight(object sender, RoutedEventArgs e) {
scroller.LineRight(); scroller.LineRight();
} }
private void SelectionChanged(object sender, SelectionChangedEventArgs e) { private void SelectionChanged(object sender, SelectionChangedEventArgs e) {
var tab = container.SelectedItem as Tab; var tab = container.SelectedItem as Tab;
if (tab == null) return; if (tab == null) return;
RaiseEvent(new TabEventArgs(TabSelectedEvent, this, tab.Id)); RaiseEvent(new TabEventArgs(TabSelectedEvent, this, tab.Id));
} }
private void CloseTab(object sender, RoutedEventArgs e) { private void CloseTab(object sender, RoutedEventArgs e) {
var tab = (sender as Button).DataContext as Tab; var tab = (sender as Button).DataContext as Tab;
if (tab == null) return; if (tab == null) return;
CloseTab(tab); CloseTab(tab);
} }
private void CloseTab(Tab tab) { private void CloseTab(Tab tab) {
var curTab = container.SelectedItem as Tab; var curTab = container.SelectedItem as Tab;
if (curTab != null && tab.Id == curTab.Id) { if (curTab != null && tab.Id == curTab.Id) {
var idx = Tabs.IndexOf(tab); var idx = Tabs.IndexOf(tab);
Tabs.Remove(tab); Tabs.Remove(tab);
if (Tabs.Count == 0) { if (Tabs.Count == 0) {
Application.Current.Shutdown(); Application.Current.Shutdown();
return; return;
} }
var last = Tabs.Count - 1; var last = Tabs.Count - 1;
var next = idx > last ? Tabs[last] : Tabs[idx]; var next = idx > last ? Tabs[last] : Tabs[idx];
container.SelectedItem = next; container.SelectedItem = next;
RaiseEvent(new TabEventArgs(TabSelectedEvent, this, next.Id)); RaiseEvent(new TabEventArgs(TabSelectedEvent, this, next.Id));
} else { } else {
Tabs.Remove(tab); Tabs.Remove(tab);
} }
RaiseEvent(new TabEventArgs(TabClosedEvent, this, tab.Id)); RaiseEvent(new TabEventArgs(TabClosedEvent, this, tab.Id));
} }
private void OnMouseMove(object sender, MouseEventArgs e) { private void OnMouseMove(object sender, MouseEventArgs e) {
var item = sender as ListBoxItem; var item = sender as ListBoxItem;
if (item == null) return; if (item == null) return;
var tab = item.DataContext as Tab; var tab = item.DataContext as Tab;
if (tab == null || tab != container.SelectedItem) return; if (tab == null || tab != container.SelectedItem) return;
if (e.LeftButton == MouseButtonState.Pressed) { if (e.LeftButton == MouseButtonState.Pressed) {
var dragging = new Controls.DragDropAdorner(item); var dragging = new Controls.DragDropAdorner(item);
DragDrop.DoDragDrop(item, item.DataContext, DragDropEffects.Move); DragDrop.DoDragDrop(item, item.DataContext, DragDropEffects.Move);
dragging.Remove(); dragging.Remove();
} }
} }
private void OnDrop(object sender, DragEventArgs e) { private void OnDrop(object sender, DragEventArgs e) {
var tabSrc = e.Data.GetData(typeof(Tab)) as Tab; var tabSrc = e.Data.GetData(typeof(Tab)) as Tab;
if (tabSrc == null) return; if (tabSrc == null) return;
var dst = e.Source as FrameworkElement; var dst = e.Source as FrameworkElement;
if (dst == null) return; if (dst == null) return;
var tabDst = dst.DataContext as Tab; var tabDst = dst.DataContext as Tab;
if (tabSrc.Id == tabDst.Id) return; if (tabSrc.Id == tabDst.Id) return;
int dstIdx = Tabs.IndexOf(tabDst); int dstIdx = Tabs.IndexOf(tabDst);
Tabs.Remove(tabSrc); Tabs.Remove(tabSrc);
Tabs.Insert(dstIdx, tabSrc); Tabs.Insert(dstIdx, tabSrc);
container.SelectedItem = tabSrc; container.SelectedItem = tabSrc;
e.Handled = true; e.Handled = true;
} }
private void OnTabContextMenuOpening(object sender, ContextMenuEventArgs e) { private void OnTabContextMenuOpening(object sender, ContextMenuEventArgs e) {
var tab = (sender as ListBoxItem).DataContext as Tab; var tab = (sender as ListBoxItem).DataContext as Tab;
if (tab == null) return; if (tab == null) return;
var menu = new ContextMenu(); var menu = new ContextMenu();
var close = new MenuItem(); var close = new MenuItem();
close.Header = App.Text("PageTabBar.Tab.Close"); close.Header = App.Text("PageTabBar.Tab.Close");
close.Click += (_, __) => { close.Click += (_, __) => {
CloseTab(tab); CloseTab(tab);
}; };
var closeOther = new MenuItem(); var closeOther = new MenuItem();
closeOther.Header = App.Text("PageTabBar.Tab.CloseOther"); closeOther.Header = App.Text("PageTabBar.Tab.CloseOther");
closeOther.Click += (_, __) => { closeOther.Click += (_, __) => {
Tabs.ToList().ForEach(t => { if (tab != t) CloseTab(t); }); Tabs.ToList().ForEach(t => { if (tab != t) CloseTab(t); });
}; };
var closeRight = new MenuItem(); var closeRight = new MenuItem();
closeRight.Header = App.Text("PageTabBar.Tab.CloseRight"); closeRight.Header = App.Text("PageTabBar.Tab.CloseRight");
closeRight.Click += (_, __) => { closeRight.Click += (_, __) => {
var tabs = Tabs.ToList(); var tabs = Tabs.ToList();
tabs.RemoveRange(0, tabs.IndexOf(tab) + 1); tabs.RemoveRange(0, tabs.IndexOf(tab) + 1);
tabs.ForEach(t => CloseTab(t)); tabs.ForEach(t => CloseTab(t));
}; };
menu.Items.Add(close); menu.Items.Add(close);
menu.Items.Add(closeOther); menu.Items.Add(closeOther);
menu.Items.Add(closeRight); menu.Items.Add(closeRight);
if (!tab.IsWelcomePage) { if (!tab.IsWelcomePage) {
var iconBookmark = FindResource("Icon.Bookmark") as Geometry; var iconBookmark = FindResource("Icon.Git") as Geometry;
var bookmark = new MenuItem(); var bookmark = new MenuItem();
bookmark.Header = App.Text("PageTabBar.Tab.Bookmark"); bookmark.Header = App.Text("PageTabBar.Tab.Bookmark");
for (int i = 0; i < Controls.Bookmark.COLORS.Length; i++) { for (int i = 0; i < Controls.Bookmark.COLORS.Length; i++) {
var icon = new System.Windows.Shapes.Path(); var icon = new System.Windows.Shapes.Path();
icon.Data = iconBookmark; icon.Data = iconBookmark;
icon.Fill = Controls.Bookmark.COLORS[i]; icon.Fill = i == 0 ? (FindResource("Brush.FG1") as Brush) : Controls.Bookmark.COLORS[i];
icon.Width = 8; icon.Width = 12;
var mark = new MenuItem(); var mark = new MenuItem();
mark.Icon = icon; mark.Icon = icon;
mark.Header = $"{i}"; mark.Header = $"{i}";
var refIdx = i; var refIdx = i;
mark.Click += (o, ev) => { mark.Click += (o, ev) => {
var repo = Models.Preference.Instance.FindRepository(tab.Id); var repo = Models.Preference.Instance.FindRepository(tab.Id);
if (repo != null) { if (repo != null) {
repo.Bookmark = refIdx; repo.Bookmark = refIdx;
tab.Bookmark = refIdx; tab.Bookmark = refIdx;
OnTabEdited?.Invoke(tab); OnTabEdited?.Invoke(tab);
} }
ev.Handled = true; ev.Handled = true;
}; };
bookmark.Items.Add(mark); bookmark.Items.Add(mark);
} }
menu.Items.Add(new Separator()); menu.Items.Add(new Separator());
menu.Items.Add(bookmark); menu.Items.Add(bookmark);
var copyPath = new MenuItem(); var copyPath = new MenuItem();
copyPath.Header = App.Text("PageTabBar.Tab.CopyPath"); copyPath.Header = App.Text("PageTabBar.Tab.CopyPath");
copyPath.Click += (_, __) => { copyPath.Click += (_, __) => {
Clipboard.SetDataObject(tab.Id); Clipboard.SetDataObject(tab.Id);
}; };
menu.Items.Add(new Separator()); menu.Items.Add(new Separator());
menu.Items.Add(copyPath); menu.Items.Add(copyPath);
} }
menu.IsOpen = true; menu.IsOpen = true;
e.Handled = true; e.Handled = true;
} }
} }
} }

View file

@ -1,274 +1,274 @@
<UserControl x:Class="SourceGit.Views.Widgets.Welcome" <UserControl x:Class="SourceGit.Views.Widgets.Welcome"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="clr-namespace:SourceGit.Views.Controls" xmlns:controls="clr-namespace:SourceGit.Views.Controls"
xmlns:widgets="clr-namespace:SourceGit.Views.Widgets" xmlns:widgets="clr-namespace:SourceGit.Views.Widgets"
xmlns:models="clr-namespace:SourceGit.Models" xmlns:models="clr-namespace:SourceGit.Models"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="800" d:DesignWidth="800"> d:DesignHeight="800" d:DesignWidth="800">
<Grid Background="Transparent" AllowDrop="True" DragEnter="OnPageDragEnter" DragLeave="OnPageDragLeave" Drop="OnPageDrop"> <Grid Background="Transparent" AllowDrop="True" DragEnter="OnPageDragEnter" DragLeave="OnPageDragLeave" Drop="OnPageDrop">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="80"/> <RowDefinition Height="80"/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="800"/> <ColumnDefinition Width="800"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<!-- App Name --> <!-- App Name -->
<TextBlock <TextBlock
Grid.Row="1" Grid.Row="1"
Grid.Column="1" Grid.Column="1"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Text="SourceGit" Text="SourceGit"
FontSize="28pt" FontSize="28pt"
TextOptions.TextFormattingMode="Ideal" TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="ClearType" TextOptions.TextRenderingMode="ClearType"
RenderOptions.ClearTypeHint="Enabled"/> RenderOptions.ClearTypeHint="Enabled"/>
<!-- App Desc --> <!-- App Desc -->
<TextBlock <TextBlock
Grid.Row="2" Grid.Row="2"
Grid.Column="1" Grid.Column="1"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Text="{DynamicResource Text.Welcome.Title}" Text="{DynamicResource Text.Welcome.Title}"
Foreground="{DynamicResource Brush.FG2}" Foreground="{DynamicResource Brush.FG2}"
FontSize="18pt" FontSize="18pt"
Margin="0,8"/> Margin="0,8"/>
<Grid x:Name="body" Grid.Row="3" Grid.Column="1" Margin="0,40,0,80" FocusManager.IsFocusScope="True"> <Grid x:Name="body" Grid.Row="3" Grid.Column="1" Margin="0,40,0,80" FocusManager.IsFocusScope="True">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="16"/> <ColumnDefinition Width="16"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<!-- Left Panel --> <!-- Left Panel -->
<Grid Grid.Column="0"> <Grid Grid.Column="0">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- Options --> <!-- Options -->
<TextBlock <TextBlock
Grid.Row="0" Grid.Row="0"
Text="{DynamicResource Text.Welcome.Start}" Text="{DynamicResource Text.Welcome.Start}"
FontSize="13pt"/> FontSize="13pt"/>
<StackPanel Grid.Row="1" Margin="4,12,0,0" Orientation="Vertical"> <StackPanel Grid.Row="1" Margin="4,12,0,0" Orientation="Vertical">
<Button Click="OnOpenClicked" Height="28" Style="{DynamicResource Style.Button.Link}"> <Button Click="OnOpenClicked" Height="28" Style="{DynamicResource Style.Button.Link}">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
<Path Width="16" Height="15" Data="{StaticResource Icon.Folder.Open}" Fill="{DynamicResource Brush.Accent1}"/> <Path Width="16" Height="15" Data="{StaticResource Icon.Folder.Open}" Fill="{DynamicResource Brush.Accent1}"/>
<TextBlock Margin="8,0,0,0" Text="{DynamicResource Text.Welcome.OpenOrInit}" Foreground="{DynamicResource Brush.Accent1}"/> <TextBlock Margin="8,0,0,0" Text="{DynamicResource Text.Welcome.OpenOrInit}" Foreground="{DynamicResource Brush.Accent1}"/>
</StackPanel> </StackPanel>
</Button> </Button>
<Button Click="OnCloneClicked" Height="28" Style="{DynamicResource Style.Button.Link}"> <Button Click="OnCloneClicked" Height="28" Style="{DynamicResource Style.Button.Link}">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Path Width="16" Height="16" Data="{StaticResource Icon.Pull}" Fill="{DynamicResource Brush.Accent1}"/> <Path Width="16" Height="16" Data="{StaticResource Icon.Pull}" Fill="{DynamicResource Brush.Accent1}"/>
<TextBlock Margin="8,0,0,0" Text="{DynamicResource Text.Welcome.Clone}" Foreground="{DynamicResource Brush.Accent1}"/> <TextBlock Margin="8,0,0,0" Text="{DynamicResource Text.Welcome.Clone}" Foreground="{DynamicResource Brush.Accent1}"/>
</StackPanel> </StackPanel>
</Button> </Button>
<Button Click="OnOpenTerminalClicked" Height="28" Style="{DynamicResource Style.Button.Link}"> <Button Click="OnOpenTerminalClicked" Height="28" Style="{DynamicResource Style.Button.Link}">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<Path Width="16" Height="14" Data="{StaticResource Icon.Terminal}" Fill="{DynamicResource Brush.Accent1}"/> <Path Width="16" Height="14" Data="{StaticResource Icon.Terminal}" Fill="{DynamicResource Brush.Accent1}"/>
<TextBlock Margin="8,0,0,0" Text="{DynamicResource Text.Welcome.OpenTerminal}" Foreground="{DynamicResource Brush.Accent1}"/> <TextBlock Margin="8,0,0,0" Text="{DynamicResource Text.Welcome.OpenTerminal}" Foreground="{DynamicResource Brush.Accent1}"/>
</StackPanel> </StackPanel>
</Button> </Button>
</StackPanel> </StackPanel>
<!-- Recents --> <!-- Recents -->
<TextBlock <TextBlock
Grid.Row="2" Margin="0,32,0,0" Grid.Row="2" Margin="0,32,0,0"
x:Name="lblRecent" x:Name="lblRecent"
Text="{DynamicResource Text.Welcome.Recent}" Text="{DynamicResource Text.Welcome.Recent}"
FontSize="13pt" FontSize="13pt"
Visibility="Hidden"/> Visibility="Hidden"/>
<DataGrid <DataGrid
Grid.Row="3" Grid.Row="3"
x:Name="list" x:Name="list"
Margin="0,12,0,0" Margin="0,12,0,0"
SelectionUnit="FullRow" SelectionUnit="FullRow"
SelectionMode="Single" SelectionMode="Single"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"
LostFocus="OnRecentLostFocus"> LostFocus="OnRecentLostFocus">
<DataGrid.RowStyle> <DataGrid.RowStyle>
<Style BasedOn="{StaticResource Style.DataGridRow}" TargetType="{x:Type DataGridRow}"> <Style BasedOn="{StaticResource Style.DataGridRow}" TargetType="{x:Type DataGridRow}">
<EventSetter Event="MouseDoubleClick" Handler="OnRecentDoubleClick"/> <EventSetter Event="MouseDoubleClick" Handler="OnRecentDoubleClick"/>
<EventSetter Event="ContextMenuOpening" Handler="OnRecentContextMenuOpening"/> <EventSetter Event="ContextMenuOpening" Handler="OnRecentContextMenuOpening"/>
</Style> </Style>
</DataGrid.RowStyle> </DataGrid.RowStyle>
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTemplateColumn Width="*"> <DataGridTemplateColumn Width="*">
<DataGridTemplateColumn.CellTemplate> <DataGridTemplateColumn.CellTemplate>
<DataTemplate> <DataTemplate>
<Grid Height="32" Margin="4,0,0,0" IsHitTestVisible="False"> <Grid Height="32" Margin="4,0,0,0" IsHitTestVisible="False">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="22"/> <ColumnDefinition Width="22"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<controls:Bookmark <controls:Bookmark
Grid.Column="0" Grid.Column="0"
Margin="2,0,0,0" Margin="2,0,0,0"
x:Name="BookmarkIcon" x:Name="BookmarkIcon"
Width="16" Height="16" Width="16" Height="16"
Color="{Binding Bookmark}" Color="{Binding Bookmark}"
IsNewPage="False"/> IsNewPage="False"/>
<StackPanel Grid.Column="1" Orientation="Horizontal"> <StackPanel Grid.Column="1" Orientation="Horizontal">
<TextBlock Margin="8,0" Text="{Binding Name}"/> <TextBlock Margin="8,0" Text="{Binding Name}"/>
<TextBlock x:Name="Path" Text="{Binding Path}" Foreground="{DynamicResource Brush.FG2}"/> <TextBlock x:Name="Path" Text="{Binding Path}" Foreground="{DynamicResource Brush.FG2}"/>
</StackPanel> </StackPanel>
</Grid> </Grid>
</DataTemplate> </DataTemplate>
</DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn> </DataGridTemplateColumn>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
</Grid> </Grid>
<!-- Right Panel --> <!-- Right Panel -->
<Grid Grid.Column="2"> <Grid Grid.Column="2">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<!-- Repositories Label --> <!-- Repositories Label -->
<TextBlock <TextBlock
Grid.Row="0" Grid.Row="0"
Text="{DynamicResource Text.Welcome.Repositories}" Text="{DynamicResource Text.Welcome.Repositories}"
FontSize="13pt" FontSize="13pt"
HorizontalAlignment="Left" VerticalAlignment="Center"/> HorizontalAlignment="Left" VerticalAlignment="Center"/>
<!-- Repositories Tree DragDrop tip --> <!-- Repositories Tree DragDrop tip -->
<StackPanel Grid.Row="1" x:Name="dropTip" Margin="4,16,0,0" HorizontalAlignment="Left" Orientation="Vertical"> <StackPanel Grid.Row="1" x:Name="dropTip" Margin="4,16,0,0" HorizontalAlignment="Left" Orientation="Vertical">
<Path <Path
Data="{DynamicResource Icon.DragDrop}" Data="{DynamicResource Icon.DragDrop}"
Fill="{DynamicResource Brush.FG2}" Fill="{DynamicResource Brush.FG2}"
Width="48" Height="48" Width="48" Height="48"
VerticalAlignment="Top"/> VerticalAlignment="Top"/>
<TextBlock <TextBlock
Text="{DynamicResource Text.Welcome.DragDrop}" Text="{DynamicResource Text.Welcome.DragDrop}"
FontSize="10pt" FontSize="10pt"
Margin="0,8,0,0" Margin="0,8,0,0"
HorizontalAlignment="Center" VerticalAlignment="Top" HorizontalAlignment="Center" VerticalAlignment="Top"
Foreground="{DynamicResource Brush.FG2}"/> Foreground="{DynamicResource Brush.FG2}"/>
</StackPanel> </StackPanel>
<!-- Repositories Tree --> <!-- Repositories Tree -->
<controls:Tree <controls:Tree
Grid.Row="1" Grid.Row="1"
x:Name="tree" x:Name="tree"
Margin="0,8,0,0" Margin="0,8,0,0"
AllowDrop="True" AllowDrop="True"
TextElement.FontSize="14" TextElement.FontSize="14"
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
ScrollViewer.VerticalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"
ContextMenuOpening="OnTreeContextMenuOpening" ContextMenuOpening="OnTreeContextMenuOpening"
MouseMove="OnTreeMouseMove" MouseMove="OnTreeMouseMove"
DragOver="OnTreeDragOver" DragOver="OnTreeDragOver"
Drop="OnTreeDrop" Drop="OnTreeDrop"
LostFocus="OnTreeLostFocus"> LostFocus="OnTreeLostFocus">
<controls:Tree.ItemContainerStyle> <controls:Tree.ItemContainerStyle>
<Style TargetType="{x:Type controls:TreeItem}" BasedOn="{StaticResource Style.TreeItem}"> <Style TargetType="{x:Type controls:TreeItem}" BasedOn="{StaticResource Style.TreeItem}">
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/> <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
<EventSetter Event="Expanded" Handler="OnTreeNodeStatusChange"/> <EventSetter Event="Expanded" Handler="OnTreeNodeStatusChange"/>
<EventSetter Event="Collapsed" Handler="OnTreeNodeStatusChange"/> <EventSetter Event="Collapsed" Handler="OnTreeNodeStatusChange"/>
<EventSetter Event="MouseDoubleClick" Handler="OnTreeNodeDoubleClick"/> <EventSetter Event="MouseDoubleClick" Handler="OnTreeNodeDoubleClick"/>
</Style> </Style>
</controls:Tree.ItemContainerStyle> </controls:Tree.ItemContainerStyle>
<controls:Tree.ItemTemplate> <controls:Tree.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding Children}"> <HierarchicalDataTemplate ItemsSource="{Binding Children}">
<Grid Height="32" IsHitTestVisible="False"> <Grid Height="32" IsHitTestVisible="False">
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="22"/> <ColumnDefinition Width="22"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Path Grid.Column="0" Margin="2,0,0,0" x:Name="Icon" Width="16" Height="16" Data="{StaticResource Icon.Folder.Fill}"/> <Path Grid.Column="0" Margin="2,0,0,0" x:Name="Icon" Width="16" Height="16" Data="{StaticResource Icon.Folder.Fill}"/>
<controls:Bookmark <controls:Bookmark
Grid.Column="0" Grid.Column="0"
Margin="2,0,0,0" Margin="2,0,0,0"
x:Name="BookmarkIcon" x:Name="BookmarkIcon"
Width="16" Height="16" Width="16" Height="16"
Color="{Binding Bookmark}" Color="{Binding Bookmark}"
IsNewPage="False"/> IsNewPage="False"/>
<StackPanel Grid.Column="1" x:Name="ContentsBookmark" Orientation="Horizontal"> <StackPanel Grid.Column="1" x:Name="ContentsBookmark" Orientation="Horizontal">
<TextBlock Margin="8,0" Text="{Binding Name}"/> <TextBlock Margin="8,0" Text="{Binding Name}"/>
<TextBlock x:Name="Path" Text="{Binding Id}" Foreground="{DynamicResource Brush.FG2}"/> <TextBlock x:Name="Path" Text="{Binding Id}" Foreground="{DynamicResource Brush.FG2}"/>
</StackPanel> </StackPanel>
<controls:TextEdit <controls:TextEdit
Grid.Column="1" Grid.Column="1"
x:Name="EditorBookmarks" x:Name="EditorBookmarks"
Height="20" Height="20"
Margin="4,0,0,0" Margin="4,0,0,0"
Text="{Binding Name}" Text="{Binding Name}"
FontSize="9pt" FontSize="9pt"
Loaded="RenameStart" Loaded="RenameStart"
KeyDown="RenameKeyDown" KeyDown="RenameKeyDown"
LostFocus="RenameEnd" LostFocus="RenameEnd"
IsHitTestVisible="True" IsHitTestVisible="True"
Visibility="Collapsed"/> Visibility="Collapsed"/>
</Grid> </Grid>
<HierarchicalDataTemplate.Triggers> <HierarchicalDataTemplate.Triggers>
<DataTrigger Binding="{Binding IsGroup}" Value="True"> <DataTrigger Binding="{Binding IsGroup}" Value="True">
<Setter TargetName="Path" Property="Visibility" Value="Collapsed"/> <Setter TargetName="Path" Property="Visibility" Value="Collapsed"/>
<Setter TargetName="Icon" Property="Visibility" Value="Visible"/> <Setter TargetName="Icon" Property="Visibility" Value="Visible"/>
<Setter TargetName="BookmarkIcon" Property="Visibility" Value="Collapsed"/> <Setter TargetName="BookmarkIcon" Property="Visibility" Value="Collapsed"/>
</DataTrigger> </DataTrigger>
<DataTrigger Binding="{Binding IsGroup}" Value="False"> <DataTrigger Binding="{Binding IsGroup}" Value="False">
<Setter TargetName="Path" Property="Visibility" Value="Visible"/> <Setter TargetName="Path" Property="Visibility" Value="Visible"/>
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed"/> <Setter TargetName="Icon" Property="Visibility" Value="Collapsed"/>
<Setter TargetName="BookmarkIcon" Property="Visibility" Value="Visible"/> <Setter TargetName="BookmarkIcon" Property="Visibility" Value="Visible"/>
</DataTrigger> </DataTrigger>
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:TreeItem}}, Path=IsExpanded}" Value="True"> <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:TreeItem}}, Path=IsExpanded}" Value="True">
<Setter TargetName="Icon" Property="Data" Value="{StaticResource Icon.Folder.Open}"/> <Setter TargetName="Icon" Property="Data" Value="{StaticResource Icon.Folder.Open}"/>
</DataTrigger> </DataTrigger>
<DataTrigger Binding="{Binding IsEditing}" Value="True"> <DataTrigger Binding="{Binding IsEditing}" Value="True">
<Setter TargetName="EditorBookmarks" Property="Visibility" Value="Visible"/> <Setter TargetName="EditorBookmarks" Property="Visibility" Value="Visible"/>
<Setter TargetName="ContentsBookmark" Property="Visibility" Value="Collapsed"/> <Setter TargetName="ContentsBookmark" Property="Visibility" Value="Collapsed"/>
</DataTrigger> </DataTrigger>
</HierarchicalDataTemplate.Triggers> </HierarchicalDataTemplate.Triggers>
</HierarchicalDataTemplate> </HierarchicalDataTemplate>
</controls:Tree.ItemTemplate> </controls:Tree.ItemTemplate>
</controls:Tree> </controls:Tree>
<!-- Drop Area --> <!-- Drop Area -->
<Rectangle <Rectangle
Grid.Row="1" Grid.Row="1"
x:Name="dropArea" x:Name="dropArea"
Margin="0,4" Margin="0,4"
Stroke="{DynamicResource Brush.Border1}" Stroke="{DynamicResource Brush.Border1}"
StrokeThickness="2" StrokeThickness="2"
StrokeDashArray="4,4" StrokeDashArray="4,4"
SnapsToDevicePixels="True" SnapsToDevicePixels="True"
Visibility="Hidden" Visibility="Hidden"
IsHitTestVisible="False"/> IsHitTestVisible="False"/>
</Grid> </Grid>
</Grid> </Grid>
<!-- Popup --> <!-- Popup -->
<widgets:PopupPanel x:Name="popup" Grid.Row="0" Grid.RowSpan="4" Grid.Column="0" Grid.ColumnSpan="3"/> <widgets:PopupPanel x:Name="popup" Grid.Row="0" Grid.RowSpan="4" Grid.Column="0" Grid.ColumnSpan="3"/>
</Grid> </Grid>
</UserControl> </UserControl>

View file

@ -188,14 +188,14 @@ namespace SourceGit.Views.Widgets {
ev.Handled = true; ev.Handled = true;
}; };
var iconBookmark = FindResource("Icon.Bookmark") as Geometry; var iconBookmark = FindResource("Icon.Git") as Geometry;
var bookmark = new MenuItem(); var bookmark = new MenuItem();
bookmark.Header = App.Text("RepoCM.Bookmark"); bookmark.Header = App.Text("RepoCM.Bookmark");
for (int i = 0; i < Controls.Bookmark.COLORS.Length; i++) { for (int i = 0; i < Controls.Bookmark.COLORS.Length; i++) {
var icon = new System.Windows.Shapes.Path(); var icon = new System.Windows.Shapes.Path();
icon.Data = iconBookmark; icon.Data = iconBookmark;
icon.Fill = Controls.Bookmark.COLORS[i]; icon.Fill = i == 0 ? (FindResource("Brush.FG1") as Brush) : Controls.Bookmark.COLORS[i];
icon.Width = 8; icon.Width = 12;
var mark = new MenuItem(); var mark = new MenuItem();
mark.Icon = icon; mark.Icon = icon;