#pragma once


namespace drukowanie {

	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>
	/// Summary for Form1
	///
	/// WARNING: If you change the name of this class, you will need to change the
	///          'Resource File Name' property for the managed resource compiler tool
	///          associated with all .resx files this class depends on.  Otherwise,
	///          the designers will not be able to interact properly with localized
	///          resources associated with this form.
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Drawing::Printing::PrintDocument^  printDocument1;

	private: System::Windows::Forms::PictureBox^  pictureBox1;

	private: System::Windows::Forms::MenuStrip^  menuStrip1;
	private: System::Windows::Forms::ToolStripMenuItem^  plikToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  otworzToolStripMenuItem;

	private: System::Windows::Forms::ToolStripMenuItem^  drukujToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  wyjdzToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  zmienToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  obrotToolStripMenuItem;



	private: System::Windows::Forms::OpenFileDialog^  openFileDialog1;
	private: System::Windows::Forms::ToolStripMenuItem^  podgladWydrukuToolStripMenuItem;
	private: System::Windows::Forms::PrintPreviewDialog^  printPreviewDialog1;
	private: System::Windows::Forms::ToolStripMenuItem^  ustawieniaToolStripMenuItem;
	private: System::Windows::Forms::PageSetupDialog^  pageSetupDialog1;
	protected: 

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
			this->printDocument1 = (gcnew System::Drawing::Printing::PrintDocument());
			this->pictureBox1 = (gcnew System::Windows::Forms::PictureBox());
			this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
			this->plikToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->otworzToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->ustawieniaToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->podgladWydrukuToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->drukujToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->wyjdzToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->zmienToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->obrotToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->openFileDialog1 = (gcnew System::Windows::Forms::OpenFileDialog());
			this->printPreviewDialog1 = (gcnew System::Windows::Forms::PrintPreviewDialog());
			this->pageSetupDialog1 = (gcnew System::Windows::Forms::PageSetupDialog());
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->BeginInit();
			this->menuStrip1->SuspendLayout();
			this->SuspendLayout();
			// 
			// printDocument1
			// 
			this->printDocument1->PrintPage += gcnew System::Drawing::Printing::PrintPageEventHandler(this, &Form1::printDocument1_PrintPage);
			// 
			// pictureBox1
			// 
			this->pictureBox1->Location = System::Drawing::Point(12, 42);
			this->pictureBox1->Name = L"pictureBox1";
			this->pictureBox1->Size = System::Drawing::Size(471, 364);
			this->pictureBox1->TabIndex = 1;
			this->pictureBox1->TabStop = false;
			// 
			// menuStrip1
			// 
			this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {this->plikToolStripMenuItem, 
				this->zmienToolStripMenuItem});
			this->menuStrip1->Location = System::Drawing::Point(0, 0);
			this->menuStrip1->Name = L"menuStrip1";
			this->menuStrip1->Size = System::Drawing::Size(495, 24);
			this->menuStrip1->TabIndex = 3;
			this->menuStrip1->Text = L"menuStrip1";
			// 
			// plikToolStripMenuItem
			// 
			this->plikToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(5) {this->otworzToolStripMenuItem, 
				this->ustawieniaToolStripMenuItem, this->podgladWydrukuToolStripMenuItem, this->drukujToolStripMenuItem, this->wyjdzToolStripMenuItem});
			this->plikToolStripMenuItem->Name = L"plikToolStripMenuItem";
			this->plikToolStripMenuItem->Size = System::Drawing::Size(34, 20);
			this->plikToolStripMenuItem->Text = L"Plik";
			// 
			// otworzToolStripMenuItem
			// 
			this->otworzToolStripMenuItem->Name = L"otworzToolStripMenuItem";
			this->otworzToolStripMenuItem->Size = System::Drawing::Size(167, 22);
			this->otworzToolStripMenuItem->Text = L"Otwórz";
			this->otworzToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::otworzToolStripMenuItem_Click);
			// 
			// ustawieniaToolStripMenuItem
			// 
			this->ustawieniaToolStripMenuItem->Name = L"ustawieniaToolStripMenuItem";
			this->ustawieniaToolStripMenuItem->Size = System::Drawing::Size(167, 22);
			this->ustawieniaToolStripMenuItem->Text = L"Ustawienia";
			this->ustawieniaToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::ustawieniaToolStripMenuItem_Click);
			// 
			// podgladWydrukuToolStripMenuItem
			// 
			this->podgladWydrukuToolStripMenuItem->Name = L"podgladWydrukuToolStripMenuItem";
			this->podgladWydrukuToolStripMenuItem->Size = System::Drawing::Size(167, 22);
			this->podgladWydrukuToolStripMenuItem->Text = L"Podglad wydruku";
			this->podgladWydrukuToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::podgladWydrukuToolStripMenuItem_Click);
			// 
			// drukujToolStripMenuItem
			// 
			this->drukujToolStripMenuItem->Name = L"drukujToolStripMenuItem";
			this->drukujToolStripMenuItem->Size = System::Drawing::Size(167, 22);
			this->drukujToolStripMenuItem->Text = L"Drukuj";
			this->drukujToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::drukujToolStripMenuItem_Click);
			// 
			// wyjdzToolStripMenuItem
			// 
			this->wyjdzToolStripMenuItem->Name = L"wyjdzToolStripMenuItem";
			this->wyjdzToolStripMenuItem->Size = System::Drawing::Size(167, 22);
			this->wyjdzToolStripMenuItem->Text = L"Wyjd";
			this->wyjdzToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::wyjdzToolStripMenuItem_Click);
			// 
			// zmienToolStripMenuItem
			// 
			this->zmienToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) {this->obrotToolStripMenuItem});
			this->zmienToolStripMenuItem->Name = L"zmienToolStripMenuItem";
			this->zmienToolStripMenuItem->Size = System::Drawing::Size(47, 20);
			this->zmienToolStripMenuItem->Text = L"Zmień";
			// 
			// obrotToolStripMenuItem
			// 
			this->obrotToolStripMenuItem->Name = L"obrotToolStripMenuItem";
			this->obrotToolStripMenuItem->Size = System::Drawing::Size(152, 22);
			this->obrotToolStripMenuItem->Text = L"Obrót";
			this->obrotToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::obrotToolStripMenuItem_Click);
			// 
			// openFileDialog1
			// 
			this->openFileDialog1->FileName = L"openFileDialog1";
			// 
			// printPreviewDialog1
			// 
			this->printPreviewDialog1->AutoScrollMargin = System::Drawing::Size(0, 0);
			this->printPreviewDialog1->AutoScrollMinSize = System::Drawing::Size(0, 0);
			this->printPreviewDialog1->ClientSize = System::Drawing::Size(400, 300);
			this->printPreviewDialog1->Enabled = true;
			this->printPreviewDialog1->Icon = (cli::safe_cast<System::Drawing::Icon^  >(resources->GetObject(L"printPreviewDialog1.Icon")));
			this->printPreviewDialog1->Name = L"printPreviewDialog1";
			this->printPreviewDialog1->Visible = false;
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(495, 447);
			this->Controls->Add(this->pictureBox1);
			this->Controls->Add(this->menuStrip1);
			this->MainMenuStrip = this->menuStrip1;
			this->Name = L"Form1";
			this->Text = L"Form1";
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->pictureBox1))->EndInit();
			this->menuStrip1->ResumeLayout(false);
			this->menuStrip1->PerformLayout();
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
				
			 }
	private: System::Void printDocument1_PrintPage(System::Object^  sender, System::Drawing::Printing::PrintPageEventArgs^  e) {
				 Graphics^ g = e->Graphics;
				
				 g->DrawImage(pictureBox1->Image,e->MarginBounds.Top,e->MarginBounds.Left);
				 e->HasMorePages=false;
			 }
	private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {

			 }
private: System::Void drukujToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
                 printDocument1->Print();
		 }
private: System::Void otworzToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
			 
		   openFileDialog1->Filter= "Pliki rysunków (*.jpg, *.bmp, *.gif)|*.jpg;*.bmp;*.gif";
		   if (openFileDialog1->ShowDialog()==System::Windows::Forms::DialogResult::OK)
		   {
			 pictureBox1->Image=System::Drawing::Image::FromFile(openFileDialog1->FileName);
		   }
		 }
private: System::Void wyjdzToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
			 Close();
		 }
private: System::Void podgladWydrukuToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
			 printPreviewDialog1->Document=printDocument1;
             printPreviewDialog1->ShowDialog();
		 }
private: System::Void ustawieniaToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
			 pageSetupDialog1->Document=printDocument1;
			 pageSetupDialog1->ShowDialog();
		 }
private: System::Void obrotToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
			 Form^ oknoObrot = gcnew Form;
			 ComboBox^ listaKatow = gcnew ComboBox;
			 Button^ przyciskOK = gcnew Button;
			 listaKatow->Items->Add("90 stopni");
			 listaKatow->Items->Add("180 stopni");
			 listaKatow->Items->Add("290 stopni");
			 przyciskOK->Text="OK";
			 przyciskOK->Location=Point(10,40);
			 przyciskOK->DialogResult = System::Windows::Forms::DialogResult::OK;
             oknoObrot->Controls->Add(listaKatow);
			 oknoObrot->Controls->Add(przyciskOK);
			 oknoObrot->ShowDialog();
			 Bitmap^ obraz = gcnew Bitmap(pictureBox1->Image);
			 switch(listaKatow->SelectedIndex) {
				 case 0: obraz->RotateFlip(System::Drawing::RotateFlipType::Rotate90FlipNone); break;
				 case 1: obraz->RotateFlip(System::Drawing::RotateFlipType::Rotate180FlipNone); break;
				 case 2: obraz->RotateFlip(System::Drawing::RotateFlipType::Rotate270FlipNone); break;
			 }
			 
			 
			 pictureBox1->Image=obraz;
		 }

};
}

