Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public string Theme
public bool UseGlyphIcons { get; set; } = true;
public bool UseAnimation { get; set; } = true;
public bool UseSound { get; set; } = true;
public double SoundVolume { get; set; } = 50;

public bool UseClock { get; set; } = true;
public bool UseDate { get; set; } = false;
public string TimeFormat { get; set; } = "hh:mm tt";
Expand Down
2 changes: 2 additions & 0 deletions Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@
<system:String x:Key="ColorSchemeDark">Dark</system:String>
<system:String x:Key="SoundEffect">Sound Effect</system:String>
<system:String x:Key="SoundEffectTip">Play a small sound when the search window opens</system:String>
<system:String x:Key="SoundEffectVolume">Sound Effect Volume</system:String>
<system:String x:Key="SoundEffectVolumeTip">Adjust the volume of the sound effect</system:String>
<system:String x:Key="Animation">Animation</system:String>
<system:String x:Key="AnimationTip">Use Animation in UI</system:String>
<system:String x:Key="AnimationSpeed">Animation Speed</system:String>
Expand Down
8 changes: 7 additions & 1 deletion Flow.Launcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using System.Media;
using static Flow.Launcher.ViewModel.SettingWindowViewModel;
using DataObject = System.Windows.DataObject;
using System.Windows.Media;

namespace Flow.Launcher
{
Expand All @@ -40,7 +41,7 @@ public partial class MainWindow
private ContextMenu contextMenu;
private MainViewModel _viewModel;
private bool _animating;
SoundPlayer animationSound = new SoundPlayer(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav");
MediaPlayer animationSound = new MediaPlayer();

#endregion

Expand All @@ -52,6 +53,9 @@ public MainWindow(Settings settings, MainViewModel mainVM)

InitializeComponent();
InitializePosition();

animationSound.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav"));

DataObject.AddPastingHandler(QueryTextBox, OnPaste);
}

Expand Down Expand Up @@ -128,6 +132,8 @@ private void OnLoaded(object sender, RoutedEventArgs _)
{
if (_settings.UseSound)
{
animationSound.Position = TimeSpan.Zero;
animationSound.Volume = _settings.SoundVolume / 100.0;
animationSound.Play();
}
UpdatePosition();
Expand Down
Binary file modified Flow.Launcher/Resources/open.wav
Binary file not shown.
78 changes: 66 additions & 12 deletions Flow.Launcher/SettingWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -2474,27 +2474,81 @@
</StackPanel>
</Border>


<Border
Margin="0"
BorderThickness="0"
Margin="0,12,0,12"
Padding="0"
CornerRadius="5"
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
<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 SoundEffect}" />
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource SoundEffectTip}" />
</StackPanel>
<ui:ToggleSwitch
x:Name="SoundEffect"
Grid.Row="0"
Grid.Column="2"
IsOn="{Binding UseSound, Mode=TwoWay}"
OffContent="{DynamicResource disable}"
OnContent="{DynamicResource enable}"
Style="{DynamicResource SideToggleSwitch}" />
<TextBlock Style="{StaticResource Glyph}">
<TextBlock Style="{StaticResource Glyph}">
&#xe7f5;
</TextBlock>
</ItemsControl>
</Border>
<Separator
Width="Auto"
BorderThickness="1"
Style="{StaticResource SettingSeparatorStyle}" />
<Border Margin="0" BorderThickness="0">
<Border.Style>
<Style BasedOn="{StaticResource SettingGroupBox}" TargetType="Border">
<Setter Property="Visibility" Value="Collapsed" />
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=SoundEffect, Path=IsOn}" Value="True">
<Setter Property="Visibility" Value="Visible" />
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>

<ItemsControl Style="{StaticResource SettingGrid}">
<StackPanel Style="{StaticResource TextPanel}">
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource SoundEffectVolume}" />
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource SoundEffectVolumeTip}" />
</StackPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal">
<TextBlock
Width="Auto"
Margin="0,0,8,2"
VerticalAlignment="Center"
Foreground="{DynamicResource Color05B}"
Text="{Binding ElementName=SoundEffectValue, Path=Value, UpdateSourceTrigger=PropertyChanged}"
TextAlignment="Right" />
<Slider
Name="SoundEffectValue"
Width="250"
Margin="0,0,18,0"
VerticalAlignment="Center"
IsMoveToPointEnabled="True"
IsSnapToTickEnabled="True"
Maximum="100"
Minimum="0"
TickFrequency="1"
Value="{Binding SoundEffectVolume, Mode=TwoWay}" />
</StackPanel>
<TextBlock Style="{StaticResource Glyph}">
&#xe994;
</TextBlock>
</ItemsControl>
</TextBlock>
</ItemsControl>
</Border>
</StackPanel>
</Border>

<Border Margin="0,12,0,12" Style="{DynamicResource SettingGroupBox}">
Expand Down
9 changes: 9 additions & 0 deletions Flow.Launcher/ViewModel/SettingWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public SettingWindowViewModel(Updater updater, IPortable portable)
case nameof(Settings.PreviewHotkey):
OnPropertyChanged(nameof(AlwaysPreviewToolTip));
break;
case nameof(Settings.SoundVolume):
OnPropertyChanged(nameof(SoundEffectVolume));
break;
}
};

Expand Down Expand Up @@ -631,6 +634,12 @@ public bool UseSound
set => Settings.UseSound = value;
}

public double SoundEffectVolume
{
get => Settings.SoundVolume;
set => Settings.SoundVolume = value;
}

public bool UseClock
{
get => Settings.UseClock;
Expand Down