From 5670085275c5bb936d6a824f109adb010d330e0d Mon Sep 17 00:00:00 2001 From: DB p Date: Wed, 15 May 2024 23:30:27 +0900 Subject: [PATCH] - add soundplay for no WMP - fix warning visibility --- Flow.Launcher/MainWindow.xaml.cs | 24 +++++++++++++++++++----- Flow.Launcher/SettingWindow.xaml | 2 +- Flow.Launcher/SettingWindow.xaml.cs | 2 +- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/Flow.Launcher/MainWindow.xaml.cs b/Flow.Launcher/MainWindow.xaml.cs index 76e587cdc..2678d7c27 100644 --- a/Flow.Launcher/MainWindow.xaml.cs +++ b/Flow.Launcher/MainWindow.xaml.cs @@ -29,6 +29,7 @@ using DataObject = System.Windows.DataObject; using System.Windows.Media; using System.Windows.Interop; using System.Runtime.InteropServices; +using System.IO; namespace Flow.Launcher { @@ -46,7 +47,8 @@ namespace Flow.Launcher private ContextMenu contextMenu = new ContextMenu(); private MainViewModel _viewModel; private bool _animating; - MediaPlayer animationSound = new MediaPlayer(); + MediaPlayer animationSoundWMP = new MediaPlayer(); + SoundPlayer animationSoundWPF = new SoundPlayer(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav"); #endregion @@ -59,7 +61,7 @@ namespace Flow.Launcher InitializeComponent(); InitializePosition(); - animationSound.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav")); + animationSoundWMP.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav")); DataObject.AddPastingHandler(QueryTextBox, OnPaste); } @@ -137,9 +139,7 @@ namespace Flow.Launcher { if (_settings.UseSound) { - animationSound.Position = TimeSpan.Zero; - animationSound.Volume = _settings.SoundVolume / 100.0; - animationSound.Play(); + SoundPlay(); } UpdatePosition(); PreviewReset(); @@ -503,6 +503,20 @@ namespace Flow.Launcher windowsb.Begin(FlowMainWindow); } + private void SoundPlay() + { + + if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Windows Media Player", "wmplayer.exe"))) + { + animationSoundWPF.Play(); + } + else + { + animationSoundWMP.Position = TimeSpan.Zero; + animationSoundWMP.Volume = _settings.SoundVolume / 100.0; + animationSoundWMP.Play(); + } + } private void OnMouseDown(object sender, MouseButtonEventArgs e) { if (e.ChangedButton == MouseButton.Left) DragMove(); diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml index fd999585d..daacd76d5 100644 --- a/Flow.Launcher/SettingWindow.xaml +++ b/Flow.Launcher/SettingWindow.xaml @@ -2570,7 +2570,7 @@ BorderBrush="{DynamicResource Color03B}" BorderThickness="0,1,0,0" CornerRadius="0 0 5 5" - Visibility="Visible"> + Visibility="Collapsed"> diff --git a/Flow.Launcher/SettingWindow.xaml.cs b/Flow.Launcher/SettingWindow.xaml.cs index 58ffbb149..292559b2f 100644 --- a/Flow.Launcher/SettingWindow.xaml.cs +++ b/Flow.Launcher/SettingWindow.xaml.cs @@ -73,7 +73,7 @@ namespace Flow.Launcher if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Windows Media Player", "wmplayer.exe"))) { - /* Binding WMPWarning visibility */ + WMPWarning.Visibility = Visibility.Visible; } } private void SettingsWindowViewModelChanged(object sender, PropertyChangedEventArgs e)