, Visual C#



 

6.1. .

private void Form1_Paint(object sender, PaintEventArgs e)

{

// :

Pen myPen1 = new Pen(Color.Black, 3);

// myRectangle :

Rectangle myRectangle = new Rectangle(10, 15, 150, 200);

// :

e.Graphics.DrawRectangle(myPen1, myRectangle);

// , myPen1:

myPen1.Dispose();

}

6.2. .

private void Form1_Paint(object sender, PaintEventArgs e)

{

// :

Pen myPen1 = new Pen(Color.Black, 3);

Pen myPen2 = new Pen(Color.Black, 1);

 

// :

Point myPoint1 = new Point(50, 50);

Point myPoint2 = new Point(100, 25);

Point myPoint3 = new Point(200, 5);

Point myPoint4 = new Point(275, 50);

Point myPoint5 = new Point(300, 150);

Point myPoint6 = new Point(350, 200);

Point myPoint7 = new Point(250, 250);

Point[] myCurvePoints =

{

myPoint1,

myPoint2,

myPoint3,

myPoint4,

myPoint5,

myPoint6,

myPoint7

};

// :

e.Graphics.DrawLines(myPen1, myCurvePoints);

e.Graphics.DrawClosedCurve(myPen2, myCurvePoints);

// myPen1, myPen2:

myPen1.Dispose();

myPen2.Dispose();

}

6.3. .

[System.Runtime.InteropServices.DllImport("gdi32.dll")]

public static extern long BitBlt(IntPtr hdcDest,

int nXDest, int nYDest, int nWidth, int nHeight,

IntPtr hdcSrc, int nXSrc, int nYSrc, int dwRop);

private Bitmap myMemoryImage;

private void myCaptureScreen()

{

Graphics myGraphics = this.CreateGraphics();

Size s = this.Size;

myMemoryImage = new Bitmap(s.Width, s.Height,

myGraphics);