diff --git a/BFR/MainWindow.xaml b/BFR/MainWindow.xaml
index 001aa27..01bcc86 100644
--- a/BFR/MainWindow.xaml
+++ b/BFR/MainWindow.xaml
@@ -2,6 +2,7 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:ops="clr-namespace:BFR.Operations;assembly=BFR"
mc:Ignorable="d" MinWidth="720" MinHeight="480"
x:Class="BFR.MainWindow"
Title="BFR">
@@ -16,13 +17,13 @@
-
+
-
+
-
+
-
+
@@ -51,16 +52,16 @@
-
+
-
-
-
-
+
+
+
+
@@ -75,6 +76,7 @@
+
@@ -120,5 +122,41 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BFR/MainWindow.xaml.cs b/BFR/MainWindow.xaml.cs
index 325366b..7d9c3c4 100644
--- a/BFR/MainWindow.xaml.cs
+++ b/BFR/MainWindow.xaml.cs
@@ -25,8 +25,8 @@ namespace BFR
Filter();
}
- public void FilterChangedAny(object sender, KeyEventArgs e) => Filter();
- public void FilterChangedAny(object sender, RoutedEventArgs e) => Filter();
+ public void FilterChanged(object sender, KeyEventArgs e) => Filter();
+ public void FilterChanged(object sender, RoutedEventArgs e) => Filter();
public void Filter()
{
// Filter all files in the directory for those satisfying the given filters
@@ -37,6 +37,10 @@ namespace BFR
Preview();
}
+ public void PreviewChanged(object sender, KeyEventArgs e) => Preview(); // TextBox.KeyUp
+ public void PreviewChanged(object sender, RoutedEventArgs e) => Preview(); // CheckBox.Click
+ public void PreviewChanged(object sender, SelectionChangedEventArgs e) => Preview(); // ComboBox.SelectionChanged
+ public void PreviewChanged(object sender, NumericUpDownValueChangedEventArgs e) => Preview(); // NumericUpDown.ValueChanged
public void Preview()
{
// Reset all files to how they currently exist
@@ -51,6 +55,32 @@ namespace BFR
Files.ReplaceAll(new List(Files));
}
+ public void AddOperation()
+ {
+ Operations.Insert(
+ SelectedOperation >= 0 ? SelectedOperation + 1 : Operations.Count,
+ OperationTypes[SelectedOperationType].Create());
+ Preview();
+ }
+
+ public void RemoveOperation()
+ {
+ if (SelectedOperation >= 0)
+ Operations.RemoveAt(SelectedOperation);
+ else Operations.RemoveAt(0);
+ Preview();
+ }
+
+ public void MoveOperation(object sender, SpinEventArgs e)
+ {
+ 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);
+ Preview();
+ }
+
public MainWindow() => InitializeComponent();
private void InitializeComponent()
{
diff --git a/BFR/MainWindowUIProperties.cs b/BFR/MainWindowUIProperties.cs
index 8cb8e42..f381cf5 100644
--- a/BFR/MainWindowUIProperties.cs
+++ b/BFR/MainWindowUIProperties.cs
@@ -16,6 +16,13 @@ namespace BFR
public AvaloniaList AllFiles { get; } = new AvaloniaList();
public AvaloniaList Files { get; } = new AvaloniaList();
public AvaloniaList Operations { get; } = new AvaloniaList();
+ public int SelectedOperation { get; set; }
+
+ public int SelectedOperationType { get; set; } = 0;
+ public OperationType[] OperationTypes { get; } = new[]
+ {
+ OperationType.Make()
+ };
// Filters
public string FilterExtension { get; set; } = "";
diff --git a/BFR/Operations/Operation.cs b/BFR/Operations/Operation.cs
index 03fb0aa..b536ed1 100644
--- a/BFR/Operations/Operation.cs
+++ b/BFR/Operations/Operation.cs
@@ -1,6 +1,7 @@
using System;
-using System.Collections.Generic;
using System.Linq;
+using System.Collections.Generic;
+
using Avalonia;
using BFR.DataModels;
@@ -24,8 +25,9 @@ namespace BFR.Operations
var backup = files.Select(file => file.Path).ToList();
try
{
- ApplyToInternal(files); // Try to apply operation
- Error = ""; // If successul, remove any previous error
+ if(IsEnabled)
+ ApplyToInternal(files); // Try to apply operation
+ Error = ""; // If successul, remove any previous error
}
catch (OperationException e) { Error = e.Message; } // If expected, show user a concise and descriptive message
catch (Exception e) { Error = $"Unexpected {e}"; } // If not, hint with the exception thrown that this is unexpected behaviour