sobota, 17 grudnia 2016

Using Threat in programming Visual C++



#pragma endregion
private: Graphics^ my_graph1;
private: Graphics^ my_graph2;
private: Graphics^ my_graph3;
private: Graphics^ my_graph4;
private: Graphics^ my_pixels;
private: Graphics^ my_lines;
private: Pen^ my_pen1;
private: Pen^ my_pen2;
private: Pen^ my_pen3;
private: Pen^ my_pen4;
private: System::Void init_Random()
{
srand(time(NULL));
}
private: System::Void draw_Ellipse(Graphics^ graph,Pen^ pen)
{
int i,j;
for(i=3;i<77;i+=5)
graph->DrawEllipse(pen,0,0,i,i);
for(j=55;j<112;j+=8)
graph->DrawEllipse(pen,j,j,144,111);
}
private: System::Void draw_Lines(Graphics^ graph, Pen^ pen)
{
int i,j;
for(i=5;i<144;i+=5)
graph->DrawLine(pen,i,0,i,111);
for(j=5;j<111;j+=5)
graph->DrawLine(pen,0,j,144,j);

}

private: System::Void init_Lines()
{
my_lines=panel6->CreateGraphics();
Pen^ Pen_line1=gcnew Pen(System::Drawing::Color::Blue);
Pen^ Pen_line2=gcnew Pen(System::Drawing::Color::Yellow);
Pen^ Pen_line3=gcnew Pen(System::Drawing::Color::Green);
Pen^ Pen_line4=gcnew Pen(System::Drawing::Color::Purple);
int i,j;
Pen_line1->DashStyle=System::Drawing::Drawing2D::DashStyle::DashDot;
Pen_line2->DashStyle=System::Drawing::Drawing2D::DashStyle::Dot;
Pen_line4->DashStyle=System::Drawing::Drawing2D::DashStyle::Solid;

int margin1=5;
int margin2=15;
for(i=margin1;i<panel6->Width-margin1;i+=margin1)
my_lines->DrawLine(Pen_line1,i,margin1,i,panel6->Height-margin1);
for(j=margin1;j<panel6->Height-margin1;j+=margin2)
my_lines->DrawLine(Pen_line2,margin1,j,panel6->Width-margin1,j);
for(i=margin1;i<panel6->Width-margin1;i+=margin1)
my_lines->DrawLine(Pen_line3,i,margin1,i+margin2,panel6->Height-margin1);
for(j=margin1;j<panel6->Height-margin1;j+=margin1)
my_lines->DrawLine(Pen_line4,margin1,j,panel6->Width-margin1,j+margin2);

}
private: System::Void init_Graph()
{
my_graph1=panel1->CreateGraphics();
my_graph2=panel2->CreateGraphics();
my_graph3=panel3->CreateGraphics();
my_graph4=panel4->CreateGraphics();
my_pen1=gcnew Pen(System::Drawing::Color::Black);
my_pen2=gcnew Pen(System::Drawing::Color::Yellow);
my_pen3=gcnew Pen(System::Drawing::Color::Green);
my_pen4=gcnew Pen(System::Drawing::Color::Red);
draw_Lines(my_graph1,my_pen1);
draw_Lines(my_graph2,my_pen2);
draw_Lines(my_graph3,my_pen3);
draw_Lines(my_graph4,my_pen4);
draw_Ellipse(my_graph1,my_pen4);
draw_Ellipse(my_graph2,my_pen3);
draw_Ellipse(my_graph3,my_pen2);
draw_Ellipse(my_graph4,my_pen1);
 
}
private: System::Void init_Pixels()
{
my_pixels=panel5->CreateGraphics();
Bitmap^ my_bitmap=gcnew Bitmap(panel5->Width,panel5->Height);
int i,x,y;
System::Drawing::Color my_color;
for(i=0;i<100000;i++)
{
x=rand()%(panel5->Width-1)+1;
y=rand()%(panel5->Height-1)+1;
my_color=System::Drawing::Color::FromArgb(rand()%255,rand()%255,rand()%255);
my_bitmap->SetPixel(x,y,my_color);
}
my_pixels->DrawImage(dynamic_cast<Image^>(my_bitmap),10,10);
}
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
Close();
}
private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
}
private: System::Void button2_Click(System::Object^  sender, System::EventArgs^  e) {
Thread^ thread_graph=gcnew Thread(gcnew ThreadStart(this,&Form1::init_Graph));
thread_graph->Start();
Thread^ thread_pixels=gcnew Thread(gcnew ThreadStart(this,&Form1::init_Pixels));
thread_pixels->Start();
Thread^ thread_lines=gcnew Thread(gcnew ThreadStart(this,&Form1::init_Lines));
thread_lines->Start();
 
}
private: System::Void panel2_Paint(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) {
}
};
}

Brak komentarzy:

Prześlij komentarz