diff --git a/qtc-net-client-2/Anims/left-horn-animated.gif b/qtc-net-client-2/Anims/left-horn-animated.gif new file mode 100644 index 0000000..23e093e Binary files /dev/null and b/qtc-net-client-2/Anims/left-horn-animated.gif differ diff --git a/qtc-net-client-2/Anims/right-horn-animated.gif b/qtc-net-client-2/Anims/right-horn-animated.gif new file mode 100644 index 0000000..429ac4f Binary files /dev/null and b/qtc-net-client-2/Anims/right-horn-animated.gif differ diff --git a/qtc-net-client-2/Forms/TokenJackpotSpinner.Designer.cs b/qtc-net-client-2/Forms/TokenJackpotSpinner.Designer.cs index 7c39bb2..cb2af41 100644 --- a/qtc-net-client-2/Forms/TokenJackpotSpinner.Designer.cs +++ b/qtc-net-client-2/Forms/TokenJackpotSpinner.Designer.cs @@ -30,23 +30,27 @@ { lblTokensWon = new Label(); btnClaim = new Button(); + pbHornLeft = new PictureBox(); + pbHornRight = new PictureBox(); + ((System.ComponentModel.ISupportInitialize)pbHornLeft).BeginInit(); + ((System.ComponentModel.ISupportInitialize)pbHornRight).BeginInit(); SuspendLayout(); // // lblTokensWon // - lblTokensWon.AutoSize = true; + lblTokensWon.AutoEllipsis = true; lblTokensWon.Font = new Font("Segoe UI Black", 13F); - lblTokensWon.Location = new Point(137, 30); + lblTokensWon.Location = new Point(145, 33); lblTokensWon.Name = "lblTokensWon"; - lblTokensWon.Size = new Size(137, 25); + lblTokensWon.Size = new Size(129, 25); lblTokensWon.TabIndex = 0; - lblTokensWon.Text = "0 Tokens Won"; + lblTokensWon.Text = "300 Q's Won"; lblTokensWon.TextAlign = ContentAlignment.MiddleCenter; // // btnClaim // btnClaim.Enabled = false; - btnClaim.Location = new Point(167, 76); + btnClaim.Location = new Point(173, 72); btnClaim.Name = "btnClaim"; btnClaim.Size = new Size(75, 23); btnClaim.TabIndex = 1; @@ -54,12 +58,36 @@ btnClaim.UseVisualStyleBackColor = true; btnClaim.Click += btnClaim_Click; // + // pbHornLeft + // + pbHornLeft.Image = Properties.Resources.right_horn_animated; + pbHornLeft.Location = new Point(12, 8); + pbHornLeft.Name = "pbHornLeft"; + pbHornLeft.Size = new Size(80, 100); + pbHornLeft.SizeMode = PictureBoxSizeMode.Zoom; + pbHornLeft.TabIndex = 2; + pbHornLeft.TabStop = false; + pbHornLeft.Visible = false; + // + // pbHornRight + // + pbHornRight.Image = Properties.Resources.left_horn_animated; + pbHornRight.Location = new Point(337, 8); + pbHornRight.Name = "pbHornRight"; + pbHornRight.Size = new Size(78, 101); + pbHornRight.SizeMode = PictureBoxSizeMode.Zoom; + pbHornRight.TabIndex = 3; + pbHornRight.TabStop = false; + pbHornRight.Visible = false; + // // TokenJackpotSpinner // AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; BackColor = Color.DodgerBlue; - ClientSize = new Size(427, 125); + ClientSize = new Size(427, 117); + Controls.Add(pbHornRight); + Controls.Add(pbHornLeft); Controls.Add(btnClaim); Controls.Add(lblTokensWon); DoubleBuffered = true; @@ -73,13 +101,16 @@ FormClosing += TokenJackpotSpinner_FormClosing; FormClosed += TokenJackpotSpinner_FormClosed; Load += TokenJackpotSpinner_Load; + ((System.ComponentModel.ISupportInitialize)pbHornLeft).EndInit(); + ((System.ComponentModel.ISupportInitialize)pbHornRight).EndInit(); ResumeLayout(false); - PerformLayout(); } #endregion private Label lblTokensWon; private Button btnClaim; + private PictureBox pbHornLeft; + private PictureBox pbHornRight; } } \ No newline at end of file diff --git a/qtc-net-client-2/Forms/TokenJackpotSpinner.cs b/qtc-net-client-2/Forms/TokenJackpotSpinner.cs index 2a3c8c9..a69c5d6 100644 --- a/qtc-net-client-2/Forms/TokenJackpotSpinner.cs +++ b/qtc-net-client-2/Forms/TokenJackpotSpinner.cs @@ -26,12 +26,15 @@ namespace qtc_net_client_2.Forms { btnClaim.Enabled = false; AllowClose = false; + + _audioService.OnSoundEnded += _audioService_OnSoundEnded; await StartSpinAnimation(lblTokensWon); } private void TokenJackpotSpinner_FormClosed(object sender, FormClosedEventArgs e) { DialogResult = DialogResult.OK; + _audioService.Dispose(); Close(); } @@ -46,6 +49,16 @@ namespace qtc_net_client_2.Forms Close(); } + private void _audioService_OnSoundEnded(object? sender, SoundEndedEventArgs e) + { + switch(e.EventString) + { + case "sndTokenWin": + DetermineWinAnim(); + break; + } + } + public async Task StartSpinAnimation(Label label) { if (label.IsHandleCreated) @@ -55,7 +68,7 @@ namespace qtc_net_client_2.Forms while (_audioService.OutputDevice?.PlaybackState == NAudio.Wave.PlaybackState.Playing) { - label.BeginInvoke(delegate () { label.Text = $"{rnd.Next(0, 300)} Tokens Won"; }); + label.BeginInvoke(delegate () { label.Text = $"{rnd.Next(0, 300)} Q's Won"; }); await Task.Delay(10); } @@ -63,15 +76,26 @@ namespace qtc_net_client_2.Forms label.BeginInvoke(delegate () { - label.Text = $"{win} Tokens Won"; + label.Text = $"{win} Q's Won"; btnClaim.Enabled = true; - _audioService.PlaySoundEffect("sndTokenWin"); + _audioService.PlaySoundEffectWithEventString("sndTokenWin", "sndTokenWin"); }); - _audioService.Dispose(); AllowClose = true; TokensWon = win; } } + + public void DetermineWinAnim() + { + switch(TokensWon) + { + case > 200: + pbHornLeft.BeginInvoke(delegate () { pbHornLeft.Visible = true; }); + pbHornRight.BeginInvoke(delegate () { pbHornRight.Visible = true; }); + _audioService.PlaySoundEffect("sndTokenJackpot"); + break; + } + } } } diff --git a/qtc-net-client-2/Properties/Resources.Designer.cs b/qtc-net-client-2/Properties/Resources.Designer.cs index c224803..63bca4a 100644 --- a/qtc-net-client-2/Properties/Resources.Designer.cs +++ b/qtc-net-client-2/Properties/Resources.Designer.cs @@ -140,6 +140,16 @@ namespace qtc_net_client_2.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap left_horn_animated { + get { + object obj = ResourceManager.GetObject("left-horn-animated", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// @@ -200,6 +210,16 @@ namespace qtc_net_client_2.Properties { } } + /// + /// Looks up a localized resource of type System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap right_horn_animated { + get { + object obj = ResourceManager.GetObject("right-horn-animated", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// diff --git a/qtc-net-client-2/Properties/Resources.resx b/qtc-net-client-2/Properties/Resources.resx index 8d7726e..d3e583e 100644 --- a/qtc-net-client-2/Properties/Resources.resx +++ b/qtc-net-client-2/Properties/Resources.resx @@ -118,6 +118,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + ..\Anims\right-horn-animated.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Icons\SendIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -139,6 +142,9 @@ ..\Icons\AwayIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Icons\CurrencyIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + ..\Icons\AddContactIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a @@ -160,7 +166,7 @@ ..\Icons\AcceptContactIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - - ..\Icons\CurrencyIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + ..\Anims\left-horn-animated.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a \ No newline at end of file diff --git a/qtc-net-client-2/Services/AudioService.cs b/qtc-net-client-2/Services/AudioService.cs index 942d28f..f3b02a8 100644 --- a/qtc-net-client-2/Services/AudioService.cs +++ b/qtc-net-client-2/Services/AudioService.cs @@ -12,6 +12,8 @@ namespace qtc_net_client_2.Services { public WaveOutEvent? OutputDevice { get; set; } public AudioFileReader? AudioFileReader { get; set; } + + public event EventHandler? OnSoundEnded; public void PlaySoundEffect(string soundName) { if (!File.Exists($"./Sounds/{soundName}.wav")) return; @@ -24,6 +26,18 @@ namespace qtc_net_client_2.Services return; } + public void PlaySoundEffectWithEventString(string soundName, string eventString) + { + if (!File.Exists($"./Sounds/{soundName}.wav")) return; + + OutputDevice = new WaveOutEvent(); + AudioFileReader = new AudioFileReader($"./Sounds/{soundName}.wav"); + OutputDevice.Init(AudioFileReader); + OutputDevice.Play(); + + OutputDevice.PlaybackStopped += (sender, args) => OnSoundEnded?.Invoke(null, new SoundEndedEventArgs { EventString = eventString }); + } + public void PlaySoundLooped(string soundName, int loopCount) { if (!File.Exists($"./Sounds/{soundName}.wav")) return; @@ -50,4 +64,9 @@ namespace qtc_net_client_2.Services if (AudioFileReader != null) { AudioFileReader.Dispose(); AudioFileReader = null; } } } + + public class SoundEndedEventArgs : EventArgs + { + public string EventString { get; set; } = "UNKNOWN"; + } }