#pragma once

namespace Tastaturereignisse {

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:
	Form1(void)
	{
		InitializeComponent();
		//
		//TODO: Konstruktorcode hier hinzufügen.
		//
	}

protected:
	/// <summary>
	/// Verwendete Ressourcen bereinigen.
	/// </summary>
	~Form1()
	{
		if (components)
		{
			delete components;
		}
	}
private: System::Windows::Forms::PictureBox^  pictureBox1;
private: System::Windows::Forms::TextBox^  textBox1;
protected: 

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)
	{
		System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
		this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
		this->textBox1 = (gcnew System::Windows::Forms::TextBox());
		(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->BeginInit();
		this->SuspendLayout();
		// 
		// pictureBox1
		// 
		this->pictureBox1->Image = (cli::safe_cast<System::Drawing::Image^  >(resources->GetObject(L"pictureBox1.Image")));
		this->pictureBox1->Location = System::Drawing::Point(212, 82);
		this->pictureBox1->Name = L"pictureBox1";
		this->pictureBox1->Size = System::Drawing::Size(272, 220);
		this->pictureBox1->SizeMode = System::Windows::Forms::PictureBoxSizeMode::AutoSize;
		this->pictureBox1->TabIndex = 0;
		this->pictureBox1->TabStop = false;
		// 
		// textBox1
		// 
		this->textBox1->Enabled = false;
		this->textBox1->Location = System::Drawing::Point(13, 13);
		this->textBox1->Multiline = true;
		this->textBox1->Name = L"textBox1";
		this->textBox1->ReadOnly = true;
		this->textBox1->Size = System::Drawing::Size(485, 40);
		this->textBox1->TabIndex = 1;
		this->textBox1->Text = L"Durch Drücken der Pfeiltasten oder der Tasten a,w,s,d können Sie das UFO um 1 Pix" 
			L"el verschieben.  Wenn Sie gleichzeitig die Umschalt-Taste gedrückt halten, versc" 
			L"hieben Sie um 10 Pixel.";
		// 
		// Form1
		// 
		this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
		this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
		this->ClientSize = System::Drawing::Size(697, 404);
		this->Controls->Add(this->textBox1);
		this->Controls->Add(this->pictureBox1);
		this->Name = L"Form1";
		this->Text = L"Tastaturereignisse";
		this->KeyDown += gcnew System::Windows::Forms::KeyEventHandler(this, &Form1::Form1_KeyDown);
		this->KeyPress += gcnew System::Windows::Forms::KeyPressEventHandler(this, &Form1::Form1_KeyPress);
		(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->EndInit();
		this->ResumeLayout(false);
		this->PerformLayout();

	}
#pragma endregion
private: 
	void Form1_KeyDown(Object^  sender, KeyEventArgs^  e) 
	{
		// Abfragen einer Tastenkombination über KeyData
        if (e->KeyData == (Keys::Shift | Keys::A))
        {
            pictureBox1->Left -= 10;			
        }
        else if (e->KeyData == (Keys::Shift | Keys::W))
        {
            pictureBox1->Top -= 10;				
        }
        else if (e->KeyData == (Keys::Shift | Keys::S))
        {
            pictureBox1->Top += 10;				
        }
        else if (e->KeyData == (Keys::Shift | Keys::D))
        {
            pictureBox1->Left += 10;				
        }

		// Abfragen einer Taste über KeyCode
        if (e->KeyCode == Keys::Left)
        {
            pictureBox1->Left -= 1;			
        }
        else if (e->KeyCode == Keys::Up)
        {
            pictureBox1->Top -= 1;				
        }
        else if (e->KeyCode == Keys::Down)
        {
            pictureBox1->Top += 1;				
        }
        else if (e->KeyCode == Keys::Right)
        {
            pictureBox1->Left += 1;				
        }

		// Abfragen einer Tastenkombination über KeyCode und Modifiers
        if (e->KeyCode == Keys::Left && e->Modifiers == Keys::Shift)
        {
            pictureBox1->Left -= 10;			
        }
        else if (e->KeyCode == Keys::Up && e->Modifiers == Keys::Shift)
        {
            pictureBox1->Top -= 10;				
        }
        else if (e->KeyCode == Keys::Down && e->Modifiers == Keys::Shift)
        {
            pictureBox1->Top += 10;				
        }
        else if (e->KeyCode == Keys::Right && e->Modifiers == Keys::Shift)
        {
            pictureBox1->Left += 10;				
        }			
	}

	void Form1_KeyPress(Object^  sender, KeyPressEventArgs^  e) 
	{
		// Abfragen einer Taste über KeyChar
		if (e->KeyChar == 'a')
		{
			pictureBox1->Left -= 1;			
		}
		else if (e->KeyChar == 'w')
		{
			pictureBox1->Top -= 1;			
		}
		else if (e->KeyChar == 's')
		{
			pictureBox1->Top += 1;			
		}
		else if (e->KeyChar == 'd')
		{
			pictureBox1->Left += 1;			
		}
	}
};
}

