mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-23 20:47:25 -08:00
feature(Launcher): enable drag-drop on title bar
This commit is contained in:
parent
c6e094b95c
commit
a4d1617c5a
2 changed files with 35 additions and 2 deletions
|
@ -5,7 +5,6 @@
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:source="clr-namespace:SourceGit"
|
xmlns:source="clr-namespace:SourceGit"
|
||||||
xmlns:local="clr-namespace:SourceGit.UI"
|
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
MinWidth="800" MinHeight="600"
|
MinWidth="800" MinHeight="600"
|
||||||
Title="Source Git"
|
Title="Source Git"
|
||||||
|
@ -52,7 +51,7 @@
|
||||||
<TabControl
|
<TabControl
|
||||||
x:Name="openedTabs"
|
x:Name="openedTabs"
|
||||||
Grid.Column="0"
|
Grid.Column="0"
|
||||||
Padding="0"
|
Padding="0"
|
||||||
ItemsSource="{Binding ElementName=me, Path=Tabs}">
|
ItemsSource="{Binding ElementName=me, Path=Tabs}">
|
||||||
<TabControl.Style>
|
<TabControl.Style>
|
||||||
<Style TargetType="{x:Type TabControl}">
|
<Style TargetType="{x:Type TabControl}">
|
||||||
|
@ -76,6 +75,7 @@
|
||||||
|
|
||||||
<TabControl.ItemContainerStyle>
|
<TabControl.ItemContainerStyle>
|
||||||
<Style TargetType="{x:Type TabItem}">
|
<Style TargetType="{x:Type TabItem}">
|
||||||
|
<Setter Property="AllowDrop" Value="True"/>
|
||||||
<Setter Property="IsSelected" Value="{Binding IsActive, Mode=TwoWay}"/>
|
<Setter Property="IsSelected" Value="{Binding IsActive, Mode=TwoWay}"/>
|
||||||
<Setter Property="Template">
|
<Setter Property="Template">
|
||||||
<Setter.Value>
|
<Setter.Value>
|
||||||
|
@ -113,6 +113,9 @@
|
||||||
</ControlTemplate>
|
</ControlTemplate>
|
||||||
</Setter.Value>
|
</Setter.Value>
|
||||||
</Setter>
|
</Setter>
|
||||||
|
|
||||||
|
<EventSetter Event="PreviewMouseMove" Handler="TabsPreviewMouseMove"/>
|
||||||
|
<EventSetter Event="Drop" Handler="TabsDrop"/>
|
||||||
</Style>
|
</Style>
|
||||||
</TabControl.ItemContainerStyle>
|
</TabControl.ItemContainerStyle>
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Input;
|
||||||
|
|
||||||
namespace SourceGit.UI {
|
namespace SourceGit.UI {
|
||||||
|
|
||||||
|
@ -177,5 +178,34 @@ namespace SourceGit.UI {
|
||||||
App.Current.Shutdown();
|
App.Current.Shutdown();
|
||||||
}
|
}
|
||||||
#endregion
|
#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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue