55using Common . Logging ;
66using Definitions . ObjectModels ;
77using Definitions . ObjectModels . Types ;
8- using DynamicData ;
98using ReactiveUI ;
109using ReactiveUI . Fody . Helpers ;
1110using SixLabors . ImageSharp ;
@@ -62,9 +61,6 @@ public class ImageTableViewModel : ReactiveObject, IExtraContentViewModel
6261 [ Reactive ]
6362 public SelectionModel < ImageViewModel > SelectionModel { get ; set ; }
6463
65- [ Reactive ]
66- public IList < ImageViewModel > SelectedImages { get ; set ; }
67-
6864 [ Reactive ]
6965 public ImageViewModel ? SelectedImage { get ; set ; }
7066
@@ -84,8 +80,8 @@ public ImageTableViewModel(IList<GraphicsElement> graphicsElements, IImageTableN
8480 var index = 0 ;
8581 foreach ( var ge in graphicsElements )
8682 {
87- _ = imageNameProvider . TryGetImageName ( index , out var imageName ) ;
88- ImageViewModels . Add ( new ImageViewModel ( index , imageName , ge , paletteMap ) ) ;
83+ var success = imageNameProvider . TryGetImageName ( index , out var imageName ) ;
84+ ImageViewModels . Add ( new ImageViewModel ( index , success ? imageName ! : "failed to get image name" , ge , paletteMap ) ) ;
8985 index ++ ;
9086 }
9187
@@ -119,10 +115,7 @@ public ImageTableViewModel(IList<GraphicsElement> graphicsElements, IImageTableN
119115 ImportImagesCommand = ReactiveCommand . CreateFromTask ( ImportImages ) ;
120116 ExportImagesCommand = ReactiveCommand . CreateFromTask ( ExportImages ) ;
121117 ReplaceImageCommand = ReactiveCommand . CreateFromTask ( ReplaceImage ) ;
122- CropAllImagesCommand = ReactiveCommand . Create ( ( ) =>
123- {
124- CropAllImages ( SelectedPrimarySwatch , SelectedSecondarySwatch ) ;
125- } ) ;
118+ CropAllImagesCommand = ReactiveCommand . Create ( CropAllImages ) ;
126119
127120 ZeroOffsetAllImagesCommand = ReactiveCommand . Create ( ( ) =>
128121 {
@@ -164,19 +157,16 @@ void SelectionChanged(object sender, SelectionModelSelectionChangedEventArgs e)
164157 {
165158 return ;
166159 }
167-
168- // ... handle selection changed
169- SelectedImages = [ .. sm . SelectedItems . Cast < ImageViewModel > ( ) ] ;
170160 }
171161
172162 void AnimationTimer_Tick ( object ? sender , EventArgs e )
173163 {
174- if ( SelectionModel == null || SelectedImages == null || SelectedImages . Count == 0 || SelectionModel . SelectedIndexes . Count == 0 )
164+ if ( SelectionModel == null || SelectionModel . SelectedIndexes . Count == 0 )
175165 {
176166 return ;
177167 }
178168
179- if ( currentFrameIndex >= SelectedImages . Count )
169+ if ( currentFrameIndex >= SelectionModel . SelectedIndexes . Count )
180170 {
181171 currentFrameIndex = 0 ;
182172 }
@@ -185,7 +175,7 @@ void AnimationTimer_Tick(object? sender, EventArgs e)
185175 SelectedImageIndex = SelectionModel . SelectedIndexes [ currentFrameIndex ] ; // disabling this also makes the memory leaks stop
186176
187177 // Move to the next frame, looping back to the beginning if necessary
188- currentFrameIndex = ( currentFrameIndex + 1 ) % SelectedImages . Count ;
178+ currentFrameIndex = ( currentFrameIndex + 1 ) % SelectionModel . SelectedIndexes . Count ;
189179 }
190180
191181 public void ClearSelectionModel ( )
@@ -207,7 +197,7 @@ public async Task ImportImages()
207197 }
208198
209199 var dirPath = dir . Path . LocalPath ;
210- await ImportImages ( dirPath , SelectedPrimarySwatch , SelectedSecondarySwatch ) ;
200+ await ImportImages ( dirPath ) ;
211201 }
212202
213203 animationTimer . Start ( ) ;
@@ -257,7 +247,7 @@ public void RecolourImages(ColourRemapSwatch primary, ColourRemapSwatch secondar
257247 }
258248 }
259249
260- public void CropAllImages ( ColourRemapSwatch primary , ColourRemapSwatch secondary )
250+ public void CropAllImages ( )
261251 {
262252 foreach ( var ivm in ImageViewModels )
263253 {
@@ -276,7 +266,7 @@ public static string TrimZeroes(string str)
276266 return result . Length == 0 ? "0" : result ;
277267 }
278268
279- public async Task ImportImages ( string directory , ColourRemapSwatch primary , ColourRemapSwatch secondary )
269+ public async Task ImportImages ( string directory )
280270 {
281271 if ( string . IsNullOrEmpty ( directory ) )
282272 {
0 commit comments