@@ -27,6 +27,8 @@ namespace AutoActions
2727{
2828 public class AutoActionsDaemon : BaseViewModel
2929 {
30+ CodectoryCore . UI . Wpf . SplashScreen _splashScreen = new CodectoryCore . UI . Wpf . SplashScreen ( ) ;
31+
3032 readonly object _accessLock = new object ( ) ;
3133 private bool _showView = false ;
3234 private ApplicationItem _currentApplication = null ;
@@ -80,7 +82,7 @@ public class AutoActionsDaemon : BaseViewModel
8082
8183
8284 public bool Initialized { get ; private set ; } = false ;
83- public bool ShowView { get => _showView ; set { _showView = value ; OnPropertyChanged ( ) ; } }
85+ public bool ShowView { get => _showView ; set { _showView = value ; OnPropertyChanged ( ) ; } }
8486
8587 public ApplicationItem CurrentApplication { get => _currentApplication ; set { _currentApplication = value ; OnPropertyChanged ( ) ; } }
8688
@@ -97,6 +99,12 @@ public Version Version
9799 public AutoActionsDaemon ( )
98100 {
99101 //ChangeLanguage( new System.Globalization.CultureInfo("en-US"));
102+ _splashScreen . SetImageFromBitmap ( ProjectLocales . SplashScreen ) ;
103+ if ( ! Settings . HideSplashScreenOnStartup )
104+ {
105+ _splashScreen . Show ( ) ;
106+ System . Threading . Thread . Sleep ( 1000 ) ;
107+ }
100108 Initialize ( ) ;
101109 }
102110
@@ -115,7 +123,7 @@ private void Initialize()
115123
116124 lock ( _accessLock )
117125 {
118- CodectoryCore . UI . Wpf . SplashScreen splashScreen = new CodectoryCore . UI . Wpf . SplashScreen ( ) ;
126+
119127 try
120128 {
121129 if ( Initialized )
@@ -125,24 +133,19 @@ private void Initialize()
125133 _logsStorage = new LogsStorage ( ) ;
126134 _lastActions = new ObservableCollection < IProfileAction > ( ) ;
127135 InitializeApplicationWatcher ( ) ;
128- LoadSettings ( ) ;
129- splashScreen . SetImageFromBitmap ( ProjectLocales . SplashScreen ) ;
130- if ( ! Settings . HideSplashScreenOnStartup )
131- {
132- splashScreen . Show ( ) ;
133- System . Threading . Thread . Sleep ( 1000 ) ;
134- }
136+ InitializeSettings ( ) ;
137+
135138 Globals . Logs . Add ( "Initializing..." , false ) ;
136139 if ( Settings . CheckForNewVersion )
137140 Task . Run ( ( ) =>
138141 {
139142 CheckUpdateResult result = Globals . Instance . CheckUpdate ( ) ;
140143 if ( result . UpdateAvailable && Settings . AutoUpdate )
141144 {
142- splashScreen . Text = ProjectLocales . Updating ;
145+ _splashScreen . Text = ProjectLocales . Updating ;
143146 if ( ! Settings . HideSplashScreenOnAutoUpdate )
144147 {
145- splashScreen . Show ( ) ;
148+ _splashScreen . Show ( ) ;
146149 System . Threading . Thread . Sleep ( 1000 ) ;
147150 }
148151 Globals . Instance . AutoUpdate ( result . GitHubData ) ;
@@ -157,7 +160,7 @@ private void Initialize()
157160 Initialized = true ;
158161 Globals . Logs . Add ( "Initialized" , false ) ;
159162 Start ( ) ;
160- splashScreen . Close ( ) ;
163+ _splashScreen . Close ( ) ;
161164
162165 }
163166 catch ( Exception ex )
@@ -167,7 +170,7 @@ private void Initialize()
167170 }
168171 finally
169172 {
170- splashScreen . Close ( ) ;
173+ _splashScreen . Close ( ) ;
171174 }
172175 }
173176 }
@@ -339,12 +342,8 @@ private void TrayMenuHelper_CloseApplicationRequested(object sender, EventArgs e
339342 Shutdown ( ) ;
340343 }
341344
342- private void LoadSettings ( )
345+ private void InitializeSettings ( )
343346 {
344- Globals . Instance . LoadSettings ( ) ;
345- FixAssignments ( ) ;
346- Globals . Instance . SaveSettings ( ) ;
347-
348347 Settings . ApplicationProfileAssignments . Sort ( a => a . Position , ListSortDirection . Ascending ) ;
349348 Settings . ApplicationProfileAssignments . CollectionChanged += ApplicationProfileAssigments_CollectionChanged ;
350349 Settings . ApplicationProfiles . CollectionChanged += ApplicationProfiles_CollectionChanged ;
@@ -366,36 +365,6 @@ private void LoadSettings()
366365 }
367366
368367
369- private void FixAssignments ( )
370- {
371- int count = Settings . ApplicationProfileAssignments . Count ;
372- for ( int i = 0 ; i < count ; i ++ )
373- {
374- int positionCount = Settings . ApplicationProfileAssignments . Count ( a => a . Position == i ) ;
375- if ( positionCount == 0 )
376- {
377- int u = i ;
378- while ( Settings . ApplicationProfileAssignments . Count ( a => a . Position == i ) == 0 )
379- {
380- var assignemnt = Settings . ApplicationProfileAssignments . FirstOrDefault ( a => a . Position == u ) ;
381- if ( assignemnt != null )
382- assignemnt . Position = i ;
383- u ++ ;
384- }
385- }
386- if ( positionCount > 1 )
387- Settings . ApplicationProfileAssignments . First ( a => a . Position == i ) . Position = i + 1 ;
388- }
389- while ( Settings . ApplicationProfileAssignments . Any ( a => a . Position >= count ) )
390- {
391- foreach ( var assignment in Settings . ApplicationProfileAssignments )
392- if ( assignment . Position >= count )
393- do
394- {
395- assignment . Position = assignment . Position - 1 ;
396- } while ( Settings . ApplicationProfileAssignments . Count ( a => a . Position == assignment . Position ) > 1 ) ;
397- }
398- }
399368
400369
401370 private void TrayMenu_TrayLeftMouseDown ( object sender , RoutedEventArgs e )
0 commit comments