diff --git a/Flow.Launcher/MainWindow.xaml b/Flow.Launcher/MainWindow.xaml index daea406db..cf471beb7 100644 --- a/Flow.Launcher/MainWindow.xaml +++ b/Flow.Launcher/MainWindow.xaml @@ -1,105 +1,192 @@ - + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + - - + + - + - - - + + + - - + + - + @@ -121,49 +208,69 @@ - + - - + - - - + + + - + - - - + + + - - - + + + - + - - - + + + - - - - + + + + diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 16e4be8a0..9b44c7b78 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -196,7 +196,7 @@ namespace Flow.Launcher Header = InternationalizationManager.Instance.GetTranslation("iconTrayExit") }; - open.Click += (o, e) => Visibility = Visibility.Visible; + open.Click += (o, e) => _viewModel.ToggleFlowLauncher(); settings.Click += (o, e) => App.API.OpenSettingDialog(); exit.Click += (o, e) => Close(); contextMenu.Items.Add(header); @@ -235,6 +235,48 @@ namespace Flow.Launcher isProgressBarStoryboardPaused = true; } + public void WindowAnimator() + { + InitializePosition(); + Storyboard sb = new Storyboard(); + var da = new DoubleAnimation + { + From = 0, + To = 1, + Duration = TimeSpan.FromSeconds(0.2), + FillBehavior = FillBehavior.Stop + }; + + var da2 = new DoubleAnimation + { + From = Top + 8, + To = Top, + Duration = TimeSpan.FromSeconds(0.2), + FillBehavior = FillBehavior.Stop + }; + + var da3 = new DoubleAnimation + { + From = Left, + To = Left, + Duration = TimeSpan.FromSeconds(0.1), + FillBehavior = FillBehavior.Stop + }; + System.Diagnostics.Debug.WriteLine("Left: " + Left); + System.Diagnostics.Debug.WriteLine("Top: " + Top); + Storyboard.SetTargetProperty(da3, new PropertyPath(Window.LeftProperty)); + sb.Children.Add(da3); + Storyboard.SetTarget(da, this); + Storyboard.SetTargetProperty(da, new PropertyPath(Window.OpacityProperty)); + Storyboard.SetTargetProperty(da2, new PropertyPath(Window.TopProperty)); + + sb.Children.Add(da); + sb.Children.Add(da2); + + sb.Begin(FlowMainWindow); + } + + private void OnMouseDown(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left) DragMove(); diff --git a/Flow.Launcher/ViewModel/MainViewModel.cs b/Flow.Launcher/ViewModel/MainViewModel.cs index 547228ee3..02f2908d2 100644 --- a/Flow.Launcher/ViewModel/MainViewModel.cs +++ b/Flow.Launcher/ViewModel/MainViewModel.cs @@ -380,6 +380,8 @@ namespace Flow.Launcher.ViewModel public Visibility ProgressBarVisibility { get; set; } public Visibility MainWindowVisibility { get; set; } + public double MainWindowOpacity { get; set; } = 1; + public bool WinToggleStatus { get; set; } = true; public double MainWindowWidth => _settings.WindowSize; @@ -708,9 +710,12 @@ namespace Flow.Launcher.ViewModel public void ToggleFlowLauncher() { - if (MainWindowVisibility != Visibility.Visible) + if (WinToggleStatus != true) { MainWindowVisibility = Visibility.Visible; + ((MainWindow)Application.Current.MainWindow).WindowAnimator(); + WinToggleStatus = true; + MainWindowOpacity = 1; } else { @@ -720,24 +725,30 @@ namespace Flow.Launcher.ViewModel public async void Hide() { + MainWindowOpacity = 0; switch (_settings.LastQueryMode) { case LastQueryMode.Empty: ChangeQueryText(string.Empty); - Application.Current.MainWindow.Opacity = 0; // Trick for no delay - await Task.Delay(100); - Application.Current.MainWindow.Opacity = 1; + MainWindowOpacity = 0; // Trick for no delay + await Task.Delay(100); //Time for change to opacity break; case LastQueryMode.Preserved: + MainWindowOpacity = 0; + await Task.Delay(100); LastQuerySelected = true; break; case LastQueryMode.Selected: + MainWindowOpacity = 0; + await Task.Delay(100); LastQuerySelected = false; break; default: throw new ArgumentException($"wrong LastQueryMode: <{_settings.LastQueryMode}>"); } + WinToggleStatus = false; MainWindowVisibility = Visibility.Collapsed; + } #endregion