From 4a8696268d111dd744f0ea3399b6ae030be5b353 Mon Sep 17 00:00:00 2001 From: DB p Date: Sun, 14 Nov 2021 04:54:17 +0900 Subject: [PATCH] - Fix RememberLastPosition when Re-Excute --- Flow.Launcher/MainWindow.xaml | 1 + Flow.Launcher/MainWindow.xaml.cs | 33 +++++++++++++++++--------------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index cf471beb7..359ddc7e6 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -26,6 +26,7 @@ PreviewKeyDown="OnKeyDown" ResizeMode="NoResize" ShowInTaskbar="False" + SizeChanged="OnSizeChanged" SizeToContent="Height" Style="{DynamicResource WindowStyle}" Topmost="True" diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 02a21a44c..b17749e64 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -42,6 +42,7 @@ namespace Flow.Launcher DataContext = mainVM; _viewModel = mainVM; _settings = settings; + InitializePosition(); InitializeComponent(); } @@ -69,10 +70,8 @@ namespace Flow.Launcher { // show notify icon when flowlauncher is hidden InitializeNotifyIcon(); - WindowsInteropHelper.DisableControlBox(this); InitProgressbarAnimation(); - InitializePosition(); // since the default main window visibility is visible // so we need set focus during startup QueryTextBox.Focus(); @@ -85,9 +84,9 @@ namespace Flow.Launcher { if (_viewModel.WinToggleStatus == true) { + UpdatePosition(); Activate(); QueryTextBox.Focus(); - //UpdatePosition(); _settings.ActivateTimes++; if (!_viewModel.LastQuerySelected) { @@ -156,21 +155,15 @@ namespace Flow.Launcher private void InitializePosition() { - /* - Top = WindowTop(); - Left = WindowLeft(); - _settings.WindowTop = Top; - _settings.WindowLeft = Left; - */ if (_settings.RememberLastLaunchLocation) { - Left = _settings.WindowLeft; - Top = _settings.WindowTop; + this.Top = this._settings.WindowTop; + this.Left = this._settings.WindowLeft; } else { - Left = WindowLeft(); - Top = WindowTop(); + this.Left = WindowLeft(); + this.Top = WindowTop(); } } @@ -251,7 +244,6 @@ namespace Flow.Launcher public void WindowAnimator() { - //InitializePosition(); UpdatePosition(); Storyboard sb = new Storyboard(); var da = new DoubleAnimation @@ -277,10 +269,10 @@ namespace Flow.Launcher Duration = TimeSpan.FromSeconds(0.1), FillBehavior = FillBehavior.Stop }; - Storyboard.SetTargetProperty(da3, new PropertyPath(Window.LeftProperty)); Storyboard.SetTarget(da, this); Storyboard.SetTargetProperty(da, new PropertyPath(Window.OpacityProperty)); Storyboard.SetTargetProperty(da2, new PropertyPath(Window.TopProperty)); + Storyboard.SetTargetProperty(da3, new PropertyPath(Window.LeftProperty)); sb.Children.Add(da); sb.Children.Add(da2); sb.Children.Add(da3); @@ -328,6 +320,7 @@ namespace Flow.Launcher private void OnDeactivated(object sender, EventArgs e) { + _viewModel.Save(); if (_settings.HideWhenDeactive) { _viewModel.Hide(); @@ -348,6 +341,16 @@ namespace Flow.Launcher } } + private void OnSizeChanged(object sender, SizeChangedEventArgs e) + { + if (_settings.RememberLastLaunchLocation) + { + return; + _settings.WindowLeft = Left; + _settings.WindowTop = Top; + } + } + private void OnLocationChanged(object sender, EventArgs e) { if (_settings.RememberLastLaunchLocation)