#pragma once
#include "MDIChild.h"

namespace MDI {

	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
	///
	/// 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.
			//
         fensterToolStripMenuItem->Visible = false;
		}

	protected:
		/// <summary>
		/// Verwendete Ressourcen bereinigen.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
   private: System::Windows::Forms::MenuStrip^  menuStrip1;
   protected: 
   private: System::Windows::Forms::ToolStripMenuItem^  dateiToolStripMenuItem;
   private: System::Windows::Forms::ToolStripMenuItem^  neuToolStripMenuItem;
   private: System::Windows::Forms::ToolStripMenuItem^  öffnenToolStripMenuItem;
   private: System::Windows::Forms::ToolStripSeparator^  toolStripMenuItem1;
   private: System::Windows::Forms::ToolStripMenuItem^  beendenToolStripMenuItem;
   private: System::Windows::Forms::ToolStripMenuItem^  fensterToolStripMenuItem;
   private: System::Windows::Forms::ToolStripMenuItem^  neuesFensterToolStripMenuItem;
   private: System::Windows::Forms::ToolStripSeparator^  toolStripMenuItem2;
   private: System::Windows::Forms::ToolStripMenuItem^  überlappendToolStripMenuItem;
   private: System::Windows::Forms::ToolStripMenuItem^  untereinanderToolStripMenuItem;
   private: System::Windows::Forms::ToolStripMenuItem^  nebeneinanderToolStripMenuItem;
   private: System::Windows::Forms::ToolStripMenuItem^  alleSchließenToolStripMenuItem;
   private: System::Windows::Forms::ToolStripSeparator^  toolStripMenuItem3;

	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->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
         this->dateiToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
         this->neuToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
         this->öffnenToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
         this->toolStripMenuItem1 = (gcnew System::Windows::Forms::ToolStripSeparator());
         this->beendenToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
         this->fensterToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
         this->neuesFensterToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
         this->toolStripMenuItem2 = (gcnew System::Windows::Forms::ToolStripSeparator());
         this->überlappendToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
         this->untereinanderToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
         this->nebeneinanderToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
         this->alleSchließenToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
         this->toolStripMenuItem3 = (gcnew System::Windows::Forms::ToolStripSeparator());
         this->menuStrip1->SuspendLayout();
         this->SuspendLayout();
         // 
         // menuStrip1
         // 
         this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {this->dateiToolStripMenuItem, 
            this->fensterToolStripMenuItem});
         this->menuStrip1->Location = System::Drawing::Point(0, 0);
         this->menuStrip1->MdiWindowListItem = this->fensterToolStripMenuItem;
         this->menuStrip1->Name = L"menuStrip1";
         this->menuStrip1->Size = System::Drawing::Size(503, 24);
         this->menuStrip1->TabIndex = 1;
         this->menuStrip1->Text = L"menuStrip1";
         // 
         // dateiToolStripMenuItem
         // 
         this->dateiToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(4) {this->neuToolStripMenuItem, 
            this->öffnenToolStripMenuItem, this->toolStripMenuItem1, this->beendenToolStripMenuItem});
         this->dateiToolStripMenuItem->Name = L"dateiToolStripMenuItem";
         this->dateiToolStripMenuItem->Size = System::Drawing::Size(46, 20);
         this->dateiToolStripMenuItem->Text = L"&Datei";
         // 
         // neuToolStripMenuItem
         // 
         this->neuToolStripMenuItem->Name = L"neuToolStripMenuItem";
         this->neuToolStripMenuItem->Size = System::Drawing::Size(152, 22);
         this->neuToolStripMenuItem->Text = L"&Neu";
         this->neuToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::neuToolStripMenuItem_Click);
         // 
         // öffnenToolStripMenuItem
         // 
         this->öffnenToolStripMenuItem->Name = L"öffnenToolStripMenuItem";
         this->öffnenToolStripMenuItem->Size = System::Drawing::Size(152, 22);
         this->öffnenToolStripMenuItem->Text = L"Ö&ffnen";
         this->öffnenToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::öffnenToolStripMenuItem_Click);
         // 
         // toolStripMenuItem1
         // 
         this->toolStripMenuItem1->Name = L"toolStripMenuItem1";
         this->toolStripMenuItem1->Size = System::Drawing::Size(149, 6);
         // 
         // beendenToolStripMenuItem
         // 
         this->beendenToolStripMenuItem->Name = L"beendenToolStripMenuItem";
         this->beendenToolStripMenuItem->Size = System::Drawing::Size(152, 22);
         this->beendenToolStripMenuItem->Text = L"&Beenden";
         this->beendenToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::beendenToolStripMenuItem_Click);
         // 
         // fensterToolStripMenuItem
         // 
         this->fensterToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(7) {this->neuesFensterToolStripMenuItem, 
            this->toolStripMenuItem2, this->überlappendToolStripMenuItem, this->untereinanderToolStripMenuItem, this->nebeneinanderToolStripMenuItem, 
            this->alleSchließenToolStripMenuItem, this->toolStripMenuItem3});
         this->fensterToolStripMenuItem->Name = L"fensterToolStripMenuItem";
         this->fensterToolStripMenuItem->Size = System::Drawing::Size(57, 20);
         this->fensterToolStripMenuItem->Text = L"&Fenster";
         // 
         // neuesFensterToolStripMenuItem
         // 
         this->neuesFensterToolStripMenuItem->Name = L"neuesFensterToolStripMenuItem";
         this->neuesFensterToolStripMenuItem->Size = System::Drawing::Size(155, 22);
         this->neuesFensterToolStripMenuItem->Text = L"Neues &Fenster";
         this->neuesFensterToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::neuesFensterToolStripMenuItem_Click);
         // 
         // toolStripMenuItem2
         // 
         this->toolStripMenuItem2->Name = L"toolStripMenuItem2";
         this->toolStripMenuItem2->Size = System::Drawing::Size(152, 6);
         // 
         // überlappendToolStripMenuItem
         // 
         this->überlappendToolStripMenuItem->Name = L"überlappendToolStripMenuItem";
         this->überlappendToolStripMenuItem->Size = System::Drawing::Size(155, 22);
         this->überlappendToolStripMenuItem->Text = L"Ü&berlappend";
         this->überlappendToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::überlappendToolStripMenuItem_Click);
         // 
         // untereinanderToolStripMenuItem
         // 
         this->untereinanderToolStripMenuItem->Name = L"untereinanderToolStripMenuItem";
         this->untereinanderToolStripMenuItem->Size = System::Drawing::Size(155, 22);
         this->untereinanderToolStripMenuItem->Text = L"&Untereinander";
         this->untereinanderToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::untereinanderToolStripMenuItem_Click);
         // 
         // nebeneinanderToolStripMenuItem
         // 
         this->nebeneinanderToolStripMenuItem->Name = L"nebeneinanderToolStripMenuItem";
         this->nebeneinanderToolStripMenuItem->Size = System::Drawing::Size(155, 22);
         this->nebeneinanderToolStripMenuItem->Text = L"&Nebeneinander";
         this->nebeneinanderToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::nebeneinanderToolStripMenuItem_Click);
         // 
         // alleSchließenToolStripMenuItem
         // 
         this->alleSchließenToolStripMenuItem->Name = L"alleSchließenToolStripMenuItem";
         this->alleSchließenToolStripMenuItem->Size = System::Drawing::Size(155, 22);
         this->alleSchließenToolStripMenuItem->Text = L"&Alle schließen";
         this->alleSchließenToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::alleSchließenToolStripMenuItem_Click);
         // 
         // toolStripMenuItem3
         // 
         this->toolStripMenuItem3->Name = L"toolStripMenuItem3";
         this->toolStripMenuItem3->Size = System::Drawing::Size(152, 6);
         // 
         // Form1
         // 
         this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
         this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
         this->ClientSize = System::Drawing::Size(503, 339);
         this->Controls->Add(this->menuStrip1);
         this->IsMdiContainer = true;
         this->MainMenuStrip = this->menuStrip1;
         this->Name = L"Form1";
         this->Text = L"Hauptfenster";
         this->MdiChildActivate += gcnew System::EventHandler(this, &Form1::Form1_MdiChildActivate);
         this->menuStrip1->ResumeLayout(false);
         this->menuStrip1->PerformLayout();
         this->ResumeLayout(false);
         this->PerformLayout();

      }
#pragma endregion
   private: 
      void neuToolStripMenuItem_Click(Object^  sender, EventArgs^  e) 
      {
         MDIChild^ mdiChild = gcnew MDIChild();
         mdiChild->MdiParent = this;
         mdiChild->Show();

         fensterToolStripMenuItem->Visible = true;
      }
      void öffnenToolStripMenuItem_Click(Object^  sender, EventArgs^  e) 
      {
         MDIChild^ mdiChild = gcnew MDIChild();
         mdiChild->MdiParent = this;

         // Hier würde an sich der Datei öffnen-Dialog
         // aufgerufen. Die MDI-Kindfenster sollte möglichst eine Methode
         // definieren, die den Namen der ausgewählten Datei
         // übernimmt und einliest.

         mdiChild->Show();
         fensterToolStripMenuItem->Visible = true;
      }
      void beendenToolStripMenuItem_Click(Object^  sender, EventArgs^  e) 
      {
         Close();
      }


      void  Form1_MdiChildActivate(Object^  sender, EventArgs^  e) 
      {
         if (this->ActiveMdiChild == nullptr)
            fensterToolStripMenuItem->Visible = false;
      }


      // Fenster / Neues Fenster
      // Dieser Menübefehl sollte eigentlich eine Kopie des 
      // gerade aktiven Kind-fensters erzeugen. Dienen die 
      // Kindfenster der Bearbeitung bestimmter Dokumente gehört
      // dazu auch, dass das neue Fenster die gleiche Datei 
      // lädt. Hier wird jedoch der Einfachheit halber nur ein 
      // neues Fenster erzeugt.
      void neuesFensterToolStripMenuItem_Click(Object^  sender, EventArgs^  e) 
      {
         MDIChild^ mdiChild = gcnew MDIChild();
         mdiChild->MdiParent = this;
         mdiChild->Show();
      }
      void überlappendToolStripMenuItem_Click(Object^  sender, EventArgs^  e) 
      {
         LayoutMdi(MdiLayout::Cascade);
      }
      void untereinanderToolStripMenuItem_Click(Object^  sender, EventArgs^  e) 
      {
         LayoutMdi(MdiLayout::TileHorizontal);
      }
      void nebeneinanderToolStripMenuItem_Click(Object^  sender, EventArgs^  e) 
      {
         LayoutMdi(MdiLayout::TileVertical);
      }
      void alleSchließenToolStripMenuItem_Click(Object^  sender, EventArgs^  e) 
      {
         for each (Form ^mdiChild in MdiChildren)
             mdiChild->Close();
      }
};
}

