diff --git a/NotEnoughAV1Encodes/Controls/MainWindowTopButtons.xaml b/NotEnoughAV1Encodes/Controls/MainWindowTopButtons.xaml
new file mode 100644
index 0000000..b02a304
--- /dev/null
+++ b/NotEnoughAV1Encodes/Controls/MainWindowTopButtons.xaml
@@ -0,0 +1,46 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/NotEnoughAV1Encodes/Controls/MainWindowTopButtons.xaml.cs b/NotEnoughAV1Encodes/Controls/MainWindowTopButtons.xaml.cs
new file mode 100644
index 0000000..ec1b025
--- /dev/null
+++ b/NotEnoughAV1Encodes/Controls/MainWindowTopButtons.xaml.cs
@@ -0,0 +1,61 @@
+using System;
+using System.ComponentModel;
+using System.Runtime.CompilerServices;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Media;
+
+namespace NotEnoughAV1Encodes.Controls
+{
+ public partial class MainWindowTopButtons : UserControl
+ {
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ // Button Event Handlers
+ public event EventHandler OpenSource;
+ public event EventHandler SetDestination;
+ public event EventHandler AddToQueue;
+ public event EventHandler OpenSettings;
+ public event EventHandler Start;
+ public event EventHandler Cancel;
+
+ // Background for Buttons
+ public new SolidColorBrush Background { get; set; }
+
+ public MainWindowTopButtons()
+ {
+ InitializeComponent();
+ DataContext = this;
+ }
+
+ private void ButtonOpenSource_Click(object sender, RoutedEventArgs e)
+ {
+ OpenSource?.Invoke(this, e);
+ }
+
+ private void ButtonSetDestination_Click(object sender, RoutedEventArgs e)
+ {
+ SetDestination?.Invoke(this, e);
+ }
+
+ private void ButtonAddToQueue_Click(object sender, RoutedEventArgs e)
+ {
+ AddToQueue?.Invoke(this, e);
+ }
+
+ private void ButtonProgramSettings_Click(object sender, RoutedEventArgs e)
+ {
+ OpenSettings?.Invoke(this, e);
+ }
+
+ private void ButtonStartStop_Click(object sender, RoutedEventArgs e)
+ {
+ Start?.Invoke(this, e);
+ }
+
+ private void ButtonCancelEncode_Click(object sender, RoutedEventArgs e)
+ {
+ Cancel?.Invoke(this, e);
+ }
+ }
+}
\ No newline at end of file
diff --git a/NotEnoughAV1Encodes/MainWindow.xaml b/NotEnoughAV1Encodes/MainWindow.xaml
index 94236e3..3989198 100644
--- a/NotEnoughAV1Encodes/MainWindow.xaml
+++ b/NotEnoughAV1Encodes/MainWindow.xaml
@@ -6,6 +6,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:lex="http://wpflocalizeextension.codeplex.com"
xmlns:local="clr-namespace:NotEnoughAV1Encodes"
+ xmlns:neav1eControls="clr-namespace:NotEnoughAV1Encodes.Controls"
mc:Ignorable="d"
lex:LocalizeDictionary.DesignCulture="en"
lex:ResxLocalizationProvider.DefaultAssembly="NotEnoughAV1Encodes"
@@ -19,24 +20,19 @@
-
-
-
+
+
+
+
+
@@ -1355,22 +1351,6 @@
-
-
-
+
diff --git a/NotEnoughAV1Encodes/MainWindow.xaml.cs b/NotEnoughAV1Encodes/MainWindow.xaml.cs
index 76c6437..9fb6d92 100644
--- a/NotEnoughAV1Encodes/MainWindow.xaml.cs
+++ b/NotEnoughAV1Encodes/MainWindow.xaml.cs
@@ -196,14 +196,14 @@ private void ButtonCropPreviewBackward_Click(object sender, RoutedEventArgs e)
LoadCropPreview(index);
}
- private void ButtonCancelEncode_Click(object sender, RoutedEventArgs e)
+ private void ButtonCancelEncode_Click(object sender, EventArgs e)
{
if (cancellationTokenSource == null) return;
try
{
cancellationTokenSource.Cancel();
- ImageStartStop.Source = new BitmapImage(new Uri(@"/NotEnoughAV1Encodes;component/resources/img/start.png", UriKind.Relative));
- ButtonAddToQueue.IsEnabled = true;
+ TopButtonsControl.ImageStartStop.Source = new BitmapImage(new Uri(@"/NotEnoughAV1Encodes;component/resources/img/start.png", UriKind.Relative));
+ TopButtonsControl.ButtonAddToQueue.IsEnabled = true;
ButtonRemoveSelectedQueueItem.IsEnabled = true;
ButtonEditSelectedItem.IsEnabled = true;
ButtonClearQueue.IsEnabled = true;
@@ -219,7 +219,7 @@ private void ButtonCancelEncode_Click(object sender, RoutedEventArgs e)
catch { }
}
- private void ButtonProgramSettings_Click(object sender, RoutedEventArgs e)
+ private void ButtonProgramSettings_Click(object sender, EventArgs e)
{
Views.ProgramSettings programSettings = new(settingsDB);
programSettings.ShowDialog();
@@ -258,7 +258,7 @@ private void QueueMenuItemOpenOutputDir_Click(object sender, RoutedEventArgs e)
catch { }
}
- private void ButtonOpenSource_Click(object sender, RoutedEventArgs e)
+ private void ButtonOpenSource_Click(object sender, EventArgs e)
{
Views.OpenSource openSource = new(settingsDB.Theme);
openSource.ShowDialog();
@@ -488,7 +488,7 @@ private void SingleFileInput(string path)
CreateCropPreviewsOnLoad();
}
- private void ButtonSetDestination_Click(object sender, RoutedEventArgs e)
+ private void ButtonSetDestination_Click(object sender, EventArgs e)
{
string fileName = "";
@@ -532,7 +532,7 @@ private void ButtonSetDestination_Click(object sender, RoutedEventArgs e)
}
}
- private void ButtonStartStop_Click(object sender, RoutedEventArgs e)
+ private void ButtonStartStop_Click(object sender, EventArgs e)
{
if (ListBoxQueue.Items.Count == 0)
{
@@ -543,13 +543,13 @@ private void ButtonStartStop_Click(object sender, RoutedEventArgs e)
{
if (ProgramState is 0 or 2)
{
- ImageStartStop.Source = new BitmapImage(new Uri(@"/NotEnoughAV1Encodes;component/resources/img/pause.png", UriKind.Relative));
- LabelStartPauseButton.Content = LocalizedStrings.Instance["Pause"];
+ TopButtonsControl.ImageStartStop.Source = new BitmapImage(new Uri(@"/NotEnoughAV1Encodes;component/resources/img/pause.png", UriKind.Relative));
+ TopButtonsControl.LabelStartPauseButton.Content = LocalizedStrings.Instance["Pause"];
// Main Start
if (ProgramState is 0)
{
- ButtonAddToQueue.IsEnabled = false;
+ TopButtonsControl.ButtonAddToQueue.IsEnabled = false;
ButtonRemoveSelectedQueueItem.IsEnabled = false;
ButtonEditSelectedItem.IsEnabled = false;
ButtonClearQueue.IsEnabled = false;
@@ -572,8 +572,8 @@ private void ButtonStartStop_Click(object sender, RoutedEventArgs e)
else if (ProgramState is 1)
{
ProgramState = 2;
- ImageStartStop.Source = new BitmapImage(new Uri(@"/NotEnoughAV1Encodes;component/resources/img/resume.png", UriKind.Relative));
- LabelStartPauseButton.Content = LocalizedStrings.Instance["Resume"];
+ TopButtonsControl.ImageStartStop.Source = new BitmapImage(new Uri(@"/NotEnoughAV1Encodes;component/resources/img/resume.png", UriKind.Relative));
+ TopButtonsControl.LabelStartPauseButton.Content = LocalizedStrings.Instance["Resume"];
// Pause all PIDs
foreach (int pid in Global.LaunchedPIDs)
@@ -588,7 +588,7 @@ private void ButtonStartStop_Click(object sender, RoutedEventArgs e)
}
}
- private void ButtonAddToQueue_Click(object sender, RoutedEventArgs e)
+ private void ButtonAddToQueue_Click(object sender, EventArgs e)
{
PreAddToQueue();
}
@@ -1848,8 +1848,8 @@ private void AutoPauseResume()
// Pause
if (time < 40.0)
{
- Dispatcher.Invoke(() => ImageStartStop.Source = new BitmapImage(new Uri(@"/NotEnoughAV1Encodes;component/resources/img/resume.png", UriKind.Relative)));
- Dispatcher.Invoke(() => LabelStartPauseButton.Content = LocalizedStrings.Instance["Resume"]);
+ Dispatcher.Invoke(() => TopButtonsControl.ImageStartStop.Source = new BitmapImage(new Uri(@"/NotEnoughAV1Encodes;component/resources/img/resume.png", UriKind.Relative)));
+ Dispatcher.Invoke(() => TopButtonsControl.LabelStartPauseButton.Content = LocalizedStrings.Instance["Resume"]);
Dispatcher.Invoke(() => Title = "NEAV1E - " + LocalizedStrings.Instance["ToggleSwitchAutoPauseResume"] + " => Paused");
// Pause all PIDs
@@ -1867,8 +1867,8 @@ private void AutoPauseResume()
// Resume
if (time > 60.0)
{
- Dispatcher.Invoke(() => ImageStartStop.Source = new BitmapImage(new Uri(@"/NotEnoughAV1Encodes;component/resources/img/pause.png", UriKind.Relative)));
- Dispatcher.Invoke(() => LabelStartPauseButton.Content = LocalizedStrings.Instance["Pause"]);
+ Dispatcher.Invoke(() => TopButtonsControl.ImageStartStop.Source = new BitmapImage(new Uri(@"/NotEnoughAV1Encodes;component/resources/img/pause.png", UriKind.Relative)));
+ Dispatcher.Invoke(() => TopButtonsControl.LabelStartPauseButton.Content = LocalizedStrings.Instance["Pause"]);
Dispatcher.Invoke(() => Title = "NEAV1E - " + LocalizedStrings.Instance["ToggleSwitchAutoPauseResume"] + " => Encoding");
// Resume all PIDs
@@ -2882,9 +2882,9 @@ private async Task MainStartAsync(CancellationToken _cancelToken)
catch (OperationCanceledException) { }
ProgramState = 0;
- ImageStartStop.Source = new BitmapImage(new Uri(@"/NotEnoughAV1Encodes;component/resources/img/start.png", UriKind.Relative));
- LabelStartPauseButton.Content = LocalizedStrings.Instance["LabelStartPauseButton"];
- ButtonAddToQueue.IsEnabled = true;
+ TopButtonsControl.ImageStartStop.Source = new BitmapImage(new Uri(@"/NotEnoughAV1Encodes;component/resources/img/start.png", UriKind.Relative));
+ TopButtonsControl.LabelStartPauseButton.Content = LocalizedStrings.Instance["LabelStartPauseButton"];
+ TopButtonsControl.ButtonAddToQueue.IsEnabled = true;
ButtonRemoveSelectedQueueItem.IsEnabled = true;
ButtonEditSelectedItem.IsEnabled = true;
ButtonClearQueue.IsEnabled = true;
@@ -3036,5 +3036,6 @@ private void UpdateTaskbarProgress()
catch { }
}
#endregion
+
}
}