summaryrefslogtreecommitdiff
path: root/task05/Guschin/MyForm.h
blob: de6955a503b75bfee1a7e7af84c6c304abec0c7c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#pragma once

namespace Guschin {

	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 std;

	mat3 T;
	mat3 initT;

	public ref class MyForm : public System::Windows::Forms::Form
	{
	public:
		MyForm(void)
		{
			InitializeComponent();
		}

	protected:
		~MyForm()
		{
			if (components)
			{
				delete components;
			}
		}

	private:
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		void InitializeComponent(void)
		{
			this->SuspendLayout();
			// 
			// MyForm
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(737, 686);
			this->KeyPreview = true;
			this->Margin = System::Windows::Forms::Padding(4, 4, 4, 4);
			this->Name = L"MyForm";
			this->Text = L"MyForm";
			this->Load += gcnew System::EventHandler(this, &MyForm::MyForm_Load);
			this->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &MyForm::MyForm_Paint);
			this->KeyDown += gcnew System::Windows::Forms::KeyEventHandler(this, &MyForm::MyForm_KeyDown);
			this->Resize += gcnew System::EventHandler(this, &MyForm::MyForm_Resize);
			this->ResumeLayout(false);

		}
#pragma endregion
	private: 
		float left = 30, right = 100, top = 20, bottom = 50;
		float minX = left, maxX;
		float minY = top, maxY;
		float Wcx = left, Wcy;
		float Wx, Wy;

	private: 
		System::Void rectCalc() {
			maxX = ClientRectangle.Width - right;
			maxY = ClientRectangle.Height - bottom;
			Wcy = maxY;
			Wx = maxX - left;
			Wy = maxY - top;
		}
	private: 
		System::Void MyForm_Resize(System::Object^ sender, System::EventArgs^ e) {
			rectCalc();
			Refresh();
		}
	private:
		System::Void MyForm_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) {
			Graphics^ g = e->Graphics;
			g->Clear(Color::Aquamarine);

			Pen^ rectPen = gcnew Pen(Color::Black, 2);
			g->DrawRectangle(rectPen, left, top, Wx, Wy);
		}
	private:
		System::Void MyForm_Load(System::Object^  sender, System::EventArgs^  e) {
			rectCalc();
			initT = mat3(1.f);
			T = initT;
		}
	private:
		System::Void MyForm_KeyDown(System::Object^ sender, System::Windows::Forms::KeyEventArgs^ e) {
			switch (e->KeyCode) {
			case Keys::Escape:
				T = initT;
				break;
			default:
				break;
			}
			Refresh();
		}
	};
}