diff --git a/src/Resources/Styles/Window.xaml b/src/Resources/Styles/Window.xaml
index 710e1f58..f7ed1acf 100644
--- a/src/Resources/Styles/Window.xaml
+++ b/src/Resources/Styles/Window.xaml
@@ -24,15 +24,13 @@
-
-
-
-
-
+
+
+
diff --git a/src/Views/Controls/DragDropAdorner.cs b/src/Views/Controls/DragDropAdorner.cs
deleted file mode 100644
index b3312f38..00000000
--- a/src/Views/Controls/DragDropAdorner.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using System.Runtime.InteropServices;
-using System.Windows;
-using System.Windows.Documents;
-using System.Windows.Media;
-
-namespace SourceGit.Views.Controls {
- ///
- /// 展示正在拖拽的视图
- ///
- public class DragDropAdorner : Adorner {
- private FrameworkElement renderElem;
-
- public struct PInPoint {
- public int X;
- public int Y;
-
- public PInPoint(int x, int y) { X = x; Y = y; }
- public PInPoint(double x, double y) { X = (int)x; Y = (int)y; }
- }
-
- [DllImport("user32.dll")]
- static extern void GetCursorPos(ref PInPoint p);
-
- public DragDropAdorner(FrameworkElement elem) : base(elem) {
- renderElem = elem;
- IsHitTestVisible = false;
- Window.AddAdorner(elem, this);
- }
-
- public void Remove() {
- Window.RemoveAdorner(renderElem, this);
- }
-
- protected override void OnRender(DrawingContext dc) {
- base.OnRender(dc);
-
- PInPoint p = new PInPoint();
- GetCursorPos(ref p);
-
- Point pos = PointFromScreen(new Point(p.X, p.Y));
- Rect rect = new Rect(pos.X, pos.Y, renderElem.RenderSize.Width, renderElem.RenderSize.Height);
-
- dc.PushOpacity(1);
- dc.DrawRectangle(FindResource("Brush.Window") as Brush, null, rect);
- dc.DrawRectangle(new VisualBrush(renderElem), null, rect);
- dc.DrawRectangle(null, new Pen(Brushes.DeepSkyBlue, 2), rect);
- }
- }
-}
diff --git a/src/Views/Controls/Window.cs b/src/Views/Controls/Window.cs
index 24dfaa64..cd4282a5 100644
--- a/src/Views/Controls/Window.cs
+++ b/src/Views/Controls/Window.cs
@@ -20,37 +20,9 @@ namespace SourceGit.Views.Controls {
set { SetValue(IsMaximizedProperty, value); }
}
- private AdornerLayer adornerLayer = null;
- private List adorners = new List();
-
public Window() {
Style = FindResource("Style.Window") as Style;
-
- Loaded += (_, __) => {
- adornerLayer = AdornerLayer.GetAdornerLayer(Content as FrameworkElement);
- OnStateChanged(null);
- };
- }
-
- public static void AddAdorner(FrameworkElement windowContext, Adorner adorner) {
- var wnd = GetWindow(windowContext) as Window;
- if (wnd != null && wnd.adornerLayer != null) {
- wnd.adorners.Add(adorner);
- wnd.adornerLayer.Add(adorner);
- }
- }
-
- public static void RemoveAdorner(FrameworkElement windowContext, Adorner adorner) {
- var wnd = GetWindow(windowContext) as Window;
- if (wnd != null && wnd.adornerLayer != null) {
- wnd.adorners.Remove(adorner);
- wnd.adornerLayer.Remove(adorner);
- }
- }
-
- protected override void OnPreviewGiveFeedback(GiveFeedbackEventArgs e) {
- base.OnPreviewGiveFeedback(e);
- if (adornerLayer != null && adorners.Count > 0) adornerLayer.Update();
+ Loaded += (_, __) => OnStateChanged(null);
}
protected override void OnStateChanged(EventArgs e) {
diff --git a/src/Views/Converters/IntToBookmarkBrush.cs b/src/Views/Converters/IntToBookmarkBrush.cs
index aa6c6063..114e5eb0 100644
--- a/src/Views/Converters/IntToBookmarkBrush.cs
+++ b/src/Views/Converters/IntToBookmarkBrush.cs
@@ -19,7 +19,7 @@ namespace SourceGit.Views.Converters {
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
var index = (int)value;
- return index == 0 ? (App.Current.FindResource("Brush.FG1") as Brush) : COLORS[index];
+ return COLORS[index];
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) {
diff --git a/src/Views/Launcher.xaml.cs b/src/Views/Launcher.xaml.cs
index 812ff65b..b0c01a58 100644
--- a/src/Views/Launcher.xaml.cs
+++ b/src/Views/Launcher.xaml.cs
@@ -144,7 +144,6 @@ namespace SourceGit.Views {
#region TAB_OPERATION
private void OnTabAdding(object sender, Widgets.PageTabBar.TabEventArgs e) {
var page = new Widgets.Welcome();
- page.OnBookmarkChanged += repo => tabs.Update(repo.Path, repo.Bookmark, repo.Name);
container.Add(e.TabId, page);
Controls.PopupWidget.RegisterContainer(e.TabId, page);
}
diff --git a/src/Views/Widgets/PageTabBar.xaml b/src/Views/Widgets/PageTabBar.xaml
index 31cbd511..49c6a424 100644
--- a/src/Views/Widgets/PageTabBar.xaml
+++ b/src/Views/Widgets/PageTabBar.xaml
@@ -64,6 +64,11 @@
diff --git a/src/Views/Widgets/PageTabBar.xaml.cs b/src/Views/Widgets/PageTabBar.xaml.cs
index 1b57e301..4e049677 100644
--- a/src/Views/Widgets/PageTabBar.xaml.cs
+++ b/src/Views/Widgets/PageTabBar.xaml.cs
@@ -269,12 +269,25 @@ namespace SourceGit.Views.Widgets {
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 OnGiveFeedback(object sender, GiveFeedbackEventArgs e) {
+ if (e.Effects == DragDropEffects.Move) {
+ e.UseDefaultCursors = false;
+ Mouse.SetCursor(Cursors.Hand);
+ } else {
+ e.UseDefaultCursors = true;
+ }
+
+ e.Handled = true;
+ }
+
+ private void OnDragOver(object sender, DragEventArgs e) {
+ OnDrop(sender, e);
+ }
+
private void OnDrop(object sender, DragEventArgs e) {
var tabSrc = e.Data.GetData(typeof(Tab)) as Tab;
if (tabSrc == null) return;
@@ -323,13 +336,12 @@ namespace SourceGit.Views.Widgets {
menu.Items.Add(closeRight);
if (tab.IsRepository) {
- var iconBookmark = FindResource("Icon.Git") as Geometry;
var bookmark = new MenuItem();
bookmark.Header = App.Text("PageTabBar.Tab.Bookmark");
for (int i = 0; i < Converters.IntToBookmarkBrush.COLORS.Length; i++) {
var icon = new System.Windows.Shapes.Path();
- icon.Data = iconBookmark;
- icon.Fill = i == 0 ? (FindResource("Brush.FG1") as Brush) : Converters.IntToBookmarkBrush.COLORS[i];
+ icon.Data = new EllipseGeometry(new Point(0, 0), 12, 12);
+ icon.Fill = Converters.IntToBookmarkBrush.COLORS[i];
icon.Width = 12;
var mark = new MenuItem();
diff --git a/src/Views/Widgets/Welcome.xaml b/src/Views/Widgets/Welcome.xaml
index 87eac4b7..3efde1cf 100644
--- a/src/Views/Widgets/Welcome.xaml
+++ b/src/Views/Widgets/Welcome.xaml
@@ -124,25 +124,20 @@
Height="36" Margin="0,2"
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}"
Background="{DynamicResource Brush.Contents}">
-
+
-
+
+
-
+
-
+
diff --git a/src/Views/Widgets/Welcome.xaml.cs b/src/Views/Widgets/Welcome.xaml.cs
index 2ab437ca..d15d2039 100644
--- a/src/Views/Widgets/Welcome.xaml.cs
+++ b/src/Views/Widgets/Welcome.xaml.cs
@@ -16,11 +16,6 @@ namespace SourceGit.Views.Widgets {
///
public partial class Welcome : UserControl, Controls.IPopupContainer {
- ///
- /// 修改仓库标签颜色的回调
- ///
- public event Action OnBookmarkChanged;
-
public Welcome() {
InitializeComponent();
UpdateVisibles();
@@ -135,45 +130,6 @@ namespace SourceGit.Views.Widgets {
e.Handled = true;
}
- private void OnChangeRepositoryBookmark(object sender, RoutedEventArgs e) {
- var btn = (sender as Button);
- var repo = btn.DataContext as Models.Repository;
- if (repo == null) return;
-
- var menu = new ContextMenu();
- menu.Placement = PlacementMode.Bottom;
- menu.PlacementTarget = btn;
- menu.StaysOpen = false;
- menu.Focusable = true;
-
- for (int i = 0; i < Converters.IntToBookmarkBrush.COLORS.Length; i++) {
- var icon = new System.Windows.Shapes.Path();
- icon.Data = new EllipseGeometry(new Point(0, 0), 8, 8);
- icon.Fill = i == 0 ? (FindResource("Brush.FG1") as Brush) : Converters.IntToBookmarkBrush.COLORS[i];
- icon.Width = 12;
-
- var mark = new MenuItem();
- mark.Icon = icon;
- mark.Header = $"{i}";
-
- var refIdx = i;
- mark.Click += (o, ev) => {
- if (repo != null) {
- repo.Bookmark = refIdx;
- UpdateVisibles();
- OnBookmarkChanged?.Invoke(repo);
- }
- ev.Handled = true;
- };
-
- menu.Items.Add(mark);
- }
-
- btn.ContextMenu = menu;
- btn.ContextMenu.IsOpen = true;
- e.Handled = true;
- }
-
private void OnOpenRepositoryTerminal(object sender, RoutedEventArgs e) {
var repo = (sender as Button).DataContext as Models.Repository;
if (repo == null) return;