mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
- move sound play code to animator from show
- Adjusting the delay time. - Delete unused code. - Process so that there is no delay when the animation settings are turned off. (Exclude erasing queries.)
This commit is contained in:
parent
8f1a9bfa94
commit
3c78802eae
2 changed files with 19 additions and 38 deletions
|
|
@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Media.Animation;
|
using System.Windows.Media.Animation;
|
||||||
|
using System.Windows.Media;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Flow.Launcher.Core.Plugin;
|
using Flow.Launcher.Core.Plugin;
|
||||||
|
|
@ -243,7 +244,6 @@ namespace Flow.Launcher
|
||||||
{
|
{
|
||||||
if (_animating)
|
if (_animating)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_animating = true;
|
_animating = true;
|
||||||
UpdatePosition();
|
UpdatePosition();
|
||||||
Storyboard sb = new Storyboard();
|
Storyboard sb = new Storyboard();
|
||||||
|
|
@ -272,6 +272,12 @@ namespace Flow.Launcher
|
||||||
_settings.WindowTop = Top;
|
_settings.WindowTop = Top;
|
||||||
sb.Begin(FlowMainWindow);
|
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)
|
private void OnMouseDown(object sender, MouseButtonEventArgs e)
|
||||||
|
|
@ -309,7 +315,7 @@ namespace Flow.Launcher
|
||||||
private async void OnContextMenusForSettingsClick(object sender, RoutedEventArgs e)
|
private async void OnContextMenusForSettingsClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
_viewModel.Hide();
|
_viewModel.Hide();
|
||||||
await Task.Delay(100);
|
await Task.Delay(50);
|
||||||
App.API.OpenSettingDialog();
|
App.API.OpenSettingDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -318,7 +324,7 @@ namespace Flow.Launcher
|
||||||
{
|
{
|
||||||
// need time to initialize the main query window animation
|
// need time to initialize the main query window animation
|
||||||
if (_settings.UseAnimation)
|
if (_settings.UseAnimation)
|
||||||
await Task.Delay(100);
|
await Task.Delay(50);
|
||||||
if (_settings.HideWhenDeactive)
|
if (_settings.HideWhenDeactive)
|
||||||
{
|
{
|
||||||
_viewModel.Hide();
|
_viewModel.Hide();
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Threading.Tasks.Dataflow;
|
using System.Threading.Tasks.Dataflow;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using Flow.Launcher.Core.Plugin;
|
using Flow.Launcher.Core.Plugin;
|
||||||
using Flow.Launcher.Core.Resource;
|
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()
|
private void InitializeKeyCommands()
|
||||||
{
|
{
|
||||||
EscCommand = new RelayCommand(_ =>
|
EscCommand = new RelayCommand(_ =>
|
||||||
|
|
@ -383,7 +362,6 @@ namespace Flow.Launcher.ViewModel
|
||||||
public Visibility MainWindowVisibility { get; set; }
|
public Visibility MainWindowVisibility { get; set; }
|
||||||
public double MainWindowOpacity { get; set; } = 1;
|
public double MainWindowOpacity { get; set; } = 1;
|
||||||
public bool WinToggleStatus { get; set; } = true;
|
public bool WinToggleStatus { get; set; } = true;
|
||||||
|
|
||||||
public double MainWindowWidth => _settings.WindowSize;
|
public double MainWindowWidth => _settings.WindowSize;
|
||||||
|
|
||||||
public ICommand EscCommand { get; set; }
|
public ICommand EscCommand { get; set; }
|
||||||
|
|
@ -720,45 +698,42 @@ namespace Flow.Launcher.ViewModel
|
||||||
Hide();
|
Hide();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Show()
|
public void Show()
|
||||||
{
|
{
|
||||||
if (_settings.UseSound)
|
((MainWindow)Application.Current.MainWindow).WindowAnimator();
|
||||||
{
|
|
||||||
MediaPlayer media = new MediaPlayer();
|
|
||||||
media.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav"));
|
|
||||||
media.Play();
|
|
||||||
}
|
|
||||||
MainWindowVisibility = Visibility.Visible;
|
MainWindowVisibility = Visibility.Visible;
|
||||||
WinToggleStatus = true;
|
WinToggleStatus = true;
|
||||||
((MainWindow)Application.Current.MainWindow).WindowAnimator();
|
|
||||||
MainWindowOpacity = 1;
|
MainWindowOpacity = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void Hide()
|
public async void Hide()
|
||||||
{
|
{
|
||||||
MainWindowOpacity = 0;
|
|
||||||
switch (_settings.LastQueryMode)
|
switch (_settings.LastQueryMode)
|
||||||
{
|
{
|
||||||
case LastQueryMode.Empty:
|
case LastQueryMode.Empty:
|
||||||
ChangeQueryText(string.Empty);
|
ChangeQueryText(string.Empty);
|
||||||
MainWindowOpacity = 0; // Trick for no delay
|
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;
|
break;
|
||||||
case LastQueryMode.Preserved:
|
case LastQueryMode.Preserved:
|
||||||
MainWindowOpacity = 0;
|
MainWindowOpacity = 0;
|
||||||
await Task.Delay(100);
|
if (_settings.UseAnimation)
|
||||||
|
{
|
||||||
|
await Task.Delay(30);
|
||||||
|
}
|
||||||
LastQuerySelected = true;
|
LastQuerySelected = true;
|
||||||
break;
|
break;
|
||||||
case LastQueryMode.Selected:
|
case LastQueryMode.Selected:
|
||||||
MainWindowOpacity = 0;
|
MainWindowOpacity = 0;
|
||||||
await Task.Delay(100);
|
if (_settings.UseAnimation)
|
||||||
|
{
|
||||||
|
await Task.Delay(30);
|
||||||
|
}
|
||||||
LastQuerySelected = false;
|
LastQuerySelected = false;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentException($"wrong LastQueryMode: <{_settings.LastQueryMode}>");
|
throw new ArgumentException($"wrong LastQueryMode: <{_settings.LastQueryMode}>");
|
||||||
}
|
}
|
||||||
|
|
||||||
WinToggleStatus = false;
|
WinToggleStatus = false;
|
||||||
MainWindowVisibility = Visibility.Collapsed;
|
MainWindowVisibility = Visibility.Collapsed;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue