Skip to content

Commit 62eb1b6

Browse files
committed
- Add Sound
- Add Sound/Animation in Setting - Add related String
1 parent ca2d696 commit 62eb1b6

File tree

7 files changed

+159
-59
lines changed

7 files changed

+159
-59
lines changed

Flow.Launcher.Infrastructure/UserSettings/Settings.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public string Language
3737
public string ResultFontStretch { get; set; }
3838
public bool UseGlyphIcons { get; set; } = true;
3939

40+
public bool UseAnimation { get; set; } = true;
41+
public bool UseSound { get; set; } = false;
42+
4043

4144
/// <summary>
4245
/// when false Alphabet static service will always return empty results

Flow.Launcher/Languages/en.xaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@
8080
<system:String x:Key="theme_load_failure_parse_error">Fail to load theme {0}, fallback to default theme</system:String>
8181
<system:String x:Key="ThemeFolder">Theme Folder</system:String>
8282
<system:String x:Key="OpenThemeFolder">Open Theme Folder</system:String>
83+
<system:String x:Key="SoundEffect">Sound Effect</system:String>
84+
<system:String x:Key="SoundEffectTip">Play a small sound when window open.</system:String>
85+
<system:String x:Key="Animation">Animation</system:String>
86+
<system:String x:Key="AnimationTip">Use Animation in UI.</system:String>
8387

8488
<!--Setting Hotkey-->
8589
<system:String x:Key="hotkey">Hotkey</system:String>

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -238,44 +238,47 @@ private void InitProgressbarAnimation()
238238

239239
public void WindowAnimator()
240240
{
241-
if (_animating)
242-
return;
241+
if (_settings.UseAnimation)
242+
{
243+
if (_animating)
244+
return;
243245

244-
_animating = true;
245-
UpdatePosition();
246-
Storyboard sb = new Storyboard();
247-
var da = new DoubleAnimation
248-
{
249-
From = 0,
250-
To = 1,
251-
Duration = TimeSpan.FromSeconds(0.2),
252-
FillBehavior = FillBehavior.Stop
253-
};
246+
_animating = true;
247+
UpdatePosition();
248+
Storyboard sb = new Storyboard();
249+
var da = new DoubleAnimation
250+
{
251+
From = 0,
252+
To = 1,
253+
Duration = TimeSpan.FromSeconds(0.2),
254+
FillBehavior = FillBehavior.Stop
255+
};
254256

255-
var da2 = new DoubleAnimation
256-
{
257-
From = Top + 8,
258-
To = Top,
259-
Duration = TimeSpan.FromSeconds(0.2),
260-
FillBehavior = FillBehavior.Stop
261-
};
257+
var da2 = new DoubleAnimation
258+
{
259+
From = Top + 8,
260+
To = Top,
261+
Duration = TimeSpan.FromSeconds(0.2),
262+
FillBehavior = FillBehavior.Stop
263+
};
262264

263-
var da3 = new DoubleAnimation
264-
{
265-
From = Left,
266-
To = Left,
267-
Duration = TimeSpan.FromSeconds(0.1),
268-
FillBehavior = FillBehavior.Stop
269-
};
270-
Storyboard.SetTarget(da, this);
271-
Storyboard.SetTargetProperty(da, new PropertyPath(Window.OpacityProperty));
272-
Storyboard.SetTargetProperty(da2, new PropertyPath(Window.TopProperty));
273-
Storyboard.SetTargetProperty(da3, new PropertyPath(Window.LeftProperty));
274-
sb.Children.Add(da);
275-
sb.Children.Add(da2);
276-
sb.Children.Add(da3);
277-
sb.Completed += (_, _) => _animating = false;
278-
sb.Begin(FlowMainWindow);
265+
var da3 = new DoubleAnimation
266+
{
267+
From = Left,
268+
To = Left,
269+
Duration = TimeSpan.FromSeconds(0.1),
270+
FillBehavior = FillBehavior.Stop
271+
};
272+
Storyboard.SetTarget(da, this);
273+
Storyboard.SetTargetProperty(da, new PropertyPath(Window.OpacityProperty));
274+
Storyboard.SetTargetProperty(da2, new PropertyPath(Window.TopProperty));
275+
Storyboard.SetTargetProperty(da3, new PropertyPath(Window.LeftProperty));
276+
sb.Children.Add(da);
277+
sb.Children.Add(da2);
278+
sb.Children.Add(da3);
279+
sb.Completed += (_, _) => _animating = false;
280+
sb.Begin(FlowMainWindow);
281+
}
279282
}
280283

281284

Flow.Launcher/Resources/open.wav

4.67 KB
Binary file not shown.

Flow.Launcher/SettingWindow.xaml

Lines changed: 95 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1388,11 +1388,15 @@
13881388
TextAlignment="left" />
13891389
</Border>
13901390

1391-
<StackPanel Grid.Row="1" Margin="0" Background="{Binding PreviewBackground}">
1392-
<StackPanel Margin="0,30,0,0"
1393-
HorizontalAlignment="Center"
1394-
VerticalAlignment="Center"
1395-
Orientation="Horizontal">
1391+
<StackPanel
1392+
Grid.Row="1"
1393+
Margin="0"
1394+
Background="{Binding PreviewBackground}">
1395+
<StackPanel
1396+
Margin="0,30,0,0"
1397+
HorizontalAlignment="Center"
1398+
VerticalAlignment="Center"
1399+
Orientation="Horizontal">
13961400
<Border Width="{Binding WindowWidthSize}" Style="{DynamicResource WindowBorderStyle}">
13971401
<Border Style="{DynamicResource WindowRadius}">
13981402
<Border.Clip>
@@ -1470,26 +1474,29 @@
14701474
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource windowWidthSize}" />
14711475
</StackPanel>
14721476
<StackPanel Grid.Column="2" Orientation="Horizontal">
1473-
<TextBlock Width="100"
1474-
Margin="0,0,8,2"
1475-
VerticalAlignment="Center"
1476-
Text="{Binding ElementName=WindowWidthValue, Path=Value, UpdateSourceTrigger=PropertyChanged}"
1477-
TextAlignment="Right" />
1478-
<Slider Name="WindowWidthValue"
1479-
Width="300"
1480-
Margin="0,0,18,0"
1481-
IsMoveToPointEnabled="True"
1482-
IsSnapToTickEnabled="True"
1483-
Maximum="900"
1484-
Minimum="400"
1485-
TickFrequency="10"
1486-
Value="{Binding WindowWidthSize, Mode=TwoWay}" />
1477+
<TextBlock
1478+
Width="100"
1479+
Margin="0,0,8,2"
1480+
VerticalAlignment="Center"
1481+
Text="{Binding ElementName=WindowWidthValue, Path=Value, UpdateSourceTrigger=PropertyChanged}"
1482+
TextAlignment="Right" />
1483+
<Slider
1484+
Name="WindowWidthValue"
1485+
Width="300"
1486+
Margin="0,0,18,0"
1487+
IsMoveToPointEnabled="True"
1488+
IsSnapToTickEnabled="True"
1489+
Maximum="900"
1490+
Minimum="400"
1491+
TickFrequency="10"
1492+
Value="{Binding WindowWidthSize, Mode=TwoWay}" />
14871493
</StackPanel>
1488-
<TextBlock Grid.Column="0"
1489-
Margin="24,0,16,0"
1490-
VerticalAlignment="Center"
1491-
FontFamily="/Resources/#Segoe Fluent Icons"
1492-
FontSize="20">
1494+
<TextBlock
1495+
Grid.Column="0"
1496+
Margin="24,0,16,0"
1497+
VerticalAlignment="Center"
1498+
FontFamily="/Resources/#Segoe Fluent Icons"
1499+
FontSize="20">
14931500
&#xe740;
14941501
</TextBlock>
14951502
</ItemsControl>
@@ -1749,6 +1756,70 @@
17491756
</Border>
17501757

17511758
<StackPanel>
1759+
1760+
<Border
1761+
Margin="0,30,0,0"
1762+
Padding="0"
1763+
CornerRadius="5"
1764+
Style="{DynamicResource SettingGroupBox}">
1765+
<StackPanel Orientation="Vertical">
1766+
<Border
1767+
Margin="0"
1768+
BorderThickness="0"
1769+
Style="{DynamicResource SettingGroupBox}">
1770+
<ItemsControl Style="{StaticResource SettingGrid}">
1771+
<StackPanel Style="{StaticResource TextPanel}">
1772+
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource Animation}" />
1773+
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource AnimationTip}" />
1774+
</StackPanel>
1775+
<ui:ToggleSwitch
1776+
Grid.Row="0"
1777+
Grid.Column="2"
1778+
Width="100"
1779+
Margin="0,0,2,0"
1780+
IsOn="{Binding UseAnimation, Mode=TwoWay}" />
1781+
<TextBlock
1782+
Grid.Column="0"
1783+
Margin="24,0,16,0"
1784+
VerticalAlignment="Center"
1785+
FontFamily="/Resources/#Segoe Fluent Icons"
1786+
FontSize="20">
1787+
&#xedb5;
1788+
</TextBlock>
1789+
</ItemsControl>
1790+
</Border>
1791+
<Separator
1792+
Width="Auto"
1793+
BorderBrush="#e5e5e5"
1794+
BorderThickness="1" />
1795+
<Border
1796+
Margin="0"
1797+
BorderThickness="0"
1798+
Style="{DynamicResource SettingGroupBox}">
1799+
<ItemsControl Style="{StaticResource SettingGrid}">
1800+
<StackPanel Style="{StaticResource TextPanel}">
1801+
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource SoundEffect}" />
1802+
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource SoundEffectTip}" />
1803+
</StackPanel>
1804+
<ui:ToggleSwitch
1805+
Grid.Row="0"
1806+
Grid.Column="2"
1807+
Width="100"
1808+
Margin="0,0,2,0"
1809+
IsOn="{Binding UseSound, Mode=TwoWay}" />
1810+
<TextBlock
1811+
Grid.Column="0"
1812+
Margin="24,0,16,0"
1813+
VerticalAlignment="Center"
1814+
FontFamily="/Resources/#Segoe Fluent Icons"
1815+
FontSize="20">
1816+
&#xe994;
1817+
</TextBlock>
1818+
</ItemsControl>
1819+
</Border>
1820+
</StackPanel>
1821+
</Border>
1822+
17521823
<Border Margin="0,12,0,18" Style="{DynamicResource SettingGroupBox}">
17531824
<ItemsControl Style="{StaticResource SettingGrid}">
17541825
<StackPanel Style="{StaticResource TextPanel}">

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Threading.Tasks;
66
using System.Threading.Tasks.Dataflow;
77
using System.Windows;
8+
using System.Windows.Media;
89
using System.Windows.Input;
910
using Flow.Launcher.Core.Plugin;
1011
using Flow.Launcher.Core.Resource;
@@ -712,6 +713,12 @@ public void ToggleFlowLauncher()
712713
{
713714
if (WinToggleStatus != true)
714715
{
716+
if (_settings.UseSound)
717+
{
718+
MediaPlayer media = new MediaPlayer();
719+
media.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav"));
720+
media.Play();
721+
}
715722
MainWindowVisibility = Visibility.Visible;
716723
WinToggleStatus = true;
717724
((MainWindow)Application.Current.MainWindow).WindowAnimator();

Flow.Launcher/ViewModel/SettingWindowViewModel.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,18 @@ public bool UseGlyphIcons
328328
set => Settings.UseGlyphIcons = value;
329329
}
330330

331+
public bool UseAnimation
332+
{
333+
get => Settings.UseAnimation;
334+
set => Settings.UseAnimation = value;
335+
}
336+
337+
public bool UseSound
338+
{
339+
get => Settings.UseSound;
340+
set => Settings.UseSound = value;
341+
}
342+
331343
public Brush PreviewBackground
332344
{
333345
get

0 commit comments

Comments
 (0)