From b87237fd6cdb3d30dbc6698a98309e9d3ea04516 Mon Sep 17 00:00:00 2001 From: DB p Date: Tue, 28 May 2024 16:27:25 +0900 Subject: [PATCH] - Fix Window Width Save - Removed Unused code - Adjust MinWidth --- Flow.Launcher/MainWindow.xaml | 3 ++- Flow.Launcher/MainWindow.xaml.cs | 11 +++++++++-- .../ViewModels/SettingsPaneThemeViewModel.cs | 6 ------ 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index 788c3c597..c3753f53f 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -13,7 +13,7 @@ Name="FlowMainWindow" Title="Flow Launcher" Width="{Binding MainWindowWidth, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" - MinWidth="430" + MinWidth="400" MinHeight="30" d:DataContext="{d:DesignInstance Type=vm:MainViewModel}" AllowDrop="True" @@ -30,6 +30,7 @@ PreviewKeyUp="OnKeyUp" ResizeMode="CanResize" ShowInTaskbar="False" + SizeChanged="Window_SizeChanged" SizeToContent="Height" Topmost="True" Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index c333c4e85..0a63b1808 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -45,6 +45,7 @@ namespace Flow.Launcher private MainViewModel _viewModel; private bool _animating; private bool isArrowKeyPressed = false; + private double WindowWidthForSave; private MediaPlayer animationSoundWMP; private SoundPlayer animationSoundWPF; @@ -120,8 +121,6 @@ namespace Flow.Launcher _settings.MaxResultsToShow = Convert.ToInt32(Math.Truncate(itemCount)); } } - - _viewModel.MainWindowWidth = Width; FlowMainWindow.SizeToContent = SizeToContent.Height; } @@ -155,6 +154,9 @@ namespace Flow.Launcher private async void OnClosing(object sender, CancelEventArgs e) { _notifyIcon.Visible = false; + /* In this timing, window alreayd closed and it effect to window size. So at this point, whenever the window changes, + we recall the width we've stored as a variable and specify it in the settings. This way, the existing window size will be recalled on the next run.*/ + _settings.WindowSize = WindowWidthForSave; App.API.SaveAppAllSettings(); e.Cancel = true; await PluginManager.DisposePluginsAsync(); @@ -832,5 +834,10 @@ namespace Flow.Launcher be.UpdateSource(); } } + + private void Window_SizeChanged(object sender, SizeChangedEventArgs e) + { + WindowWidthForSave = Width; + } } } diff --git a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs index 667d0b726..5046a4754 100644 --- a/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs +++ b/Flow.Launcher/SettingPages/ViewModels/SettingsPaneThemeViewModel.cs @@ -173,12 +173,6 @@ public partial class SettingsPaneThemeViewModel : BaseModel public string DateText => DateTime.Now.ToString(DateFormat, CultureInfo.CurrentCulture); - public double WindowWidthSize - { - get => Settings.WindowSize; - set => Settings.WindowSize = value; - } - public bool UseGlyphIcons { get => Settings.UseGlyphIcons;