- Add Sound

- Add Sound/Animation in Setting
- Add related String
This commit is contained in:
DB p 2021-11-14 07:45:47 +09:00
parent ca2d696791
commit 62eb1b6cff
7 changed files with 159 additions and 59 deletions

View file

@ -37,6 +37,9 @@ namespace Flow.Launcher.Infrastructure.UserSettings
public string ResultFontStretch { get; set; }
public bool UseGlyphIcons { get; set; } = true;
public bool UseAnimation { get; set; } = true;
public bool UseSound { get; set; } = false;
/// <summary>
/// when false Alphabet static service will always return empty results

View file

@ -80,6 +80,10 @@
<system:String x:Key="theme_load_failure_parse_error">Fail to load theme {0}, fallback to default theme</system:String>
<system:String x:Key="ThemeFolder">Theme Folder</system:String>
<system:String x:Key="OpenThemeFolder">Open Theme Folder</system:String>
<system:String x:Key="SoundEffect">Sound Effect</system:String>
<system:String x:Key="SoundEffectTip">Play a small sound when window open.</system:String>
<system:String x:Key="Animation">Animation</system:String>
<system:String x:Key="AnimationTip">Use Animation in UI.</system:String>
<!--Setting Hotkey-->
<system:String x:Key="hotkey">Hotkey</system:String>

View file

@ -238,44 +238,47 @@ namespace Flow.Launcher
public void WindowAnimator()
{
if (_animating)
return;
if (_settings.UseAnimation)
{
if (_animating)
return;
_animating = true;
UpdatePosition();
Storyboard sb = new Storyboard();
var da = new DoubleAnimation
{
From = 0,
To = 1,
Duration = TimeSpan.FromSeconds(0.2),
FillBehavior = FillBehavior.Stop
};
_animating = true;
UpdatePosition();
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 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
};
Storyboard.SetTarget(da, this);
Storyboard.SetTargetProperty(da, new PropertyPath(Window.OpacityProperty));
Storyboard.SetTargetProperty(da2, new PropertyPath(Window.TopProperty));
Storyboard.SetTargetProperty(da3, new PropertyPath(Window.LeftProperty));
sb.Children.Add(da);
sb.Children.Add(da2);
sb.Children.Add(da3);
sb.Completed += (_, _) => _animating = false;
sb.Begin(FlowMainWindow);
var da3 = new DoubleAnimation
{
From = Left,
To = Left,
Duration = TimeSpan.FromSeconds(0.1),
FillBehavior = FillBehavior.Stop
};
Storyboard.SetTarget(da, this);
Storyboard.SetTargetProperty(da, new PropertyPath(Window.OpacityProperty));
Storyboard.SetTargetProperty(da2, new PropertyPath(Window.TopProperty));
Storyboard.SetTargetProperty(da3, new PropertyPath(Window.LeftProperty));
sb.Children.Add(da);
sb.Children.Add(da2);
sb.Children.Add(da3);
sb.Completed += (_, _) => _animating = false;
sb.Begin(FlowMainWindow);
}
}

Binary file not shown.

View file

@ -1388,11 +1388,15 @@
TextAlignment="left" />
</Border>
<StackPanel Grid.Row="1" Margin="0" Background="{Binding PreviewBackground}">
<StackPanel Margin="0,30,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal">
<StackPanel
Grid.Row="1"
Margin="0"
Background="{Binding PreviewBackground}">
<StackPanel
Margin="0,30,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Orientation="Horizontal">
<Border Width="{Binding WindowWidthSize}" Style="{DynamicResource WindowBorderStyle}">
<Border Style="{DynamicResource WindowRadius}">
<Border.Clip>
@ -1470,26 +1474,29 @@
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource windowWidthSize}" />
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal">
<TextBlock Width="100"
Margin="0,0,8,2"
VerticalAlignment="Center"
Text="{Binding ElementName=WindowWidthValue, Path=Value, UpdateSourceTrigger=PropertyChanged}"
TextAlignment="Right" />
<Slider Name="WindowWidthValue"
Width="300"
Margin="0,0,18,0"
IsMoveToPointEnabled="True"
IsSnapToTickEnabled="True"
Maximum="900"
Minimum="400"
TickFrequency="10"
Value="{Binding WindowWidthSize, Mode=TwoWay}" />
<TextBlock
Width="100"
Margin="0,0,8,2"
VerticalAlignment="Center"
Text="{Binding ElementName=WindowWidthValue, Path=Value, UpdateSourceTrigger=PropertyChanged}"
TextAlignment="Right" />
<Slider
Name="WindowWidthValue"
Width="300"
Margin="0,0,18,0"
IsMoveToPointEnabled="True"
IsSnapToTickEnabled="True"
Maximum="900"
Minimum="400"
TickFrequency="10"
Value="{Binding WindowWidthSize, Mode=TwoWay}" />
</StackPanel>
<TextBlock Grid.Column="0"
Margin="24,0,16,0"
VerticalAlignment="Center"
FontFamily="/Resources/#Segoe Fluent Icons"
FontSize="20">
<TextBlock
Grid.Column="0"
Margin="24,0,16,0"
VerticalAlignment="Center"
FontFamily="/Resources/#Segoe Fluent Icons"
FontSize="20">
&#xe740;
</TextBlock>
</ItemsControl>
@ -1749,6 +1756,70 @@
</Border>
<StackPanel>
<Border
Margin="0,30,0,0"
Padding="0"
CornerRadius="5"
Style="{DynamicResource SettingGroupBox}">
<StackPanel Orientation="Vertical">
<Border
Margin="0"
BorderThickness="0"
Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource Animation}" />
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource AnimationTip}" />
</StackPanel>
<ui:ToggleSwitch
Grid.Row="0"
Grid.Column="2"
Width="100"
Margin="0,0,2,0"
IsOn="{Binding UseAnimation, Mode=TwoWay}" />
<TextBlock
Grid.Column="0"
Margin="24,0,16,0"
VerticalAlignment="Center"
FontFamily="/Resources/#Segoe Fluent Icons"
FontSize="20">
&#xedb5;
</TextBlock>
</ItemsControl>
</Border>
<Separator
Width="Auto"
BorderBrush="#e5e5e5"
BorderThickness="1" />
<Border
Margin="0"
BorderThickness="0"
Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource SoundEffect}" />
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource SoundEffectTip}" />
</StackPanel>
<ui:ToggleSwitch
Grid.Row="0"
Grid.Column="2"
Width="100"
Margin="0,0,2,0"
IsOn="{Binding UseSound, Mode=TwoWay}" />
<TextBlock
Grid.Column="0"
Margin="24,0,16,0"
VerticalAlignment="Center"
FontFamily="/Resources/#Segoe Fluent Icons"
FontSize="20">
&#xe994;
</TextBlock>
</ItemsControl>
</Border>
</StackPanel>
</Border>
<Border Margin="0,12,0,18" Style="{DynamicResource SettingGroupBox}">
<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">

View file

@ -5,6 +5,7 @@ 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;
@ -712,6 +713,12 @@ namespace Flow.Launcher.ViewModel
{
if (WinToggleStatus != true)
{
if (_settings.UseSound)
{
MediaPlayer media = new MediaPlayer();
media.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav"));
media.Play();
}
MainWindowVisibility = Visibility.Visible;
WinToggleStatus = true;
((MainWindow)Application.Current.MainWindow).WindowAnimator();

View file

@ -328,6 +328,18 @@ namespace Flow.Launcher.ViewModel
set => Settings.UseGlyphIcons = value;
}
public bool UseAnimation
{
get => Settings.UseAnimation;
set => Settings.UseAnimation = value;
}
public bool UseSound
{
get => Settings.UseSound;
set => Settings.UseSound = value;
}
public Brush PreviewBackground
{
get