#pragma once


namespace systemmon {

	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::Panel^  panel1;
	protected: 
	private: System::Windows::Forms::Panel^  panel2;
	private: System::Windows::Forms::Panel^  panel3;
	private: System::Windows::Forms::Label^  label1;
	private: System::Windows::Forms::Label^  label2;
	private: System::Windows::Forms::Label^  label3;
	private: System::Windows::Forms::Label^  label4;
	private: System::Windows::Forms::Label^  label5;
	private: System::Windows::Forms::Label^  label6;
	private: System::Diagnostics::PerformanceCounter^  performanceCounter1;
	private: System::Diagnostics::PerformanceCounter^  performanceCounter2;
	private: System::Diagnostics::PerformanceCounter^  performanceCounter3;
	private: System::Windows::Forms::NotifyIcon^  notifyIcon1;
	private: System::Windows::Forms::ContextMenuStrip^  contextMenuStrip1;
	private: System::Windows::Forms::Timer^  timer1;
	private: System::Windows::Forms::ToolStripMenuItem^  pokazToolStripMenuItem;

	private: System::Windows::Forms::ToolStripMenuItem^  ukryjToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  wyjscieToolStripMenuItem;
	private: System::ComponentModel::IContainer^  components;

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>


#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->components = (gcnew System::ComponentModel::Container());
			System::ComponentModel::ComponentResourceManager^  resources = (gcnew System::ComponentModel::ComponentResourceManager(Form1::typeid));
			this->panel1 = (gcnew System::Windows::Forms::Panel());
			this->panel2 = (gcnew System::Windows::Forms::Panel());
			this->panel3 = (gcnew System::Windows::Forms::Panel());
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->label2 = (gcnew System::Windows::Forms::Label());
			this->label3 = (gcnew System::Windows::Forms::Label());
			this->label4 = (gcnew System::Windows::Forms::Label());
			this->label5 = (gcnew System::Windows::Forms::Label());
			this->label6 = (gcnew System::Windows::Forms::Label());
			this->performanceCounter1 = (gcnew System::Diagnostics::PerformanceCounter());
			this->performanceCounter2 = (gcnew System::Diagnostics::PerformanceCounter());
			this->performanceCounter3 = (gcnew System::Diagnostics::PerformanceCounter());
			this->notifyIcon1 = (gcnew System::Windows::Forms::NotifyIcon(this->components));
			this->contextMenuStrip1 = (gcnew System::Windows::Forms::ContextMenuStrip(this->components));
			this->pokazToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->ukryjToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->wyjscieToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->performanceCounter1))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->performanceCounter2))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->performanceCounter3))->BeginInit();
			this->contextMenuStrip1->SuspendLayout();
			this->SuspendLayout();
			// 
			// panel1
			// 
			this->panel1->BackColor = System::Drawing::Color::White;
			this->panel1->Location = System::Drawing::Point(94, 28);
			this->panel1->Name = L"panel1";
			this->panel1->Size = System::Drawing::Size(250, 101);
			this->panel1->TabIndex = 0;
			this->panel1->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::panel1_Paint);
			// 
			// panel2
			// 
			this->panel2->BackColor = System::Drawing::Color::White;
			this->panel2->Location = System::Drawing::Point(94, 135);
			this->panel2->Name = L"panel2";
			this->panel2->Size = System::Drawing::Size(250, 101);
			this->panel2->TabIndex = 1;
			this->panel2->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::panel2_Paint);
			// 
			// panel3
			// 
			this->panel3->BackColor = System::Drawing::Color::White;
			this->panel3->Location = System::Drawing::Point(94, 242);
			this->panel3->Name = L"panel3";
			this->panel3->Size = System::Drawing::Size(250, 101);
			this->panel3->TabIndex = 2;
			this->panel3->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::panel3_Paint);
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->Location = System::Drawing::Point(9, 76);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(71, 26);
			this->label1->TabIndex = 3;
			this->label1->Text = L"Obciążenie \r\nprocesora [%]";
			// 
			// label2
			// 
			this->label2->AutoSize = true;
			this->label2->Location = System::Drawing::Point(9, 178);
			this->label2->Name = L"label2";
			this->label2->Size = System::Drawing::Size(79, 26);
			this->label2->TabIndex = 4;
			this->label2->Text = L"Wykorzystanie \r\npamięci  [%]";
			// 
			// label3
			// 
			this->label3->AutoSize = true;
			this->label3->Location = System::Drawing::Point(9, 291);
			this->label3->Name = L"label3";
			this->label3->Size = System::Drawing::Size(63, 26);
			this->label3->TabIndex = 5;
			this->label3->Text = L"Obciążenie \r\ndysku [%]";
			// 
			// label4
			// 
			this->label4->AutoSize = true;
			this->label4->Location = System::Drawing::Point(379, 76);
			this->label4->Name = L"label4";
			this->label4->Size = System::Drawing::Size(13, 13);
			this->label4->TabIndex = 6;
			this->label4->Text = L"0";
			// 
			// label5
			// 
			this->label5->AutoSize = true;
			this->label5->Location = System::Drawing::Point(382, 178);
			this->label5->Name = L"label5";
			this->label5->Size = System::Drawing::Size(13, 13);
			this->label5->TabIndex = 7;
			this->label5->Text = L"0";
			// 
			// label6
			// 
			this->label6->AutoSize = true;
			this->label6->Location = System::Drawing::Point(384, 291);
			this->label6->Name = L"label6";
			this->label6->Size = System::Drawing::Size(13, 13);
			this->label6->TabIndex = 8;
			this->label6->Text = L"0";
			// 
			// performanceCounter1
			// 
			this->performanceCounter1->CategoryName = L"Procesor";
			this->performanceCounter1->CounterName = L"Czas procesora (%)";
			this->performanceCounter1->InstanceName = L"_Total";
			// 
			// performanceCounter2
			// 
			this->performanceCounter2->CategoryName = L"Pamięć";
			this->performanceCounter2->CounterName = L"Zadeklarowane bajty w użyciu (%)";
			// 
			// performanceCounter3
			// 
			this->performanceCounter3->CategoryName = L"Dysk logiczny";
			this->performanceCounter3->CounterName = L"Czas dysku (%)";
			this->performanceCounter3->InstanceName = L"_Total";
			// 
			// notifyIcon1
			// 
			this->notifyIcon1->ContextMenuStrip = this->contextMenuStrip1;
			this->notifyIcon1->Icon = (cli::safe_cast<System::Drawing::Icon^  >(resources->GetObject(L"notifyIcon1.Icon")));
			this->notifyIcon1->Text = L"notifyIcon1";
			this->notifyIcon1->Visible = true;
			// 
			// contextMenuStrip1
			// 
			this->contextMenuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(3) {this->pokazToolStripMenuItem, 
				this->ukryjToolStripMenuItem, this->wyjscieToolStripMenuItem});
			this->contextMenuStrip1->Name = L"contextMenuStrip1";
			this->contextMenuStrip1->Size = System::Drawing::Size(123, 70);
			// 
			// pokazToolStripMenuItem
			// 
			this->pokazToolStripMenuItem->Name = L"pokazToolStripMenuItem";
			this->pokazToolStripMenuItem->Size = System::Drawing::Size(122, 22);
			this->pokazToolStripMenuItem->Text = L"Pokaż";
			this->pokazToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::pokazToolStripMenuItem_Click);
			// 
			// ukryjToolStripMenuItem
			// 
			this->ukryjToolStripMenuItem->Name = L"ukryjToolStripMenuItem";
			this->ukryjToolStripMenuItem->Size = System::Drawing::Size(122, 22);
			this->ukryjToolStripMenuItem->Text = L"Ukryj";
			this->ukryjToolStripMenuItem->TextAlign = System::Drawing::ContentAlignment::BottomCenter;
			this->ukryjToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::ukryjToolStripMenuItem_Click);
			// 
			// wyjscieToolStripMenuItem
			// 
			this->wyjscieToolStripMenuItem->Name = L"wyjscieToolStripMenuItem";
			this->wyjscieToolStripMenuItem->Size = System::Drawing::Size(122, 22);
			this->wyjscieToolStripMenuItem->Text = L"Wyjście";
			this->wyjscieToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::wyjscieToolStripMenuItem_Click);
			// 
			// timer1
			// 
			this->timer1->Interval = 500;
			this->timer1->Tick += gcnew System::EventHandler(this, &Form1::timer1_Tick);
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(465, 391);
			this->Controls->Add(this->label6);
			this->Controls->Add(this->label5);
			this->Controls->Add(this->label4);
			this->Controls->Add(this->label3);
			this->Controls->Add(this->label2);
			this->Controls->Add(this->label1);
			this->Controls->Add(this->panel3);
			this->Controls->Add(this->panel2);
			this->Controls->Add(this->panel1);
			this->Name = L"Form1";
			this->Text = L"Form1";
			this->Shown += gcnew System::EventHandler(this, &Form1::Form1_Shown);
			this->Click += gcnew System::EventHandler(this, &Form1::pokazToolStripMenuItem_Click);
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->performanceCounter1))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->performanceCounter2))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->performanceCounter3))->EndInit();
			this->contextMenuStrip1->ResumeLayout(false);
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion

		private: System::Int32 x; //wspolrzedna x wspolna dla wszystkich paneli
        private: array<System::Int32>^ Y1; //stara wartosc y dla
	    private: array<System::Int32>^ Y2;
	    private: array<System::Int32>^ Y3;

	private: System::Void timer1_Tick(System::Object^  sender, System::EventArgs^  e) {
		    label4->Text=performanceCounter1->NextValue().ToString();
			label5->Text=performanceCounter2->NextValue().ToString();
		    label6->Text=performanceCounter3->NextValue().ToString();
   	    	DrawChart();
			 }
private: System::Void pokazToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
			  timer1->Enabled=true;
			  this->Show(); 

		 }
private: System::Void Form1_Shown(System::Object^  sender, System::EventArgs^  e) {
			 this->Hide();
			 x=0;
             Y1 = gcnew array<System::Int32>(260);
			 Y2 = gcnew array<System::Int32>(260);
			 Y3 = gcnew array<System::Int32>(260);
		 }
private: System::Void ukryjToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
			  this->Hide();
			  timer1->Enabled=false;
		 }

private: System::Void wyjscieToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
			 Close();
		 }
private: System::Void DrawChart() {
    		x++;
			System::Single YSingle;
			//pierwszy wykres
			YSingle=Convert::ToSingle(label4->Text);
			Y1[x]=(System::Int32)YSingle;
			panel1->Refresh();
            //drugi wykres
			YSingle=Convert::ToSingle(label5->Text);
			Y2[x]=(System::Int32)YSingle;
			panel2->Refresh();
            //trzeci wykres
			YSingle=Convert::ToSingle(label6->Text);
			Y3[x]=(System::Int32)YSingle;
			panel3->Refresh();

		  }
private: System::Void panel1_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
			  Pen^ LinePen1= gcnew Pen(System::Drawing::Color::Blue);
			 if (x>250) {x=0;e->Graphics->Clear(System::Drawing::Color::White);}
			  for (System::Int32 x1=1;x1<x;x1++)
			 {
				e->Graphics->DrawLine(LinePen1,x1-1,100-Y1[x1-1],x1,100-Y1[x1]);
			 }
		 }
private: System::Void panel2_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
			  Pen^ LinePen1= gcnew Pen(System::Drawing::Color::Blue);
			 if (x>250) {x=0;e->Graphics->Clear(System::Drawing::Color::White);}
			  for (System::Int32 x1=1;x1<x;x1++)
			 {
				e->Graphics->DrawLine(LinePen1,x1-1,100-Y2[x1-1],x1,100-Y2[x1]);
			 } 
		 }
private: System::Void panel3_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
			 Pen^ LinePen1= gcnew Pen(System::Drawing::Color::Blue);
			 if (x>250) {x=0;e->Graphics->Clear(System::Drawing::Color::White);}
			  for (System::Int32 x1=1;x1<x;x1++)
			 {
				e->Graphics->DrawLine(LinePen1,x1-1,100-Y3[x1-1],x1,100-Y3[x1]);
			 } 
		 }
};
}

