@@ -60,6 +60,8 @@ public class MainViewModel : Screen, INotifyDataErrorInfo
6060 private bool _isSavingConfiguration ;
6161 private bool _isUninstallingService ;
6262 private bool _isWorkingOnService ;
63+ private int _windowWidth ;
64+ private int _windowHeight ;
6365
6466 private ObservableCollection < Language > _languages ;
6567
@@ -85,6 +87,8 @@ public MainViewModel(IWindowManager windowManager, IEventAggregator events)
8587 _windowManager = windowManager ;
8688 _events = events ;
8789 _events . Subscribe ( this ) ;
90+ _windowWidth = Properties . Settings . Default . WindowWidth ;
91+ _windowHeight = Properties . Settings . Default . WindowHeight ;
8892 _windowTitle =
8993 $ "{ Global . ApplicationName } { VersionHelper . PublishVersion } { VersionHelper . PublishBuild } [dnscrypt-proxy { DnsCryptProxyManager . GetVersion ( ) } ]";
9094 SelectedTab = Tabs . MainTab ;
@@ -95,6 +99,7 @@ public MainViewModel(IWindowManager windowManager, IEventAggregator events)
9599 {
96100 WindowTitle = LocalizationEx . GetUiString ( "settings" , Thread . CurrentThread . CurrentCulture )
97101 } ;
102+
98103 _settingsViewModel . PropertyChanged += SettingsViewModelOnPropertyChanged ;
99104 _listenAddressesViewModel = new ListenAddressesViewModel ( ) ;
100105 _fallbackResolversViewModel = new FallbackResolversViewModel ( ) ;
@@ -390,6 +395,26 @@ public BindableCollection<AvailableResolver> Resolvers
390395 }
391396 }
392397
398+ /// <summary>
399+ /// Closing the main window.
400+ /// </summary>
401+ /// <param name="cancelEventArgs"></param>
402+ public void OnClose ( CancelEventArgs cancelEventArgs )
403+ {
404+ try
405+ {
406+ Properties . Settings . Default . WindowWidth = WindowWidth ;
407+ Properties . Settings . Default . WindowHeight = WindowHeight ;
408+ Properties . Settings . Default . Save ( ) ;
409+ }
410+ catch ( Exception exception )
411+ {
412+ Log . Error ( exception ) ;
413+ }
414+ }
415+
416+
417+
393418 /// <summary>
394419 /// The title of the window.
395420 /// </summary>
@@ -403,6 +428,32 @@ public string WindowTitle
403428 }
404429 }
405430
431+ /// <summary>
432+ /// The width of the main window.
433+ /// </summary>
434+ public int WindowWidth
435+ {
436+ get => _windowWidth ;
437+ set
438+ {
439+ _windowWidth = value ;
440+ NotifyOfPropertyChange ( ( ) => WindowWidth ) ;
441+ }
442+ }
443+
444+ /// <summary>
445+ /// The height of the main window.
446+ /// </summary>
447+ public int WindowHeight
448+ {
449+ get => _windowHeight ;
450+ set
451+ {
452+ _windowHeight = value ;
453+ NotifyOfPropertyChange ( ( ) => WindowHeight ) ;
454+ }
455+ }
456+
406457 /// <summary>
407458 /// Show or hide the filtered network cards.
408459 /// </summary>
@@ -609,7 +660,7 @@ public void TabControl_SelectionChanged(SelectionChangedEventArgs selectionChang
609660
610661 public void About ( )
611662 {
612- var win = new AboutViewModel ( _windowManager , _events )
663+ var win = new AboutViewModel ( )
613664 {
614665 WindowTitle = LocalizationEx . GetUiString ( "about" , Thread . CurrentThread . CurrentCulture )
615666 } ;
0 commit comments