Skip to content

Commit fbdfdc8

Browse files
NeWbY100claude
andcommitted
fix: eliminate startup flash and remove batch SRS mode
- Fix white window flash by starting with Opacity=0, restoring window state in SourceInitialized, and setting Opacity=1 in ContentRendered - Add WindowBackground to MainWindow.xaml for dark first frame - Remove batch SRS creation mode (ViewModel, XAML, code-behind) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ccc4ec4 commit fbdfdc8

6 files changed

Lines changed: 18 additions & 301 deletions

File tree

ReScene.NET/App.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ protected override void OnStartup(StartupEventArgs e)
1616
MainWindow = new MainWindow
1717
{
1818
WindowStateService = windowState,
19+
Opacity = 0,
1920
DataContext = new MainWindowViewModel(
2021
new SrrCreationService(), new SrsCreationService(), new SrsReconstructionService(),
2122
new SampleRestorerService(tempDir), new BruteForceService(), new FileCompareService(), new FileDialogService(), new RecentFilesService(), tempDir, new SrrEditingService())

ReScene.NET/ViewModels/SrsCreatorViewModel.cs

Lines changed: 2 additions & 217 deletions
Original file line numberDiff line numberDiff line change
@@ -25,98 +25,6 @@ public SrsCreatorViewModel(ISrsCreationService srsService, IFileDialogService fi
2525
_srsService.Progress += OnProgress;
2626
}
2727

28-
#region Batch Mode
29-
30-
/// <summary>
31-
/// Gets or sets whether batch mode is enabled.
32-
/// </summary>
33-
[ObservableProperty]
34-
[NotifyCanExecuteChangedFor(nameof(CreateSrsCommand))]
35-
[NotifyPropertyChangedFor(nameof(ShowIsoSelection))]
36-
private bool _isBatchMode;
37-
38-
/// <summary>
39-
/// Gets or sets the currently selected batch file item.
40-
/// </summary>
41-
[ObservableProperty]
42-
private BatchSrsItem? _selectedBatchFile;
43-
44-
/// <summary>
45-
/// Gets the collection of files to process in batch mode.
46-
/// </summary>
47-
public ObservableCollection<BatchSrsItem> BatchFiles { get; } = [];
48-
49-
/// <summary>
50-
/// Represents a single file entry in the batch SRS creation list.
51-
/// </summary>
52-
public partial class BatchSrsItem : ObservableObject
53-
{
54-
[ObservableProperty]
55-
private string _filePath = string.Empty;
56-
57-
[ObservableProperty]
58-
private string _outputPath = string.Empty;
59-
60-
[ObservableProperty]
61-
private string _status = "Pending";
62-
63-
public string FileName => Path.GetFileName(FilePath);
64-
}
65-
66-
[RelayCommand]
67-
private async Task AddBatchFilesAsync()
68-
{
69-
IReadOnlyList<string> paths = await _fileDialog.OpenFilesAsync(
70-
"Select Sample Files", FileDialogFilters.MediaSamples);
71-
72-
AddBatchFilePaths(paths);
73-
}
74-
75-
/// <summary>
76-
/// Adds the specified file paths to the batch list.
77-
/// Called from both the command and drag-drop handler.
78-
/// </summary>
79-
public void AddBatchFilePaths(IReadOnlyList<string> paths)
80-
{
81-
foreach (string path in paths)
82-
{
83-
if (BatchFiles.Any(f => f.FilePath.Equals(path, StringComparison.OrdinalIgnoreCase)))
84-
{
85-
continue;
86-
}
87-
88-
string dir = Path.GetDirectoryName(path) ?? ".";
89-
string name = Path.GetFileNameWithoutExtension(path);
90-
91-
BatchFiles.Add(new BatchSrsItem
92-
{
93-
FilePath = path,
94-
OutputPath = Path.Combine(dir, name + ".srs")
95-
});
96-
}
97-
98-
CreateSrsCommand.NotifyCanExecuteChanged();
99-
}
100-
101-
[RelayCommand]
102-
private void RemoveBatchFile()
103-
{
104-
if (SelectedBatchFile is not null)
105-
{
106-
BatchFiles.Remove(SelectedBatchFile);
107-
CreateSrsCommand.NotifyCanExecuteChanged();
108-
}
109-
}
110-
111-
[RelayCommand]
112-
private void ClearBatchFiles()
113-
{
114-
BatchFiles.Clear();
115-
CreateSrsCommand.NotifyCanExecuteChanged();
116-
}
117-
118-
#endregion
119-
12028
// Input
12129
[ObservableProperty]
12230
[NotifyCanExecuteChangedFor(nameof(CreateSrsCommand))]
@@ -138,9 +46,8 @@ private void ClearBatchFiles()
13846

13947
/// <summary>
14048
/// Gets whether the ISO file selection combo should be visible.
141-
/// Only shown when an ISO source is loaded and batch mode is off.
14249
/// </summary>
143-
public bool ShowIsoSelection => IsIsoSource && !IsBatchMode;
50+
public bool ShowIsoSelection => IsIsoSource;
14451

14552
// ISO progress (for modal window)
14653
[ObservableProperty]
@@ -259,17 +166,7 @@ private async Task BrowseOutputAsync()
259166

260167
private bool CanCreateSrs()
261168
{
262-
if (IsCreating)
263-
{
264-
return false;
265-
}
266-
267-
if (IsBatchMode)
268-
{
269-
return BatchFiles.Count > 0;
270-
}
271-
272-
if (string.IsNullOrWhiteSpace(InputPath) || string.IsNullOrWhiteSpace(OutputPath))
169+
if (IsCreating || string.IsNullOrWhiteSpace(InputPath) || string.IsNullOrWhiteSpace(OutputPath))
273170
{
274171
return false;
275172
}
@@ -284,17 +181,6 @@ private bool CanCreateSrs()
284181

285182
[RelayCommand(CanExecute = nameof(CanCreateSrs))]
286183
private async Task CreateSrsAsync()
287-
{
288-
if (IsBatchMode)
289-
{
290-
await CreateBatchSrsAsync();
291-
return;
292-
}
293-
294-
await CreateSingleSrsAsync();
295-
}
296-
297-
private async Task CreateSingleSrsAsync()
298184
{
299185
IsCreating = true;
300186
ShowProgress = true;
@@ -408,107 +294,6 @@ await IsoMediaExtractor.ExtractFileAsync(
408294
}
409295
}
410296

411-
private async Task CreateBatchSrsAsync()
412-
{
413-
IsCreating = true;
414-
ShowProgress = true;
415-
ProgressPercent = 0;
416-
ProgressMessage = "Starting batch...";
417-
LogEntries.Clear();
418-
419-
_cts = new CancellationTokenSource();
420-
421-
int total = BatchFiles.Count;
422-
int completed = 0;
423-
int succeeded = 0;
424-
int failed = 0;
425-
426-
try
427-
{
428-
var options = new SrsCreationOptions
429-
{
430-
AppName = string.IsNullOrWhiteSpace(AppName) ? FormatUtilities.GetDefaultAppName() : AppName
431-
};
432-
433-
Log($"Starting batch SRS creation ({total} files)...");
434-
435-
foreach (BatchSrsItem item in BatchFiles)
436-
{
437-
_cts.Token.ThrowIfCancellationRequested();
438-
439-
item.Status = "Creating...";
440-
ProgressMessage = $"Processing {completed + 1} of {total}: {item.FileName}";
441-
Log($"Processing: {item.FileName}");
442-
443-
try
444-
{
445-
SrsCreationResult result = await _srsService.CreateAsync(
446-
item.OutputPath, item.FilePath, options, _cts.Token);
447-
448-
if (result.Success)
449-
{
450-
item.Status = "Done";
451-
succeeded++;
452-
Log($" OK — {result.ContainerType}, {result.TrackCount} track(s), CRC {result.SampleCrc32:X8}");
453-
}
454-
else
455-
{
456-
item.Status = $"Error: {result.ErrorMessage}";
457-
failed++;
458-
Log($" ERROR: {result.ErrorMessage}");
459-
}
460-
461-
foreach (string warning in result.Warnings)
462-
{
463-
Log($" WARNING: {warning}");
464-
}
465-
}
466-
catch (OperationCanceledException)
467-
{
468-
throw;
469-
}
470-
catch (Exception ex)
471-
{
472-
item.Status = $"Error: {ex.Message}";
473-
failed++;
474-
Log($" ERROR: {ex.Message}");
475-
}
476-
477-
completed++;
478-
ProgressPercent = (int)((double)completed / total * 100);
479-
}
480-
481-
ProgressPercent = 100;
482-
ProgressMessage = $"Batch complete — {succeeded} succeeded, {failed} failed.";
483-
Log($"Batch complete: {succeeded} succeeded, {failed} failed out of {total}.");
484-
}
485-
catch (OperationCanceledException)
486-
{
487-
ProgressMessage = "Cancelled.";
488-
Log("Cancelled.");
489-
490-
// Mark remaining items as cancelled
491-
foreach (BatchSrsItem item in BatchFiles)
492-
{
493-
if (item.Status == "Pending" || item.Status == "Creating...")
494-
{
495-
item.Status = "Cancelled";
496-
}
497-
}
498-
}
499-
catch (Exception ex)
500-
{
501-
ProgressMessage = "Error.";
502-
Log($"ERROR: {ex.Message}");
503-
}
504-
finally
505-
{
506-
IsCreating = false;
507-
_cts?.Dispose();
508-
_cts = null;
509-
}
510-
}
511-
512297
[RelayCommand]
513298
private void CancelCreation()
514299
{

ReScene.NET/Views/MainWindow.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
x:Class="ReScene.NET.Views.MainWindow"
66
Title="{Binding WindowTitle}"
77
MinWidth="700" MinHeight="450"
8+
Background="{DynamicResource WindowBackground}"
89
FontSize="{DynamicResource FontSizeBody}"
910
Icon="/Resources/app_icon.png"
1011
AllowDrop="True"

ReScene.NET/Views/MainWindow.xaml.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,22 @@ public partial class MainWindow : Window
1717
public MainWindow()
1818
{
1919
InitializeComponent();
20-
SourceInitialized += (_, _) => DarkTitleBar.Enable(this);
20+
SourceInitialized += OnSourceInitialized;
2121

2222
Drop += OnDrop;
2323
DragOver += OnDragOver;
2424
}
2525

26+
private void OnSourceInitialized(object? _, EventArgs e)
27+
{
28+
DarkTitleBar.Enable(this);
29+
RestoreWindowState();
30+
}
31+
2632
protected override void OnContentRendered(EventArgs e)
2733
{
2834
base.OnContentRendered(e);
29-
RestoreWindowState();
35+
Opacity = 1;
3036

3137
// Handle command-line arguments
3238
var args = Environment.GetCommandLineArgs();

ReScene.NET/Views/SrsCreatorView.xaml

Lines changed: 6 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,9 @@
1111
Foreground="{DynamicResource ForegroundSecondary}" FontSize="{DynamicResource FontSizeCaption}"
1212
TextWrapping="Wrap" Margin="0,0,0,6" />
1313

14-
<!-- ── Batch Mode Toggle ─────────────────────────────────── -->
15-
<CheckBox DockPanel.Dock="Top"
16-
Content="Batch Mode"
17-
IsChecked="{Binding IsBatchMode}"
18-
Margin="0,0,0,4" />
19-
20-
<!-- ── Single-file input (hidden in batch mode) ──────────── -->
21-
<TextBlock DockPanel.Dock="Top" Text="Sample File" FontWeight="SemiBold" Margin="0,0,0,2"
22-
Visibility="{Binding IsBatchMode, Converter={StaticResource InverseBoolToVisibility}}" />
23-
<DockPanel DockPanel.Dock="Top"
24-
Visibility="{Binding IsBatchMode, Converter={StaticResource InverseBoolToVisibility}}">
14+
<!-- ── Sample File ─────────────────────────────────────────── -->
15+
<TextBlock DockPanel.Dock="Top" Text="Sample File" FontWeight="SemiBold" Margin="0,0,0,2" />
16+
<DockPanel DockPanel.Dock="Top">
2517
<Button DockPanel.Dock="Right" Content="Browse"
2618
Command="{Binding BrowseInputCommand}"
2719
Style="{StaticResource GhostButton}"
@@ -41,51 +33,12 @@
4133
FontSize="{DynamicResource FontSizeCaption}" />
4234
</DockPanel>
4335

44-
<!-- ── Batch file list (visible in batch mode) ───────────── -->
45-
<DockPanel DockPanel.Dock="Top"
46-
Visibility="{Binding IsBatchMode, Converter={StaticResource BoolToVisibility}}"
47-
MaxHeight="250">
48-
<StackPanel DockPanel.Dock="Bottom" Orientation="Horizontal" Margin="0,4,0,0">
49-
<Button Content="Add Files..."
50-
Command="{Binding AddBatchFilesCommand}"
51-
Style="{StaticResource GhostButton}"
52-
MinWidth="75" Margin="0,0,4,0" />
53-
<Button Content="Remove"
54-
Command="{Binding RemoveBatchFileCommand}"
55-
Style="{StaticResource GhostButton}"
56-
MinWidth="75" Margin="0,0,4,0" />
57-
<Button Content="Clear"
58-
Command="{Binding ClearBatchFilesCommand}"
59-
Style="{StaticResource GhostButton}"
60-
MinWidth="75" />
61-
</StackPanel>
62-
<DataGrid x:Name="BatchDataGrid"
63-
ItemsSource="{Binding BatchFiles}"
64-
SelectedItem="{Binding SelectedBatchFile}"
65-
AutoGenerateColumns="False"
66-
IsReadOnly="True"
67-
SelectionMode="Single"
68-
BorderThickness="1"
69-
BorderBrush="{DynamicResource BorderSeparator}"
70-
AllowDrop="True"
71-
PreviewDragOver="OnBatchDragOver"
72-
PreviewDrop="OnBatchDrop">
73-
<DataGrid.Columns>
74-
<DataGridTextColumn Header="File Name" Binding="{Binding FileName}" Width="*" />
75-
<DataGridTextColumn Header="Output Path" Binding="{Binding OutputPath}" Width="2*" />
76-
<DataGridTextColumn Header="Status" Binding="{Binding Status}" Width="100" />
77-
</DataGrid.Columns>
78-
</DataGrid>
79-
</DockPanel>
80-
8136
<!-- separator -->
8237
<Border DockPanel.Dock="Top" Height="1" Background="{DynamicResource BorderSeparator}" Margin="0,4" />
8338

84-
<!-- ── Output (hidden in batch mode) ─────────────────────── -->
85-
<TextBlock DockPanel.Dock="Top" Text="Output" FontWeight="SemiBold" Margin="0,0,0,2"
86-
Visibility="{Binding IsBatchMode, Converter={StaticResource InverseBoolToVisibility}}" />
87-
<DockPanel DockPanel.Dock="Top"
88-
Visibility="{Binding IsBatchMode, Converter={StaticResource InverseBoolToVisibility}}">
39+
<!-- ── Output ────────────────────────────────────────────── -->
40+
<TextBlock DockPanel.Dock="Top" Text="Output" FontWeight="SemiBold" Margin="0,0,0,2" />
41+
<DockPanel DockPanel.Dock="Top">
8942
<Button DockPanel.Dock="Right" Content="Browse"
9043
Command="{Binding BrowseOutputCommand}"
9144
Style="{StaticResource GhostButton}"

0 commit comments

Comments
 (0)