mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-28 15:45:00 +00: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
|
@ -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…
Add table
Add a link
Reference in a new issue