From 30625845d1eca0c35cbc6b138085d036010cedb5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommy=20=C3=96man?= Date: Wed, 13 Jul 2022 22:59:19 +0200 Subject: [PATCH] Inferred sound handling --- WinGreed/frmStart.Designer.cs | 14 ++++++++++++++ WinGreed/frmStart.cs | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/WinGreed/frmStart.Designer.cs b/WinGreed/frmStart.Designer.cs index bdd3f1b..cf3ffc2 100644 --- a/WinGreed/frmStart.Designer.cs +++ b/WinGreed/frmStart.Designer.cs @@ -37,6 +37,7 @@ this.btnAddPlayer = new System.Windows.Forms.Button(); this.txtNewName = new System.Windows.Forms.TextBox(); this.btnAddOk = new System.Windows.Forms.Button(); + this.btnSound = new System.Windows.Forms.Button(); this.SuspendLayout(); // // label1 @@ -122,11 +123,23 @@ this.btnAddOk.Visible = false; this.btnAddOk.Click += new System.EventHandler(this.btnAddOk_Click); // + // btnSound + // + this.btnSound.Location = new System.Drawing.Point(350, 34); + this.btnSound.Name = "btnSound"; + this.btnSound.Size = new System.Drawing.Size(75, 23); + this.btnSound.TabIndex = 6; + this.btnSound.Text = "sound"; + this.btnSound.UseVisualStyleBackColor = true; + this.btnSound.Visible = false; + this.btnSound.Click += new System.EventHandler(this.btnSound_Click); + // // frmStart // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.btnSound); this.Controls.Add(this.btnAddOk); this.Controls.Add(this.txtNewName); this.Controls.Add(this.btnAddPlayer); @@ -152,5 +165,6 @@ private Button btnAddPlayer; private TextBox txtNewName; private Button btnAddOk; + private Button btnSound; } } \ No newline at end of file diff --git a/WinGreed/frmStart.cs b/WinGreed/frmStart.cs index 4ac58c3..f6649ba 100644 --- a/WinGreed/frmStart.cs +++ b/WinGreed/frmStart.cs @@ -1,3 +1,5 @@ +using System.Media; + namespace WinGreed { public partial class frmStart : Form @@ -64,5 +66,17 @@ namespace WinGreed btnAddOk.Visible = false; } } + + private void PlaySomething() + { + var soundPlayer = new SoundPlayer(); + soundPlayer.SoundLocation = @"C:\Users\tommy\Downloads\smartsound_HUMAN_CROWD_Applause_Short.wav"; + soundPlayer.Play(); + } + + private void btnSound_Click(object sender, EventArgs e) + { + PlaySomething(); + } } } \ No newline at end of file