@@ -46,6 +46,7 @@ public MainWindow(Settings settings, MainViewModel mainVM)
46
46
_viewModel = mainVM ;
47
47
_settings = settings ;
48
48
InitializeComponent ( ) ;
49
+ InitializePosition ( ) ;
49
50
animationSound . Open ( new Uri ( AppDomain . CurrentDomain . BaseDirectory + "Resources\\ open.wav" ) ) ;
50
51
}
51
52
@@ -176,12 +177,6 @@ private void OnLoaded(object sender, RoutedEventArgs _)
176
177
case nameof ( Settings . Hotkey ) :
177
178
UpdateNotifyIconText ( ) ;
178
179
break ;
179
- case nameof ( Settings . WindowLeft ) :
180
- Left = _settings . WindowLeft ;
181
- break ;
182
- case nameof ( Settings . WindowTop ) :
183
- Top = _settings . WindowTop ;
184
- break ;
185
180
}
186
181
} ;
187
182
}
@@ -195,19 +190,19 @@ private void InitializePosition()
195
190
Left = _settings . WindowLeft ;
196
191
break ;
197
192
case LauncherPositions . MouseScreenCenter :
198
- Left = WindowLeft ( ) ;
199
- Top = WindowTop ( ) ;
193
+ Left = HorizonCenter ( ) ;
194
+ Top = VerticalCenter ( ) ;
200
195
break ;
201
196
case LauncherPositions . MouseScreenCenterTop :
202
- Left = WindowLeft ( ) ;
197
+ Left = HorizonCenter ( ) ;
203
198
Top = 10 ;
204
199
break ;
205
200
case LauncherPositions . MouseScreenLeftTop :
206
201
Left = 10 ;
207
202
Top = 10 ;
208
203
break ;
209
204
case LauncherPositions . MouseScreenRightTop :
210
- Left = WindowRight ( ) ;
205
+ Left = HorizonRight ( ) ;
211
206
Top = 10 ;
212
207
break ;
213
208
}
@@ -315,17 +310,17 @@ private void ToggleGameMode()
315
310
_viewModel . GameModeStatus = true ;
316
311
}
317
312
}
318
- private void PositionReset ( )
313
+ private async void PositionReset ( )
319
314
{
320
- _settings . WindowLeft = WindowLeft ( ) ;
321
- _settings . WindowTop = WindowTop ( ) ;
322
- // Left = _settings.WindowLeft ;
323
- // Top = _settings.WindowTop ;
315
+ _viewModel . Show ( ) ;
316
+ await Task . Delay ( 300 ) ; // If don't give a time, Positioning will be weired.
317
+ Left = HorizonCenter ( ) ;
318
+ Top = VerticalCenter ( ) ;
324
319
}
325
320
private void InitProgressbarAnimation ( )
326
321
{
327
322
var da = new DoubleAnimation ( ProgressBar . X2 , ActualWidth + 150 ,
328
- new Duration ( new TimeSpan ( 0 , 0 , 0 , 0 , 1600 ) ) ) ;
323
+ new Duration ( new TimeSpan ( 0 , 0 , 0 , 0 , 1600 ) ) ) ;
329
324
var da1 = new DoubleAnimation ( ProgressBar . X1 , ActualWidth + 50 , new Duration ( new TimeSpan ( 0 , 0 , 0 , 0 , 1600 ) ) ) ;
330
325
Storyboard . SetTargetProperty ( da , new PropertyPath ( "(Line.X2)" ) ) ;
331
326
Storyboard . SetTargetProperty ( da1 , new PropertyPath ( "(Line.X1)" ) ) ;
@@ -429,6 +424,8 @@ private async void OnContextMenusForSettingsClick(object sender, RoutedEventArgs
429
424
430
425
private async void OnDeactivated ( object sender , EventArgs e )
431
426
{
427
+ _settings . WindowLeft = Left ;
428
+ _settings . WindowTop = Top ;
432
429
//This condition stops extra hide call when animator is on,
433
430
// which causes the toggling to occasional hide instead of show.
434
431
if ( _viewModel . MainWindowVisibilityStatus )
@@ -477,7 +474,7 @@ public void HideStartup()
477
474
}
478
475
}
479
476
480
- public double WindowLeft ( )
477
+ public double HorizonCenter ( )
481
478
{
482
479
var screen = Screen . FromPoint ( System . Windows . Forms . Cursor . Position ) ;
483
480
var dip1 = WindowsInteropHelper . TransformPixelsToDIP ( this , screen . WorkingArea . X , 0 ) ;
@@ -486,7 +483,7 @@ public double WindowLeft()
486
483
return left ;
487
484
}
488
485
489
- public double WindowTop ( )
486
+ public double VerticalCenter ( )
490
487
{
491
488
var screen = Screen . FromPoint ( System . Windows . Forms . Cursor . Position ) ;
492
489
var dip1 = WindowsInteropHelper . TransformPixelsToDIP ( this , 0 , screen . WorkingArea . Y ) ;
@@ -495,7 +492,7 @@ public double WindowTop()
495
492
return top ;
496
493
}
497
494
498
- public double WindowRight ( )
495
+ public double HorizonRight ( )
499
496
{
500
497
var screen = Screen . FromPoint ( System . Windows . Forms . Cursor . Position ) ;
501
498
var dip1 = WindowsInteropHelper . TransformPixelsToDIP ( this , screen . WorkingArea . X , 0 ) ;
0 commit comments