@@ -34,12 +34,37 @@ public class MainWindowViewModel : ViewModelBase
3434 private string _statusBarBackground ;
3535 private double _transparencyValue ;
3636 private int _transparencyInPercent ;
37- private Settings _settings ;
3837 private ObservableCollection < string > _fonts ;
3938 private ObservableCollection < string > _themes ;
4039 private ObservableCollection < string > _accents ;
4140 private string _selectedTheme ;
4241 private string _selectedAccent ;
42+ private bool _ontop ;
43+ private bool _showintaskbar ;
44+ private bool _displaydetails ;
45+ private string _currentfont ;
46+
47+
48+ public string CurrentFont
49+ {
50+ get { return _currentfont ; }
51+ set { SetProperty ( ref _currentfont , value , ( ) => CurrentFont ) ; }
52+ }
53+ public bool OnTop
54+ {
55+ get { return _ontop ; }
56+ set { SetProperty ( ref _ontop , value , ( ) => OnTop ) ; }
57+ }
58+ public bool DisplayDetails
59+ {
60+ get { return _displaydetails ; }
61+ set { SetProperty ( ref _displaydetails , value , ( ) => DisplayDetails ) ; }
62+ }
63+ public bool ShowInTaskbar
64+ {
65+ get { return _showintaskbar ; }
66+ set { SetProperty ( ref _showintaskbar , value , ( ) => ShowInTaskbar ) ; }
67+ }
4368 public string SelectedAccent
4469 {
4570 get => _selectedAccent ;
@@ -58,7 +83,7 @@ public string SelectedTheme
5883 StatusBarBackground = this . SelectedTheme == ThemeManager . BaseColorLight ? WHITE : BLACK ;
5984 DragAreaColor = this . SelectedTheme == ThemeManager . BaseColorLight ? LIGHT_GRAY : GRAY ;
6085 ThemeChanger . ChangeTheme ( this . SelectedAccent , this . SelectedTheme ) ;
61- ThemeSelectionChanged ( ) ;
86+ UpdateFontColorOnThemeSelectionChanged ( ) ;
6287 }
6388 }
6489 public ObservableCollection < string > Accents
@@ -76,11 +101,6 @@ public ObservableCollection<string> Fonts
76101 get { return _fonts ; }
77102 set { SetProperty ( ref _fonts , value , ( ) => Fonts ) ; }
78103 }
79- public Settings Settings
80- {
81- get { return _settings ; }
82- set { SetProperty ( ref _settings , value , ( ) => Settings ) ; }
83- }
84104 public int TransparencyInPercent
85105 {
86106 get { return _transparencyInPercent ; }
@@ -89,8 +109,8 @@ public int TransparencyInPercent
89109 public double TransparencyValue
90110 {
91111 get { return _transparencyValue ; }
92- set
93- {
112+ set
113+ {
94114 SetProperty ( ref _transparencyValue , value , ( ) => TransparencyValue ) ;
95115 TransparencyInPercent = ( Int32 ) ( TransparencyValue * 100 ) ;
96116 }
@@ -123,14 +143,17 @@ public string MultiLine
123143
124144 #endregion MVVM Properties
125145
146+
147+ public Settings Settings { get ; set ; }
126148 public ICommand ClearMultiLineCommand { get ; set ; }
127149 public ICommand ResetViewCommand { get ; set ; }
128150
129151
152+
130153 public MainWindowViewModel ( )
131154 {
132- LoadAvailableThemes ( ) ;
133- LoadSettings ( ) ;
155+ LoadAvailableThemesAndAccents ( ) ;
156+ LoadSettings ( SettingsLoadLocations . FromFile ) ;
134157 Init ( ) ;
135158 }
136159
@@ -145,29 +168,28 @@ private void Init()
145168
146169 private IEnumerable < string > LoadInstalledFonts ( )
147170 {
148- using ( var fonts = new InstalledFontCollection ( ) )
149- foreach ( FontFamily font in fonts . Families )
150- yield return font . Name ;
171+ using ( var fonts = new InstalledFontCollection ( ) )
172+ foreach ( FontFamily font in fonts . Families )
173+ yield return font . Name ;
151174 }
152175
153176 private void ClearMultiLine ( ) => this . MultiLine = String . Empty ;
154177
155178 private void ResetView ( )
156179 {
157- this . TransparencyValue = 1 ;
158- this . SelectedTheme = Themes . First ( ) ;
159- this . SelectedAccent = Accents . First ( f => f == CYAN ) ;
160- this . Settings . CurrentFont = Fonts . First ( f => f == DEFAULT_FONT ) ;
180+ var defaultSettings = SettingsLogic . GetDefaultSettings ( ) ;
181+ LoadSettings ( SettingsLoadLocations . Default ) ;
161182 }
162183
163184
164185 #region Themes
165- private void LoadAvailableThemes ( )
186+ private void LoadAvailableThemesAndAccents ( )
166187 {
167188 Themes = new ObservableCollection < string > ( ) { ThemeManager . BaseColorLight , ThemeManager . BaseColorDark } ;
168189 Accents = new ObservableCollection < string > ( ThemeManager . Current . ColorSchemes ) ;
169190 }
170- private void ThemeSelectionChanged ( )
191+
192+ private void UpdateFontColorOnThemeSelectionChanged ( )
171193 {
172194 if ( ! String . IsNullOrEmpty ( SelectedTheme ) )
173195 MultiLineTextForegroundColor = SelectedTheme == ThemeManager . BaseColorLight ? BLACK : WHITE ;
@@ -178,18 +200,46 @@ private void ThemeSelectionChanged()
178200
179201
180202 #region Settings
181- private void LoadSettings ( )
203+ private void LoadSettings ( SettingsLoadLocations location )
182204 {
183- this . Settings = SettingsLogic . GetSettings ( ) ;
184- SelectedTheme = Themes . FirstOrDefault ( f => f == this . Settings . SelectedThemeName ) ;
185- SelectedAccent = Accents . FirstOrDefault ( f => f == this . Settings . SelectedAccentName ) ;
186- TransparencyValue = Settings . TransparencyValue ;
205+ InitSettingsBeforePropertiesUpdate ( location ) ;
206+ UpdateProperties ( ) ;
187207 }
208+
209+ private void InitSettingsBeforePropertiesUpdate ( SettingsLoadLocations location )
210+ {
211+ switch ( location )
212+ {
213+ case SettingsLoadLocations . FromFile :
214+ Settings = SettingsLogic . GetSettings ( ) ;
215+ break ;
216+ case SettingsLoadLocations . Default :
217+ Settings = SettingsLogic . GetDefaultSettings ( ) ;
218+ break ;
219+ }
220+ }
221+
222+ private void UpdateProperties ( )
223+ {
224+ this . SelectedTheme = Themes . FirstOrDefault ( f => f == this . Settings . SelectedThemeName ) ;
225+ this . SelectedAccent = Accents . FirstOrDefault ( f => f == this . Settings . SelectedAccentName ) ;
226+ this . TransparencyValue = Settings . TransparencyValue ;
227+ this . OnTop = Settings . OnTop ;
228+ this . CurrentFont = Settings . CurrentFont ;
229+ this . DisplayDetails = Settings . DisplayDetails ;
230+ this . ShowInTaskbar = Settings . ShowInTaskbar ;
231+ }
232+
233+
188234 public void SaveSettings ( )
189235 {
190236 Settings . SelectedAccentName = this . SelectedAccent ;
191237 Settings . SelectedThemeName = this . SelectedTheme ;
192238 Settings . TransparencyValue = this . TransparencyValue ;
239+ Settings . OnTop = this . OnTop ;
240+ Settings . CurrentFont = this . CurrentFont ;
241+ Settings . DisplayDetails = this . DisplayDetails ;
242+ Settings . ShowInTaskbar = this . ShowInTaskbar ;
193243 SettingsLogic . SaveSettings ( this . Settings ) ;
194244 }
195245
0 commit comments