Polish AmiReel UI and improve render workflow
This commit is contained in:
@@ -16,6 +16,7 @@ public partial class MainWindow : Window
|
||||
private readonly ObservableCollection<string> _inputs = [];
|
||||
private readonly AppSettings _loadedSettings;
|
||||
private CancellationTokenSource? _renderCancellation;
|
||||
private string? _lastRenderedFile;
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
@@ -26,6 +27,7 @@ public partial class MainWindow : Window
|
||||
EndCardBox.Text = _loadedSettings.EndCardPath;
|
||||
FfmpegPathBox.Text = _loadedSettings.FfmpegPath;
|
||||
FfprobePathBox.Text = _loadedSettings.FfprobePath;
|
||||
PreviewPlayerPathBox.Text = _loadedSettings.PreviewPlayerPath;
|
||||
TrimBox.Text = _loadedSettings.TrimStart;
|
||||
FadeBox.Text = _loadedSettings.FadeSeconds;
|
||||
HoldBox.Text = _loadedSettings.EndCardHoldSeconds;
|
||||
@@ -70,6 +72,12 @@ public partial class MainWindow : Window
|
||||
if (dialog.ShowDialog(this) == true) FfprobePathBox.Text = dialog.FileName;
|
||||
}
|
||||
|
||||
private void BrowsePreviewPlayer_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
OpenFileDialog dialog = new() { Filter = "Video player (*.exe)|*.exe|All files|*.*" };
|
||||
if (dialog.ShowDialog(this) == true) PreviewPlayerPathBox.Text = dialog.FileName;
|
||||
}
|
||||
|
||||
private void OpenSettings_Click(object sender, RoutedEventArgs e) => SettingsOverlay.Visibility = Visibility.Visible;
|
||||
|
||||
private void CloseSettings_Click(object sender, RoutedEventArgs e)
|
||||
@@ -89,7 +97,9 @@ public partial class MainWindow : Window
|
||||
_renderCancellation = new CancellationTokenSource();
|
||||
Progress<RenderProgress> progress = new(UpdateProgress);
|
||||
await new RenderPipeline().RenderAsync(settings, progress, AppendLog, _renderCancellation.Token);
|
||||
_lastRenderedFile = Path.Combine(settings.OutputDirectory, settings.OutputName + "_final.mp4");
|
||||
OpenOutputButton.IsEnabled = true;
|
||||
PreviewRenderedButton.IsEnabled = File.Exists(_lastRenderedFile);
|
||||
MessageBox.Show(this, "The AmiReel render completed successfully.", "Render complete",
|
||||
MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
@@ -140,6 +150,27 @@ public partial class MainWindow : Window
|
||||
Process.Start(new ProcessStartInfo("explorer.exe", OutputFolderBox.Text) { UseShellExecute = true });
|
||||
}
|
||||
|
||||
private void PreviewSource_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (InputList.SelectedItem is string path)
|
||||
OpenPreview(path);
|
||||
}
|
||||
|
||||
private void PreviewRendered_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_lastRenderedFile) && File.Exists(_lastRenderedFile))
|
||||
OpenPreview(_lastRenderedFile);
|
||||
}
|
||||
|
||||
private void InputList_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
=> PreviewSourceButton.IsEnabled = InputList.SelectedItem is string;
|
||||
|
||||
private void InputList_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
if (InputList.SelectedItem is string path)
|
||||
OpenPreview(path);
|
||||
}
|
||||
|
||||
private void SetRendering(bool rendering)
|
||||
{
|
||||
RenderButton.IsEnabled = !rendering;
|
||||
@@ -187,6 +218,7 @@ public partial class MainWindow : Window
|
||||
EndCardBox.Text.Trim(),
|
||||
FfmpegPathBox.Text.Trim(),
|
||||
FfprobePathBox.Text.Trim(),
|
||||
PreviewPlayerPathBox.Text.Trim(),
|
||||
SelectedTheme(),
|
||||
SelectedEncoder(),
|
||||
TrimBox.Text.Trim(),
|
||||
@@ -195,6 +227,42 @@ public partial class MainWindow : Window
|
||||
IntervalBox.Text.Trim()));
|
||||
}
|
||||
|
||||
private void OpenPreview(string mediaPath)
|
||||
{
|
||||
if (!File.Exists(mediaPath))
|
||||
{
|
||||
MessageBox.Show(this, "The selected media file was not found.", "Preview unavailable",
|
||||
MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
string playerPath = PreviewPlayerPathBox.Text.Trim();
|
||||
|
||||
try
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(playerPath))
|
||||
{
|
||||
if (!File.Exists(playerPath))
|
||||
throw new FileNotFoundException("Configured preview player was not found.", playerPath);
|
||||
|
||||
ProcessStartInfo customPlayer = new()
|
||||
{
|
||||
FileName = playerPath,
|
||||
UseShellExecute = false
|
||||
};
|
||||
customPlayer.ArgumentList.Add(mediaPath);
|
||||
Process.Start(customPlayer);
|
||||
return;
|
||||
}
|
||||
|
||||
Process.Start(new ProcessStartInfo(mediaPath) { UseShellExecute = true });
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
MessageBox.Show(this, exception.Message, "Preview failed", MessageBoxButton.OK, MessageBoxImage.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private string SelectedTheme() => ((ComboBoxItem)ThemeBox.SelectedItem).Tag!.ToString()!;
|
||||
private string SelectedEncoder() => ((ComboBoxItem)EncoderBox.SelectedItem).Tag!.ToString()!;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user