diff --git a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs index 8ecd6dc4b76..211bc179876 100644 --- a/Flow.Launcher.Infrastructure/UserSettings/Settings.cs +++ b/Flow.Launcher.Infrastructure/UserSettings/Settings.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Drawing; @@ -43,6 +43,11 @@ public string Language public bool UseSound { get; set; } = true; public bool FirstLaunch { get; set; } = true; + public double SettingWindowWidth { get; set; } = 1000; + public double SettingWindowHeight { get; set; } = 700; + public double SettingWindowTop { get; set; } + public double SettingWindowLeft { get; set; } + public int CustomExplorerIndex { get; set; } = 0; [JsonIgnore] @@ -220,4 +225,4 @@ public enum ColorSchemes Light, Dark } -} \ No newline at end of file +} diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index 14520cfe0a1..72a2ecb2086 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -13,18 +13,20 @@ xmlns:userSettings="clr-namespace:Flow.Launcher.Infrastructure.UserSettings;assembly=Flow.Launcher.Infrastructure" xmlns:vm="clr-namespace:Flow.Launcher.ViewModel" Title="{DynamicResource flowlauncher_settings}" - Width="1000" - Height="700" + Width="{Binding SettingWindowWidth, Mode=TwoWay}" + Height="{Binding SettingWindowHeight, Mode=TwoWay}" MinWidth="900" MinHeight="600" d:DataContext="{d:DesignInstance vm:SettingWindowViewModel}" Closed="OnClosed" Icon="Images\app.ico" + Left="{Binding SettingWindowLeft, Mode=TwoWay}" Loaded="OnLoaded" MouseDown="window_MouseDown" ResizeMode="CanResize" StateChanged="Window_StateChanged" - WindowStartupLocation="CenterScreen" + Top="{Binding SettingWindowTop, Mode=TwoWay}" + WindowStartupLocation="Manual" mc:Ignorable="d"> @@ -1114,7 +1116,6 @@ = 0 && settings.SettingWindowLeft >= 0) + { + Top = settings.SettingWindowTop; + Left = settings.SettingWindowLeft; + } + else + { + Top = WindowTop(); + Left = WindowLeft(); + } + } + public double WindowLeft() + { + var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position); + var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0); + var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.Width, 0); + var left = (dip2.X - this.ActualWidth) / 2 + dip1.X; + return left; + } + + public double WindowTop() + { + var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position); + var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y); + var dip2 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Height); + var top = (dip2.Y - this.ActualHeight) / 2 + dip1.Y - 20; + return top; + } private void OnExternalPluginUninstallClick(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left) @@ -360,6 +395,7 @@ private void OnExternalPluginUninstallClick(object sender, MouseButtonEventArgs API.ChangeQuery($"{actionKeyword} uninstall {id}"); API.ShowMainWindow(); } + } } } diff --git a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs index 64cb9e36cbe..952f8bd4e07 100644 --- a/Flow.Launcher/ViewModel/SettingWindowViewModel.cs +++ b/Flow.Launcher/ViewModel/SettingWindowViewModel.cs @@ -51,7 +51,7 @@ public async void UpdateApp() { await _updater.UpdateAppAsync(App.API, false); } - + public bool AutoUpdates { get => Settings.AutoUpdates; @@ -406,6 +406,30 @@ public bool UseSound set => Settings.UseSound = value; } + public double SettingWindowWidth + { + get => Settings.SettingWindowWidth; + set => Settings.SettingWindowWidth = value; + } + + public double SettingWindowHeight + { + get => Settings.SettingWindowHeight; + set => Settings.SettingWindowHeight = value; + } + + public double SettingWindowTop + { + get => Settings.SettingWindowTop; + set => Settings.SettingWindowTop = value; + } + + public double SettingWindowLeft + { + get => Settings.SettingWindowLeft; + set => Settings.SettingWindowLeft = value; + } + public Brush PreviewBackground { get