#pragma once


namespace Sound {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Media;
	using namespace System::Drawing;

	/// <summary>
	/// Zusammenfassung für Form1
	///
	/// Warnung: Wenn Sie den Namen dieser Klasse ändern, müssen Sie auch
	///          die Ressourcendateiname-Eigenschaft für das Tool zur Kompilierung verwalteter Ressourcen ändern,
	///          das allen RESX-Dateien zugewiesen ist, von denen diese Klasse abhängt.
	///          Anderenfalls können die Designer nicht korrekt mit den lokalisierten Ressourcen
	///          arbeiten, die diesem Formular zugewiesen sind.
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Konstruktorcode hier hinzufügen.
			//
		}

	protected:
		/// <summary>
		/// Verwendete Ressourcen bereinigen.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
   private: System::Windows::Forms::Button^  button6;
   protected: 
   private: System::Windows::Forms::Label^  label6;
   private: System::Windows::Forms::Button^  button5;
   private: System::Windows::Forms::Label^  label5;
   private: System::Windows::Forms::Button^  button4;
   private: System::Windows::Forms::Label^  label4;
   private: System::Windows::Forms::Button^  button3;
   private: System::Windows::Forms::Label^  label3;
   private: System::Windows::Forms::Button^  button2;
   private: System::Windows::Forms::Label^  label2;
   private: System::Windows::Forms::Label^  label1;
   private: System::Windows::Forms::Button^  button1;

	private:
		/// <summary>
		/// Erforderliche Designervariable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Erforderliche Methode für die Designerunterstützung.
		/// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden.
		/// </summary>
		void InitializeComponent(void)
		{
         this->button6 = (gcnew System::Windows::Forms::Button());
         this->label6 = (gcnew System::Windows::Forms::Label());
         this->button5 = (gcnew System::Windows::Forms::Button());
         this->label5 = (gcnew System::Windows::Forms::Label());
         this->button4 = (gcnew System::Windows::Forms::Button());
         this->label4 = (gcnew System::Windows::Forms::Label());
         this->button3 = (gcnew System::Windows::Forms::Button());
         this->label3 = (gcnew System::Windows::Forms::Label());
         this->button2 = (gcnew System::Windows::Forms::Button());
         this->label2 = (gcnew System::Windows::Forms::Label());
         this->label1 = (gcnew System::Windows::Forms::Label());
         this->button1 = (gcnew System::Windows::Forms::Button());
         this->SuspendLayout();
         // 
         // button6
         // 
         this->button6->Location = System::Drawing::Point(295, 241);
         this->button6->Name = L"button6";
         this->button6->Size = System::Drawing::Size(75, 23);
         this->button6->TabIndex = 23;
         this->button6->Text = L"Play";
         this->button6->UseVisualStyleBackColor = true;
         this->button6->Click += gcnew System::EventHandler(this, &Form1::button6_Click);
         // 
         // label6
         // 
         this->label6->AutoSize = true;
         this->label6->Location = System::Drawing::Point(121, 246);
         this->label6->Name = L"label6";
         this->label6->Size = System::Drawing::Size(60, 13);
         this->label6->TabIndex = 22;
         this->label6->Text = L"WAV-Datei";
         // 
         // button5
         // 
         this->button5->Location = System::Drawing::Point(295, 201);
         this->button5->Name = L"button5";
         this->button5->Size = System::Drawing::Size(75, 23);
         this->button5->TabIndex = 21;
         this->button5->Text = L"Play";
         this->button5->UseVisualStyleBackColor = true;
         this->button5->Click += gcnew System::EventHandler(this, &Form1::button5_Click);
         // 
         // label5
         // 
         this->label5->AutoSize = true;
         this->label5->Location = System::Drawing::Point(121, 206);
         this->label5->Name = L"label5";
         this->label5->Size = System::Drawing::Size(122, 13);
         this->label5->TabIndex = 20;
         this->label5->Text = L"SystemSounds.Question";
         // 
         // button4
         // 
         this->button4->Location = System::Drawing::Point(295, 161);
         this->button4->Name = L"button4";
         this->button4->Size = System::Drawing::Size(75, 23);
         this->button4->TabIndex = 19;
         this->button4->Text = L"Play";
         this->button4->UseVisualStyleBackColor = true;
         this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);
         // 
         // label4
         // 
         this->label4->AutoSize = true;
         this->label4->Location = System::Drawing::Point(121, 166);
         this->label4->Name = L"label4";
         this->label4->Size = System::Drawing::Size(106, 13);
         this->label4->TabIndex = 18;
         this->label4->Text = L"SystemSounds.Hand";
         // 
         // button3
         // 
         this->button3->Location = System::Drawing::Point(295, 121);
         this->button3->Name = L"button3";
         this->button3->Size = System::Drawing::Size(75, 23);
         this->button3->TabIndex = 17;
         this->button3->Text = L"Play";
         this->button3->UseVisualStyleBackColor = true;
         this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
         // 
         // label3
         // 
         this->label3->AutoSize = true;
         this->label3->Location = System::Drawing::Point(121, 126);
         this->label3->Name = L"label3";
         this->label3->Size = System::Drawing::Size(137, 13);
         this->label3->TabIndex = 16;
         this->label3->Text = L"SystemSounds.Exclamation";
         // 
         // button2
         // 
         this->button2->Location = System::Drawing::Point(295, 81);
         this->button2->Name = L"button2";
         this->button2->Size = System::Drawing::Size(75, 23);
         this->button2->TabIndex = 15;
         this->button2->Text = L"Play";
         this->button2->UseVisualStyleBackColor = true;
         this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
         // 
         // label2
         // 
         this->label2->AutoSize = true;
         this->label2->Location = System::Drawing::Point(121, 86);
         this->label2->Name = L"label2";
         this->label2->Size = System::Drawing::Size(105, 13);
         this->label2->TabIndex = 14;
         this->label2->Text = L"SystemSounds.Beep";
         // 
         // label1
         // 
         this->label1->AutoSize = true;
         this->label1->Location = System::Drawing::Point(121, 46);
         this->label1->Name = L"label1";
         this->label1->Size = System::Drawing::Size(117, 13);
         this->label1->TabIndex = 13;
         this->label1->Text = L"SystemSounds.Asterisk";
         // 
         // button1
         // 
         this->button1->Location = System::Drawing::Point(295, 41);
         this->button1->Name = L"button1";
         this->button1->Size = System::Drawing::Size(75, 23);
         this->button1->TabIndex = 12;
         this->button1->Text = L"Play";
         this->button1->UseVisualStyleBackColor = true;
         this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
         // 
         // Form1
         // 
         this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
         this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
         this->ClientSize = System::Drawing::Size(490, 304);
         this->Controls->Add(this->button6);
         this->Controls->Add(this->label6);
         this->Controls->Add(this->button5);
         this->Controls->Add(this->label5);
         this->Controls->Add(this->button4);
         this->Controls->Add(this->label4);
         this->Controls->Add(this->button3);
         this->Controls->Add(this->label3);
         this->Controls->Add(this->button2);
         this->Controls->Add(this->label2);
         this->Controls->Add(this->label1);
         this->Controls->Add(this->button1);
         this->Name = L"Form1";
         this->Text = L"Sound";
         this->ResumeLayout(false);
         this->PerformLayout();

      }
#pragma endregion
   private: 
      void button1_Click(Object^  sender, EventArgs^  e) 
      {
         SystemSounds::Asterisk->Play();
      }
      void button2_Click(Object^  sender, EventArgs^  e) 
      {
         SystemSounds::Beep->Play();
      }
      void button3_Click(Object^  sender, EventArgs^  e) 
      {
         SystemSounds::Exclamation->Play();
      }
      void button4_Click(Object^  sender, EventArgs^  e) 
      {
         SystemSounds::Hand->Play();
      }
      void button5_Click(Object^  sender, EventArgs^  e) 
      {
         SystemSounds::Question->Play();
      }
      void button6_Click(Object^  sender, EventArgs^  e) 
      {
            SoundPlayer^ player = gcnew SoundPlayer();
            player->SoundLocation = "tada.wav";
            //player->Play();
            
            player->LoadCompleted += gcnew AsyncCompletedEventHandler(this, &Form1::player_LoadCompleted);
            player->LoadAsync();
      }
      void player_LoadCompleted(Object^  sender, AsyncCompletedEventArgs ^e)
      {
            SoundPlayer^ player = dynamic_cast<SoundPlayer^>(sender);
            
            if (player != nullptr)
                player->PlaySync();
      }
};
}

