diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 7ecafbf76..cbd9460de 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Input; using System.Windows.Media.Animation; +using System.Windows.Media; using System.Windows.Controls; using System.Windows.Forms; using Flow.Launcher.Core.Plugin; @@ -243,7 +244,6 @@ namespace Flow.Launcher { if (_animating) return; - _animating = true; UpdatePosition(); Storyboard sb = new Storyboard(); @@ -272,6 +272,12 @@ namespace Flow.Launcher _settings.WindowTop = Top; sb.Begin(FlowMainWindow); } + if (_settings.UseSound) + { + MediaPlayer media = new MediaPlayer(); + media.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav")); + media.Play(); + } } private void OnMouseDown(object sender, MouseButtonEventArgs e) @@ -309,7 +315,7 @@ namespace Flow.Launcher private async void OnContextMenusForSettingsClick(object sender, RoutedEventArgs e) { _viewModel.Hide(); - await Task.Delay(100); + await Task.Delay(50); App.API.OpenSettingDialog(); } @@ -318,7 +324,7 @@ namespace Flow.Launcher { // need time to initialize the main query window animation if (_settings.UseAnimation) - await Task.Delay(100); + await Task.Delay(50); if (_settings.HideWhenDeactive) { _viewModel.Hide(); diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index aa0efdca6..87e38f332 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -5,7 +5,6 @@ using System.Threading; using System.Threading.Tasks; using System.Threading.Tasks.Dataflow; using System.Windows; -using System.Windows.Media; using System.Windows.Input; using Flow.Launcher.Core.Plugin; using Flow.Launcher.Core.Resource; @@ -157,26 +156,6 @@ namespace Flow.Launcher.ViewModel }; } } - - private void UpdateLastQUeryMode() - { - switch (_settings.LastQueryMode) - { - case LastQueryMode.Empty: - ChangeQueryText(string.Empty); - break; - case LastQueryMode.Preserved: - LastQuerySelected = true; - break; - case LastQueryMode.Selected: - LastQuerySelected = false; - break; - default: - throw new ArgumentException($"wrong LastQueryMode: <{_settings.LastQueryMode}>"); - - } - } - private void InitializeKeyCommands() { EscCommand = new RelayCommand(_ => @@ -383,7 +362,6 @@ namespace Flow.Launcher.ViewModel public Visibility MainWindowVisibility { get; set; } public double MainWindowOpacity { get; set; } = 1; public bool WinToggleStatus { get; set; } = true; - public double MainWindowWidth => _settings.WindowSize; public ICommand EscCommand { get; set; } @@ -720,45 +698,42 @@ namespace Flow.Launcher.ViewModel Hide(); } } - public void Show() { - if (_settings.UseSound) - { - MediaPlayer media = new MediaPlayer(); - media.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav")); - media.Play(); - } + ((MainWindow)Application.Current.MainWindow).WindowAnimator(); MainWindowVisibility = Visibility.Visible; WinToggleStatus = true; - ((MainWindow)Application.Current.MainWindow).WindowAnimator(); MainWindowOpacity = 1; } public async void Hide() { - MainWindowOpacity = 0; switch (_settings.LastQueryMode) { case LastQueryMode.Empty: ChangeQueryText(string.Empty); MainWindowOpacity = 0; // Trick for no delay - await Task.Delay(100); //Time for change to opacity + await Task.Delay(50); //Time for change to opacity break; case LastQueryMode.Preserved: MainWindowOpacity = 0; - await Task.Delay(100); + if (_settings.UseAnimation) + { + await Task.Delay(30); + } LastQuerySelected = true; break; case LastQueryMode.Selected: MainWindowOpacity = 0; - await Task.Delay(100); + if (_settings.UseAnimation) + { + await Task.Delay(30); + } LastQuerySelected = false; break; default: throw new ArgumentException($"wrong LastQueryMode: <{_settings.LastQueryMode}>"); } - WinToggleStatus = false; MainWindowVisibility = Visibility.Collapsed; }