private async void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { DragMove(); if (!isPlaying) { // Manually rewind that storyboard to the beginning because I am sick of WPF's bullshit SharkleBubbleFlickerAnim.Seek(TimeSpan.Zero); // Start waving SharkleWavingAnim.Begin(); SharkleShowBubblesAnim.Begin(); // Play a sound and wait for it to end // When isPlaying == true, clicking on Sharkle will do nothing isPlaying = true; await Task.Run(() => { var sndResource = App.GetResourceStream(new Uri(this.HeySource)); var sndPlayer = new SoundPlayer(sndResource.Stream); sndPlayer.PlaySync(); }); isPlaying = false; // Fetch a new sound bite OnPropertyChanged("HeySource"); } }
private void Window_Loaded(object sender, RoutedEventArgs e) { var workingArea = SystemParameters.WorkArea; var padding = 20; this.Left = workingArea.Right - this.Width - padding; this.Top = workingArea.Bottom - this.Height - padding; SharkleIdleAnim = (Storyboard)FindResource("SharkleIdleAnim"); SharkleBubbleFlickerAnim = (Storyboard)FindResource("SharkleBubbleFlickerAnim"); SharkleWavingAnim = (Storyboard)FindResource("SharkleWavingAnim"); SharkleShowBubblesAnim = (Storyboard)FindResource("SharkleShowBubblesAnim"); SharkleIcon = (TaskbarIcon)FindResource("SharkleIcon"); // I'm starting these two Storyboards manually here because otherwise, the .Seek()s below won't work SharkleIdleAnim.Begin(); SharkleBubbleFlickerAnim.Begin(); }