TASK 18: manual rename modal for finished recordings

RenameRecordingDialog (themed, mirrors GoLiveWindow chrome): pre-fills the auto stem,
Enter/OK saves, Esc/Cancel keeps the auto name, strips stray .mp4, rejects invalid
filename chars. FinalizeRecordingAsync shows it before UniquePath rename. Naming logic
still covered by RecordingFileTests; UI shell is pure. verify.sh gate: 0 warnings,
244/246 (2 known).
This commit is contained in:
2026-08-29 09:24:13 -07:00
parent be529a46d7
commit 46f4696db6
5 changed files with 116 additions and 6 deletions
+63
View File
@@ -0,0 +1,63 @@
using System.IO;
using System.Windows;
using System.Windows.Input;
namespace ytLive;
/// <summary>Modal that lets the creator rename an auto-named recording before it is
/// finalized. Returns the chosen file stem (no extension) via <see cref="ResultFileName"/>,
/// or <c>null</c> on Cancel / keep-auto-name.</summary>
public partial class RenameRecordingDialog : Window
{
private readonly string _autoStem;
/// <summary>Stem (no extension) the creator chose, or <c>null</c> to keep auto-name.</summary>
public string? ResultFileName { get; private set; }
public RenameRecordingDialog(string autoStem)
{
InitializeComponent();
_autoStem = autoStem;
NameBox.Text = autoStem;
Loaded += (_, _) => { NameBox.Focus(); NameBox.SelectAll(); };
NameBox.KeyDown += OnKeyDown;
}
private void OnKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter) { Save(); e.Handled = true; }
else if (e.Key == Key.Escape) { DialogResult = false; e.Handled = true; }
}
private void Cancel_Click(object sender, RoutedEventArgs e) => DialogResult = false;
private void Save_Click(object sender, RoutedEventArgs e) => Save();
private void Save()
{
var name = NameBox.Text?.Trim();
if (string.IsNullOrEmpty(name))
{
// Empty = keep the auto name.
ResultFileName = null;
DialogResult = true;
return;
}
// Strip any accidental ".mp4" so we return a clean stem.
if (name.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase))
name = Path.GetFileNameWithoutExtension(name);
// Reject characters that are illegal in Windows file names.
if (name.IndexOfAny(Path.GetInvalidFileNameChars()) >= 0)
{
MessageBox.Show(this, "That name contains characters not allowed in file names.",
"Invalid name", MessageBoxButton.OK, MessageBoxImage.Warning);
NameBox.Focus();
return;
}
ResultFileName = name;
DialogResult = true;
}
}