optimize<Welcome>: allow drop on welcome page

This commit is contained in:
leo 2022-10-18 11:44:16 +08:00
parent 18e8036e11
commit bdd147f737
2 changed files with 3 additions and 30 deletions

View file

@ -9,7 +9,7 @@
xmlns:converters="clr-namespace:SourceGit.Views.Converters" xmlns:converters="clr-namespace:SourceGit.Views.Converters"
mc:Ignorable="d" mc:Ignorable="d"
d:DesignHeight="800" d:DesignWidth="800"> d:DesignHeight="800" d:DesignWidth="800">
<Grid Background="Transparent" AllowDrop="True" DragEnter="OnPageDragEnter" DragLeave="OnPageDragLeave" Drop="OnPageDrop"> <Grid Background="Transparent" AllowDrop="True" Drop="OnPageDrop">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/>
@ -101,7 +101,7 @@
</Grid> </Grid>
<!-- Repositories List --> <!-- Repositories List -->
<Grid Grid.Row="2" Grid.Column="1" Margin="0,0,0,80" AllowDrop="True" Drop="OnDropFolder"> <Grid Grid.Row="2" Grid.Column="1" Margin="0,0,0,80">
<Grid.Resources> <Grid.Resources>
<converters:IntToBookmarkBrush x:Key="IntToBookmarkBrush"/> <converters:IntToBookmarkBrush x:Key="IntToBookmarkBrush"/>
</Grid.Resources> </Grid.Resources>
@ -121,7 +121,7 @@
<Control.Template> <Control.Template>
<ControlTemplate> <ControlTemplate>
<Border <Border
Height="36" Height="36" Margin="0,2"
BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}"
Background="{DynamicResource Brush.Contents}"> Background="{DynamicResource Brush.Contents}">
<Grid Margin="8,0"> <Grid Margin="8,0">
@ -169,16 +169,6 @@
</ItemsControl.ItemTemplate> </ItemsControl.ItemTemplate>
</ItemsControl> </ItemsControl>
</ScrollViewer> </ScrollViewer>
<!-- Drop Area -->
<Rectangle
x:Name="dropArea"
Stroke="{DynamicResource Brush.Border1}"
StrokeThickness="2"
StrokeDashArray="4,4"
SnapsToDevicePixels="True"
Visibility="Hidden"
IsHitTestVisible="False"/>
</Grid> </Grid>
<!-- Popup --> <!-- Popup -->

View file

@ -194,26 +194,9 @@ namespace SourceGit.Views.Widgets {
private void OnSearchFilterChanged(object sender, TextChangedEventArgs e) { private void OnSearchFilterChanged(object sender, TextChangedEventArgs e) {
UpdateVisibles(); UpdateVisibles();
} }
#endregion
#region DRAG_DROP
private void OnPageDragEnter(object sender, DragEventArgs e) {
if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
dropArea.Visibility = Visibility.Visible;
}
}
private void OnPageDragLeave(object sender, DragEventArgs e) {
dropArea.Visibility = Visibility.Hidden;
}
private void OnPageDrop(object sender, DragEventArgs e) { private void OnPageDrop(object sender, DragEventArgs e) {
dropArea.Visibility = Visibility.Hidden;
}
private void OnDropFolder(object sender, DragEventArgs e) {
bool rebuild = false; bool rebuild = false;
dropArea.Visibility = Visibility.Hidden;
if (e.Data.GetDataPresent(DataFormats.FileDrop)) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) {
if (!MakeSureReady()) return; if (!MakeSureReady()) return;