diff --git a/SourceGit/UI/Launcher.xaml b/SourceGit/UI/Launcher.xaml index 5fc13d21..64600f87 100644 --- a/SourceGit/UI/Launcher.xaml +++ b/SourceGit/UI/Launcher.xaml @@ -5,7 +5,6 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:source="clr-namespace:SourceGit" - xmlns:local="clr-namespace:SourceGit.UI" mc:Ignorable="d" MinWidth="800" MinHeight="600" Title="Source Git" @@ -52,7 +51,7 @@ diff --git a/SourceGit/UI/Launcher.xaml.cs b/SourceGit/UI/Launcher.xaml.cs index 7cb79167..1431c224 100644 --- a/SourceGit/UI/Launcher.xaml.cs +++ b/SourceGit/UI/Launcher.xaml.cs @@ -1,6 +1,7 @@ using System.Collections.ObjectModel; using System.Windows; using System.Windows.Controls; +using System.Windows.Input; namespace SourceGit.UI { @@ -177,5 +178,34 @@ namespace SourceGit.UI { App.Current.Shutdown(); } #endregion + + #region DRAG_DROP + private void TabsPreviewMouseMove(object sender, MouseEventArgs e) { + var tab = e.Source as TabItem; + if (tab == null || (tab.DataContext as Tab).Repo == null) return; + + if (Mouse.LeftButton == MouseButtonState.Pressed) { + DragDrop.DoDragDrop(tab, tab, DragDropEffects.All); + } + } + + private void TabsDrop(object sender, DragEventArgs e) { + var tabItemSrc = e.Data.GetData(typeof(TabItem)) as TabItem; + var tabItemDst = e.Source as TabItem; + if (tabItemSrc.Equals(tabItemDst)) return; + + var tabSrc = tabItemSrc.DataContext as Tab; + var tabDst = tabItemDst.DataContext as Tab; + if (tabDst.Repo == null) { + Tabs.Remove(tabSrc); + Tabs.Insert(1, tabSrc); + } else { + int dstIdx = Tabs.IndexOf(tabDst); + + Tabs.Remove(tabSrc); + Tabs.Insert(dstIdx, tabSrc); + } + } + #endregion } }