#pragma once
#include"Sorting.h"


namespace Lab7 {

	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::Windows::Forms::Button^  button1;
	protected: 
	private: System::Windows::Forms::Button^  button2;
	private: System::Windows::Forms::Button^  button3;
	private: System::Windows::Forms::ListBox^  listBox1;
	private: System::Windows::Forms::Button^  button4;
	private: System::Windows::Forms::Button^  button5;

	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)
		{
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->button2 = (gcnew System::Windows::Forms::Button());
			this->button3 = (gcnew System::Windows::Forms::Button());
			this->listBox1 = (gcnew System::Windows::Forms::ListBox());
			this->button4 = (gcnew System::Windows::Forms::Button());
			this->button5 = (gcnew System::Windows::Forms::Button());
			this->SuspendLayout();
			// 
			// button1
			// 
			this->button1->Location = System::Drawing::Point(24, 42);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(107, 24);
			this->button1->TabIndex = 0;
			this->button1->Text = L"Bubble Sort Nos";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
			// 
			// button2
			// 
			this->button2->Location = System::Drawing::Point(167, 42);
			this->button2->Name = L"button2";
			this->button2->Size = System::Drawing::Size(103, 24);
			this->button2->TabIndex = 1;
			this->button2->Text = L"Find Min index";
			this->button2->UseVisualStyleBackColor = true;
			this->button2->Click += gcnew System::EventHandler(this, &Form1::button2_Click);
			// 
			// button3
			// 
			this->button3->Location = System::Drawing::Point(24, 73);
			this->button3->Name = L"button3";
			this->button3->Size = System::Drawing::Size(106, 24);
			this->button3->TabIndex = 2;
			this->button3->Text = L"Selection Sort Nos";
			this->button3->UseVisualStyleBackColor = true;
			this->button3->Click += gcnew System::EventHandler(this, &Form1::button3_Click);
			// 
			// listBox1
			// 
			this->listBox1->FormattingEnabled = true;
			this->listBox1->Location = System::Drawing::Point(24, 103);
			this->listBox1->Name = L"listBox1";
			this->listBox1->Size = System::Drawing::Size(246, 147);
			this->listBox1->TabIndex = 3;
			// 
			// button4
			// 
			this->button4->Location = System::Drawing::Point(100, 12);
			this->button4->Name = L"button4";
			this->button4->Size = System::Drawing::Size(103, 24);
			this->button4->TabIndex = 4;
			this->button4->Text = L"Unsorted";
			this->button4->UseVisualStyleBackColor = true;
			this->button4->Click += gcnew System::EventHandler(this, &Form1::button4_Click);
			// 
			// button5
			// 
			this->button5->Location = System::Drawing::Point(167, 73);
			this->button5->Name = L"button5";
			this->button5->Size = System::Drawing::Size(103, 24);
			this->button5->TabIndex = 5;
			this->button5->Text = L"Find Max index";
			this->button5->UseVisualStyleBackColor = true;
			this->button5->Click += gcnew System::EventHandler(this, &Form1::button5_Click);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(292, 266);
			this->Controls->Add(this->button5);
			this->Controls->Add(this->button4);
			this->Controls->Add(this->listBox1);
			this->Controls->Add(this->button3);
			this->Controls->Add(this->button2);
			this->Controls->Add(this->button1);
			this->Name = L"Form1";
			this->Text = L"Form1";
			this->ResumeLayout(false);

		}
#pragma endregion
	private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) 
			 {
				 int nums[] = {67,22,9,10,45};
				 Sorting s1;
				 s1.bubbleSort(nums, 5);

				 this->listBox1->Items->Clear();

				 for (int r=0; r<5; r++)
				 {
					 listBox1->Items->Add(nums[r]);
				 }
			 }
	private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) 
			 {
				 int nums[] = {67,22,9,10,45};
				 Sorting s2;

				 int v = s2.findMinIndex(nums, 5);

				 MessageBox::Show(Convert::ToString(nums[v]));
			 }
private: System::Void button3_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			 int nums[] = {67,22,9,10,45};
				 Sorting s3;
				 s3.selectionSort(nums, 5);

				 this->listBox1->Items->Clear();

				 for (int r=0; r<5; r++)
				 {
					 listBox1->Items->Add(nums[r]);
				 }
		 }
private: System::Void button4_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			 int nums[] = {67,22,9,10,45};

				 this->listBox1->Items->Clear();

				 for (int r=0; r<5; r++)
				 {
					 listBox1->Items->Add(nums[r]);
				 }
		 }
private: System::Void button5_Click(System::Object^  sender, System::EventArgs^  e) 
		 {
			 int nums[] = {67,22,9,10,45};
				 Sorting s4;

				 int v = s4.findMaxIndex(nums, 5);

				 MessageBox::Show(Convert::ToString(nums[v]));
		 }
};
}

