@@ -42,6 +42,7 @@ public MainWindow(Settings settings, MainViewModel mainVM)
42
42
DataContext = mainVM ;
43
43
_viewModel = mainVM ;
44
44
_settings = settings ;
45
+ InitializePosition ( ) ;
45
46
InitializeComponent ( ) ;
46
47
}
47
48
@@ -69,10 +70,8 @@ private void OnLoaded(object sender, RoutedEventArgs _)
69
70
{
70
71
// show notify icon when flowlauncher is hidden
71
72
InitializeNotifyIcon ( ) ;
72
-
73
73
WindowsInteropHelper . DisableControlBox ( this ) ;
74
74
InitProgressbarAnimation ( ) ;
75
- InitializePosition ( ) ;
76
75
// since the default main window visibility is visible
77
76
// so we need set focus during startup
78
77
QueryTextBox . Focus ( ) ;
@@ -85,9 +84,9 @@ private void OnLoaded(object sender, RoutedEventArgs _)
85
84
{
86
85
if ( _viewModel . WinToggleStatus == true )
87
86
{
87
+ UpdatePosition ( ) ;
88
88
Activate ( ) ;
89
89
QueryTextBox . Focus ( ) ;
90
- //UpdatePosition();
91
90
_settings . ActivateTimes ++ ;
92
91
if ( ! _viewModel . LastQuerySelected )
93
92
{
@@ -156,21 +155,15 @@ private void OnLoaded(object sender, RoutedEventArgs _)
156
155
157
156
private void InitializePosition ( )
158
157
{
159
- /*
160
- Top = WindowTop();
161
- Left = WindowLeft();
162
- _settings.WindowTop = Top;
163
- _settings.WindowLeft = Left;
164
- */
165
158
if ( _settings . RememberLastLaunchLocation )
166
159
{
167
- Left = _settings . WindowLeft ;
168
- Top = _settings . WindowTop ;
160
+ this . Top = this . _settings . WindowTop ;
161
+ this . Left = this . _settings . WindowLeft ;
169
162
}
170
163
else
171
164
{
172
- Left = WindowLeft ( ) ;
173
- Top = WindowTop ( ) ;
165
+ this . Left = WindowLeft ( ) ;
166
+ this . Top = WindowTop ( ) ;
174
167
}
175
168
}
176
169
@@ -251,7 +244,6 @@ private void InitProgressbarAnimation()
251
244
252
245
public void WindowAnimator ( )
253
246
{
254
- //InitializePosition();
255
247
UpdatePosition ( ) ;
256
248
Storyboard sb = new Storyboard ( ) ;
257
249
var da = new DoubleAnimation
@@ -277,10 +269,10 @@ public void WindowAnimator()
277
269
Duration = TimeSpan . FromSeconds ( 0.1 ) ,
278
270
FillBehavior = FillBehavior . Stop
279
271
} ;
280
- Storyboard . SetTargetProperty ( da3 , new PropertyPath ( Window . LeftProperty ) ) ;
281
272
Storyboard . SetTarget ( da , this ) ;
282
273
Storyboard . SetTargetProperty ( da , new PropertyPath ( Window . OpacityProperty ) ) ;
283
274
Storyboard . SetTargetProperty ( da2 , new PropertyPath ( Window . TopProperty ) ) ;
275
+ Storyboard . SetTargetProperty ( da3 , new PropertyPath ( Window . LeftProperty ) ) ;
284
276
sb . Children . Add ( da ) ;
285
277
sb . Children . Add ( da2 ) ;
286
278
sb . Children . Add ( da3 ) ;
@@ -328,6 +320,7 @@ private void OnContextMenusForSettingsClick(object sender, RoutedEventArgs e)
328
320
329
321
private void OnDeactivated ( object sender , EventArgs e )
330
322
{
323
+ _viewModel . Save ( ) ;
331
324
if ( _settings . HideWhenDeactive )
332
325
{
333
326
_viewModel . Hide ( ) ;
@@ -348,6 +341,16 @@ private void UpdatePosition()
348
341
}
349
342
}
350
343
344
+ private void OnSizeChanged ( object sender , SizeChangedEventArgs e )
345
+ {
346
+ if ( _settings . RememberLastLaunchLocation )
347
+ {
348
+ return ;
349
+ _settings . WindowLeft = Left ;
350
+ _settings . WindowTop = Top ;
351
+ }
352
+ }
353
+
351
354
private void OnLocationChanged ( object sender , EventArgs e )
352
355
{
353
356
if ( _settings . RememberLastLaunchLocation )
0 commit comments