#pragma once
#include "Auto.h"

namespace Demo_Klassen_anlegen {

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

	/// <summary>
	/// Zusammenfassung für Form1
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Auto ^VW_Golf;
		Auto ^BMW;
	private: System::Windows::Forms::Label^  label1;
	public: 
		Auto ^Porsche;

	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Konstruktorcode hier hinzufügen.
			//
			VW_Golf = gcnew Auto();
			BMW = gcnew Auto();
			Porsche  = gcnew Auto();			
		}

	protected:
		/// <summary>
		/// Verwendete Ressourcen bereinigen.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::ListBox^  listBox1;
	protected: 
	private: System::Windows::Forms::Button^  button2;
	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->listBox1 = (gcnew System::Windows::Forms::ListBox());
			this->button2 = (gcnew System::Windows::Forms::Button());
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->SuspendLayout();
			// 
			// listBox1
			// 
			this->listBox1->Anchor = System::Windows::Forms::AnchorStyles::None;
			this->listBox1->FormattingEnabled = true;
			this->listBox1->Items->AddRange(gcnew cli::array< System::Object^  >(3) {L"VW Golf", L"BMW", L"Porsche"});
			this->listBox1->Location = System::Drawing::Point(116, 46);
			this->listBox1->Name = L"listBox1";
			this->listBox1->Size = System::Drawing::Size(52, 43);
			this->listBox1->TabIndex = 5;
			this->listBox1->SelectedIndexChanged += gcnew System::EventHandler(this, &Form1::listBox1_SelectedIndexChanged);
			// 
			// button2
			// 
			this->button2->Anchor = System::Windows::Forms::AnchorStyles::None;
			this->button2->Location = System::Drawing::Point(100, 166);
			this->button2->Name = L"button2";
			this->button2->Size = System::Drawing::Size(84, 23);
			this->button2->TabIndex = 4;
			this->button2->Text = L"bremsen";
			this->button2->UseVisualStyleBackColor = true;
			this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
			// 
			// button1
			// 
			this->button1->Anchor = System::Windows::Forms::AnchorStyles::None;
			this->button1->Location = System::Drawing::Point(100, 136);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(84, 23);
			this->button1->TabIndex = 3;
			this->button1->Text = L"beschleunigen";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
			// 
			// label1
			// 
			this->label1->Anchor = System::Windows::Forms::AnchorStyles::None;
			this->label1->AutoSize = true;
			this->label1->Location = System::Drawing::Point(94, 98);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(0, 13);
			this->label1->TabIndex = 6;
			this->label1->TextAlign = System::Drawing::ContentAlignment::MiddleCenter;
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(284, 264);
			this->Controls->Add(this->label1);
			this->Controls->Add(this->listBox1);
			this->Controls->Add(this->button2);
			this->Controls->Add(this->button1);
			this->Name = L"Form1";
			this->Text = L"Demo Klassen anlegen";
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	private: System::Void listBox1_SelectedIndexChanged(System::Object^  sender, System::EventArgs^  e) {
				 if (listBox1->SelectedIndex != -1)
				 {
					 if(listBox1->SelectedItem->ToString() == "VW Golf")					 
						 label1->Text = "Geschwindigkeit: " + VW_Golf->Geschwindigkeit.ToString();
					 if(listBox1->SelectedItem->ToString() == "BMW")
						 label1->Text = "Geschwindigkeit: " + BMW->Geschwindigkeit.ToString();
					 if(listBox1->SelectedItem->ToString() == "Porsche")						 
						 label1->Text = "Geschwindigkeit: " + Porsche->Geschwindigkeit.ToString();
				 }
			 }
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
				 if (listBox1->SelectedIndex != -1)
				 {
					 if(listBox1->SelectedItem->ToString() == "VW Golf")
					 {
						 VW_Golf->beschleunigen(5);
						 label1->Text = "Geschwindigkeit: " + VW_Golf->Geschwindigkeit.ToString();
					 }
					 if(listBox1->SelectedItem->ToString() == "BMW")
					 {
						 BMW->beschleunigen(15);
						 label1->Text = "Geschwindigkeit: " + BMW->Geschwindigkeit.ToString();
					 }
					 if(listBox1->SelectedItem->ToString() == "Porsche")
					 {
						 Porsche->beschleunigen(30);
						 label1->Text = "Geschwindigkeit: " + Porsche->Geschwindigkeit.ToString();
					 }
				 }

			 }
	private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
				 if (listBox1->SelectedIndex != -1)
				 {
					 if(listBox1->SelectedItem->ToString() == "VW Golf")
					 {
						 VW_Golf->Geschwindigkeit = 0;
						 label1->Text = "Geschwindigkeit: " + VW_Golf->Geschwindigkeit.ToString();
					 }
					 if(listBox1->SelectedItem->ToString() == "BMW")
					 {
						 BMW->Geschwindigkeit = 0;
						 label1->Text = "Geschwindigkeit: " + BMW->Geschwindigkeit.ToString();
					 }
					 if(listBox1->SelectedItem->ToString() == "Porsche")
					 {
						 Porsche->Geschwindigkeit = 0;
						 label1->Text = "Geschwindigkeit: " + Porsche->Geschwindigkeit.ToString();
					 }
				 }
			 }
	};
}

