5
5
using Common . Logging ;
6
6
using Definitions . ObjectModels ;
7
7
using Definitions . ObjectModels . Types ;
8
- using DynamicData ;
9
8
using ReactiveUI ;
10
9
using ReactiveUI . Fody . Helpers ;
11
10
using SixLabors . ImageSharp ;
@@ -62,9 +61,6 @@ public class ImageTableViewModel : ReactiveObject, IExtraContentViewModel
62
61
[ Reactive ]
63
62
public SelectionModel < ImageViewModel > SelectionModel { get ; set ; }
64
63
65
- [ Reactive ]
66
- public IList < ImageViewModel > SelectedImages { get ; set ; }
67
-
68
64
[ Reactive ]
69
65
public ImageViewModel ? SelectedImage { get ; set ; }
70
66
@@ -84,8 +80,8 @@ public ImageTableViewModel(IList<GraphicsElement> graphicsElements, IImageTableN
84
80
var index = 0 ;
85
81
foreach ( var ge in graphicsElements )
86
82
{
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 ) ) ;
89
85
index ++ ;
90
86
}
91
87
@@ -119,10 +115,7 @@ public ImageTableViewModel(IList<GraphicsElement> graphicsElements, IImageTableN
119
115
ImportImagesCommand = ReactiveCommand . CreateFromTask ( ImportImages ) ;
120
116
ExportImagesCommand = ReactiveCommand . CreateFromTask ( ExportImages ) ;
121
117
ReplaceImageCommand = ReactiveCommand . CreateFromTask ( ReplaceImage ) ;
122
- CropAllImagesCommand = ReactiveCommand . Create ( ( ) =>
123
- {
124
- CropAllImages ( SelectedPrimarySwatch , SelectedSecondarySwatch ) ;
125
- } ) ;
118
+ CropAllImagesCommand = ReactiveCommand . Create ( CropAllImages ) ;
126
119
127
120
ZeroOffsetAllImagesCommand = ReactiveCommand . Create ( ( ) =>
128
121
{
@@ -164,19 +157,16 @@ void SelectionChanged(object sender, SelectionModelSelectionChangedEventArgs e)
164
157
{
165
158
return ;
166
159
}
167
-
168
- // ... handle selection changed
169
- SelectedImages = [ .. sm . SelectedItems . Cast < ImageViewModel > ( ) ] ;
170
160
}
171
161
172
162
void AnimationTimer_Tick ( object ? sender , EventArgs e )
173
163
{
174
- if ( SelectionModel == null || SelectedImages == null || SelectedImages . Count == 0 || SelectionModel . SelectedIndexes . Count == 0 )
164
+ if ( SelectionModel == null || SelectionModel . SelectedIndexes . Count == 0 )
175
165
{
176
166
return ;
177
167
}
178
168
179
- if ( currentFrameIndex >= SelectedImages . Count )
169
+ if ( currentFrameIndex >= SelectionModel . SelectedIndexes . Count )
180
170
{
181
171
currentFrameIndex = 0 ;
182
172
}
@@ -185,7 +175,7 @@ void AnimationTimer_Tick(object? sender, EventArgs e)
185
175
SelectedImageIndex = SelectionModel . SelectedIndexes [ currentFrameIndex ] ; // disabling this also makes the memory leaks stop
186
176
187
177
// 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 ;
189
179
}
190
180
191
181
public void ClearSelectionModel ( )
@@ -207,7 +197,7 @@ public async Task ImportImages()
207
197
}
208
198
209
199
var dirPath = dir . Path . LocalPath ;
210
- await ImportImages ( dirPath , SelectedPrimarySwatch , SelectedSecondarySwatch ) ;
200
+ await ImportImages ( dirPath ) ;
211
201
}
212
202
213
203
animationTimer . Start ( ) ;
@@ -257,7 +247,7 @@ public void RecolourImages(ColourRemapSwatch primary, ColourRemapSwatch secondar
257
247
}
258
248
}
259
249
260
- public void CropAllImages ( ColourRemapSwatch primary , ColourRemapSwatch secondary )
250
+ public void CropAllImages ( )
261
251
{
262
252
foreach ( var ivm in ImageViewModels )
263
253
{
@@ -276,7 +266,7 @@ public static string TrimZeroes(string str)
276
266
return result . Length == 0 ? "0" : result ;
277
267
}
278
268
279
- public async Task ImportImages ( string directory , ColourRemapSwatch primary , ColourRemapSwatch secondary )
269
+ public async Task ImportImages ( string directory )
280
270
{
281
271
if ( string . IsNullOrEmpty ( directory ) )
282
272
{
0 commit comments