SlideShare uma empresa Scribd logo
1 de 64
Baixar para ler offline
C++.NET
Windows Forms Course
L08- GDI Part 1

Mohammad Shaker
mohammadshakergtr.wordpress.com
C++.NET Windows Forms Course
@ZGTRShaker
GDI
- Part 1 -
What do u need to draw sth?
• Pen (stroke width, color, etc)
• Paper
• Brush to filling your drawing
Drawing::Graphic
• Encapsulates a GDI* + drawing surface.
• This class cannot be inherited.

___________________
• GDI* : Graphical Device Interface
Drawing::Graphics

private: System::Void button1_Click_5(System::Object^
sender, System::EventArgs^ e)
{
Drawing::Graphics ^MyGraphics;
MyGraphics = pictureBox1->CreateGraphics();
}
Drawing::Graphics
private void DrawImagePointF(PaintEventArgs e)
{
// Create image.
Image newImage = Image.FromFile("SampImag.jpg");
// Create point for upper-left corner of image.
PointF ulCorner = new PointF(100.0F, 100.0F);
// Draw image to screen.
e.Graphics.DrawImage(newImage, ulCorner);
}
Method
AddMetafileComment
BeginContainer()

Description

BeginContainer(Rectangle, Rectangle,
GraphicsUnit)

Adds a comment to the current Metafile.
Saves a graphics container with the current state of this Graphics and opens
and uses a new graphics container.
Saves a graphics container with the current state of this Graphics and opens
and uses a new graphics container with the specified scale transformation.

BeginContainer(RectangleF, RectangleF,
GraphicsUnit)

Saves a graphics container with the current state of this Graphics and opens
and uses a new graphics container with the specified scale transformation.

Clear

Clears the entire drawing surface and fills it with the specified background
color.
Performs a bit-block transfer of color data, corresponding to a rectangle of
pixels, from the screen to the drawing surface of the Graphics.

CopyFromScreen(Point, Point, Size)
CopyFromScreen(Point, Point, Size,
CopyPixelOperation)

Performs a bit-block transfer of color data, corresponding to a rectangle of
pixels, from the screen to the drawing surface of the Graphics.

CopyFromScreen(Int32, Int32, Int32, Int32,
Size)

Performs a bit-block transfer of the color data, corresponding to a rectangle of
pixels, from the screen to the drawing surface of the Graphics.

CopyFromScreen(Int32, Int32, Int32, Int32,
Size, CopyPixelOperation)

Performs a bit-block transfer of the color data, corresponding to a rectangle of
pixels, from the screen to the drawing surface of the Graphics.

CreateObjRef

Creates an object that contains all the relevant information required to
generate a proxy used to communicate with a remote object. (Inherited
fromMarshalByRefObject.)
Releases all resources used by this Graphics.
Draws an arc representing a portion of an ellipse specified by
a Rectangle structure.
Draws an arc representing a portion of an ellipse specified by a RectangleF

Dispose
DrawArc(Pen, Rectangle, Single, Single)

DrawArc(Pen, RectangleF, Single, Single)
DrawArc(Pen, Int32, Int32, Int32, Int32, Int32, Int32) Draws an arc representing a portion of an ellipse specified by a pair of coordinates, a width,
and a height.
DrawArc(Pen, Single, Single, Single, Single, Single,
Single)

Draws an arc representing a portion of an ellipse specified by a pair of coordinates, a width,
and a height.

DrawBezier(Pen, Point, Point, Point, Point)

Draws a Bézier spline defined by four Point structures.

DrawBezier(Pen, PointF, PointF, PointF, PointF)

Draws a Bézier spline defined by four PointF structures.

DrawBezier(Pen, Single, Single, Single, Single, Single, Draws a Bézier spline defined by four ordered pairs of coordinates that represent points.
Single, Single, Single)
DrawBeziers(Pen, Point[])
Draws a series of Bézier splines from an array of Point structures.
DrawBeziers(Pen, PointF[])

Draws a series of Bézier splines from an array of PointF structures.

DrawClosedCurve(Pen, Point[])

Draws a closed cardinal spline defined by an array of Point structures.

DrawClosedCurve(Pen, PointF[])

Draws a closed cardinal spline defined by an array of PointF structures.

DrawClosedCurve(Pen, Point[], Single, FillMode)

Draws a closed cardinal spline defined by an array of Point structures using a specified
tension.

DrawClosedCurve(Pen, PointF[], Single, FillMode)

Draws a closed cardinal spline defined by an array of PointF structures using a specified
tension.

DrawCurve(Pen, Point[])

Draws a cardinal spline through a specified array of Point structures.

DrawCurve(Pen, PointF[])

Draws a cardinal spline through a specified array of PointF structures.

DrawCurve(Pen, Point[], Single)

Draws a cardinal spline through a specified array of Point structures using a specified tension.
DrawCurve(Pen, PointF[], Single)
DrawCurve(Pen, PointF[], Int32, Int32)

Draws a cardinal spline through a specified array of PointF structures using a
specified tension.
Draws a cardinal spline through a specified array of PointF structures. The
drawing begins offset from the beginning of the array.

DrawCurve(Pen, Point[], Int32, Int32, Single)

Draws a cardinal spline through a specified array of Point structures using a
specified tension.
DrawCurve(Pen, PointF[], Int32, Int32, Single) Draws a cardinal spline through a specified array of PointF structures using a
specified tension. The drawing begins offset from the beginning of the array.
DrawEllipse(Pen, Rectangle)

Draws an ellipse specified by a bounding Rectangle structure.

DrawEllipse(Pen, RectangleF)
DrawEllipse(Pen, Int32, Int32, Int32, Int32)

Draws an ellipse defined by a bounding RectangleF.
Draws an ellipse defined by a bounding rectangle specified by coordinates for
the upper-left corner of the rectangle, a height, and a width.

DrawEllipse(Pen, Single, Single, Single, Single) Draws an ellipse defined by a bounding rectangle specified by a pair of
coordinates, a height, and a width.
DrawIcon(Icon, Rectangle)
Draws the image represented by the specified Icon within the area specified
by aRectangle structure.
DrawIcon(Icon, Int32, Int32)
DrawIconUnstretched
DrawImage(Image, Point)
DrawImage(Image, Point[])

Draws the image represented by the specified Icon at the specified
coordinates.
Draws the image represented by the specified Icon without scaling the image.
Draws the specified Image, using its original physical size, at the specified
location.
Draws the specified Image at the specified location and with the specified
shape
System::Drawing
System::Drawing
• Graphics Class :
– Can’t be inherited

• Inheritance Hierarchy :
– System::Object
System::MarshalByRefObject
System.Drawing::Graphics
Drawing::Point
• What will happen now?
private: System::Void button1_Click(System::Object^
sender, System::EventArgs^ e)
{
button1->Location = 30,120;
}
Drawing::Point
Drawing::Point
• What will happen now?
private: System::Void button1_Click(System::Object^
System::EventArgs^ e)
{
Drawing::Point P;
P.X = 2;
P.Y = 23;
button1->Location = P;
}

sender,
Drawing::Point
Changing the size of the form at
run time

So, what should
we do?
Drawing::Size
• Can we do this? Form’s size?
private: System::Void button1_Click_1(System::Object^
System::EventArgs^ e)
{
Drawing::Size S;
S.Height = 200;
S.Width = 300;
this->Size = S;
}

Yep!

sender,
Drawing::Size
• Can we do this?
private: System::Void button1_Click_1(System::Object^
System::EventArgs^ e)
{
Drawing::Size ^S;
S->Height = 200;
S->Width = 300;
this->Size = S;
}

sender,

Compile error

Error
1
error C2664: 'void
System::Windows::Forms::Control::Size::set(System::Drawing::Size)'
: cannot convert parameter 1 from 'System::Drawing::Size ^' to
'System::Drawing::Size'
c:userszgtrdocumentsvisual studio
2008projectsdotnet4dotnet4Form1.h 129
dotNet4
Drawing::Size
• Do this:
private: System::Void button1_Click_1(System::Object^
sender, System::EventArgs^ e)
{
this->Size = Drawing::Size(200,300);
}

• Or Add Drawing in using
Drawing::Size
System::Drawing::Pen
private: System::Void button1_Click_5(System::Object^ sender,
System::EventArgs^ e)
{
System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red);
}
Let’s draw a line!
Graphics.DrawLine() Method
private: System::Void button1_Click_5(System::Object^
System::EventArgs^ e)
{
System::Drawing::Graphics::DrawLine(
}

sender,
System::Drawing::Pen
private: System::Void button1_Click_5(System::Object^ sender,
System::EventArgs^ e)
{
System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red);
Drawing::Graphics::DrawLine( MyPen, 2, 3, 4,5 );
}
Graphics.DrawLine Method
•
•
•
•

public: void DrawLine(Pen*, Point, Point);
public: void DrawLine(Pen*, PointF, PointF);
public: void DrawLine(Pen*, int, int, int, int);
public: void DrawLine(Pen*, float, float, float, float);
System::Drawing
• What will happen now?
private: System::Void button1_Click_5(System::Object^ sender,
System::EventArgs^ e)
{
System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red);
Drawing::Graphics::DrawLine( MyPen, 2, 3, 4,5 );
}

Compiler error ..
System::Drawing
• What will happen now?
private: System::Void button1_Click_5(System::Object^ sender,
System::EventArgs^ e)
{
System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red);
Drawing::Graphics ^MyGraphics;
MyGraphics->DrawLine( MyPen, 2, 3, 4,5 );
}
No compiler error but Runtime error when clicking button1
System::Drawing
• What will happen now?
private: System::Void button1_Click_5(System::Object^ sender, System::EventArgs^
e)
{
System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red);
Drawing::Graphics ^MyGraphics;
MyGraphics = pictureBox1->CreateGraphics();
MyGraphics->DrawLine( MyPen, 2, 3, 50,105 );
}

A line will be drawn!
System::Drawing
• After clicking the button
System::Drawing
• Can we do this?
private: System::Void button1_Click_5(System::Object^ sender,
System::EventArgs^ e)
{
Drawing::Graphics ^MyGraphics;
MyGraphics = pictureBox1->CreateGraphics();
MyGraphics->DrawLine(System::Drawing::Pen(Color::Red),2,3,50,105);
}

Compiler error
System::Drawing
• Can we do this?
private: System::Void button1_Click_5(System::Object^
System::EventArgs^ e)
{
System::Drawing::Pen MyPen();
MyPen.Color = Color::Red;
Drawing::Graphics ^MyGraphics;
MyGraphics = pictureBox1->CreateGraphics();
MyGraphics->DrawLine(MyPen, 2, 3, 50,105 );
}
Compiler error

sender,
System::Drawing
• Can we do this?
private: System::Void button1_Click_5(System::Object^
System::EventArgs^ e)
{
System::Drawing::Pen MyPen(Color::Red );
Drawing::Graphics ^MyGraphics;
MyGraphics = pictureBox1->CreateGraphics();
MyGraphics->DrawLine(MyPen, 2, 3, 50,105 );
}
Compiler error

sender,
System::Drawing
• Can we do this?
private: System::Void button1_Click_5(System::Object^
System::EventArgs^ e)
{
System::Drawing::Pen ^MyPen(Color::Red);
Drawing::Graphics ^MyGraphics;
MyGraphics = pictureBox1->CreateGraphics();
MyGraphics->DrawLine(MyPen, 2, 3, 50,105 );
}
Compiler error!

sender,
System::Drawing
• Can we do this?
private: System::Void button1_Click_5(System::Object^
System::EventArgs^ e)
{
System::Drawing::Pen ^MyPen = gcnew Pen;
Drawing::Graphics ^MyGraphics;
MyGraphics = pictureBox1->CreateGraphics();
MyGraphics->DrawLine(MyPen, 2, 3, 50,105 );
}
Compiler error

sender,
System::Drawing
• Can we do this?
private: System::Void button1_Click_5(System::Object^ sender,
System::EventArgs^ e)
{
System::Drawing::Color ^MyColor = gcnew Color;
MyColor = Drawing::Color::Red;
System::Drawing::Pen ^MyPen = gcnew Pen(*MyColor);
Drawing::Graphics ^MyGraphics;
MyGraphics = pictureBox1->CreateGraphics();
MyGraphics->DrawLine(MyPen, 2, 3, 50,105 );
}
Working!
System::Drawing
• Can we do this?
private: System::Void button1_Click_5(System::Object^ sender,
System::EventArgs^ e)
{
System::Drawing::Color ^MyColor = gcnew Color; // 1
MyColor = Drawing::Color::Red;
// 2
System::Drawing::Pen ^MyPen = gcnew Pen(MyColor); // 3
Drawing::Graphics ^MyGraphics;
MyGraphics = pictureBox1->CreateGraphics();
MyGraphics->DrawLine(MyPen, 2, 3, 50,105 );
}
Compiler error in // 3
System::Drawing
• Can we do this?
private: System::Void button1_Click_5(System::Object^ sender,
System::EventArgs^ e)
{
System::Drawing::Color MyColor = gcnew Color; // 1
MyColor = Drawing::Color::Red;
// 2
System::Drawing::Pen ^MyPen = gcnew Pen(*MyColor); // 3
Drawing::Graphics ^MyGraphics;
MyGraphics = pictureBox1->CreateGraphics();
MyGraphics->DrawLine(MyPen, 2, 3, 50,105 );
}
Compiler error in // 1 . ^
System::Drawing
• Can we do this?
private: System::Void button1_Click_5(System::Object^ sender,
System::EventArgs^ e)
{
System::Drawing::Color ^MyColor = gcnew Color; // 1
MyColor = Red;
// 2
System::Drawing::Pen ^MyPen = gcnew Pen(*MyColor); // 3
Drawing::Graphics ^MyGraphics;
MyGraphics = pictureBox1->CreateGraphics();
MyGraphics->DrawLine(MyPen, 2, 3, 50,105 );
}
Compiler error in // 2

un-declared Red
System::Drawing
• But remember we can just do this
private: System::Void button1_Click_5(System::Object^ sender,
System::EventArgs^ e)
{
System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red);
Drawing::Graphics ^MyGraphics;
MyGraphics = pictureBox1->CreateGraphics();
MyGraphics->DrawLine( MyPen, 2, 3, 50,105 );
}
System::Drawing
• Another way!
private: System::Void button1_Click_5(System::Object^ sender,
System::EventArgs^ e)
{
System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red);
Drawing::Graphics ^MyGraphics;
MyGraphics = pictureBox1->CreateGraphics();
Drawing::Point ^P1 = gcnew Point(50,60);
Drawing::Point ^P2 = gcnew Point(150,160);
MyGraphics->DrawLine( MyPen, *P1, *P2 );
}
What will happen?
System::Drawing
System::Drawing
• Another way!
private: System::Void button1_Click_5(System::Object^ sender,
System::EventArgs^ e)
{
System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red);
Drawing::Graphics ^MyGraphics;
MyGraphics = pictureBox1->CreateGraphics();
Drawing::Point P1 = gcnew Point(50,60);
Drawing::Point P2 = gcnew Point(150,160);
MyGraphics->DrawLine( MyPen, *P1, *P2 );
}
What will happen?
Compiler error
System::Drawing
• Another way!
private: System::Void button1_Click_5(System::Object^ sender,
System::EventArgs^ e)
{
System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red);
Drawing::Graphics ^MyGraphics;
MyGraphics = pictureBox1->CreateGraphics();
Drawing::Point P1 = gcnew Point(50,60);
Drawing::Point P2 = gcnew Point(150,160);
MyGraphics->DrawLine( MyPen, P1, P2 );
}
What will happen?
Compiler error
System::Drawing
• Can we do this?
private: System::Void button1_Click_5(System::Object^ sender,
System::EventArgs^ e)
{
System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red);
Drawing::Graphics ^MyGraphics;
MyGraphics = pictureBox1->CreateGraphics();
Drawing::Point P1(50,60);
Drawing::Point P2(150,160);
MyGraphics->DrawLine( MyPen, P1, P2 );
}
Works!
System::Drawing
• Sth wrong?
private: System::Void button1_Click_5(System::Object^ sender,
System::EventArgs^ e)
{
System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red);
Drawing::Graphics ^MyGraphics;
MyGraphics = pictureBox1->CreateGraphics();
Drawing::Point P1; P1.X = 50; P1.Y = 60;
Drawing::Point P2; P2.X = 150; P2.Y = 160;
MyGraphics->DrawLine( MyPen, P1, P2 );
}
Works!
System::Drawing
• What will happen now?
private: System::Void button1_Click_5(System::Object^ sender,
System::EventArgs^ e)
{
System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red);
Drawing::Graphics ^MyGraphics;
MyGraphics = pictureBox1->CreateGraphics();
Drawing::Point P1, P2;
P1.X = 50; P1.Y = 60;
P2.X = 150; P2.Y = 160;
MyGraphics->DrawLine( MyPen, P1, P2 );
P1.X = 50; P1.Y = 60;
P2.X = 510; P2.Y = 610;
MyGraphics->DrawLine( MyPen, P1, P2 );
}
System::Drawing
• What’s missing? Next Lesson we’ll find out!
Mouse!
private: System::Void panel1_MouseClick(System::Object^ sender,
System::Windows::Forms::MouseEventArgs^ e)
{
System::Drawing::Point P(0,0);
MyGraphics->DrawEllipse(MyPen,e->X,e->Y,10,10);
MyGraphics->FillEllipse(MyBrush,e->X,e->Y,10,10);
}
That’s it for today!

Mais conteúdo relacionado

Mais procurados

The Ring programming language version 1.5.3 book - Part 48 of 184
The Ring programming language version 1.5.3 book - Part 48 of 184The Ring programming language version 1.5.3 book - Part 48 of 184
The Ring programming language version 1.5.3 book - Part 48 of 184Mahmoud Samir Fayed
 
The Ring programming language version 1.3 book - Part 5 of 88
The Ring programming language version 1.3 book - Part 5 of 88The Ring programming language version 1.3 book - Part 5 of 88
The Ring programming language version 1.3 book - Part 5 of 88Mahmoud Samir Fayed
 
The Ring programming language version 1.6 book - Part 32 of 189
The Ring programming language version 1.6 book - Part 32 of 189The Ring programming language version 1.6 book - Part 32 of 189
The Ring programming language version 1.6 book - Part 32 of 189Mahmoud Samir Fayed
 
The Ring programming language version 1.5.3 book - Part 30 of 184
The Ring programming language version 1.5.3 book - Part 30 of 184The Ring programming language version 1.5.3 book - Part 30 of 184
The Ring programming language version 1.5.3 book - Part 30 of 184Mahmoud Samir Fayed
 
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays 2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays kinan keshkeh
 
PART 6: FROM GEO INTO YOUR REPORT
PART 6: FROM GEO INTO YOUR REPORTPART 6: FROM GEO INTO YOUR REPORT
PART 6: FROM GEO INTO YOUR REPORTAndrea Antonello
 
Presentation1 computer shaan
Presentation1 computer shaanPresentation1 computer shaan
Presentation1 computer shaanwalia Shaan
 
Csphtp1 07
Csphtp1 07Csphtp1 07
Csphtp1 07HUST
 
Yin Yangs of Software Development
Yin Yangs of Software DevelopmentYin Yangs of Software Development
Yin Yangs of Software DevelopmentNaveenkumar Muguda
 
Python GUI Programming
Python GUI ProgrammingPython GUI Programming
Python GUI ProgrammingRTS Tech
 
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYAPYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYAMaulik Borsaniya
 
03 Geographic scripting in uDig - halfway between user and developer
03 Geographic scripting in uDig - halfway between user and developer03 Geographic scripting in uDig - halfway between user and developer
03 Geographic scripting in uDig - halfway between user and developerAndrea Antonello
 

Mais procurados (19)

The Ring programming language version 1.5.3 book - Part 48 of 184
The Ring programming language version 1.5.3 book - Part 48 of 184The Ring programming language version 1.5.3 book - Part 48 of 184
The Ring programming language version 1.5.3 book - Part 48 of 184
 
The Ring programming language version 1.3 book - Part 5 of 88
The Ring programming language version 1.3 book - Part 5 of 88The Ring programming language version 1.3 book - Part 5 of 88
The Ring programming language version 1.3 book - Part 5 of 88
 
The Ring programming language version 1.6 book - Part 32 of 189
The Ring programming language version 1.6 book - Part 32 of 189The Ring programming language version 1.6 book - Part 32 of 189
The Ring programming language version 1.6 book - Part 32 of 189
 
Gui programming
Gui programmingGui programming
Gui programming
 
37c
37c37c
37c
 
The Ring programming language version 1.5.3 book - Part 30 of 184
The Ring programming language version 1.5.3 book - Part 30 of 184The Ring programming language version 1.5.3 book - Part 30 of 184
The Ring programming language version 1.5.3 book - Part 30 of 184
 
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays 2 BytesC++ course_2014_c9_ pointers and dynamic arrays
2 BytesC++ course_2014_c9_ pointers and dynamic arrays
 
My favorite slides
My favorite slidesMy favorite slides
My favorite slides
 
PART 6: FROM GEO INTO YOUR REPORT
PART 6: FROM GEO INTO YOUR REPORTPART 6: FROM GEO INTO YOUR REPORT
PART 6: FROM GEO INTO YOUR REPORT
 
Presentation1 computer shaan
Presentation1 computer shaanPresentation1 computer shaan
Presentation1 computer shaan
 
Cc code cards
Cc code cardsCc code cards
Cc code cards
 
Csphtp1 07
Csphtp1 07Csphtp1 07
Csphtp1 07
 
Yin Yangs of Software Development
Yin Yangs of Software DevelopmentYin Yangs of Software Development
Yin Yangs of Software Development
 
Python GUI Programming
Python GUI ProgrammingPython GUI Programming
Python GUI Programming
 
R-Shiny Cheat sheet
R-Shiny Cheat sheetR-Shiny Cheat sheet
R-Shiny Cheat sheet
 
PART 5: RASTER DATA
PART 5: RASTER DATAPART 5: RASTER DATA
PART 5: RASTER DATA
 
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYAPYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
PYTHON - EXTRA Chapter GUI - MAULIK BORSANIYA
 
03 Geographic scripting in uDig - halfway between user and developer
03 Geographic scripting in uDig - halfway between user and developer03 Geographic scripting in uDig - halfway between user and developer
03 Geographic scripting in uDig - halfway between user and developer
 
OpenVX 1.0 Reference Guide
OpenVX 1.0 Reference GuideOpenVX 1.0 Reference Guide
OpenVX 1.0 Reference Guide
 

Semelhante a C++ Windows Forms L08 - GDI P1

C++ Windows Forms L09 - GDI P2
C++ Windows Forms L09 - GDI P2C++ Windows Forms L09 - GDI P2
C++ Windows Forms L09 - GDI P2Mohammad Shaker
 
Java applet handouts
Java applet handoutsJava applet handouts
Java applet handoutsiamkim
 
On the tomcat drive in folder cosc210 you will find file named Paint.docx
On the tomcat drive in folder cosc210 you will find file named Paint.docxOn the tomcat drive in folder cosc210 you will find file named Paint.docx
On the tomcat drive in folder cosc210 you will find file named Paint.docxdunhamadell
 
XNA L04–Primitives, IndexBuffer and VertexBuffer
XNA L04–Primitives, IndexBuffer and VertexBufferXNA L04–Primitives, IndexBuffer and VertexBuffer
XNA L04–Primitives, IndexBuffer and VertexBufferMohammad Shaker
 
XNA L09–2D Graphics and Particle Engines
XNA L09–2D Graphics and Particle EnginesXNA L09–2D Graphics and Particle Engines
XNA L09–2D Graphics and Particle EnginesMohammad Shaker
 
Basic_Introduction_to_AUTOCAD.ppt
Basic_Introduction_to_AUTOCAD.pptBasic_Introduction_to_AUTOCAD.ppt
Basic_Introduction_to_AUTOCAD.pptVinodKumar257660
 
AutoCAD-ppt.pptx
AutoCAD-ppt.pptxAutoCAD-ppt.pptx
AutoCAD-ppt.pptxMadhu797724
 
AutoCAD-ppt.pptx
AutoCAD-ppt.pptxAutoCAD-ppt.pptx
AutoCAD-ppt.pptxABUFAZZIL
 
mech AutoCAD ppt.pptx
mech AutoCAD ppt.pptxmech AutoCAD ppt.pptx
mech AutoCAD ppt.pptxHarish181
 
asmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docx
asmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docxasmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docx
asmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docxfredharris32
 

Semelhante a C++ Windows Forms L08 - GDI P1 (20)

C++ Windows Forms L09 - GDI P2
C++ Windows Forms L09 - GDI P2C++ Windows Forms L09 - GDI P2
C++ Windows Forms L09 - GDI P2
 
Chapter 13
Chapter 13Chapter 13
Chapter 13
 
Java applet handouts
Java applet handoutsJava applet handouts
Java applet handouts
 
On the tomcat drive in folder cosc210 you will find file named Paint.docx
On the tomcat drive in folder cosc210 you will find file named Paint.docxOn the tomcat drive in folder cosc210 you will find file named Paint.docx
On the tomcat drive in folder cosc210 you will find file named Paint.docx
 
Intake 37 6
Intake 37 6Intake 37 6
Intake 37 6
 
Intake 38 6
Intake 38 6Intake 38 6
Intake 38 6
 
Delphi L06 GDI Drawing
Delphi L06 GDI DrawingDelphi L06 GDI Drawing
Delphi L06 GDI Drawing
 
Cg lab cse-v (1) (1)
Cg lab cse-v (1) (1)Cg lab cse-v (1) (1)
Cg lab cse-v (1) (1)
 
XNA L04–Primitives, IndexBuffer and VertexBuffer
XNA L04–Primitives, IndexBuffer and VertexBufferXNA L04–Primitives, IndexBuffer and VertexBuffer
XNA L04–Primitives, IndexBuffer and VertexBuffer
 
XNA L09–2D Graphics and Particle Engines
XNA L09–2D Graphics and Particle EnginesXNA L09–2D Graphics and Particle Engines
XNA L09–2D Graphics and Particle Engines
 
Basic_Introduction_to_AUTOCAD.ppt
Basic_Introduction_to_AUTOCAD.pptBasic_Introduction_to_AUTOCAD.ppt
Basic_Introduction_to_AUTOCAD.ppt
 
AutoCAD-ppt.pptx
AutoCAD-ppt.pptxAutoCAD-ppt.pptx
AutoCAD-ppt.pptx
 
AutoCAD-ppt.pptx
AutoCAD-ppt.pptxAutoCAD-ppt.pptx
AutoCAD-ppt.pptx
 
AutoCAD-ppt.pptx
AutoCAD-ppt.pptxAutoCAD-ppt.pptx
AutoCAD-ppt.pptx
 
mech AutoCAD ppt.pptx
mech AutoCAD ppt.pptxmech AutoCAD ppt.pptx
mech AutoCAD ppt.pptx
 
GeoGebra 10
GeoGebra 10GeoGebra 10
GeoGebra 10
 
asmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docx
asmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docxasmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docx
asmt7~$sc_210_-_assignment_7_fall_15.docasmt7cosc_210_-_as.docx
 
Scmad Chapter06
Scmad Chapter06Scmad Chapter06
Scmad Chapter06
 
Eg5 n
Eg5 nEg5 n
Eg5 n
 
autocad.ppt
autocad.pptautocad.ppt
autocad.ppt
 

Mais de Mohammad Shaker

12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian GraduateMohammad Shaker
 
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Mohammad Shaker
 
Interaction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyInteraction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyMohammad Shaker
 
Short, Matters, Love - Passioneers Event 2015
Short, Matters, Love -  Passioneers Event 2015Short, Matters, Love -  Passioneers Event 2015
Short, Matters, Love - Passioneers Event 2015Mohammad Shaker
 
Unity L01 - Game Development
Unity L01 - Game DevelopmentUnity L01 - Game Development
Unity L01 - Game DevelopmentMohammad Shaker
 
Android L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesAndroid L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesMohammad Shaker
 
Interaction Design L03 - Color
Interaction Design L03 - ColorInteraction Design L03 - Color
Interaction Design L03 - ColorMohammad Shaker
 
Interaction Design L05 - Typography
Interaction Design L05 - TypographyInteraction Design L05 - Typography
Interaction Design L05 - TypographyMohammad Shaker
 
Interaction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingInteraction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingMohammad Shaker
 
Android L04 - Notifications and Threading
Android L04 - Notifications and ThreadingAndroid L04 - Notifications and Threading
Android L04 - Notifications and ThreadingMohammad Shaker
 
Android L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSAndroid L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSMohammad Shaker
 
Interaction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsInteraction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsMohammad Shaker
 
Interaction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsInteraction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsMohammad Shaker
 
Android L10 - Stores and Gaming
Android L10 - Stores and GamingAndroid L10 - Stores and Gaming
Android L10 - Stores and GamingMohammad Shaker
 
Android L06 - Cloud / Parse
Android L06 - Cloud / ParseAndroid L06 - Cloud / Parse
Android L06 - Cloud / ParseMohammad Shaker
 
Android L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesAndroid L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesMohammad Shaker
 
Android L03 - Styles and Themes
Android L03 - Styles and Themes Android L03 - Styles and Themes
Android L03 - Styles and Themes Mohammad Shaker
 
Android L02 - Activities and Adapters
Android L02 - Activities and AdaptersAndroid L02 - Activities and Adapters
Android L02 - Activities and AdaptersMohammad Shaker
 

Mais de Mohammad Shaker (20)

12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate12 Rules You Should to Know as a Syrian Graduate
12 Rules You Should to Know as a Syrian Graduate
 
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
Ultra Fast, Cross Genre, Procedural Content Generation in Games [Master Thesis]
 
Interaction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with PsychologyInteraction Design L06 - Tricks with Psychology
Interaction Design L06 - Tricks with Psychology
 
Short, Matters, Love - Passioneers Event 2015
Short, Matters, Love -  Passioneers Event 2015Short, Matters, Love -  Passioneers Event 2015
Short, Matters, Love - Passioneers Event 2015
 
Unity L01 - Game Development
Unity L01 - Game DevelopmentUnity L01 - Game Development
Unity L01 - Game Development
 
Android L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and WearablesAndroid L07 - Touch, Screen and Wearables
Android L07 - Touch, Screen and Wearables
 
Interaction Design L03 - Color
Interaction Design L03 - ColorInteraction Design L03 - Color
Interaction Design L03 - Color
 
Interaction Design L05 - Typography
Interaction Design L05 - TypographyInteraction Design L05 - Typography
Interaction Design L05 - Typography
 
Interaction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and CouplingInteraction Design L04 - Materialise and Coupling
Interaction Design L04 - Materialise and Coupling
 
Android L05 - Storage
Android L05 - StorageAndroid L05 - Storage
Android L05 - Storage
 
Android L04 - Notifications and Threading
Android L04 - Notifications and ThreadingAndroid L04 - Notifications and Threading
Android L04 - Notifications and Threading
 
Android L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOSAndroid L09 - Windows Phone and iOS
Android L09 - Windows Phone and iOS
 
Interaction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile ConstraintsInteraction Design L01 - Mobile Constraints
Interaction Design L01 - Mobile Constraints
 
Interaction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and GridsInteraction Design L02 - Pragnanz and Grids
Interaction Design L02 - Pragnanz and Grids
 
Android L10 - Stores and Gaming
Android L10 - Stores and GamingAndroid L10 - Stores and Gaming
Android L10 - Stores and Gaming
 
Android L06 - Cloud / Parse
Android L06 - Cloud / ParseAndroid L06 - Cloud / Parse
Android L06 - Cloud / Parse
 
Android L08 - Google Maps and Utilities
Android L08 - Google Maps and UtilitiesAndroid L08 - Google Maps and Utilities
Android L08 - Google Maps and Utilities
 
Android L03 - Styles and Themes
Android L03 - Styles and Themes Android L03 - Styles and Themes
Android L03 - Styles and Themes
 
Android L02 - Activities and Adapters
Android L02 - Activities and AdaptersAndroid L02 - Activities and Adapters
Android L02 - Activities and Adapters
 
Android L01 - Warm Up
Android L01 - Warm UpAndroid L01 - Warm Up
Android L01 - Warm Up
 

Último

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 

Último (20)

Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

C++ Windows Forms L08 - GDI P1

  • 1. C++.NET Windows Forms Course L08- GDI Part 1 Mohammad Shaker mohammadshakergtr.wordpress.com C++.NET Windows Forms Course @ZGTRShaker
  • 2.
  • 4. What do u need to draw sth? • Pen (stroke width, color, etc) • Paper • Brush to filling your drawing
  • 5. Drawing::Graphic • Encapsulates a GDI* + drawing surface. • This class cannot be inherited. ___________________ • GDI* : Graphical Device Interface
  • 6. Drawing::Graphics private: System::Void button1_Click_5(System::Object^ sender, System::EventArgs^ e) { Drawing::Graphics ^MyGraphics; MyGraphics = pictureBox1->CreateGraphics(); }
  • 7. Drawing::Graphics private void DrawImagePointF(PaintEventArgs e) { // Create image. Image newImage = Image.FromFile("SampImag.jpg"); // Create point for upper-left corner of image. PointF ulCorner = new PointF(100.0F, 100.0F); // Draw image to screen. e.Graphics.DrawImage(newImage, ulCorner); }
  • 8. Method AddMetafileComment BeginContainer() Description BeginContainer(Rectangle, Rectangle, GraphicsUnit) Adds a comment to the current Metafile. Saves a graphics container with the current state of this Graphics and opens and uses a new graphics container. Saves a graphics container with the current state of this Graphics and opens and uses a new graphics container with the specified scale transformation. BeginContainer(RectangleF, RectangleF, GraphicsUnit) Saves a graphics container with the current state of this Graphics and opens and uses a new graphics container with the specified scale transformation. Clear Clears the entire drawing surface and fills it with the specified background color. Performs a bit-block transfer of color data, corresponding to a rectangle of pixels, from the screen to the drawing surface of the Graphics. CopyFromScreen(Point, Point, Size) CopyFromScreen(Point, Point, Size, CopyPixelOperation) Performs a bit-block transfer of color data, corresponding to a rectangle of pixels, from the screen to the drawing surface of the Graphics. CopyFromScreen(Int32, Int32, Int32, Int32, Size) Performs a bit-block transfer of the color data, corresponding to a rectangle of pixels, from the screen to the drawing surface of the Graphics. CopyFromScreen(Int32, Int32, Int32, Int32, Size, CopyPixelOperation) Performs a bit-block transfer of the color data, corresponding to a rectangle of pixels, from the screen to the drawing surface of the Graphics. CreateObjRef Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited fromMarshalByRefObject.) Releases all resources used by this Graphics. Draws an arc representing a portion of an ellipse specified by a Rectangle structure. Draws an arc representing a portion of an ellipse specified by a RectangleF Dispose DrawArc(Pen, Rectangle, Single, Single) DrawArc(Pen, RectangleF, Single, Single)
  • 9. DrawArc(Pen, Int32, Int32, Int32, Int32, Int32, Int32) Draws an arc representing a portion of an ellipse specified by a pair of coordinates, a width, and a height. DrawArc(Pen, Single, Single, Single, Single, Single, Single) Draws an arc representing a portion of an ellipse specified by a pair of coordinates, a width, and a height. DrawBezier(Pen, Point, Point, Point, Point) Draws a Bézier spline defined by four Point structures. DrawBezier(Pen, PointF, PointF, PointF, PointF) Draws a Bézier spline defined by four PointF structures. DrawBezier(Pen, Single, Single, Single, Single, Single, Draws a Bézier spline defined by four ordered pairs of coordinates that represent points. Single, Single, Single) DrawBeziers(Pen, Point[]) Draws a series of Bézier splines from an array of Point structures. DrawBeziers(Pen, PointF[]) Draws a series of Bézier splines from an array of PointF structures. DrawClosedCurve(Pen, Point[]) Draws a closed cardinal spline defined by an array of Point structures. DrawClosedCurve(Pen, PointF[]) Draws a closed cardinal spline defined by an array of PointF structures. DrawClosedCurve(Pen, Point[], Single, FillMode) Draws a closed cardinal spline defined by an array of Point structures using a specified tension. DrawClosedCurve(Pen, PointF[], Single, FillMode) Draws a closed cardinal spline defined by an array of PointF structures using a specified tension. DrawCurve(Pen, Point[]) Draws a cardinal spline through a specified array of Point structures. DrawCurve(Pen, PointF[]) Draws a cardinal spline through a specified array of PointF structures. DrawCurve(Pen, Point[], Single) Draws a cardinal spline through a specified array of Point structures using a specified tension.
  • 10. DrawCurve(Pen, PointF[], Single) DrawCurve(Pen, PointF[], Int32, Int32) Draws a cardinal spline through a specified array of PointF structures using a specified tension. Draws a cardinal spline through a specified array of PointF structures. The drawing begins offset from the beginning of the array. DrawCurve(Pen, Point[], Int32, Int32, Single) Draws a cardinal spline through a specified array of Point structures using a specified tension. DrawCurve(Pen, PointF[], Int32, Int32, Single) Draws a cardinal spline through a specified array of PointF structures using a specified tension. The drawing begins offset from the beginning of the array. DrawEllipse(Pen, Rectangle) Draws an ellipse specified by a bounding Rectangle structure. DrawEllipse(Pen, RectangleF) DrawEllipse(Pen, Int32, Int32, Int32, Int32) Draws an ellipse defined by a bounding RectangleF. Draws an ellipse defined by a bounding rectangle specified by coordinates for the upper-left corner of the rectangle, a height, and a width. DrawEllipse(Pen, Single, Single, Single, Single) Draws an ellipse defined by a bounding rectangle specified by a pair of coordinates, a height, and a width. DrawIcon(Icon, Rectangle) Draws the image represented by the specified Icon within the area specified by aRectangle structure. DrawIcon(Icon, Int32, Int32) DrawIconUnstretched DrawImage(Image, Point) DrawImage(Image, Point[]) Draws the image represented by the specified Icon at the specified coordinates. Draws the image represented by the specified Icon without scaling the image. Draws the specified Image, using its original physical size, at the specified location. Draws the specified Image at the specified location and with the specified shape
  • 12. System::Drawing • Graphics Class : – Can’t be inherited • Inheritance Hierarchy : – System::Object System::MarshalByRefObject System.Drawing::Graphics
  • 13. Drawing::Point • What will happen now? private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) { button1->Location = 30,120; }
  • 15. Drawing::Point • What will happen now? private: System::Void button1_Click(System::Object^ System::EventArgs^ e) { Drawing::Point P; P.X = 2; P.Y = 23; button1->Location = P; } sender,
  • 17. Changing the size of the form at run time So, what should we do?
  • 18. Drawing::Size • Can we do this? Form’s size? private: System::Void button1_Click_1(System::Object^ System::EventArgs^ e) { Drawing::Size S; S.Height = 200; S.Width = 300; this->Size = S; } Yep! sender,
  • 19. Drawing::Size • Can we do this? private: System::Void button1_Click_1(System::Object^ System::EventArgs^ e) { Drawing::Size ^S; S->Height = 200; S->Width = 300; this->Size = S; } sender, Compile error Error 1 error C2664: 'void System::Windows::Forms::Control::Size::set(System::Drawing::Size)' : cannot convert parameter 1 from 'System::Drawing::Size ^' to 'System::Drawing::Size' c:userszgtrdocumentsvisual studio 2008projectsdotnet4dotnet4Form1.h 129 dotNet4
  • 20.
  • 21. Drawing::Size • Do this: private: System::Void button1_Click_1(System::Object^ sender, System::EventArgs^ e) { this->Size = Drawing::Size(200,300); } • Or Add Drawing in using
  • 22.
  • 24. System::Drawing::Pen private: System::Void button1_Click_5(System::Object^ sender, System::EventArgs^ e) { System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red); }
  • 25.
  • 26.
  • 27. Let’s draw a line!
  • 28. Graphics.DrawLine() Method private: System::Void button1_Click_5(System::Object^ System::EventArgs^ e) { System::Drawing::Graphics::DrawLine( } sender,
  • 29.
  • 30. System::Drawing::Pen private: System::Void button1_Click_5(System::Object^ sender, System::EventArgs^ e) { System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red); Drawing::Graphics::DrawLine( MyPen, 2, 3, 4,5 ); }
  • 31. Graphics.DrawLine Method • • • • public: void DrawLine(Pen*, Point, Point); public: void DrawLine(Pen*, PointF, PointF); public: void DrawLine(Pen*, int, int, int, int); public: void DrawLine(Pen*, float, float, float, float);
  • 32.
  • 33.
  • 34. System::Drawing • What will happen now? private: System::Void button1_Click_5(System::Object^ sender, System::EventArgs^ e) { System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red); Drawing::Graphics::DrawLine( MyPen, 2, 3, 4,5 ); } Compiler error ..
  • 35.
  • 36. System::Drawing • What will happen now? private: System::Void button1_Click_5(System::Object^ sender, System::EventArgs^ e) { System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red); Drawing::Graphics ^MyGraphics; MyGraphics->DrawLine( MyPen, 2, 3, 4,5 ); } No compiler error but Runtime error when clicking button1
  • 37.
  • 38. System::Drawing • What will happen now? private: System::Void button1_Click_5(System::Object^ sender, System::EventArgs^ e) { System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red); Drawing::Graphics ^MyGraphics; MyGraphics = pictureBox1->CreateGraphics(); MyGraphics->DrawLine( MyPen, 2, 3, 50,105 ); } A line will be drawn!
  • 40. System::Drawing • Can we do this? private: System::Void button1_Click_5(System::Object^ sender, System::EventArgs^ e) { Drawing::Graphics ^MyGraphics; MyGraphics = pictureBox1->CreateGraphics(); MyGraphics->DrawLine(System::Drawing::Pen(Color::Red),2,3,50,105); } Compiler error
  • 41.
  • 42. System::Drawing • Can we do this? private: System::Void button1_Click_5(System::Object^ System::EventArgs^ e) { System::Drawing::Pen MyPen(); MyPen.Color = Color::Red; Drawing::Graphics ^MyGraphics; MyGraphics = pictureBox1->CreateGraphics(); MyGraphics->DrawLine(MyPen, 2, 3, 50,105 ); } Compiler error sender,
  • 43.
  • 44. System::Drawing • Can we do this? private: System::Void button1_Click_5(System::Object^ System::EventArgs^ e) { System::Drawing::Pen MyPen(Color::Red ); Drawing::Graphics ^MyGraphics; MyGraphics = pictureBox1->CreateGraphics(); MyGraphics->DrawLine(MyPen, 2, 3, 50,105 ); } Compiler error sender,
  • 45.
  • 46. System::Drawing • Can we do this? private: System::Void button1_Click_5(System::Object^ System::EventArgs^ e) { System::Drawing::Pen ^MyPen(Color::Red); Drawing::Graphics ^MyGraphics; MyGraphics = pictureBox1->CreateGraphics(); MyGraphics->DrawLine(MyPen, 2, 3, 50,105 ); } Compiler error! sender,
  • 47.
  • 48. System::Drawing • Can we do this? private: System::Void button1_Click_5(System::Object^ System::EventArgs^ e) { System::Drawing::Pen ^MyPen = gcnew Pen; Drawing::Graphics ^MyGraphics; MyGraphics = pictureBox1->CreateGraphics(); MyGraphics->DrawLine(MyPen, 2, 3, 50,105 ); } Compiler error sender,
  • 49.
  • 50. System::Drawing • Can we do this? private: System::Void button1_Click_5(System::Object^ sender, System::EventArgs^ e) { System::Drawing::Color ^MyColor = gcnew Color; MyColor = Drawing::Color::Red; System::Drawing::Pen ^MyPen = gcnew Pen(*MyColor); Drawing::Graphics ^MyGraphics; MyGraphics = pictureBox1->CreateGraphics(); MyGraphics->DrawLine(MyPen, 2, 3, 50,105 ); } Working!
  • 51. System::Drawing • Can we do this? private: System::Void button1_Click_5(System::Object^ sender, System::EventArgs^ e) { System::Drawing::Color ^MyColor = gcnew Color; // 1 MyColor = Drawing::Color::Red; // 2 System::Drawing::Pen ^MyPen = gcnew Pen(MyColor); // 3 Drawing::Graphics ^MyGraphics; MyGraphics = pictureBox1->CreateGraphics(); MyGraphics->DrawLine(MyPen, 2, 3, 50,105 ); } Compiler error in // 3
  • 52. System::Drawing • Can we do this? private: System::Void button1_Click_5(System::Object^ sender, System::EventArgs^ e) { System::Drawing::Color MyColor = gcnew Color; // 1 MyColor = Drawing::Color::Red; // 2 System::Drawing::Pen ^MyPen = gcnew Pen(*MyColor); // 3 Drawing::Graphics ^MyGraphics; MyGraphics = pictureBox1->CreateGraphics(); MyGraphics->DrawLine(MyPen, 2, 3, 50,105 ); } Compiler error in // 1 . ^
  • 53. System::Drawing • Can we do this? private: System::Void button1_Click_5(System::Object^ sender, System::EventArgs^ e) { System::Drawing::Color ^MyColor = gcnew Color; // 1 MyColor = Red; // 2 System::Drawing::Pen ^MyPen = gcnew Pen(*MyColor); // 3 Drawing::Graphics ^MyGraphics; MyGraphics = pictureBox1->CreateGraphics(); MyGraphics->DrawLine(MyPen, 2, 3, 50,105 ); } Compiler error in // 2 un-declared Red
  • 54. System::Drawing • But remember we can just do this private: System::Void button1_Click_5(System::Object^ sender, System::EventArgs^ e) { System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red); Drawing::Graphics ^MyGraphics; MyGraphics = pictureBox1->CreateGraphics(); MyGraphics->DrawLine( MyPen, 2, 3, 50,105 ); }
  • 55. System::Drawing • Another way! private: System::Void button1_Click_5(System::Object^ sender, System::EventArgs^ e) { System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red); Drawing::Graphics ^MyGraphics; MyGraphics = pictureBox1->CreateGraphics(); Drawing::Point ^P1 = gcnew Point(50,60); Drawing::Point ^P2 = gcnew Point(150,160); MyGraphics->DrawLine( MyPen, *P1, *P2 ); } What will happen?
  • 57. System::Drawing • Another way! private: System::Void button1_Click_5(System::Object^ sender, System::EventArgs^ e) { System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red); Drawing::Graphics ^MyGraphics; MyGraphics = pictureBox1->CreateGraphics(); Drawing::Point P1 = gcnew Point(50,60); Drawing::Point P2 = gcnew Point(150,160); MyGraphics->DrawLine( MyPen, *P1, *P2 ); } What will happen? Compiler error
  • 58. System::Drawing • Another way! private: System::Void button1_Click_5(System::Object^ sender, System::EventArgs^ e) { System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red); Drawing::Graphics ^MyGraphics; MyGraphics = pictureBox1->CreateGraphics(); Drawing::Point P1 = gcnew Point(50,60); Drawing::Point P2 = gcnew Point(150,160); MyGraphics->DrawLine( MyPen, P1, P2 ); } What will happen? Compiler error
  • 59. System::Drawing • Can we do this? private: System::Void button1_Click_5(System::Object^ sender, System::EventArgs^ e) { System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red); Drawing::Graphics ^MyGraphics; MyGraphics = pictureBox1->CreateGraphics(); Drawing::Point P1(50,60); Drawing::Point P2(150,160); MyGraphics->DrawLine( MyPen, P1, P2 ); } Works!
  • 60. System::Drawing • Sth wrong? private: System::Void button1_Click_5(System::Object^ sender, System::EventArgs^ e) { System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red); Drawing::Graphics ^MyGraphics; MyGraphics = pictureBox1->CreateGraphics(); Drawing::Point P1; P1.X = 50; P1.Y = 60; Drawing::Point P2; P2.X = 150; P2.Y = 160; MyGraphics->DrawLine( MyPen, P1, P2 ); } Works!
  • 61. System::Drawing • What will happen now? private: System::Void button1_Click_5(System::Object^ sender, System::EventArgs^ e) { System::Drawing::Pen ^ MyPen = gcnew Pen(Color::Red); Drawing::Graphics ^MyGraphics; MyGraphics = pictureBox1->CreateGraphics(); Drawing::Point P1, P2; P1.X = 50; P1.Y = 60; P2.X = 150; P2.Y = 160; MyGraphics->DrawLine( MyPen, P1, P2 ); P1.X = 50; P1.Y = 60; P2.X = 510; P2.Y = 610; MyGraphics->DrawLine( MyPen, P1, P2 ); }
  • 62. System::Drawing • What’s missing? Next Lesson we’ll find out!
  • 63. Mouse! private: System::Void panel1_MouseClick(System::Object^ sender, System::Windows::Forms::MouseEventArgs^ e) { System::Drawing::Point P(0,0); MyGraphics->DrawEllipse(MyPen,e->X,e->Y,10,10); MyGraphics->FillEllipse(MyBrush,e->X,e->Y,10,10); }
  • 64. That’s it for today!