Draw Animation Line


#pragma once

namespace My31 {
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 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.
///

public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
///
/// Clean up any resources being used.
///

~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Timer^ t;
private: System::Windows::Forms::Button^ BtnStart;
protected:
private: System::ComponentModel::IContainer^ components;
private:
///
/// Required designer variable.
///


#pragma region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

void InitializeComponent(void)
{
this->components = (gcnew System::ComponentModel::Container());
this->t = (gcnew System::Windows::Forms::Timer(this->components));
this->BtnStart = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// t
//
this->t->Interval = 1;
this->t->Tick += gcnew System::EventHandler(this, &Form1::t_Tick);
//
// BtnStart
//
this->BtnStart->Location = System::Drawing::Point(12, 12);
this->BtnStart->Name = L"BtnStart";
this->BtnStart->Size = System::Drawing::Size(111, 27);
this->BtnStart->TabIndex = 0;
this->BtnStart->Text = L"Start";
this->BtnStart->UseVisualStyleBackColor = true;
this->BtnStart->Click += gcnew System::EventHandler(this, &Form1::BtnStart_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->BtnStart);
this->Name = L"Form1";
this->Text = L"Form1";
this->Load += gcnew System::EventHandler(this, &Form1::Form1_Load);
this->ResumeLayout(false);
}
#pragma endregion
//Draw Animation Line
Graphics^G;
Pen^HPen;
Pen^HPen2;
int cY1;
int cY2;
private: System::Void t_Tick(System::Object^ sender, System::EventArgs^ e) {
HPen=gcnew Pen(Color::Yellow,1);
HPen2=gcnew Pen(Color::Blue,2);
HPen->DashStyle=System::Drawing::Drawing2D::DashStyle::DashDot;
HPen2->DashStyle=System::Drawing::Drawing2D::DashStyle::DashDotDot;
cY1++;
cY2--;
G->DrawLine(HPen,0,cY1,500,cY1);
G->DrawLine(HPen2,500,cY2,this->Width,cY2);
}
private: System::Void BtnStart_Click(System::Object^ sender, System::EventArgs^ e) {
G->Clear(this->BackColor);
cY2=this->Height;
cY1=0;
t->Enabled=true;
}
private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {
this->BackColor=Color::Black;
this->Text="Draw Animation Line";
this->FormBorderStyle=Windows::Forms::FormBorderStyle::FixedToolWindow;
this->Left=0;
this->Top=0;
this->Width=Screen::PrimaryScreen->WorkingArea.Width;
this->Height=Screen::PrimaryScreen->WorkingArea.Height;
G=this->CreateGraphics();
}
};
}