#pragma once


namespace Mausereignisse {

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

	/// <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^  button1;
    protected: 
    private: System::Windows::Forms::ListBox^  listBox1;

    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)
		{
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->listBox1 = (gcnew System::Windows::Forms::ListBox());
			this->SuspendLayout();
			// 
			// button1
			// 
			this->button1->Location = System::Drawing::Point(79, 221);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(134, 23);
			this->button1->TabIndex = 0;
			this->button1->Text = L"Hier klicken";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
			this->button1->MouseClick += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::button1_MouseClick);
			this->button1->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::button1_MouseDown);
			this->button1->MouseEnter += gcnew System::EventHandler(this, &Form1::button1_MouseEnter);
			this->button1->MouseLeave += gcnew System::EventHandler(this, &Form1::button1_MouseLeave);
			this->button1->MouseHover += gcnew System::EventHandler(this, &Form1::button1_MouseHover);
			this->button1->MouseUp += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::button1_MouseUp);
			// 
			// listBox1
			// 
			this->listBox1->Dock = System::Windows::Forms::DockStyle::Right;
			this->listBox1->FormattingEnabled = true;
			this->listBox1->Location = System::Drawing::Point(297, 0);
			this->listBox1->Name = L"listBox1";
			this->listBox1->Size = System::Drawing::Size(148, 256);
			this->listBox1->TabIndex = 1;
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(445, 256);
			this->Controls->Add(this->listBox1);
			this->Controls->Add(this->button1);
			this->Name = L"Form1";
			this->Text = L"Mausereignisse";
			this->MouseClick += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::Form1_MouseClick);
			this->MouseMove += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::Form1_MouseMove);
			this->ResumeLayout(false);

		}
#pragma endregion


	private: 
		
        void Form1_MouseClick(Object^ sender, MouseEventArgs^ e) 
        {
            // nur auf Klicks der linken Maustaste reagieren
            if (e->Button == System::Windows::Forms::MouseButtons::Left)
            {
                // Graphics-Objekt zum Zeichen in Fenster besorgen
                Graphics ^g = this->CreateGraphics();

                // An Position des Mausklicks einen Kreis zeichnen
                g->DrawEllipse(Pens::Blue, e->X -5, e->Y -5, 10, 10);

                delete g;
            }
        }
        void button1_Click(Object^  sender, EventArgs^  e) 
        {
            listBox1->Items->Add("Click-Ereignis");
        }
        void button1_MouseClick(Object^  sender, MouseEventArgs^  e) 
        {
            listBox1->Items->Add("MouseClick-Ereignis");
        }
        void button1_MouseDown(Object^  sender, MouseEventArgs^  e)
        {
            listBox1->Items->Add("MouseDown-Ereignis");
        }
        void button1_MouseEnter(Object^  sender, EventArgs^  e)
        {
            listBox1->Items->Add("MouseEnter-Ereignis");
        }
        void button1_MouseHover(Object^  sender, EventArgs^  e)
        {
            listBox1->Items->Add("MouseHover-Ereignis");
        }
        void button1_MouseLeave(Object^  sender, EventArgs^  e) 
        {
            listBox1->Items->Add("MouseLeave-Ereignis");
        }
        void button1_MouseUp(Object^  sender, MouseEventArgs^  e) 
        {
            listBox1->Items->Add("MouseUp-Ereignis");
        }
        void Form1_MouseMove(Object^  sender, MouseEventArgs^  e) 
        {
            // Graphics-Objekt zum Zeichen in Fenster besorgen
            Graphics ^g = this->CreateGraphics();

            // An Position des Mausklicks einen Kreis zeichnen
            g->DrawRectangle(Pens::Black, e->X, e->Y, 1, 1);

            delete g;
        }
};
}

