mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
style<Bookmark>: unify icons for repository
This commit is contained in:
parent
bc9f9dc2c6
commit
fec14eb04a
6 changed files with 697 additions and 700 deletions
|
@ -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.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.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.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>
|
||||
|
|
|
@ -299,9 +299,9 @@
|
|||
<sys:String x:Key="Text.Merge.Mode">Merge Option :</sys:String>
|
||||
|
||||
<sys:String x:Key="Text.Welcome.Title">Free & 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.OpenTerminal">Open terminal</sys:String>
|
||||
<sys:String x:Key="Text.Welcome.Clone">Clone remote 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.Clone">Clone Repository</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.Recent">RECENT OPENED</sys:String>
|
||||
|
|
|
@ -1,66 +1,64 @@
|
|||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace SourceGit.Views.Controls {
|
||||
|
||||
/// <summary>
|
||||
/// 标签页图标
|
||||
/// </summary>
|
||||
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 {
|
||||
|
||||
/// <summary>
|
||||
/// 标签页图标
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
||||
/// <summary>
|
||||
/// 主窗体标题栏的标签页容器控件
|
||||
/// </summary>
|
||||
public partial class PageTabBar : UserControl {
|
||||
|
||||
/// <summary>
|
||||
/// 标签数据
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 仓库标签页编辑事件参数
|
||||
/// </summary>
|
||||
public event Action<Tab> OnTabEdited;
|
||||
|
||||
/// <summary>
|
||||
/// 标签相关事件参数
|
||||
/// </summary>
|
||||
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<TabEventArgs>),
|
||||
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<TabEventArgs>),
|
||||
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<TabEventArgs>),
|
||||
typeof(PageTabBar));
|
||||
|
||||
public event RoutedEventHandler TabClosed {
|
||||
add { AddHandler(TabClosedEvent, value); }
|
||||
remove { RemoveHandler(TabClosedEvent, value); }
|
||||
}
|
||||
|
||||
public ObservableCollection<Tab> Tabs {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public string Current {
|
||||
get { return (container.SelectedItem as Tab).Id; }
|
||||
}
|
||||
|
||||
public PageTabBar() {
|
||||
Tabs = new ObservableCollection<Tab>();
|
||||
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 {
|
||||
|
||||
/// <summary>
|
||||
/// 主窗体标题栏的标签页容器控件
|
||||
/// </summary>
|
||||
public partial class PageTabBar : UserControl {
|
||||
|
||||
/// <summary>
|
||||
/// 标签数据
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 仓库标签页编辑事件参数
|
||||
/// </summary>
|
||||
public event Action<Tab> OnTabEdited;
|
||||
|
||||
/// <summary>
|
||||
/// 标签相关事件参数
|
||||
/// </summary>
|
||||
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<TabEventArgs>),
|
||||
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<TabEventArgs>),
|
||||
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<TabEventArgs>),
|
||||
typeof(PageTabBar));
|
||||
|
||||
public event RoutedEventHandler TabClosed {
|
||||
add { AddHandler(TabClosedEvent, value); }
|
||||
remove { RemoveHandler(TabClosedEvent, value); }
|
||||
}
|
||||
|
||||
public ObservableCollection<Tab> Tabs {
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
public string Current {
|
||||
get { return (container.SelectedItem as Tab).Id; }
|
||||
}
|
||||
|
||||
public PageTabBar() {
|
||||
Tabs = new ObservableCollection<Tab>();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,274 +1,274 @@
|
|||
<UserControl x:Class="SourceGit.Views.Widgets.Welcome"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
|
||||
xmlns:widgets="clr-namespace:SourceGit.Views.Widgets"
|
||||
xmlns:models="clr-namespace:SourceGit.Models"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="800" d:DesignWidth="800">
|
||||
<Grid Background="Transparent" AllowDrop="True" DragEnter="OnPageDragEnter" DragLeave="OnPageDragLeave" Drop="OnPageDrop">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="80"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="800"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- App Name -->
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Left"
|
||||
Text="SourceGit"
|
||||
FontSize="28pt"
|
||||
TextOptions.TextFormattingMode="Ideal"
|
||||
TextOptions.TextRenderingMode="ClearType"
|
||||
RenderOptions.ClearTypeHint="Enabled"/>
|
||||
|
||||
<!-- App Desc -->
|
||||
<TextBlock
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Left"
|
||||
Text="{DynamicResource Text.Welcome.Title}"
|
||||
Foreground="{DynamicResource Brush.FG2}"
|
||||
FontSize="18pt"
|
||||
Margin="0,8"/>
|
||||
|
||||
<Grid x:Name="body" Grid.Row="3" Grid.Column="1" Margin="0,40,0,80" FocusManager.IsFocusScope="True">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="16"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Left Panel -->
|
||||
<Grid Grid.Column="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Options -->
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Text="{DynamicResource Text.Welcome.Start}"
|
||||
FontSize="13pt"/>
|
||||
<StackPanel Grid.Row="1" Margin="4,12,0,0" Orientation="Vertical">
|
||||
<Button Click="OnOpenClicked" Height="28" Style="{DynamicResource Style.Button.Link}">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<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}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Click="OnCloneClicked" Height="28" Style="{DynamicResource Style.Button.Link}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<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}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Click="OnOpenTerminalClicked" Height="28" Style="{DynamicResource Style.Button.Link}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<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}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Recents -->
|
||||
<TextBlock
|
||||
Grid.Row="2" Margin="0,32,0,0"
|
||||
x:Name="lblRecent"
|
||||
Text="{DynamicResource Text.Welcome.Recent}"
|
||||
FontSize="13pt"
|
||||
Visibility="Hidden"/>
|
||||
<DataGrid
|
||||
Grid.Row="3"
|
||||
x:Name="list"
|
||||
Margin="0,12,0,0"
|
||||
SelectionUnit="FullRow"
|
||||
SelectionMode="Single"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
LostFocus="OnRecentLostFocus">
|
||||
<DataGrid.RowStyle>
|
||||
<Style BasedOn="{StaticResource Style.DataGridRow}" TargetType="{x:Type DataGridRow}">
|
||||
<EventSetter Event="MouseDoubleClick" Handler="OnRecentDoubleClick"/>
|
||||
<EventSetter Event="ContextMenuOpening" Handler="OnRecentContextMenuOpening"/>
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn Width="*">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Height="32" Margin="4,0,0,0" IsHitTestVisible="False">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="22"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<controls:Bookmark
|
||||
Grid.Column="0"
|
||||
Margin="2,0,0,0"
|
||||
x:Name="BookmarkIcon"
|
||||
Width="16" Height="16"
|
||||
Color="{Binding Bookmark}"
|
||||
IsNewPage="False"/>
|
||||
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
||||
<TextBlock Margin="8,0" Text="{Binding Name}"/>
|
||||
<TextBlock x:Name="Path" Text="{Binding Path}" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
|
||||
<!-- Right Panel -->
|
||||
<Grid Grid.Column="2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Repositories Label -->
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Text="{DynamicResource Text.Welcome.Repositories}"
|
||||
FontSize="13pt"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
|
||||
<!-- Repositories Tree DragDrop tip -->
|
||||
<StackPanel Grid.Row="1" x:Name="dropTip" Margin="4,16,0,0" HorizontalAlignment="Left" Orientation="Vertical">
|
||||
<Path
|
||||
Data="{DynamicResource Icon.DragDrop}"
|
||||
Fill="{DynamicResource Brush.FG2}"
|
||||
Width="48" Height="48"
|
||||
VerticalAlignment="Top"/>
|
||||
|
||||
<TextBlock
|
||||
Text="{DynamicResource Text.Welcome.DragDrop}"
|
||||
FontSize="10pt"
|
||||
Margin="0,8,0,0"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Top"
|
||||
Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Repositories Tree -->
|
||||
<controls:Tree
|
||||
Grid.Row="1"
|
||||
x:Name="tree"
|
||||
Margin="0,8,0,0"
|
||||
AllowDrop="True"
|
||||
TextElement.FontSize="14"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
ContextMenuOpening="OnTreeContextMenuOpening"
|
||||
MouseMove="OnTreeMouseMove"
|
||||
DragOver="OnTreeDragOver"
|
||||
Drop="OnTreeDrop"
|
||||
LostFocus="OnTreeLostFocus">
|
||||
<controls:Tree.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type controls:TreeItem}" BasedOn="{StaticResource Style.TreeItem}">
|
||||
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
|
||||
|
||||
<EventSetter Event="Expanded" Handler="OnTreeNodeStatusChange"/>
|
||||
<EventSetter Event="Collapsed" Handler="OnTreeNodeStatusChange"/>
|
||||
<EventSetter Event="MouseDoubleClick" Handler="OnTreeNodeDoubleClick"/>
|
||||
</Style>
|
||||
</controls:Tree.ItemContainerStyle>
|
||||
|
||||
<controls:Tree.ItemTemplate>
|
||||
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
|
||||
<Grid Height="32" IsHitTestVisible="False">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="22"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Path Grid.Column="0" Margin="2,0,0,0" x:Name="Icon" Width="16" Height="16" Data="{StaticResource Icon.Folder.Fill}"/>
|
||||
|
||||
<controls:Bookmark
|
||||
Grid.Column="0"
|
||||
Margin="2,0,0,0"
|
||||
x:Name="BookmarkIcon"
|
||||
Width="16" Height="16"
|
||||
Color="{Binding Bookmark}"
|
||||
IsNewPage="False"/>
|
||||
|
||||
<StackPanel Grid.Column="1" x:Name="ContentsBookmark" Orientation="Horizontal">
|
||||
<TextBlock Margin="8,0" Text="{Binding Name}"/>
|
||||
<TextBlock x:Name="Path" Text="{Binding Id}" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</StackPanel>
|
||||
|
||||
<controls:TextEdit
|
||||
Grid.Column="1"
|
||||
x:Name="EditorBookmarks"
|
||||
Height="20"
|
||||
Margin="4,0,0,0"
|
||||
Text="{Binding Name}"
|
||||
FontSize="9pt"
|
||||
Loaded="RenameStart"
|
||||
KeyDown="RenameKeyDown"
|
||||
LostFocus="RenameEnd"
|
||||
IsHitTestVisible="True"
|
||||
Visibility="Collapsed"/>
|
||||
</Grid>
|
||||
|
||||
<HierarchicalDataTemplate.Triggers>
|
||||
<DataTrigger Binding="{Binding IsGroup}" Value="True">
|
||||
<Setter TargetName="Path" Property="Visibility" Value="Collapsed"/>
|
||||
<Setter TargetName="Icon" Property="Visibility" Value="Visible"/>
|
||||
<Setter TargetName="BookmarkIcon" Property="Visibility" Value="Collapsed"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsGroup}" Value="False">
|
||||
<Setter TargetName="Path" Property="Visibility" Value="Visible"/>
|
||||
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed"/>
|
||||
<Setter TargetName="BookmarkIcon" Property="Visibility" Value="Visible"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:TreeItem}}, Path=IsExpanded}" Value="True">
|
||||
<Setter TargetName="Icon" Property="Data" Value="{StaticResource Icon.Folder.Open}"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsEditing}" Value="True">
|
||||
<Setter TargetName="EditorBookmarks" Property="Visibility" Value="Visible"/>
|
||||
<Setter TargetName="ContentsBookmark" Property="Visibility" Value="Collapsed"/>
|
||||
</DataTrigger>
|
||||
</HierarchicalDataTemplate.Triggers>
|
||||
</HierarchicalDataTemplate>
|
||||
</controls:Tree.ItemTemplate>
|
||||
</controls:Tree>
|
||||
|
||||
<!-- Drop Area -->
|
||||
<Rectangle
|
||||
Grid.Row="1"
|
||||
x:Name="dropArea"
|
||||
Margin="0,4"
|
||||
Stroke="{DynamicResource Brush.Border1}"
|
||||
StrokeThickness="2"
|
||||
StrokeDashArray="4,4"
|
||||
SnapsToDevicePixels="True"
|
||||
Visibility="Hidden"
|
||||
IsHitTestVisible="False"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<!-- Popup -->
|
||||
<widgets:PopupPanel x:Name="popup" Grid.Row="0" Grid.RowSpan="4" Grid.Column="0" Grid.ColumnSpan="3"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
<UserControl x:Class="SourceGit.Views.Widgets.Welcome"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
|
||||
xmlns:widgets="clr-namespace:SourceGit.Views.Widgets"
|
||||
xmlns:models="clr-namespace:SourceGit.Models"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="800" d:DesignWidth="800">
|
||||
<Grid Background="Transparent" AllowDrop="True" DragEnter="OnPageDragEnter" DragLeave="OnPageDragLeave" Drop="OnPageDrop">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="80"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="800"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- App Name -->
|
||||
<TextBlock
|
||||
Grid.Row="1"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Left"
|
||||
Text="SourceGit"
|
||||
FontSize="28pt"
|
||||
TextOptions.TextFormattingMode="Ideal"
|
||||
TextOptions.TextRenderingMode="ClearType"
|
||||
RenderOptions.ClearTypeHint="Enabled"/>
|
||||
|
||||
<!-- App Desc -->
|
||||
<TextBlock
|
||||
Grid.Row="2"
|
||||
Grid.Column="1"
|
||||
HorizontalAlignment="Left"
|
||||
Text="{DynamicResource Text.Welcome.Title}"
|
||||
Foreground="{DynamicResource Brush.FG2}"
|
||||
FontSize="18pt"
|
||||
Margin="0,8"/>
|
||||
|
||||
<Grid x:Name="body" Grid.Row="3" Grid.Column="1" Margin="0,40,0,80" FocusManager.IsFocusScope="True">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="16"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<!-- Left Panel -->
|
||||
<Grid Grid.Column="0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Options -->
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Text="{DynamicResource Text.Welcome.Start}"
|
||||
FontSize="13pt"/>
|
||||
<StackPanel Grid.Row="1" Margin="4,12,0,0" Orientation="Vertical">
|
||||
<Button Click="OnOpenClicked" Height="28" Style="{DynamicResource Style.Button.Link}">
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
|
||||
<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}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Click="OnCloneClicked" Height="28" Style="{DynamicResource Style.Button.Link}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<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}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Click="OnOpenTerminalClicked" Height="28" Style="{DynamicResource Style.Button.Link}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<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}"/>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Recents -->
|
||||
<TextBlock
|
||||
Grid.Row="2" Margin="0,32,0,0"
|
||||
x:Name="lblRecent"
|
||||
Text="{DynamicResource Text.Welcome.Recent}"
|
||||
FontSize="13pt"
|
||||
Visibility="Hidden"/>
|
||||
<DataGrid
|
||||
Grid.Row="3"
|
||||
x:Name="list"
|
||||
Margin="0,12,0,0"
|
||||
SelectionUnit="FullRow"
|
||||
SelectionMode="Single"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
LostFocus="OnRecentLostFocus">
|
||||
<DataGrid.RowStyle>
|
||||
<Style BasedOn="{StaticResource Style.DataGridRow}" TargetType="{x:Type DataGridRow}">
|
||||
<EventSetter Event="MouseDoubleClick" Handler="OnRecentDoubleClick"/>
|
||||
<EventSetter Event="ContextMenuOpening" Handler="OnRecentContextMenuOpening"/>
|
||||
</Style>
|
||||
</DataGrid.RowStyle>
|
||||
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn Width="*">
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Height="32" Margin="4,0,0,0" IsHitTestVisible="False">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="22"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<controls:Bookmark
|
||||
Grid.Column="0"
|
||||
Margin="2,0,0,0"
|
||||
x:Name="BookmarkIcon"
|
||||
Width="16" Height="16"
|
||||
Color="{Binding Bookmark}"
|
||||
IsNewPage="False"/>
|
||||
|
||||
<StackPanel Grid.Column="1" Orientation="Horizontal">
|
||||
<TextBlock Margin="8,0" Text="{Binding Name}"/>
|
||||
<TextBlock x:Name="Path" Text="{Binding Path}" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
|
||||
<!-- Right Panel -->
|
||||
<Grid Grid.Column="2">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<!-- Repositories Label -->
|
||||
<TextBlock
|
||||
Grid.Row="0"
|
||||
Text="{DynamicResource Text.Welcome.Repositories}"
|
||||
FontSize="13pt"
|
||||
HorizontalAlignment="Left" VerticalAlignment="Center"/>
|
||||
|
||||
<!-- Repositories Tree DragDrop tip -->
|
||||
<StackPanel Grid.Row="1" x:Name="dropTip" Margin="4,16,0,0" HorizontalAlignment="Left" Orientation="Vertical">
|
||||
<Path
|
||||
Data="{DynamicResource Icon.DragDrop}"
|
||||
Fill="{DynamicResource Brush.FG2}"
|
||||
Width="48" Height="48"
|
||||
VerticalAlignment="Top"/>
|
||||
|
||||
<TextBlock
|
||||
Text="{DynamicResource Text.Welcome.DragDrop}"
|
||||
FontSize="10pt"
|
||||
Margin="0,8,0,0"
|
||||
HorizontalAlignment="Center" VerticalAlignment="Top"
|
||||
Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Repositories Tree -->
|
||||
<controls:Tree
|
||||
Grid.Row="1"
|
||||
x:Name="tree"
|
||||
Margin="0,8,0,0"
|
||||
AllowDrop="True"
|
||||
TextElement.FontSize="14"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
ContextMenuOpening="OnTreeContextMenuOpening"
|
||||
MouseMove="OnTreeMouseMove"
|
||||
DragOver="OnTreeDragOver"
|
||||
Drop="OnTreeDrop"
|
||||
LostFocus="OnTreeLostFocus">
|
||||
<controls:Tree.ItemContainerStyle>
|
||||
<Style TargetType="{x:Type controls:TreeItem}" BasedOn="{StaticResource Style.TreeItem}">
|
||||
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
|
||||
|
||||
<EventSetter Event="Expanded" Handler="OnTreeNodeStatusChange"/>
|
||||
<EventSetter Event="Collapsed" Handler="OnTreeNodeStatusChange"/>
|
||||
<EventSetter Event="MouseDoubleClick" Handler="OnTreeNodeDoubleClick"/>
|
||||
</Style>
|
||||
</controls:Tree.ItemContainerStyle>
|
||||
|
||||
<controls:Tree.ItemTemplate>
|
||||
<HierarchicalDataTemplate ItemsSource="{Binding Children}">
|
||||
<Grid Height="32" IsHitTestVisible="False">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="22"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Path Grid.Column="0" Margin="2,0,0,0" x:Name="Icon" Width="16" Height="16" Data="{StaticResource Icon.Folder.Fill}"/>
|
||||
|
||||
<controls:Bookmark
|
||||
Grid.Column="0"
|
||||
Margin="2,0,0,0"
|
||||
x:Name="BookmarkIcon"
|
||||
Width="16" Height="16"
|
||||
Color="{Binding Bookmark}"
|
||||
IsNewPage="False"/>
|
||||
|
||||
<StackPanel Grid.Column="1" x:Name="ContentsBookmark" Orientation="Horizontal">
|
||||
<TextBlock Margin="8,0" Text="{Binding Name}"/>
|
||||
<TextBlock x:Name="Path" Text="{Binding Id}" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</StackPanel>
|
||||
|
||||
<controls:TextEdit
|
||||
Grid.Column="1"
|
||||
x:Name="EditorBookmarks"
|
||||
Height="20"
|
||||
Margin="4,0,0,0"
|
||||
Text="{Binding Name}"
|
||||
FontSize="9pt"
|
||||
Loaded="RenameStart"
|
||||
KeyDown="RenameKeyDown"
|
||||
LostFocus="RenameEnd"
|
||||
IsHitTestVisible="True"
|
||||
Visibility="Collapsed"/>
|
||||
</Grid>
|
||||
|
||||
<HierarchicalDataTemplate.Triggers>
|
||||
<DataTrigger Binding="{Binding IsGroup}" Value="True">
|
||||
<Setter TargetName="Path" Property="Visibility" Value="Collapsed"/>
|
||||
<Setter TargetName="Icon" Property="Visibility" Value="Visible"/>
|
||||
<Setter TargetName="BookmarkIcon" Property="Visibility" Value="Collapsed"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsGroup}" Value="False">
|
||||
<Setter TargetName="Path" Property="Visibility" Value="Visible"/>
|
||||
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed"/>
|
||||
<Setter TargetName="BookmarkIcon" Property="Visibility" Value="Visible"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type controls:TreeItem}}, Path=IsExpanded}" Value="True">
|
||||
<Setter TargetName="Icon" Property="Data" Value="{StaticResource Icon.Folder.Open}"/>
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsEditing}" Value="True">
|
||||
<Setter TargetName="EditorBookmarks" Property="Visibility" Value="Visible"/>
|
||||
<Setter TargetName="ContentsBookmark" Property="Visibility" Value="Collapsed"/>
|
||||
</DataTrigger>
|
||||
</HierarchicalDataTemplate.Triggers>
|
||||
</HierarchicalDataTemplate>
|
||||
</controls:Tree.ItemTemplate>
|
||||
</controls:Tree>
|
||||
|
||||
<!-- Drop Area -->
|
||||
<Rectangle
|
||||
Grid.Row="1"
|
||||
x:Name="dropArea"
|
||||
Margin="0,4"
|
||||
Stroke="{DynamicResource Brush.Border1}"
|
||||
StrokeThickness="2"
|
||||
StrokeDashArray="4,4"
|
||||
SnapsToDevicePixels="True"
|
||||
Visibility="Hidden"
|
||||
IsHitTestVisible="False"/>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<!-- Popup -->
|
||||
<widgets:PopupPanel x:Name="popup" Grid.Row="0" Grid.RowSpan="4" Grid.Column="0" Grid.ColumnSpan="3"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue