@@ -12,9 +12,9 @@ public class PopupViewModel : Screen, IDisposable
1212 {
1313 private const int PopupOffsetX = - 80 ;
1414 private readonly IConfigurationProvider configurationProvider ;
15- private bool keepOpen ;
1615 private bool isClosing ;
1716 private Point initialPopupPosition ;
17+ private Configuration configuration ;
1818
1919 public FileTransfersTrayViewModel FileTransfersViewModel { get ; private set ; }
2020
@@ -26,8 +26,7 @@ Func<FileTransfersTrayViewModel> fileTransfersViewModelFactory
2626 initialPopupPosition = WpfScreenHelper . MouseHelper . MousePosition ; // Get initial mouse position as early as possible
2727
2828 this . configurationProvider = configurationProvider ;
29- var configuration = configurationProvider . Load ( ) ;
30- keepOpen = configuration . KeepActivityPopupOpen ;
29+ configuration = configurationProvider . Load ( ) ;
3130
3231 FileTransfersViewModel = fileTransfersViewModelFactory ( ) ;
3332 FileTransfersViewModel . ConductWith ( this ) ;
@@ -45,7 +44,8 @@ public void SetPopupPosition(Point popupPosition)
4544
4645 protected override void OnActivate ( )
4746 {
48- SetViewStartPosition ( ) ;
47+ LoadViewSettings ( ) ;
48+ SetViewBounds ( ) ;
4949 base . OnActivate ( ) ;
5050 }
5151
@@ -80,7 +80,8 @@ private void View_Closing(object sender, CancelEventArgs e)
8080
8181 private void View_Deactivated ( object sender , System . EventArgs e )
8282 {
83- if ( keepOpen )
83+ SaveViewSettings ( ) ;
84+ if ( configuration . KeepActivityPopupOpen )
8485 {
8586 return ;
8687 }
@@ -91,16 +92,59 @@ private void View_Deactivated(object sender, System.EventArgs e)
9192 RequestClose ( ) ;
9293 }
9394
95+ private void LoadViewSettings ( )
96+ {
97+ if ( View is not Window w )
98+ {
99+ return ;
100+ }
101+ w . ShowInTaskbar = configuration . KeepActivityPopupOpen ;
102+ w . Topmost = configuration . KeepActivityPopupOnTop ;
103+ w . Width = configuration . ActivityPopupWidth ;
104+ w . Height = configuration . ActivityPopupHeight ;
105+ }
106+
107+ private void SaveViewSettings ( )
108+ {
109+ if ( View is not Window w )
110+ {
111+ return ;
112+ }
113+
114+ var viewWidth = ( int ) w . Width ;
115+ var viewHeight = ( int ) w . Height ;
116+ if (
117+ viewWidth == configuration . ActivityPopupWidth
118+ && viewHeight == configuration . ActivityPopupHeight
119+ )
120+ {
121+ return ;
122+ }
123+
124+ // save view settings to config
125+ configurationProvider . AtomicLoadAndSave ( config =>
126+ {
127+ config . ActivityPopupWidth = viewWidth ;
128+ config . ActivityPopupHeight = viewHeight ;
129+ } ) ;
130+ }
131+
94132 private void ConfigurationChanged ( object sender , ConfigurationChangedEventArgs e )
95133 {
96- keepOpen = e . NewConfiguration . KeepActivityPopupOpen ;
97- if ( ! keepOpen && IsActive )
134+ configuration = e . NewConfiguration ;
135+ if ( ! configuration . KeepActivityPopupOpen && IsActive )
98136 {
99137 RequestClose ( ) ;
138+ return ;
139+ }
140+ if ( View is not Window w )
141+ {
142+ return ;
100143 }
144+ w . Topmost = configuration . KeepActivityPopupOnTop ;
101145 }
102146
103- private void SetViewStartPosition ( )
147+ private void SetViewBounds ( )
104148 {
105149 if ( View is not Window w )
106150 {
0 commit comments