- Fix First Launch Position to Center

- Move HideStartup code to MainWindow from app.xaml.cs
This commit is contained in:
DB p 2021-11-16 14:54:58 +09:00
parent e8e139304e
commit 7107386eaf
2 changed files with 25 additions and 12 deletions

View file

@ -100,16 +100,6 @@ namespace Flow.Launcher
AutoUpdates();
API.SaveAppAllSettings();
if (_settings.HideOnStartup)
{
_mainVM.Hide();
}
else
{
window.WindowAnimator();
}
Log.Info("|App.OnStartup|End Flow Launcher startup ---------------------------------------------------- ");
});
}

View file

@ -64,6 +64,7 @@ namespace Flow.Launcher
private void OnLoaded(object sender, RoutedEventArgs _)
{
HideStartup();
// show notify icon when flowlauncher is hidden
InitializeNotifyIcon();
WindowsInteropHelper.DisableControlBox(this);
@ -335,6 +336,8 @@ namespace Flow.Launcher
{
Left = WindowLeft();
Top = WindowTop();
_settings.WindowLeft = Left;
_settings.WindowTop = Top;
}
}
@ -350,7 +353,27 @@ namespace Flow.Launcher
}
}
private double WindowLeft()
public void HideStartup()
{
if (_settings.HideOnStartup)
{
_viewModel.Hide();
}
else
{
if (!_settings.HideOnStartup && _settings.WindowLeft == 0 && _settings.WindowTop == 0) /* First Launch */
{
Left = WindowLeft();
Top = WindowTop();
_settings.WindowLeft = Left;
_settings.WindowTop = Top;
}
_viewModel.Show();
}
}
public double WindowLeft()
{
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
@ -359,7 +382,7 @@ namespace Flow.Launcher
return left;
}
private double WindowTop()
public double WindowTop()
{
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);