@@ -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 {
0 commit comments