Skip to content
Merged
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
33 changes: 26 additions & 7 deletions Flow.Launcher/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Flow.Launcher.Infrastructure.UserSettings;
using Flow.Launcher.Plugin.SharedCommands;
using Flow.Launcher.ViewModel;
using Microsoft.Win32;
using ModernWpf.Controls;
using DataObject = System.Windows.DataObject;
using Key = System.Windows.Input.Key;
Expand Down Expand Up @@ -88,6 +89,8 @@ public MainWindow()

InitSoundEffects();
DataObject.AddPastingHandler(QueryTextBox, QueryTextBox_OnPaste);

SystemEvents.PowerModeChanged += SystemEvents_PowerModeChanged;
}

#endregion
Expand Down Expand Up @@ -540,16 +543,29 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b

#region Window Sound Effects

private void SystemEvents_PowerModeChanged(object sender, PowerModeChangedEventArgs e)
{
// Fix for sound not playing after sleep / hibernate
// https://stackoverflow.com/questions/64805186/mediaplayer-doesnt-play-after-computer-sleeps
if (e.Mode == PowerModes.Resume)
{
InitSoundEffects();
}
}

private void InitSoundEffects()
{
if (_settings.WMPInstalled)
{
animationSoundWMP?.Close();
animationSoundWMP = new MediaPlayer();
animationSoundWMP.Open(new Uri(AppContext.BaseDirectory + "Resources\\open.wav"));
}
else
{
animationSoundWPF?.Dispose();
animationSoundWPF = new SoundPlayer(AppContext.BaseDirectory + "Resources\\open.wav");
animationSoundWPF.Load();
}
}

Expand Down Expand Up @@ -816,7 +832,7 @@ private void InitProgressbarAnimation()
{
Name = progressBarAnimationName, Storyboard = progressBarStoryBoard
};

var stopStoryboard = new StopStoryboard()
{
BeginStoryboardName = progressBarAnimationName
Expand All @@ -837,7 +853,7 @@ private void InitProgressbarAnimation()
progressStyle.Triggers.Add(trigger);

ProgressBar.Style = progressStyle;

_viewModel.ProgressBarVisibility = Visibility.Hidden;
}

Expand Down Expand Up @@ -885,7 +901,7 @@ private void WindowAnimation()
Duration = TimeSpan.FromMilliseconds(animationLength),
FillBehavior = FillBehavior.HoldEnd
};

var rightMargin = GetThicknessFromStyle(ClockPanel.Style, new Thickness(0, 0, DefaultRightMargin, 0)).Right;

var thicknessAnimation = new ThicknessAnimation
Expand Down Expand Up @@ -913,10 +929,10 @@ private void WindowAnimation()
clocksb.Children.Add(ClockOpacity);
iconsb.Children.Add(IconMotion);
iconsb.Children.Add(IconOpacity);

_settings.WindowLeft = Left;
_isArrowKeyPressed = false;

clocksb.Begin(ClockPanel);
iconsb.Begin(SearchIcon);
}
Expand Down Expand Up @@ -1088,7 +1104,7 @@ private void QueryTextBox_OnPreviewDragOver(object sender, DragEventArgs e)
{
e.Handled = true;
}

#endregion

#region Placeholder
Expand Down Expand Up @@ -1140,7 +1156,7 @@ private void SetupResizeMode()
}

#endregion

#region Search Delay

private void QueryTextBox_TextChanged1(object sender, TextChangedEventArgs e)
Expand All @@ -1162,6 +1178,9 @@ protected virtual void Dispose(bool disposing)
{
_hwndSource?.Dispose();
_notifyIcon?.Dispose();
animationSoundWMP?.Close();
animationSoundWPF?.Dispose();
SystemEvents.PowerModeChanged -= SystemEvents_PowerModeChanged;
}

_disposed = true;
Expand Down
Loading