Skip to content

Commit 985003c

Browse files
committed
Rename Positioning function
1 parent 21c944e commit 985003c

File tree

1 file changed

+16
-19
lines changed

1 file changed

+16
-19
lines changed

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ public MainWindow(Settings settings, MainViewModel mainVM)
4646
_viewModel = mainVM;
4747
_settings = settings;
4848
InitializeComponent();
49+
InitializePosition();
4950
animationSound.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav"));
5051
}
5152

@@ -176,12 +177,6 @@ private void OnLoaded(object sender, RoutedEventArgs _)
176177
case nameof(Settings.Hotkey):
177178
UpdateNotifyIconText();
178179
break;
179-
case nameof(Settings.WindowLeft):
180-
Left = _settings.WindowLeft;
181-
break;
182-
case nameof(Settings.WindowTop):
183-
Top = _settings.WindowTop;
184-
break;
185180
}
186181
};
187182
}
@@ -195,19 +190,19 @@ private void InitializePosition()
195190
Left = _settings.WindowLeft;
196191
break;
197192
case LauncherPositions.MouseScreenCenter:
198-
Left = WindowLeft();
199-
Top = WindowTop();
193+
Left = HorizonCenter();
194+
Top = VerticalCenter();
200195
break;
201196
case LauncherPositions.MouseScreenCenterTop:
202-
Left = WindowLeft();
197+
Left = HorizonCenter();
203198
Top = 10;
204199
break;
205200
case LauncherPositions.MouseScreenLeftTop:
206201
Left = 10;
207202
Top = 10;
208203
break;
209204
case LauncherPositions.MouseScreenRightTop:
210-
Left = WindowRight();
205+
Left = HorizonRight();
211206
Top = 10;
212207
break;
213208
}
@@ -315,17 +310,17 @@ private void ToggleGameMode()
315310
_viewModel.GameModeStatus = true;
316311
}
317312
}
318-
private void PositionReset()
313+
private async void PositionReset()
319314
{
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();
324319
}
325320
private void InitProgressbarAnimation()
326321
{
327322
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)));
329324
var da1 = new DoubleAnimation(ProgressBar.X1, ActualWidth + 50, new Duration(new TimeSpan(0, 0, 0, 0, 1600)));
330325
Storyboard.SetTargetProperty(da, new PropertyPath("(Line.X2)"));
331326
Storyboard.SetTargetProperty(da1, new PropertyPath("(Line.X1)"));
@@ -429,6 +424,8 @@ private async void OnContextMenusForSettingsClick(object sender, RoutedEventArgs
429424

430425
private async void OnDeactivated(object sender, EventArgs e)
431426
{
427+
_settings.WindowLeft = Left;
428+
_settings.WindowTop = Top;
432429
//This condition stops extra hide call when animator is on,
433430
// which causes the toggling to occasional hide instead of show.
434431
if (_viewModel.MainWindowVisibilityStatus)
@@ -477,7 +474,7 @@ public void HideStartup()
477474
}
478475
}
479476

480-
public double WindowLeft()
477+
public double HorizonCenter()
481478
{
482479
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
483480
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
@@ -486,7 +483,7 @@ public double WindowLeft()
486483
return left;
487484
}
488485

489-
public double WindowTop()
486+
public double VerticalCenter()
490487
{
491488
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
492489
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);
@@ -495,7 +492,7 @@ public double WindowTop()
495492
return top;
496493
}
497494

498-
public double WindowRight()
495+
public double HorizonRight()
499496
{
500497
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
501498
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);

0 commit comments

Comments
 (0)