.


:




:

































 

 

 

 


.

public:

Form1(void)

{

InitializeComponent();

ImageTime = 1;

Flag =1;

// ------------ ------------------------------------

this->Size = System::Drawing::Size(330,300);

this->Text = L"Hello GDI+";

this->Padding = System::Windows::Forms::Padding(0);

this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;

 

// ------------ ---------------------------------

// ------------ -----------------------

Drawing::Point point1 = Drawing::Point(40,30);

Drawing::Point point2 = Drawing::Point(50,20);

Drawing::Size size = Drawing::Size(60, 50);

rect1 = Drawing::Rectangle(point1, size);

rect2 = Drawing::Rectangle(point2, size);

 

// ------------ ------------------------

}

Drawing::Rectangle rect1;

Drawing::Rectangle rect2;

 

Paint

//------------- -------------------------------------// ------------ ---------------------------

e->Graphics->DrawRectangle(Pens::Black, rect1);

e->Graphics->DrawRectangle(Pens::Black, rect2);

// ------------ ----------------------------

 

MouthDown.

private: System::Void Form1_MouseDown(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e)

{

// x,y

Point p = Point(e->X, e->Y);

// ?

if (Rectangle::Intersect(rect1, rect2).Contains(p))

Text = "";

// ?

else if (Rectangle::Union(rect1, rect2).Contains(p))

Text = "";

//

else

Text = " ";

}

 

. Paint

// ------------ --------------------------------

Graphics ^g = e->Graphics;

g->DrawString(Text,

gcnew Drawing::Font("Arial", 16), Brushes::Red, 75.0+ImageTime*2, 110.0+ImageTime);

// ------------ ---------------------------------

, .

//g->PageUnit = GraphicsUnit::Millimeter;

, . :

#pragma once

 

namespace MyPaintFirst {

 

using namespace System;

using namespace System::ComponentModel;

using namespace System::Collections;

using namespace System::Windows::Forms;

using namespace System::Data;

using namespace System::Drawing;

 

public ref class Form1: public System::Windows::Forms::Form

{

public: int ImageTime;

int Flag;

 

public:

Form1(void)

{

InitializeComponent();

//

//TODO:

//

ImageTime = 1;

Flag =1;

// ------------ --------------------------------

this->Size = System::Drawing::Size(330,300);

this->Text = L"Hello GDI+";

this->Padding = System::Windows::Forms::Padding(0);

this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;

 

// ------------ ---------------------------------

// ------------ -----------------------

Drawing::Point point1 = Drawing::Point(40,30);

Drawing::Point point2 = Drawing::Point(50,20);

Drawing::Size size = Drawing::Size(60, 50);

rect1 = Drawing::Rectangle(point1, size);

rect2 = Drawing::Rectangle(point2, size);

 

// ------------ ------------------------

}

Drawing::Rectangle rect1;

Drawing::Rectangle rect2;

 

protected:

// <summary>

/// .

/// </summary>

~Form1()

{

if (components)

{

delete components;

}

}

private: System::Windows::Forms::Timer^ timer1;

protected:

private: System::ComponentModel::IContainer^ components;

 

private:

/// <summary>

/// .

/// </summary>

 

 

#pragma region Windows Form Designer generated code

/// <summary>

/// -

/// .

/// </summary>

void InitializeComponent(void)

{

this->components = (gcnew System::ComponentModel::Container());

this->timer1 = (gcnew System::Windows::Forms::Timer(this->components));

this->SuspendLayout();

//

// timer1

//

this->timer1->Enabled = true;

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(851, 559);

this->Name = L"Form1";

this->Text = L"Form1";

this->Paint += gcnew System::Windows::Forms::PaintEventHandler(this, &Form1::Form1_Paint);

this->MouseDown += gcnew System::Windows::Forms::MouseEventHandler(this, &Form1::Form1_MouseDown);

this->ResumeLayout(false);

}

#pragma endregion

private: System::Void Form1_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e)

{

//

Pen^ MyPen = gcnew Pen(Color::Blue,2);

//

e->Graphics->DrawEllipse(MyPen,0, 0, 200, 220+ImageTime);

//

e->Graphics->DrawArc(MyPen, 35, 35, 35, 35, 180, -180);

//

e->Graphics->DrawEllipse(MyPen, 120, 35, 35, 35);

// ( )

e->Graphics->DrawBezier(MyPen, 100, 60, 120, 100, 90, 120,80, 100);

//

cli::array<Point>^ apt = gcnew cli::array<Point>(4);

apt[0] = Point(60, 140);

apt[1] = Point(140, 140);

apt[2] = Point(100, 180);

apt[3] = Point(60, 140);

e->Graphics->DrawCurve(MyPen, apt, 0, 3, 0.9f);

// ------------ --------------------------------

Graphics ^g = e->Graphics;

g->DrawString(Text,

gcnew Drawing::Font("Arial", 16), Brushes::Red, 75.0+ImageTime*2, 110.0+ImageTime);

 

// ------------ ---------------------------------

//------------- --------------------------------

g->DrawRectangle(Pens::Black, 5, 5, 50, 20);

// .

//g->PageUnit = GraphicsUnit::Millimeter;

g->TranslateTransform(20+ImageTime,20);

g->DrawRectangle(Pens::Green, 5, 5, 50, 20);

//------------- ---------------------------------

// ------------ -----------------------

e->Graphics->DrawRectangle(Pens::Black, rect1);

e->Graphics->DrawRectangle(Pens::Black, rect2);

 

// ------------ ------------------------ }

//=======================================================================

private: System::Void timer1_Tick(System::Object^ sender, System::EventArgs^ e)

{

int TEnd;

TEnd = 30;

Invalidate();

if((ImageTime < TEnd)&&(Flag==1)){ImageTime++;};

if((ImageTime == TEnd)){ImageTime--; Flag = 2;};

if((ImageTime < TEnd)&&(Flag==2)){ImageTime--;};

if((ImageTime == 1)){ Flag = 1;};

}

//=======================================================================

private: System::Void Form1_MouseDown(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e)

{

//

Point p = Point(e->X, e->Y);

// ?

if (Rectangle::Intersect(rect1, rect2).Contains(p))

Text = "";

// ?

else if (Rectangle::Union(rect1, rect2).Contains(p))

Text = "";

// .

else

Text = " ";

}

};



<== | ==>
3. |
:


: 2016-12-06; !; : 321 |


:

:

: , .
==> ...

2258 - | 1887 -


© 2015-2024 lektsii.org - -

: 0.029 .