@@ -13,19 +13,28 @@ public class UnknownMsuWindowService(
1313 IMapper mapper ,
1414 IMsuTypeService msuTypeService ,
1515 IMsuCacheService msuCacheService ,
16- IMsuLookupService msuLookupService ) : ControlService
16+ IMsuLookupService msuLookupService ,
17+ IMsuHardwareService msuHardwareService ) : ControlService
1718{
1819 private UnknownMsuWindowViewModel _model = new ( ) ;
1920 private const int MaxPathLength = 50 ;
21+ private bool _isHardwareMode ;
2022
21- public UnknownMsuWindowViewModel InitilizeModel ( )
23+ public UnknownMsuWindowViewModel InitilizeModel ( bool isHardwareMode )
2224 {
25+ _isHardwareMode = isHardwareMode ;
26+
2327 List < string > msuTypes = [ "" ] ;
2428 msuTypes . AddRange ( msuTypeService . MsuTypes . Select ( x => x . DisplayName ) . OrderBy ( x => x ) ) ;
2529
2630 List < MsuDetailsWindowViewModel > msuModels = [ ] ;
31+
32+ var msuList = isHardwareMode ? msuHardwareService . Msus : msuLookupService . Msus ;
33+ var msus = msuList . Where ( x =>
34+ x is { IgnoreUnknown : false , MsuType : null , NumUniqueTracks : >= 15 } &&
35+ string . IsNullOrEmpty ( x . Settings . MsuTypeName ) ) ;
2736
28- foreach ( var msu in msuLookupService . Msus . Where ( x => x is { IgnoreUnknown : false , MsuType : null , NumUniqueTracks : >= 15 } && string . IsNullOrEmpty ( x . Settings . MsuTypeName ) ) )
37+ foreach ( var msu in msus )
2938 {
3039 var msuModel = mapper . Map < MsuDetailsWindowViewModel > ( msu . Settings ) ;
3140 msuModel . Msu = msu ;
@@ -46,6 +55,7 @@ public UnknownMsuWindowViewModel InitilizeModel()
4655 {
4756 _model . HasBeenModified = true ;
4857 } ;
58+
4959 msuModels . Add ( msuModel ) ;
5060 }
5161
@@ -62,18 +72,29 @@ public void Save()
6272 foreach ( var msuModel in _model . UnknownMsus . Where ( x => x . Msu != null ) )
6373 {
6474 mapper . Map ( msuModel , msuModel . Msu ! . Settings ) ;
75+ msuModel . Msu . MsuType = msuTypeService . GetMsuType ( msuModel . MsuTypeName ) ;
6576 msuModel . Msu . Settings . IsUserUnknownMsu = string . IsNullOrEmpty ( msuModel . MsuTypeName ) ;
6677 userOptionsService . UpdateMsuSettings ( msuModel . Msu ) ;
67- msuCacheService . Remove ( msuModel . Msu . Path , false ) ;
78+
79+ if ( _isHardwareMode && ! string . IsNullOrEmpty ( msuModel . MsuTypeName ) )
80+ {
81+ msuHardwareService . RefreshMsu ( msuModel . MsuPath ) ;
82+ }
83+ else if ( ! _isHardwareMode )
84+ {
85+ msuCacheService . Remove ( msuModel . Msu . Path , false ) ;
86+ }
6887 }
6988
7089 userOptionsService . Save ( ) ;
71-
72- ITaskService . Run ( ( ) =>
90+
91+ if ( ! _isHardwareMode )
7392 {
74- msuLookupService . LookupMsus ( ) ;
75- } ) ;
76-
93+ ITaskService . Run ( ( ) =>
94+ {
95+ msuLookupService . LookupMsus ( ) ;
96+ } ) ;
97+ }
7798 }
7899
79100 public void SaveIgnore ( )
0 commit comments