diff --git a/BFR/BFR.csproj b/BFR/BFR.csproj
index 5ca4a61..a028414 100644
--- a/BFR/BFR.csproj
+++ b/BFR/BFR.csproj
@@ -12,7 +12,7 @@
-
-
+
+
diff --git a/BFR/MainWindow.xaml b/BFR/MainWindow.xaml
index 9b17ff9..311e748 100644
--- a/BFR/MainWindow.xaml
+++ b/BFR/MainWindow.xaml
@@ -35,17 +35,17 @@
-
+
-
+
-
+
-
+
@@ -55,14 +55,11 @@
-
+
-
-
-
-
-
-
+
+
+
@@ -127,20 +124,47 @@
+
+
+
-
-
+
+
+
+
@@ -153,17 +177,17 @@
-
+
-
+
-
+
@@ -192,10 +216,10 @@
-
+
-
+
@@ -226,10 +250,10 @@
-
+
-
+
@@ -256,10 +280,10 @@
-
+
-
+
@@ -276,10 +300,10 @@
-
+
-
+
@@ -294,7 +318,7 @@
-
+
diff --git a/BFR/MainWindow.xaml.cs b/BFR/MainWindow.xaml.cs
index 05f5ee3..94a03c9 100644
--- a/BFR/MainWindow.xaml.cs
+++ b/BFR/MainWindow.xaml.cs
@@ -11,6 +11,10 @@ using Avalonia.Markup.Xaml;
using BFR.Helpers;
using BFR.DataModels;
+using Avalonia.Interactivity;
+using Avalonia.Input;
+using Avalonia.LogicalTree;
+using Avalonia.VisualTree;
namespace BFR
{
@@ -80,23 +84,30 @@ namespace BFR
Preview();
}
- public void RemoveOperation()
+ private ListBox OperationsListBox;
+ private ListBoxItem DragItem;
+
+ public void DeleteOperation(object sender, PointerReleasedEventArgs e)
{
- if (SelectedOperation >= 0)
- Operations.RemoveAt(SelectedOperation);
- else Operations.RemoveAt(0);
+ var hoveredItem = (ListBoxItem)OperationsListBox.GetLogicalChildren().FirstOrDefault(x => this.GetVisualsAt(e.GetPosition(this)).Contains(((IVisual)x).GetVisualChildren().First()));
+ if(hoveredItem != null) Operations.RemoveAt(OperationsListBox.GetLogicalChildren().ToList().IndexOf(hoveredItem));
Preview();
}
- public void MoveOperation(object sender, SpinEventArgs e)
+ public void StartMoveOperation(object sender, PointerPressedEventArgs e) =>
+ DragItem = OperationsListBox.GetLogicalChildren().Cast().Single(x => x.IsPointerOver);
+
+ public void EndMoveOperation(object sender, PointerReleasedEventArgs e)
{
- HandleEvents = false;
- if (Operations.Count > 1)
- if (e.Direction == SpinDirection.Increase && SelectedOperation > 0)
- Operations.Move(SelectedOperation, SelectedOperation - 1);
- else if (e.Direction == SpinDirection.Decrease && SelectedOperation < Operations.Count - 1)
- Operations.Move(SelectedOperation, SelectedOperation + 1);
- HandleEvents = true;
+ var hoveredItem = (ListBoxItem)OperationsListBox.GetLogicalChildren().FirstOrDefault(x => this.GetVisualsAt(e.GetPosition(this)).Contains(((IVisual)x).GetVisualChildren().First()));
+ if (DragItem == null ||
+ hoveredItem == null ||
+ DragItem == hoveredItem)
+ return;
+ Operations.Move(
+ OperationsListBox.GetLogicalChildren().ToList().IndexOf(DragItem),
+ OperationsListBox.GetLogicalChildren().ToList().IndexOf(hoveredItem));
+ DragItem = null;
Preview();
}
@@ -128,6 +139,7 @@ namespace BFR
DataContext = this;
OpenDirectory(Environment.OSVersion.Platform == PlatformID.Win32NT ? @"C:\Users" : @"\home");
HandleEvents = true;
+ OperationsListBox = this.Find("OperationsListBox");
}
}
}
\ No newline at end of file