//---------------------------------------------------------------------------
#include <vcl.h>
#include <vector>
#include <time.h>
#pragma hdrstop
#include "test.h"
using namespace std;
vector<int> x;
vector<int> y;
int i = 0;
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image1MouseMove(TObject *Sender, TShiftState Shift,
int X, int Y)
{
struct point {int X; int Y;};
POINT pos;
GetCursorPos(&pos);
this->Edit1->Text = (pos.x);
this->Edit2->Text = (pos.y);
}
void __fastcall TForm1::buttonQuitClick(TObject *Sender)
{
this->Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Image1Click(TObject *Sender)
{
while(CheckBox1->Checked == true)
{
CheckBox1->Checked = false;
}
if(buttonPlay->Enabled == false)
{
x.push_back(this->Edit1->Text.ToInt());
y.push_back(this->Edit2->Text.ToInt());
Edit3->Text = x.size();
Edit4->Text = x.capacity();
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::buttonReverseClick(TObject *Sender)
{
vector<int> xhulp;
vector<int> yhulp;
int count = x.size();
if (!(count <= 0))
{
count -= 1;
for (int index = 0; (index < x.size()) && (count >= 0); index++)
{
xhulp.push_back(x.at(count));
yhulp.push_back(y.at(count));
count--;
}
x = xhulp;
y = yhulp;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::buttonAllClick(TObject *Sender)
{
x.clear();
y.clear();
if (x.empty() && y.empty())
{
Edit3->Text = x.size();
Edit4->Text = y.size();
CheckBox1->Checked = true;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::buttonRemoveClick(TObject *Sender)
{
if (!(x.empty()) && !(y.empty()))
{
x.pop_back();
y.pop_back();
Edit3->Text = x.size();
}
else
{
Edit3->Text = x.size();
Edit4->Text = y.size();
CheckBox1->Checked = true;
}
}
void __fastcall TForm1::buttonRecordClick(TObject *Sender)
{
if(buttonRecord->Caption == "record")
{
buttonRecord->Caption = "stop";
buttonPlay->Enabled = false;
}
else
{
buttonRecord->Caption = "record";
buttonPlay->Enabled = true;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::buttonPlayClick(TObject *Sender)
{
Timer1->Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
int c;
if(Timer1->Enabled == true)
{
c = x.size();
this->Image1->Canvas->Brush->Color = clRed;
this->Canvas->Ellipse(10, 10, 10, 10);
this->ProgressBar1->StepBy(c);
i++;
}
}
//---------------------------------------------------------------------------