diff --git a/src/Resources/Locales/en_US.xaml b/src/Resources/Locales/en_US.xaml
index 208f076f..48117316 100644
--- a/src/Resources/Locales/en_US.xaml
+++ b/src/Resources/Locales/en_US.xaml
@@ -24,7 +24,7 @@
SSH Private Key :
Private SSH key store path
- ABOUT
+ About
SourceGit - OPEN SOURCE GIT CLIENT
Patch
@@ -280,8 +280,7 @@
Invalid repository detected. Run `git init` under this path?
Source Git
- PREFERENCE
- ABOUT
+ Open Main Menu
ERROR
NEW PAGE
diff --git a/src/Resources/Locales/zh_CN.xaml b/src/Resources/Locales/zh_CN.xaml
index c9f169f3..d8393834 100644
--- a/src/Resources/Locales/zh_CN.xaml
+++ b/src/Resources/Locales/zh_CN.xaml
@@ -279,8 +279,7 @@
点击【确定】将在此目录执行`git init`操作
Source Git
- 偏好设置
- 关于
+ 主菜单
出错了
新建空白页
diff --git a/src/Views/Launcher.xaml b/src/Views/Launcher.xaml
index afbd321c..84c0b563 100644
--- a/src/Views/Launcher.xaml
+++ b/src/Views/Launcher.xaml
@@ -25,28 +25,34 @@
+
-
+
+
+
+
-
-
-
-
-
-
+
diff --git a/src/Views/Launcher.xaml.cs b/src/Views/Launcher.xaml.cs
index 3395036f..c44acd47 100644
--- a/src/Views/Launcher.xaml.cs
+++ b/src/Views/Launcher.xaml.cs
@@ -2,7 +2,11 @@ using System;
using System.ComponentModel;
using System.Threading.Tasks;
using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Shapes;
namespace SourceGit.Views {
@@ -77,15 +81,49 @@ namespace SourceGit.Views {
}
#endregion
- #region RIGHT_COMMANDS
- private void OpenPreference(object sender, RoutedEventArgs e) {
- var dialog = new Preference() { Owner = this };
- dialog.ShowDialog();
+ #region OPERATIONS
+ private void FillMenu(ContextMenu menu, string icon, string header, RoutedEventHandler onClick) {
+ var iconMode = new Path();
+ iconMode.Width = 12;
+ iconMode.Height = 12;
+ iconMode.Data = FindResource(icon) as Geometry;
+ iconMode.SetResourceReference(Path.FillProperty, "Brush.FG2");
+
+ var item = new MenuItem();
+ item.Icon = iconMode;
+ item.Header = App.Text(header);
+ item.Click += onClick;
+
+ menu.Items.Add(item);
}
- private void OpenAbout(object sender, RoutedEventArgs e) {
- var dialog = new About() { Owner = this };
- dialog.ShowDialog();
+ private void ToggleMainMenu(object sender, RoutedEventArgs e) {
+ var btn = (sender as Button);
+ if (btn.ContextMenu != null) {
+ btn.ContextMenu.IsOpen = true;
+ e.Handled = true;
+ return;
+ }
+
+ var menu = new ContextMenu();
+ menu.Placement = PlacementMode.Bottom;
+ menu.PlacementTarget = btn;
+ menu.StaysOpen = false;
+ menu.Focusable = true;
+
+ FillMenu(menu, "Icon.Preference", "Preference", (o, ev) => {
+ var dialog = new Preference() { Owner = this };
+ dialog.ShowDialog();
+ });
+
+ FillMenu(menu, "Icon.Help", "About", (o, ev) => {
+ var dialog = new About() { Owner = this };
+ dialog.ShowDialog();
+ });
+
+ btn.ContextMenu = menu;
+ btn.ContextMenu.IsOpen = true;
+ e.Handled = true;
}
private void Minimize(object sender, RoutedEventArgs e) {
diff --git a/src/Views/Widgets/PageTabBar.xaml b/src/Views/Widgets/PageTabBar.xaml
index d2d30bee..b6c2a173 100644
--- a/src/Views/Widgets/PageTabBar.xaml
+++ b/src/Views/Widgets/PageTabBar.xaml
@@ -7,16 +7,25 @@
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
mc:Ignorable="d"
d:DesignHeight="28" d:DesignWidth="800">
-
+
+
+
+
+
-
+
@@ -64,12 +73,13 @@
@@ -121,7 +131,7 @@
scroller.ActualWidth) {
+ startSeperator.Visibility = Visibility.Hidden;
leftScroller.Visibility = Visibility.Visible;
rightScroller.Visibility = Visibility.Visible;
} else {
leftScroller.Visibility = Visibility.Collapsed;
rightScroller.Visibility = Visibility.Collapsed;
+ if (container.SelectedIndex == 0) {
+ startSeperator.Visibility = Visibility.Hidden;
+ } else {
+ startSeperator.Visibility = Visibility.Visible;
+ }
}
}
@@ -223,17 +229,7 @@ namespace SourceGit.Views.Widgets {
private void SelectionChanged(object sender, SelectionChangedEventArgs e) {
var tab = container.SelectedItem as Tab;
if (tab == null) return;
-
- for (int i = 0; i < Tabs.Count; i++) {
- if (Tabs[i] == tab) {
- tab.IsSeperatorVisible = false;
- if (i > 0) Tabs[i - 1].IsSeperatorVisible = false;
- } else {
- Tabs[i].IsSeperatorVisible = true;
- }
- }
-
-
+ UpdateSeperators(tab);
RaiseEvent(new TabEventArgs(TabSelectedEvent, this, tab.Id));
}
@@ -260,6 +256,7 @@ namespace SourceGit.Views.Widgets {
RaiseEvent(new TabEventArgs(TabSelectedEvent, this, next.Id));
} else {
Tabs.Remove(tab);
+ UpdateSeperators(curTab);
}
RaiseEvent(new TabEventArgs(TabClosedEvent, this, tab.Id));
}
@@ -366,5 +363,24 @@ namespace SourceGit.Views.Widgets {
menu.IsOpen = true;
e.Handled = true;
}
+
+ private void UpdateSeperators(Tab actived) {
+ int curIdx = 0;
+ for (int i = 0; i < Tabs.Count; i++) {
+ if (Tabs[i] == actived) {
+ curIdx = i;
+ actived.IsSeperatorVisible = false;
+ if (i > 0) Tabs[i - 1].IsSeperatorVisible = false;
+ } else {
+ Tabs[i].IsSeperatorVisible = true;
+ }
+ }
+
+ if (leftScroller.Visibility == Visibility.Visible || curIdx == 0) {
+ startSeperator.Visibility = Visibility.Hidden;
+ } else {
+ startSeperator.Visibility = Visibility.Visible;
+ }
+ }
}
}