flabbet 9 месяцев назад
Родитель
Сommit
4f63683043

+ 4 - 5
src/PixiEditor/Views/Layers/FolderControl.axaml

@@ -40,8 +40,8 @@
                 <RowDefinition Height="16"/>
                 <RowDefinition Height="10"/>
             </Grid.RowDefinitions>
-            <Grid DragDrop.AllowDrop="True" helpers:DragDropEvents.DragEnter="Grid_DragEnter" helpers:DragDropEvents.Drop="Grid_Drop_Top" helpers:DragDropEvents.DragLeave="Grid_DragLeave" Grid.Row="0" Grid.ColumnSpan="3" Background="Transparent" Panel.ZIndex="3"/>
-            <Grid IsVisible="True" Margin="20, 0, 0,0" x:Name="middleDropGrid" Grid.Row="1" DragDrop.AllowDrop="True" Panel.ZIndex="2" Background="Transparent" helpers:DragDropEvents.DragEnter="Grid_CenterEnter" helpers:DragDropEvents.Drop="Grid_Drop_Center" helpers:DragDropEvents.DragLeave="Grid_CenterLeave" />
+            <Grid DragDrop.AllowDrop="True" Name="TopDropGrid" Grid.Row="0" Grid.ColumnSpan="3" Background="Transparent" Panel.ZIndex="3"/>
+            <Grid IsVisible="True" Margin="20, 0, 0,0" x:Name="middleDropGrid" Grid.Row="1" DragDrop.AllowDrop="True" Panel.ZIndex="2" Background="Transparent"  />
             <Grid x:Name="centerGrid" Grid.Row="0" Grid.RowSpan="3" Background="Transparent">
                 <Grid.ColumnDefinitions>
                     <ColumnDefinition Width="24"/>
@@ -130,9 +130,8 @@
             </Grid>
             <Grid
                   Grid.Row="2"
-                  helpers:DragDropEvents.DragEnter="Grid_DragEnter" helpers:DragDropEvents.Drop="Grid_Drop_Bottom"
-                  helpers:DragDropEvents.DragLeave="Grid_DragLeave"
-                  DragDrop.AllowDrop="false"
+                  Name="BottomDropGrid"
+                  DragDrop.AllowDrop="True"
                   Grid.ColumnSpan="2" Background="Transparent"/>
         </Grid>
         <Border.ContextMenu>

+ 12 - 0
src/PixiEditor/Views/Layers/FolderControl.axaml.cs

@@ -48,6 +48,18 @@ internal partial class FolderControl : UserControl
 
         Loaded += OnLoaded;
         Unloaded += OnUnloaded;
+        
+        TopDropGrid.AddHandler(DragDrop.DragEnterEvent, Grid_DragEnter);
+        TopDropGrid.AddHandler(DragDrop.DragLeaveEvent, Grid_DragLeave);
+        TopDropGrid.AddHandler(DragDrop.DropEvent, Grid_Drop_Top);
+        
+        BottomDropGrid.AddHandler(DragDrop.DragEnterEvent, Grid_DragEnter);
+        BottomDropGrid.AddHandler(DragDrop.DragLeaveEvent, Grid_DragLeave);
+        BottomDropGrid.AddHandler(DragDrop.DropEvent, Grid_Drop_Bottom);
+        
+        middleDropGrid.AddHandler(DragDrop.DragEnterEvent, Grid_CenterEnter);
+        middleDropGrid.AddHandler(DragDrop.DragLeaveEvent, Grid_CenterLeave);
+        middleDropGrid.AddHandler(DragDrop.DropEvent, Grid_Drop_Center);
     }
 
     private void OnUnloaded(object? sender, RoutedEventArgs e)

+ 3 - 8
src/PixiEditor/Views/Layers/LayerControl.axaml

@@ -42,8 +42,8 @@
                 <RowDefinition Height="10" />
                 <RowDefinition Height="26" />
             </Grid.RowDefinitions>
-            <Grid DragDrop.AllowDrop="True" helpers:DragDropEvents.DragEnter="Grid_DragEnter"
-                  helpers:DragDropEvents.Drop="Grid_Drop_Top" helpers:DragDropEvents.DragLeave="Grid_DragLeave"
+            <Grid DragDrop.AllowDrop="True"
+                  Name="TopGrid"
                   Grid.Row="0" Grid.ColumnSpan="3" Background="Transparent" />
             <Grid Grid.Row="1" Margin="0,-17,0,0" VerticalAlignment="Center" DragDrop.AllowDrop="False">
                 <Grid.ColumnDefinitions>
@@ -154,10 +154,7 @@
                     </WrapPanel>
                 </StackPanel>
                 <Grid Margin="0, 0, 0, -2.5"
-                      helpers:DragDropEvents.DragEnter="Grid_DragEnter"
                       VerticalAlignment="Bottom"
-                      helpers:DragDropEvents.Drop="Grid_Drop_Below"
-                      helpers:DragDropEvents.DragLeave="Grid_DragLeave"
                       Height="10" Grid.Row="2" Grid.Column="0"
                       DragDrop.AllowDrop="True" Background="Transparent" Name="dropBelowGrid" />
                 <Grid Margin="0, 0, 0, -2.5"
@@ -168,9 +165,7 @@
 
                 <Grid Margin="0, 0, 0, -2.5" VerticalAlignment="Bottom"
                       Height="10" Grid.Row="2" Grid.Column="2"
-                      helpers:DragDropEvents.DragEnter="Grid_DragEnter"
-                      helpers:DragDropEvents.Drop="Grid_Drop_Bottom"
-                      helpers:DragDropEvents.DragLeave="Grid_DragLeave"
+                      Name="thirdDropGrid"
                       DragDrop.AllowDrop="True" Background="Transparent" />
             </Grid>
         </Grid>

+ 11 - 0
src/PixiEditor/Views/Layers/LayerControl.axaml.cs

@@ -5,6 +5,7 @@ using Avalonia.Input;
 using Avalonia.Interactivity;
 using Avalonia.Media;
 using CommunityToolkit.Mvvm.Input;
+using PixiEditor.Helpers.UI;
 using PixiEditor.Models.Controllers.InputDevice;
 using PixiEditor.Models.Handlers;
 using PixiEditor.Models.Layers;
@@ -86,6 +87,16 @@ internal partial class LayerControl : UserControl
         {
             highlightColor = value as IBrush;
         }
+     
+        TopGrid.AddHandler(DragDrop.DragEnterEvent, Grid_DragEnter);
+        TopGrid.AddHandler(DragDrop.DragLeaveEvent, Grid_DragLeave);
+        TopGrid.AddHandler(DragDrop.DropEvent, Grid_Drop_Top);
+        dropBelowGrid.AddHandler(DragDrop.DragEnterEvent, Grid_DragEnter);
+        dropBelowGrid.AddHandler(DragDrop.DragLeaveEvent, Grid_DragLeave);
+        dropBelowGrid.AddHandler(DragDrop.DropEvent, Grid_Drop_Below);
+        thirdDropGrid.AddHandler(DragDrop.DragEnterEvent, Grid_DragEnter);
+        thirdDropGrid.AddHandler(DragDrop.DragLeaveEvent, Grid_DragLeave);
+        thirdDropGrid.AddHandler(DragDrop.DropEvent, Grid_Drop_Bottom);
     }
     
     private void LayerControl_Unloaded(object? sender, RoutedEventArgs e)

+ 1 - 1
src/PixiEditor/Views/Layers/LayersManager.axaml

@@ -155,7 +155,7 @@
                     </DataTemplate>
                 </TreeView.DataTemplates>
             </TreeView>
-            <Border Name="dropBorder" ui1:DragDropEvents.DragEnter="Grid_DragEnter" ui1:DragDropEvents.DragLeave="Grid_DragLeave" DragDrop.AllowDrop="True" ui1:DragDropEvents.Drop="Grid_Drop" Background="Transparent" BorderThickness="0, 5, 0, 0" />
+            <Border Name="dropBorder" DragDrop.AllowDrop="True" Background="Transparent" BorderThickness="0, 5, 0, 0" />
         </DockPanel>
     </Grid>
 </UserControl>

+ 5 - 0
src/PixiEditor/Views/Layers/LayersManager.axaml.cs

@@ -4,6 +4,7 @@ using Avalonia.Interactivity;
 using Avalonia.Media;
 using Avalonia.Threading;
 using PixiEditor.Helpers;
+using PixiEditor.Helpers.UI;
 using PixiEditor.Models.Controllers;
 using PixiEditor.Models.Handlers;
 using PixiEditor.Models.Layers;
@@ -28,6 +29,10 @@ internal partial class LayersManager : UserControl
         {
             highlightColor = value as IBrush;
         }
+      
+        dropBorder.AddHandler(DragDrop.DragEnterEvent, Grid_DragEnter);
+        dropBorder.AddHandler(DragDrop.DragLeaveEvent, Grid_DragLeave);
+        dropBorder.AddHandler(DragDrop.DropEvent, Grid_Drop);
     }
 
     private void LayerControl_MouseDown(object sender, PointerPressedEventArgs e)