#pragma once
namespace CppWinForm1 {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Drawing;
public ref class MyForm : public System::Windows::Forms::Form
{
public:
MyForm(void)
{
InitializeComponent();
}
protected:
~MyForm()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
private: System::Windows::Forms::Timer^ timer1;
private: System::Windows::Forms::DataVisualization::Charting::Chart^ chart1;
private: System::ComponentModel::IContainer^ components;
private:
int i, j;
int maxI = 50;
int maxJ = 5;
#pragma region Windows Form Designer generated code
void InitializeComponent(void)
{
this->components = (gcnew System::ComponentModel::Container());
System::Windows::Forms::DataVisualization::Charting::ChartArea^ chartArea2 = (gcnew System::Windows::Forms::DataVisualization::Charting::ChartArea());
System::Windows::Forms::DataVisualization::Charting::Legend^ legend2 = (gcnew System::Windows::Forms::DataVisualization::Charting::Legend());
System::Windows::Forms::DataVisualization::Charting::Series^ series2 = (gcnew System::Windows::Forms::DataVisualization::Charting::Series());
this->button1 = (gcnew System::Windows::Forms::Button());
this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));
this->chart1 = (gcnew System::Windows::Forms::DataVisualization::Charting::Chart());
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->chart1))->BeginInit();
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Drawing::Point(225, 338);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 0;
this->button1->Text = L"button1";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &MyForm::button1_Click);
//
// timer1
//
this->timer1->Tick += gcnew System::EventHandler(this, &MyForm::timer1_Tick);
//
// chart1
//
chartArea2->Name = L"ChartArea1";
this->chart1->ChartAreas->Add(chartArea2);
legend2->Name = L"Legend1";
this->chart1->Legends->Add(legend2);
this->chart1->Location = System::Drawing::Point(0, 0);
this->chart1->Name = L"chart1";
series2->ChartArea = L"ChartArea1";
series2->ChartType = System::Windows::Forms::DataVisualization::Charting::SeriesChartType::Line;
series2->Legend = L"Legend1";
series2->Name = L"Series1";
this->chart1->Series->Add(series2);
this->chart1->Size = System::Drawing::Size(300, 300);
this->chart1->TabIndex = 1;
this->chart1->Text = L"chart1";
//
// MyForm
//
this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(322, 373);
this->Controls->Add(this->chart1);
this->Controls->Add(this->button1);
this->Name = L"MyForm";
this->Text = L"MyForm";
(cli::safe_cast<System::ComponentModel::ISupportInitialize^>(this->chart1))->EndInit();
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
chart1->Series["Series1"]->Color = Color::Red;
chart1->Series["Series1"]->BorderWidth = 5;
i = 1;
j = 1;
timer1->Start();
}
private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e) {
chart1->Series["Series1"]->Points->AddXY(i, j);
i++;
if (i == maxI)
{
i = 1;
j++;
if (j == maxJ)
timer1->Stop();
}
}
};
}