@@ -148,47 +148,14 @@ public MainWindowViewModel()
148148 {
149149 LoadAvailableThemesAndAccents ( ) ;
150150 LoadSettings ( SettingsLoadLocations . FromFile ) ;
151- Init ( ) ;
151+ InitViewModel ( ) ;
152152 }
153-
154- private void Init ( )
155- {
156- ResetViewCommand = new DelegateCommand ( ResetView ) ;
157- Fonts = new ObservableCollection < string > ( LoadInstalledFonts ( ) ) ;
158- }
159-
160- private IEnumerable < string > LoadInstalledFonts ( )
161- {
162- using ( var fonts = new InstalledFontCollection ( ) )
163- foreach ( FontFamily font in fonts . Families )
164- yield return font . Name ;
165- }
166-
167- private void ResetView ( )
168- {
169- Settings defaultSettings = SettingsLogic . GetDefaultSettings ( ) ;
170- LoadSettings ( SettingsLoadLocations . Default ) ;
171- }
172-
173-
174- #region Themes
175153 private void LoadAvailableThemesAndAccents ( )
176154 {
177155 Themes = new ObservableCollection < string > ( ) { ThemeManager . BaseColorLight , ThemeManager . BaseColorDark } ;
178156 Accents = new ObservableCollection < string > ( ThemeManager . Current . ColorSchemes ) ;
179157 }
180158
181- private void UpdateFontColorOnThemeSelectionChanged ( )
182- {
183- if ( ! String . IsNullOrEmpty ( SelectedTheme ) )
184- MultiLineTextForegroundColor = SelectedTheme == ThemeManager . BaseColorLight ? BLACK : WHITE ;
185- else
186- MultiLineTextForegroundColor = LIGHT_GRAY ;
187- }
188- #endregion Themes
189-
190-
191- #region Settings
192159 private void LoadSettings ( SettingsLoadLocations location )
193160 {
194161 InitSettingsBeforePropertiesUpdate ( location ) ;
@@ -219,8 +186,40 @@ private void UpdateProperties()
219186 this . ShowInTaskbar = Settings . ShowInTaskbar ;
220187 }
221188
189+ private void InitViewModel ( )
190+ {
191+ Fonts = new ObservableCollection < string > ( LoadInstalledFonts ( ) ) ;
192+ ResetViewCommand = new DelegateCommand ( ResetView ) ;
193+ }
194+
195+ private IEnumerable < string > LoadInstalledFonts ( )
196+ {
197+ using ( var fonts = new InstalledFontCollection ( ) )
198+ foreach ( FontFamily font in fonts . Families )
199+ yield return font . Name ;
200+ }
201+
202+ private void ResetView ( )
203+ {
204+ Settings defaultSettings = SettingsLogic . GetDefaultSettings ( ) ;
205+ LoadSettings ( SettingsLoadLocations . Default ) ;
206+ }
207+
208+
209+
210+
211+ private void UpdateFontColorOnThemeSelectionChanged ( )
212+ {
213+ if ( ! String . IsNullOrEmpty ( SelectedTheme ) )
214+ MultiLineTextForegroundColor = SelectedTheme == ThemeManager . BaseColorLight ? BLACK : WHITE ;
215+ else
216+ MultiLineTextForegroundColor = LIGHT_GRAY ;
217+ }
218+
219+
220+
222221
223- public void SaveSettings ( )
222+ public void SaveSettingsOnClose ( )
224223 {
225224 Settings . SelectedAccentName = this . SelectedAccent ;
226225 Settings . SelectedThemeName = this . SelectedTheme ;
@@ -231,6 +230,5 @@ public void SaveSettings()
231230 Settings . ShowInTaskbar = this . ShowInTaskbar ;
232231 SettingsLogic . SaveSettings ( this . Settings ) ;
233232 }
234- #endregion Settings
235233 }
236234}
0 commit comments