VB.Net by API/System.Drawing/Graphics

Материал из VB Эксперт
Версия от 15:50, 26 мая 2010; Admin (обсуждение | вклад) (1 версия)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

Graphics.Clear(Color c)

<source lang="vbnet"> Imports System Imports System.Windows.Forms Imports System.Drawing

Public Class MainClass

 Shared Sub Main()
    Dim form1 As Form1 = new Form1
    Application.Run(form1)
 End Sub
 

End Class Public Class Form1

   Inherits System.Windows.Forms.Form
   Public Sub New()
       MyBase.New()
       Me.ClientSize = New System.Drawing.Size(292, 273)
   End Sub
 Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
   Dim G As Graphics = e.Graphics
   G.Clear(Color.BurlyWood)
   Dim r As Rectangle = New Rectangle(50, 50, 100, 100)
   Dim b As Brush = Brushes.Crimson
   G.FillRectangle(b, r)
 End Sub

End Class


 </source>


Graphics.Clip

<source lang="vbnet"> Imports System Imports System.ruponentModel Imports System.Windows.Forms Imports System.Data Imports System.Configuration Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Drawing.Text Imports System.Globalization Imports System.Text Imports System.Collections Public Class MainClass

   Shared Sub Main()
       
       Dim myform As Form = New ClippingRegionForm()
       Application.Run(myform)
   End Sub

End Class

Public Class ClippingRegionForm

   Inherits System.Windows.Forms.Form
  1. Region " Windows Form Designer generated code "
   Public Sub New()
       MyBase.New()
       "This call is required by the Windows Form Designer.
       InitializeComponent()
       "Add any initialization after the InitializeComponent() call
   End Sub
   "Form overrides dispose to clean up the component list.
   Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
       If disposing Then
           If Not (components Is Nothing) Then
               components.Dispose()
           End If
       End If
       MyBase.Dispose(disposing)
   End Sub
   "Required by the Windows Form Designer
   Private components As System.ruponentModel.IContainer
   "NOTE: The following procedure is required by the Windows Form Designer
   "It can be modified using the Windows Form Designer.  
   "Do not modify it using the code editor.
   <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
       components = New System.ruponentModel.Container()
       Me.Text = "ClippingRegionForm"
   End Sub
  1. End Region
   Private Sub ClippingRegionForm_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
       Dim g As Graphics = e.Graphics
       Dim path As GraphicsPath = New GraphicsPath()
       path.AddEllipse(Me.ClientRectangle)
       Dim region As Region = New Region(path)
       g.DrawPath(Pens.Red, path)
       g.Clip = region
       Dim rect As Rectangle = Me.ClientRectangle
       rect.Offset(20, 20)
       rect.Width = rect.Width - 40
       rect.Height = rect.Height - 40
       g.FillRectangle(Brushes.Black, rect)
   End Sub

End Class


 </source>


Graphics.CompositingMode

<source lang="vbnet">

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class AlphaBCompGammaCorr

  public Shared Sub Main
       Application.Run(New Form1)
  End Sub

End class public class Form1

 Inherits System.Windows.Forms.Form
 Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
       Dim g As Graphics = Me.CreateGraphics()
       g.Clear(Me.BackColor)
       Dim rect1 As New Rectangle(20, 20, 100, 100)
       Dim rect2 As New Rectangle(200, 20, 100, 100)
       Dim redBrush As New SolidBrush(Color.FromArgb(150, 255, 0, 0))
       Dim greenBrush As New SolidBrush(Color.FromArgb(180, 0, 255, 0))
       Dim tempBmp As New Bitmap(200, 150)
       Dim tempGraphics As Graphics = Graphics.FromImage(tempBmp)
       tempGraphics.rupositingMode = CompositingMode.SourceOver
       tempGraphics.rupositingQuality = CompositingQuality.GammaCorrected
       tempGraphics.FillRectangle(redBrush, rect1)
       rect1.X += 30
       rect1.Y += 30
       tempGraphics.FillEllipse(greenBrush, rect1)
       g.rupositingQuality = CompositingQuality.GammaCorrected
       g.DrawImage(tempBmp, 0, 0)
       g.FillRectangle(Brushes.Red, rect2)
       rect2.X += 30
       rect2.Y += 30
       g.FillEllipse(Brushes.Green, rect2)
       tempBmp.Dispose()
       g.Dispose()
 End Sub
 Public Sub New()
  
   MyBase.New()
   Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
   Me.ClientSize = New System.Drawing.Size(292, 273)
   Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
 End Sub

End Class


 </source>


Graphics.CompositingQuality

<source lang="vbnet">

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class CompositingQualityHighSpeed

  public Shared Sub Main
       Application.Run(New Form1)
  End Sub

End class public class Form1

 Inherits System.Windows.Forms.Form
 Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
       Dim g As Graphics = Me.CreateGraphics()
       g.Clear(Me.BackColor)
       Dim redPen As New Pen(Color.Red, 20)
       Dim bluePen As New Pen(Color.Blue, 10)
       Dim gContainer1 As GraphicsContainer = g.BeginContainer()
       g.SmoothingMode = SmoothingMode.AntiAlias
       g.rupositingQuality = CompositingQuality.GammaCorrected
       g.DrawEllipse(redPen, 10, 10, 100, 50)
       g.DrawRectangle(bluePen, 210, 0, 100, 100)
       Dim gContainer2 As GraphicsContainer = g.BeginContainer()
       g.SmoothingMode = SmoothingMode.HighSpeed
       g.rupositingQuality = CompositingQuality.HighSpeed
       g.DrawEllipse(redPen, 10, 150, 100, 50)
       g.DrawRectangle(bluePen, 210, 150, 100, 100)
       g.EndContainer(gContainer2)
       g.EndContainer(gContainer1)
       redPen.Dispose()
       bluePen.Dispose()
       g.Dispose()
 End Sub
 Public Sub New()
  
   MyBase.New()
   Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
   Me.ClientSize = New System.Drawing.Size(292, 273)
   Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
 End Sub

End Class


 </source>


Graphics.DrawArc

<source lang="vbnet"> Imports System Imports System.Windows.Forms Imports System.Drawing Imports System.Drawing.Drawing2D

Public Class MainClass

 Shared Sub Main()
    Dim form1 As Form1 = new Form1
    Application.Run(form1)
 End Sub
 

End Class Public Class Form1

 Inherits System.Windows.Forms.Form
 Public Sub New()
   MyBase.New()
   Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
   Me.ClientSize = New System.Drawing.Size(504, 629)
   Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
   Me.Text = "Form1"
 End Sub
 Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
   Dim R1 As New Rectangle(10, 10, 40, 40)
   e.Graphics.SmoothingMode = SmoothingMode.HighQuality
   e.Graphics.ResetTransform()
   e.Graphics.TranslateTransform(200.0F, 50.0F)
   e.Graphics.DrawArc(Pens.DarkBlue, R1, 40, 160)
 End Sub

End Class


 </source>


Graphics.DrawBezier

<source lang="vbnet"> Imports System Imports System.Windows.Forms Imports System.Drawing.Text Imports System.Drawing Public Class MainClass

   Shared Sub Main(ByVal args As String())
       Dim myform As Form = New Form1()
       Application.Run(myform)
   End Sub

End Class

Public Class Form1

   Inherits System.Windows.Forms.Form
   Private Sub Form1_Paint(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
       " Define the Bezier curve"s control points.
       Dim pts() As Point = { _
           New Point(100, 100), _
           New Point(20, 10), _
           New Point(50, 200), _
           New Point(200, 150) _
       }
       " Connect the points with dashed lines.
       Dim dashed_pen As New Pen(Color.Black, 0)
       dashed_pen.DashStyle = Drawing2D.DashStyle.Dash
       For i As Integer = 0 To 2
           e.Graphics.DrawLine(dashed_pen, pts(i), pts(i + 1))
       Next i
       " Draw the Bezier curve.
       e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
       Dim bez_pen As New Pen(Color.Black, 3)
       e.Graphics.DrawBezier(bez_pen, pts(0), pts(1), pts(2), pts(3))
   End Sub

End Class


 </source>


Graphics.DrawClosedCurve

<source lang="vbnet"> Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class DrawClosedCurve

  public Shared Sub Main
       Application.Run(New FillModesForm)
  End Sub

End class

Public Class FillModesForm

   Inherits System.Windows.Forms.Form
  1. Region " Windows Form Designer generated code "
   Public Sub New()
       MyBase.New()
       "This call is required by the Windows Form Designer.
       InitializeComponent()
       "Add any initialization after the InitializeComponent() call
   End Sub
   "Form overrides dispose to clean up the component list.
   Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
       If disposing Then
           If Not (components Is Nothing) Then
               components.Dispose()
           End If
       End If
       MyBase.Dispose(disposing)
   End Sub
   "Required by the Windows Form Designer
   Private components As System.ruponentModel.IContainer
   "NOTE: The following procedure is required by the Windows Form Designer
   "It can be modified using the Windows Form Designer.  
   "Do not modify it using the code editor.
   <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
       components = New System.ruponentModel.Container()
       Me.Text = "FillModesForm"
   End Sub
  1. End Region
   Private Sub FillModesForm_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
       Dim g As Graphics = e.Graphics
       Dim x As Integer = 0
       Dim y As Integer = 0
       Dim width As Integer = Me.ClientRectangle.Width / 2
       Dim height As Integer = Me.ClientRectangle.Height
       Dim fillBrush As Brush = Brushes.Gray
       Dim pen As Pen = New Pen(Color.Red, 4)
       Dim pointPen As Pen = New Pen(Color.Black, 3)
       pointPen.StartCap = pointPen.EndCap = LineCap.SquareAnchor
       Dim points As PointF() = New PointF() {New PointF(x + 25, y + height - 25), New PointF(x + width - 25, y + height - 25), New PointF(x + 25, height / 2), New PointF(x + width - 25, y + 25), New PointF(x + 25, y + 25), New PointF(x + width - 25, height / 2)}
       g.DrawClosedCurve(pen, points)
   End Sub

End Class


 </source>


Graphics.DrawCurve

<source lang="vbnet"> Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class DrawCurve

  public Shared Sub Main
       Application.Run(New Form1)
  End Sub

End class public class Form1

 Inherits System.Windows.Forms.Form
 Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
       Dim a As Graphics =  e.Graphics
       Dim mypen As Pen
       Dim mypoints(21) As PointF
       Dim i As Integer
       mypen = New Pen(System.Drawing.Color.Red, 3)
       For i = 0 To 9
           mypoints(i).X = 10 * i
           mypoints(i).Y = i * i * 3
       Next
       For i = 10 To 20
           mypoints(i).X = 10 * i
           mypoints(i).Y = (200 + i * i) / 15
       Next
       a = Me.CreateGraphics
       a.Clear(Me.BackColor)
       a.DrawCurve(mypen, mypoints)
       a.Dispose()
       mypen.Dispose()
 End Sub
 Public Sub New()
   MyBase.New()
   Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
   Me.ClientSize = New System.Drawing.Size(292, 273)
   Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
 End Sub

End Class


 </source>


Graphics.DrawEllipse(Pen, Int x, Int y, Int w, Int h)

<source lang="vbnet"> Imports System Imports System.Windows.Forms Imports System.Collections.Generic Imports System.ruponentModel Imports System.Drawing.Imaging Imports System.Drawing Public Class MainClass

  Shared Sub Main()
       Dim bm As New Bitmap(256, 256)
       " Draw on it.
       Dim gr As Graphics = Graphics.FromImage(bm)
       gr.Clear(Color.White)
       gr.DrawEllipse(Pens.Red, 0, 0, bm.Width - 1, bm.Height - 1)
       gr.DrawLine(Pens.Green, 0, 0, bm.Width - 1, bm.Height - 1)
       gr.DrawLine(Pens.Blue, bm.Width - 1, 0, 0, bm.Height - 1)
       " Save the result as a JPEG file.
       bm.Save("test.gif", ImageFormat.Gif)
  End Sub 

End Class


 </source>


Graphics.DrawIcon

<source lang="vbnet">

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class DrawIconUnstretched

  public Shared Sub Main
       Application.Run(New Form1)
  End Sub

End class public class Form1

 Inherits System.Windows.Forms.Form
 Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
       " Drawing an Icon
    Dim icon As New Icon("1.ico")
    Dim x As Integer = 50
    Dim y As Integer = 100
    e.Graphics.DrawIcon(icon, x, y)
    Dim rect As New Rectangle(50, 100, 400, 400)
    e.Graphics.DrawIconUnstretched(icon, rect)
 End Sub
 Public Sub New()
  
   MyBase.New()
   Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
   Me.ClientSize = New System.Drawing.Size(292, 273)
   Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
 End Sub

End Class


 </source>


Graphics.DrawImage(Bitmap bmp, Int x, Int y)

<source lang="vbnet">

Imports System Imports System.Windows.Forms Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Drawing.Text Imports System.Drawing.Imaging Public Class MainClass

 Shared Sub Main()
    Dim form1 As Form1 = new Form1
    Application.Run(form1)
 End Sub
 

End Class

Public Class Form1

 Inherits System.Windows.Forms.Form
 Public Sub New()
   MyBase.New()
   Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
   Me.ClientSize = New System.Drawing.Size(292, 273)
   Me.Text = "Form1"
 End Sub
 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
 End Sub
 Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
   Dim bmp As Bitmap = New Bitmap("figure2.bmp")
   Dim c As Color
   Dim x, y As Int32
   e.Graphics.DrawImage(bmp, 10, 30)
   For x = 0 To bmp.Width - 1
     For y = 0 To bmp.Height - 1
       c = bmp.GetPixel(x, y)
       c = Color.FromArgb(c.ToArgb() + 100)
       bmp.SetPixel(x, y, c)
     Next
   Next
   e.Graphics.DrawImage(bmp, 150, 30)
 End Sub

End Class


 </source>


Graphics.DrawLine(Pen p, Int x, Int y, Int x1, Int y1)

<source lang="vbnet"> Imports System Imports System.Windows.Forms Imports System.Collections.Generic Imports System.ruponentModel Imports System.Drawing.Imaging Imports System.Drawing Public Class MainClass

  Shared Sub Main()
       Dim bm As New Bitmap(256, 256)
       " Draw on it.
       Dim gr As Graphics = Graphics.FromImage(bm)
       gr.Clear(Color.White)
       gr.DrawEllipse(Pens.Red, 0, 0, bm.Width - 1, bm.Height - 1)
       gr.DrawLine(Pens.Green, 0, 0, bm.Width - 1, bm.Height - 1)
       gr.DrawLine(Pens.Blue, bm.Width - 1, 0, 0, bm.Height - 1)
       " Save the result as a JPEG file.
       bm.Save("test.gif", ImageFormat.Gif)
  End Sub 

End Class


 </source>


Graphics.DrawPath

<source lang="vbnet">

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class StringOutLine

  public Shared Sub Main
       Application.Run(New Form1)
  End Sub

End class Public Class Form1

   Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
       Dim outlinePath As New Drawing2D.GraphicsPath
       Dim useFont As Font = New Font("Times New Roman", 96, FontStyle.Regular)
       e.Graphics.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
       e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
       outlinePath.AddString("www.vbex.ru", useFont.FontFamily, FontStyle.Regular, 96, New Point(0, 0), StringFormat.GenericTypographic)
       useFont.Dispose()
       e.Graphics.FillPath(Brushes.LightGray, outlinePath)
       e.Graphics.TranslateTransform(-5, -5)
       e.Graphics.FillPath(Brushes.White, outlinePath)
       e.Graphics.DrawPath(Pens.Black, outlinePath)
       outlinePath.Dispose()
   End Sub

End Class

<Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _ Partial Class Form1

   Inherits System.Windows.Forms.Form
   "Form overrides dispose to clean up the component list.
   <System.Diagnostics.DebuggerNonUserCode()> _
   Protected Overrides Sub Dispose(ByVal disposing As Boolean)
       If disposing AndAlso components IsNot Nothing Then
           components.Dispose()
       End If
       MyBase.Dispose(disposing)
   End Sub
   "Required by the Windows Form Designer
   Private components As System.ruponentModel.IContainer
   "NOTE: The following procedure is required by the Windows Form Designer
   "It can be modified using the Windows Form Designer.  
   "Do not modify it using the code editor.
   <System.Diagnostics.DebuggerStepThrough()> _
   Private Sub InitializeComponent()
       Me.PictureBox1 = New System.Windows.Forms.PictureBox
       CType(Me.PictureBox1, System.ruponentModel.ISupportInitialize).BeginInit()
       Me.SuspendLayout()
       "
       "PictureBox1
       "
       Me.PictureBox1.BackColor = System.Drawing.Color.White
       Me.PictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
       Me.PictureBox1.Location = New System.Drawing.Point(8, 8)
       Me.PictureBox1.Name = "PictureBox1"
       Me.PictureBox1.Size = New System.Drawing.Size(780, 152)
       Me.PictureBox1.TabIndex = 0
       Me.PictureBox1.TabStop = False
       "
       "Form1
       "
       Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
       Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
       Me.ClientSize = New System.Drawing.Size(800, 166)
       Me.Controls.Add(Me.PictureBox1)
       Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
       Me.MaximizeBox = False
       Me.Name = "Form1"
       Me.Text = "Outline Text"
       CType(Me.PictureBox1, System.ruponentModel.ISupportInitialize).EndInit()
       Me.ResumeLayout(False)
   End Sub
   Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox

End Class


 </source>


Graphics.DrawPolygon

<source lang="vbnet"> Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class DrawArrow

  public Shared Sub Main
       Application.Run(New Form1)
  End Sub

End class public class Form1

 Inherits System.Windows.Forms.Form
 Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
       e.Graphics.ScaleTransform(30, 30, MatrixOrder.Append)
       DrawArrow(e.Graphics, HatchStyle.Horizontal)
   End Sub
   Private Sub DrawArrow(ByVal gr As Graphics, ByVal hatch_style As HatchStyle)
       Dim pts() As Point = { _
           New Point(0, 1), _
           New Point(2, 1), _
           New Point(2, 0), _
           New Point(4, 2), _
           New Point(2, 4), _
           New Point(2, 3), _
           New Point(0, 3) _
       }
       gr.FillPolygon(New HatchBrush(hatch_style, Color.Black, Color.White), pts)
       gr.DrawPolygon(New Pen(Color.Black, 0), pts)
   End Sub
 Public Sub New()
   MyBase.New()
   Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
   Me.ClientSize = New System.Drawing.Size(292, 273)
   Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
 End Sub

End Class


 </source>


Graphics.DrawRectangle(Pen pen1, Rectangle rectangle1)

<source lang="vbnet"> Imports System Imports System.Drawing Imports System.Windows.Forms Imports System.Drawing.Text Public Class MainClass

  Shared Sub Main()
       Dim myform As Form = New FrmDrawing()
       Application.Run(myform)
  End Sub " Main

End Class Public Class FrmDrawing

  Inherits System.Windows.Forms.Form
  Public Sub New()
     MyBase.New()
     Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
     Me.BackColor = System.Drawing.SystemColors.AppWorkspace
     Me.ClientSize = New System.Drawing.Size(472, 157)
  End Sub
  Protected Overrides Sub OnPaint(ByVal paintEvent As PaintEventArgs)
     Dim graphicsObject As Graphics = paintEvent.Graphics
     Dim rectangle1 As Rectangle = New Rectangle(15, 35, 80, 80)
     Dim brush1 As SolidBrush = New SolidBrush(Color.Firebrick)
     Dim pen1 As Pen = New Pen(brush1, 1)
     Dim brush2 As SolidBrush = New SolidBrush(Color.DarkBlue)
     Dim pen2 As Pen = New Pen(brush2, 1)
     " start at 0 and sweep 360 degrees
     graphicsObject.DrawRectangle(pen1, rectangle1)
     graphicsObject.DrawArc(pen2, rectangle1, 0, 360)
  End Sub " OnPaint

End Class " FrmDrawing


 </source>


Graphics.DrawString

<source lang="vbnet"> Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class TextureTransform

  public Shared Sub Main
       Application.Run(New Form1)
  End Sub

End class public class Form1

 Inherits System.Windows.Forms.Form
 Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
       Dim g As Graphics = e.Graphics
       Dim str As String = "www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru www.vbex.ru "
       g.ScaleTransform(2, 1)
       g.RotateTransform(45.0F, System.Drawing.Drawing2D.MatrixOrder.Prepend)
       g.TranslateTransform(-20, -70)
       g.DrawString(str, New Font("Verdana", 10), New SolidBrush(Color.Blue), New RectangleF(50, 20, 200, 300))
 End Sub
 Public Sub New()
  
   MyBase.New()
   Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
   Me.ClientSize = New System.Drawing.Size(292, 273)
   Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
 End Sub

End Class


 </source>


Graphics.DrawString(String s, Font m, Brush , Int x, Int y)

<source lang="vbnet"> Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class FontStyleOrAdding

  public Shared Sub Main
       Application.Run(New Form1)
  End Sub

End class Public Class Form1

   Inherits System.Windows.Forms.Form
   Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
       Dim canvas As Graphics = e.Graphics
       
       Dim mainFont As Font
       Dim textStyle As New FontStyle
       textStyle = FontStyle.Regular
       textStyle = textStyle Or FontStyle.Bold
       mainFont = New Font("Arial", 40, textStyle)
       
       Dim brush1 As New SolidBrush(Color.DarkBlue)
       canvas.DrawString("www.vbex.ru",mainFont, brush1, 120, 70)        
       
       canvas = Nothing
   End Sub

End Class


 </source>


Graphics.ExcludeClip

<source lang="vbnet"> Imports System Imports System.Windows.Forms Imports System.Drawing Imports System.Drawing.Drawing2D

Public Class MainClass

 Shared Sub Main()
    Dim form1 As Form1 = new Form1
    Application.Run(form1)
 End Sub
 

End Class Public Class Form1

 Inherits System.Windows.Forms.Form
  1. Region " Windows Form Designer generated code "
 Public Sub New()
   MyBase.New()
   "This call is required by the Windows Form Designer.
   InitializeComponent()
   "Add any initialization after the InitializeComponent() call
 End Sub
 "Form overrides dispose to clean up the component list.
 Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
   If disposing Then
     If Not (components Is Nothing) Then
       components.Dispose()
     End If
   End If
   MyBase.Dispose(disposing)
 End Sub
 "Required by the Windows Form Designer
 Private components As System.ruponentModel.IContainer
 "NOTE: The following procedure is required by the Windows Form Designer
 "It can be modified using the Windows Form Designer.  
 "Do not modify it using the code editor.
 <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
   Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
   Me.ClientSize = New System.Drawing.Size(352, 273)
   Me.Name = "Form1"
   Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
   Me.Text = "Form1"
   Me.ResumeLayout(False)
 End Sub
  1. End Region
  Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
   Dim G As Graphics = Me.CreateGraphics
   Dim R As New Rectangle(40.0F, 20.0F, 100.0F, 100.0F)
   Dim path As New GraphicsPath()
   G.Clear(Color.Gainsboro)
   path.AddEllipse(R)
   G.DrawPath(Pens.Black, path)
   G.ExcludeClip(New Region(path))
   " Draw some clipped strings.
   Dim F As New Font("Arial", 16)
   G.DrawString("www.vbex.ru", F, Brushes.DeepPink, 15, 25)
 End Sub

End Class


 </source>


Graphics.FillClosedCurve

<source lang="vbnet">

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class FillClosedCurve

  public Shared Sub Main
       Application.Run(New FillModesForm)
  End Sub

End class

Public Class FillModesForm

   Inherits System.Windows.Forms.Form
  1. Region " Windows Form Designer generated code "
   Public Sub New()
       MyBase.New()
       "This call is required by the Windows Form Designer.
       InitializeComponent()
       "Add any initialization after the InitializeComponent() call
   End Sub
   "Form overrides dispose to clean up the component list.
   Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
       If disposing Then
           If Not (components Is Nothing) Then
               components.Dispose()
           End If
       End If
       MyBase.Dispose(disposing)
   End Sub
   "Required by the Windows Form Designer
   Private components As System.ruponentModel.IContainer
   "NOTE: The following procedure is required by the Windows Form Designer
   "It can be modified using the Windows Form Designer.  
   "Do not modify it using the code editor.
   <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
       components = New System.ruponentModel.Container()
       Me.Text = "FillModesForm"
   End Sub
  1. End Region
   Private Sub FillModesForm_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
       Dim g As Graphics = e.Graphics
       Dim x As Integer = 0
       Dim y As Integer = 0
       Dim width As Integer = Me.ClientRectangle.Width / 2
       Dim height As Integer = Me.ClientRectangle.Height
       Dim fillBrush As Brush = Brushes.Gray
       Dim pen As Pen = New Pen(Color.Red, 4)
       Dim pointPen As Pen = New Pen(Color.Black, 3)
       pointPen.StartCap = pointPen.EndCap = LineCap.SquareAnchor
       Dim points As PointF() = New PointF() {New PointF(x + 25, y + height - 25), New PointF(x + width - 25, y + height - 25), New PointF(x + 25, height / 2), New PointF(x + width - 25, y + 25), New PointF(x + 25, y + 25), New PointF(x + width - 25, height / 2)}
       g.DrawClosedCurve(pen, points)
       Dim fill As FillMode = FillMode.Winding
       g.FillClosedCurve(fillBrush, points, fill)
   End Sub

End Class


 </source>


Graphics.FillEllipse

<source lang="vbnet"> Imports System Imports System.Drawing Imports System.Windows.Forms Imports System.Drawing.Text Public Class MainClass

  Shared Sub Main()
       Dim myform As Form = New FrmDrawing()
       Application.Run(myform)
  End Sub " Main

End Class

Public Class FrmDrawing

  Inherits System.Windows.Forms.Form
  1. Region " Windows Form Designer generated code "
  Public Sub New()
     MyBase.New()
     "This call is required by the Windows Form Designer.
     InitializeComponent()
     "Add any initialization after the InitializeComponent() call
  End Sub
  "Form overrides dispose to clean up the component list.
  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
     If disposing Then
        If Not (components Is Nothing) Then
           components.Dispose()
        End If
     End If
     MyBase.Dispose(disposing)
  End Sub
  "Required by the Windows Form Designer
  Private components As System.ruponentModel.Container
  "NOTE: The following procedure is required by the Windows Form Designer
  "It can be modified using the Windows Form Designer.  
  "Do not modify it using the code editor.
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
     "
     "frmDrawing
     "
     Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
     Me.BackColor = System.Drawing.SystemColors.AppWorkspace
     Me.ClientSize = New System.Drawing.Size(472, 157)
     Me.Name = "frmDrawing"
     Me.Text = "Drawing lines, rectangles and ovals"
  End Sub
  1. End Region
  " display ovals lines, and rectangles
  Protected Overrides Sub OnPaint( _
     ByVal paintEvent As PaintEventArgs)
     " get graphics object
     Dim g As Graphics = paintEvent.Graphics
     Dim brush As SolidBrush = New SolidBrush(Color.Blue)
     Dim pen As Pen = New Pen(Color.AliceBlue)
     " set brush to red
     brush.Color = Color.Red
     " draw base Ellipse
     g.FillEllipse(brush, 280, 75, 100, 50)
     " draw connecting lines
     g.DrawLine(pen, 380, 55, 380, 100)
     g.DrawLine(pen, 280, 55, 280, 100)
     " draw Ellipse outline
     g.DrawEllipse(pen, 280, 30, 100, 50)
  End Sub " OnPaint

End Class


 </source>


Graphics.FillPath

<source lang="vbnet">

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class StringOutLine

  public Shared Sub Main
       Application.Run(New Form1)
  End Sub

End class Public Class Form1

   Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
       Dim outlinePath As New Drawing2D.GraphicsPath
       Dim useFont As Font = New Font("Times New Roman", 96, FontStyle.Regular)
       e.Graphics.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias
       e.Graphics.SmoothingMode = Drawing2D.SmoothingMode.AntiAlias
       outlinePath.AddString("www.vbex.ru", useFont.FontFamily, FontStyle.Regular, 96, New Point(0, 0), StringFormat.GenericTypographic)
       useFont.Dispose()
       e.Graphics.FillPath(Brushes.LightGray, outlinePath)
       e.Graphics.TranslateTransform(-5, -5)
       e.Graphics.FillPath(Brushes.White, outlinePath)
       e.Graphics.DrawPath(Pens.Black, outlinePath)
       outlinePath.Dispose()
   End Sub

End Class

<Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _ Partial Class Form1

   Inherits System.Windows.Forms.Form
   "Form overrides dispose to clean up the component list.
   <System.Diagnostics.DebuggerNonUserCode()> _
   Protected Overrides Sub Dispose(ByVal disposing As Boolean)
       If disposing AndAlso components IsNot Nothing Then
           components.Dispose()
       End If
       MyBase.Dispose(disposing)
   End Sub
   "Required by the Windows Form Designer
   Private components As System.ruponentModel.IContainer
   "NOTE: The following procedure is required by the Windows Form Designer
   "It can be modified using the Windows Form Designer.  
   "Do not modify it using the code editor.
   <System.Diagnostics.DebuggerStepThrough()> _
   Private Sub InitializeComponent()
       Me.PictureBox1 = New System.Windows.Forms.PictureBox
       CType(Me.PictureBox1, System.ruponentModel.ISupportInitialize).BeginInit()
       Me.SuspendLayout()
       "
       "PictureBox1
       "
       Me.PictureBox1.BackColor = System.Drawing.Color.White
       Me.PictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
       Me.PictureBox1.Location = New System.Drawing.Point(8, 8)
       Me.PictureBox1.Name = "PictureBox1"
       Me.PictureBox1.Size = New System.Drawing.Size(780, 152)
       Me.PictureBox1.TabIndex = 0
       Me.PictureBox1.TabStop = False
       "
       "Form1
       "
       Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
       Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
       Me.ClientSize = New System.Drawing.Size(800, 166)
       Me.Controls.Add(Me.PictureBox1)
       Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
       Me.MaximizeBox = False
       Me.Name = "Form1"
       Me.Text = "Outline Text"
       CType(Me.PictureBox1, System.ruponentModel.ISupportInitialize).EndInit()
       Me.ResumeLayout(False)
   End Sub
   Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox

End Class


 </source>


Graphics.FillPie

<source lang="vbnet"> Imports System Imports System.Drawing Imports System.Windows.Forms Imports System.Drawing.Text Public Class MainClass

  Shared Sub Main()
       Dim myform As Form = New FrmDrawing()
       Application.Run(myform)
  End Sub " Main

End Class

Public Class FrmDrawing

  Inherits System.Windows.Forms.Form
  1. Region " Windows Form Designer generated code "
  Public Sub New()
     MyBase.New()
     "This call is required by the Windows Form Designer.
     InitializeComponent()
     "Add any initialization after the InitializeComponent() call
  End Sub
  "Form overrides dispose to clean up the component list.
  Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
     If disposing Then
        If Not (components Is Nothing) Then
           components.Dispose()
        End If
     End If
     MyBase.Dispose(disposing)
  End Sub
  "Required by the Windows Form Designer
  Private components As System.ruponentModel.Container
  "NOTE: The following procedure is required by the Windows Form Designer
  "It can be modified using the Windows Form Designer.  
  "Do not modify it using the code editor.
  <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
     "
     "frmDrawing
     "
     Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
     Me.BackColor = System.Drawing.SystemColors.AppWorkspace
     Me.ClientSize = New System.Drawing.Size(472, 157)
     Me.Name = "frmDrawing"
  End Sub
  1. End Region
  " display ovals lines, and rectangles
  Protected Overrides Sub OnPaint( _
     ByVal paintEvent As PaintEventArgs)
     " get graphics object
     Dim graphicsObject As Graphics = paintEvent.Graphics
     Dim rectangle1 As Rectangle = New Rectangle(15, 35, 80, 80)
     Dim brush1 As SolidBrush = New SolidBrush(Color.Firebrick)
     Dim pen1 As Pen = New Pen(brush1, 1)
     Dim brush2 As SolidBrush = New SolidBrush(Color.DarkBlue)
     Dim pen2 As Pen = New Pen(brush2, 1)
     " start at 0 and sweep 360 degrees
     rectangle1.Location = New Point(15, 120)
     rectangle1.Size = New Size(80, 40)
     graphicsObject.DrawRectangle(pen1, rectangle1)
     graphicsObject.FillPie(brush2, rectangle1, 0, 360)
  End Sub " OnPaint

End Class


 </source>


Graphics.FillPolygon

<source lang="vbnet">

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class DrawArrow

  public Shared Sub Main
       Application.Run(New Form1)
  End Sub

End class public class Form1

 Inherits System.Windows.Forms.Form
 Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
       e.Graphics.ScaleTransform(30, 30, MatrixOrder.Append)
       DrawArrow(e.Graphics, HatchStyle.Horizontal)
   End Sub
   Private Sub DrawArrow(ByVal gr As Graphics, ByVal hatch_style As HatchStyle)
       Dim pts() As Point = { _
           New Point(0, 1), _
           New Point(2, 1), _
           New Point(2, 0), _
           New Point(4, 2), _
           New Point(2, 4), _
           New Point(2, 3), _
           New Point(0, 3) _
       }
       gr.FillPolygon(New HatchBrush(hatch_style, Color.Black, Color.White), pts)
       gr.DrawPolygon(New Pen(Color.Black, 0), pts)
   End Sub
 Public Sub New()
   MyBase.New()
   Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
   Me.ClientSize = New System.Drawing.Size(292, 273)
   Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
 End Sub

End Class


 </source>


Graphics.FillRectangle(Brush b, Rectangle rect)

<source lang="vbnet"> Imports System Imports System.Collections Imports System.Data Imports System.Drawing Imports System.Windows.Forms Imports System.ruponentModel Imports System.Drawing.Drawing2D Imports System.IO Public Class MainClass

   Shared Sub Main()
       Dim form1 As Form = New Form1
       Application.Run(form1)
   End Sub

End Class Public Class Form1

   Inherits System.Windows.Forms.Form
   Public Sub New()
       MyBase.New()
       Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
       Me.ClientSize = New System.Drawing.Size(292, 266)
   End Sub
   Private Sub TextureBrushExample_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
       Dim MyBrush As New TextureBrush(Image.FromFile("figure2.bmp"))
       e.Graphics.FillRectangle(MyBrush, e.Graphics.ClipBounds)
   End Sub

End Class


 </source>


Graphics.FromImage(Bitmap m)

<source lang="vbnet"> Imports System Imports System.Windows.Forms Imports System.Collections.Generic Imports System.ruponentModel Imports System.Drawing.Imaging Imports System.Drawing Public Class MainClass

  Shared Sub Main()
       Dim bm As New Bitmap(256, 256)
       " Draw on it.
       Dim gr As Graphics = Graphics.FromImage(bm)
       gr.Clear(Color.White)
       gr.DrawEllipse(Pens.Red, 0, 0, bm.Width - 1, bm.Height - 1)
       gr.DrawLine(Pens.Green, 0, 0, bm.Width - 1, bm.Height - 1)
       gr.DrawLine(Pens.Blue, bm.Width - 1, 0, 0, bm.Height - 1)
       " Save the result as a JPEG file.
       bm.Save("test.gif", ImageFormat.Gif)
  End Sub 

End Class


 </source>


Graphics.MeasureCharacterRanges

<source lang="vbnet">

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms Imports System.Math public class MeasureCharacterRange

  public Shared Sub Main
       Application.Run(New Form1)
  End Sub

End class public class Form1

 Inherits System.Windows.Forms.Form
 Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
       Dim txt As String = "www.vbex.ru"
       Dim the_font As New Font("Times New Roman", 50, FontStyle.Bold, GraphicsUnit.Pixel)
       Dim layout_rect As New RectangleF(0, 0, Me.ClientSize.Width, Me.ClientSize.Height)
       Dim string_format As New StringFormat
       string_format.LineAlignment = StringAlignment.Center
       string_format.Alignment = StringAlignment.Center
       e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit
       Dim character_ranges(txt.Length - 1) As CharacterRange
       For i As Integer = 0 To txt.Length - 1
           character_ranges(i) = New CharacterRange(i, 1)
       Next i
       string_format.SetMeasurableCharacterRanges(character_ranges)
       Dim character_regions() As Region = e.Graphics.MeasureCharacterRanges(txt, the_font, layout_rect, string_format)
       For Each rgn As Region In character_regions
           Dim character_bounds As RectangleF = rgn.GetBounds(e.Graphics)
           Dim character_rect As Rectangle = Rectangle.Round(character_bounds)
           e.Graphics.DrawRectangle(Pens.White, character_rect)
       Next rgn
       e.Graphics.DrawString(txt, the_font, Brushes.Black, layout_rect, string_format)
 End Sub
 Public Sub New()
  
   MyBase.New()
   Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
   Me.ClientSize = New System.Drawing.Size(292, 273)
   Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
 End Sub

End Class


 </source>


Graphics.MeasureString

<source lang="vbnet">

Imports System Imports System.Drawing Imports System.Collections Imports System.ruponentModel Imports System.Windows.Forms Imports System.Globalization

public class GraphicsMeasureString

  public Shared Sub Main
       Application.Run(New Form1)
  End Sub

End class Public Class Form1

   Inherits System.Windows.Forms.Form
   Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
       Dim g As Graphics = e.Graphics
       Dim s As String = "a multi-line string:" & vbCrLf & "line 2" & vbCrLf & "line 3"
       Dim layoutRect As RectangleF = RectangleF.op_Implicit(ClientRectangle)
       g.DrawString(s, Me.Font, Brushes.Black, layoutRect)
       Dim size As SizeF = g.MeasureString(s, Me.Font, layoutRect.Size)
       g.DrawRectangle(Pens.Black, 0, 0, size.Width, size.Height)
   End Sub
   Public Sub New()
       MyBase.New()
       InitializeComponent()
   End Sub
   Private components As System.ruponentModel.IContainer
   <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
       Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
       Me.ClientSize = New System.Drawing.Size(20, 60)
       Me.Name = "Form1"
       Me.Text = "Form1"
       Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
   End Sub

End Class


 </source>


Graphics.PageUnit

<source lang="vbnet">

Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class GraphicsPageUnitGraphicsUnitInch

  public Shared Sub Main
       Application.Run(New Form1)
  End Sub

End class Public Class Form1

   Private Sub Form11_Paint(ByVal sender As Object, _
         ByVal e As System.Windows.Forms.PaintEventArgs) _
         Handles Me.Paint
        e.Graphics.PageUnit = GraphicsUnit.Inch
        e.Graphics.FillRectangle(Brushes.Red, 0, 0, 1,1)
   End Sub

End Class

<Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _ Partial Class Form1

   Inherits System.Windows.Forms.Form
   "Form overrides dispose to clean up the component list.
   <System.Diagnostics.DebuggerNonUserCode()> _
   Protected Overrides Sub Dispose(ByVal disposing As Boolean)
       If disposing AndAlso components IsNot Nothing Then
           components.Dispose()
       End If
       MyBase.Dispose(disposing)
   End Sub
   "Required by the Windows Form Designer
   Private components As System.ruponentModel.IContainer
   "NOTE: The following procedure is required by the Windows Form Designer
   "It can be modified using the Windows Form Designer.  
   "Do not modify it using the code editor.
   <System.Diagnostics.DebuggerStepThrough()> _
   Private Sub InitializeComponent()
       Me.SuspendLayout()
       "
       "Form1
       "
       Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
       Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
       Me.ClientSize = New System.Drawing.Size(617, 197)
       Me.MaximizeBox = False
       Me.ResumeLayout(False)
   End Sub

End Class


 </source>


Graphics.ResetTransform()

<source lang="vbnet"> Imports System Imports System.Windows.Forms Imports System.Drawing Imports System.Drawing.Drawing2D

Public Class MainClass

 Shared Sub Main()
    Dim form1 As Form1 = new Form1
    Application.Run(form1)
 End Sub
 

End Class Public Class Form1

 Inherits System.Windows.Forms.Form
 Public Sub New()
   MyBase.New()
   Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
   Me.ClientSize = New System.Drawing.Size(504, 629)
   Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
   Me.Text = "Form1"
 End Sub
 Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
   Dim R1 As New Rectangle(10, 10, 40, 40)
   e.Graphics.SmoothingMode = SmoothingMode.HighQuality
   e.Graphics.ResetTransform()
   e.Graphics.TranslateTransform(200.0F, 50.0F)
   e.Graphics.DrawArc(Pens.DarkBlue, R1, 40, 160)
 End Sub

End Class


 </source>


Graphics.Restore

<source lang="vbnet"> Imports System.Drawing.Drawing2D Imports System Imports System.Drawing.Text Imports System.Drawing Imports System.Windows.Forms Imports System.Math Public Class MainClass

  Shared Sub Main()
      Dim form1 As Form = New Form1()
      Application.Run(form1)
  End Sub 

End Class

Public Class Form1

   Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
       Const PEN_WID As Integer = 100
       Dim the_pen As New Pen(Color.Black, PEN_WID)
       Dim graphics_state As GraphicsState = e.Graphics.Save
       e.Graphics.DrawEllipse(Pens.White, PEN_WID , PEN_WID , PEN_WID, PEN_WID)
       e.Graphics.Restore(graphics_state)
   End Sub

End Class


<Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _ Partial Public Class Form1

   Inherits System.Windows.Forms.Form
   "Form overrides dispose to clean up the component list.
   <System.Diagnostics.DebuggerNonUserCode()> _
   Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
       If disposing AndAlso components IsNot Nothing Then
           components.Dispose()
       End If
       MyBase.Dispose(disposing)
   End Sub
   "Required by the Windows Form Designer
   Private components As System.ruponentModel.IContainer
   "NOTE: The following procedure is required by the Windows Form Designer
   "It can be modified using the Windows Form Designer.  
   "Do not modify it using the code editor.
   <System.Diagnostics.DebuggerStepThrough()> _
   Private Sub InitializeComponent()
       Me.SuspendLayout()
       "
       "Form1
       "
       Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
       Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
       Me.ClientSize = New System.Drawing.Size(200, 200)
       Me.Name = "Form1"
       Me.Text = ""
       Me.ResumeLayout(False)
   End Sub

End Class


 </source>


Graphics.ScaleTransform

<source lang="vbnet"> Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms Imports System.Math public class DrawCurveSin

  public Shared Sub Main
       Application.Run(New Form1)
  End Sub

End class public class Form1

 Inherits System.Windows.Forms.Form
 Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
       Dim a As Graphics =  e.Graphics
       Dim mypen As Pen
       Dim mypoints() As PointF
       Dim i As Integer
       Dim mycount As Integer
       mypen = New Pen(System.Drawing.Color.Red, 3)
       mycount = Me.Width / 10
       ReDim mypoints(mycount)
       For i = 1 To mycount
           mypoints(i).X = i * 10
           mypoints(i).Y = -1 * (Sin(i)) ^ 2 * Me.Height
       Next
       a = Me.CreateGraphics
       a.Clear(Me.BackColor)
       a.ScaleTransform(1, -1)
       a.DrawCurve(mypen, mypoints)
       a.Dispose()
       mypen.Dispose()
 End Sub
 Public Sub New()
   MyBase.New()
   Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
   Me.ClientSize = New System.Drawing.Size(292, 273)
   Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
 End Sub

End Class


 </source>


Graphics.SetClip(Shape shape,CombineMode)

<source lang="vbnet"> Imports System Imports System.Windows.Forms Imports System.Drawing Imports System.Drawing.Drawing2D

Public Class MainClass

 Shared Sub Main()
    Dim form1 As Form1 = new Form1
    Application.Run(form1)
 End Sub
 

End Class Public Class Form1

 Inherits System.Windows.Forms.Form
  1. Region " Windows Form Designer generated code "
 Public Sub New()
   MyBase.New()
   "This call is required by the Windows Form Designer.
   InitializeComponent()
   "Add any initialization after the InitializeComponent() call
 End Sub
 "Form overrides dispose to clean up the component list.
 Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
   If disposing Then
     If Not (components Is Nothing) Then
       components.Dispose()
     End If
   End If
   MyBase.Dispose(disposing)
 End Sub
 "Required by the Windows Form Designer
 Private components As System.ruponentModel.IContainer
 "NOTE: The following procedure is required by the Windows Form Designer
 "It can be modified using the Windows Form Designer.  
 "Do not modify it using the code editor.
 <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
   Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
   Me.ClientSize = New System.Drawing.Size(352, 273)
   Me.Name = "Form1"
   Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
   Me.Text = "Form1"
   Me.ResumeLayout(False)
 End Sub
  1. End Region
  Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
   Dim G As Graphics = Me.CreateGraphics
   Dim R As New Rectangle(40.0F, 20.0F, 100.0F, 100.0F)
   Dim R2 As New Rectangle(60.0F, 20.0F, 120.0F, 120.0F)
   Dim P1 As New GraphicsPath()
   Dim P2 As New GraphicsPath()
   G.Clear(Color.Gainsboro)
   P1.AddEllipse(R)
   G.DrawPath(Pens.Black, P1)
   P2.AddEllipse(R2)
   G.DrawPath(Pens.Black, P2)
   G.SetClip(P1)
   G.SetClip(P2, CombineMode.Intersect)
   " Draw some clipped strings.
   Dim F As New Font("Arial", 16)
   G.DrawString("www.vbex.ru", F, Brushes.DeepPink, 15, 25)
 End Sub

End Class


 </source>


Graphics.SmoothingMode

<source lang="vbnet">

Imports System Imports System.Windows.Forms Imports System.Drawing Imports System.Drawing.Drawing2D

Public Class MainClass

 Shared Sub Main()
    Dim form1 As Form1 = new Form1
    Application.Run(form1)
 End Sub
 

End Class Public Class Form1

 Inherits System.Windows.Forms.Form
 Public Sub New()
   MyBase.New()
   Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
   Me.ClientSize = New System.Drawing.Size(504, 629)
   Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
   Me.Text = "Form1"
 End Sub
 Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
   Dim R1 As New Rectangle(10, 10, 40, 40)
   e.Graphics.SmoothingMode = SmoothingMode.HighQuality
   e.Graphics.ResetTransform()
   e.Graphics.TranslateTransform(200.0F, 50.0F)
   e.Graphics.DrawArc(Pens.DarkBlue, R1, 40, 160)
 End Sub

End Class


 </source>


Graphics.TextRenderingHint

<source lang="vbnet"> Imports System Imports System.Windows.Forms Imports System.Drawing.Text Imports System.Drawing Public Class MainClass

   Shared Sub Main(ByVal args As String())
       Dim myform As Form = New Form1()
       Application.Run(myform)
   End Sub

End Class

Public Class Form1

   Private Sub Form1_Paint(ByVal sender As Object, _
    ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
       Dim the_font As New Font(Me.Font.FontFamily, _
           40, FontStyle.Bold, GraphicsUnit.Pixel)
       e.Graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit
       e.Graphics.DrawString("TextRenderingHint.AntiAliasGridFit", the_font, Brushes.Black, 5, 5)
       e.Graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixel
       e.Graphics.DrawString("TextRenderingHint.SingleBitPerPixel",the_font, Brushes.Black, 5, 50)
       the_font.Dispose()
   End Sub

End Class

<Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _ Partial Public Class Form1

   Inherits System.Windows.Forms.Form
   "Form overrides dispose to clean up the component list.
   <System.Diagnostics.DebuggerNonUserCode()> _
   Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
       If disposing AndAlso components IsNot Nothing Then
           components.Dispose()
       End If
       MyBase.Dispose(disposing)
   End Sub
   "Required by the Windows Form Designer
   Private components As System.ruponentModel.IContainer
   "NOTE: The following procedure is required by the Windows Form Designer
   "It can be modified using the Windows Form Designer.  
   "Do not modify it using the code editor.
   <System.Diagnostics.DebuggerStepThrough()> _
   Private Sub InitializeComponent()
       Me.SuspendLayout()
       "
       "Form1
       "
       Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
       Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
       Me.ClientSize = New System.Drawing.Size(764, 109)
       Me.Name = "Form1"
       Me.Text = "Title"
       Me.ResumeLayout(False)
   End Sub

End Class


 </source>


Graphics.Transform

<source lang="vbnet"> Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Windows.Forms public class MatrixTranslationDemo

  public Shared Sub Main
       Application.Run(New TranslationForm)
  End Sub

End class

Public Class TranslationForm

   Inherits System.Windows.Forms.Form
   Public Sub New()
       MyBase.New()
   End Sub
   Sub TranlationForm_Pain(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
       Dim g As Graphics = e.Graphics
       Dim rect As RectangleF = New RectangleF(0, 0, 125, 125)
       g.FillRectangle(Brushes.White, rect)
       g.DrawRectangle(Pens.Black, rect.X, rect.Y, rect.Width, rect.Height)
       Dim matrix As Matrix = New Matrix()
       matrix.Translate(150, 150)
       g.Transform = matrix
       g.FillRectangle(Brushes.White, rect)
       g.DrawRectangle(Pens.Black, rect.X, rect.Y, rect.Width, rect.Height)
   End Sub

End Class


 </source>


Graphics.TranslateTransform

<source lang="vbnet"> Imports System Imports System.Windows.Forms Imports System.Drawing Imports System.Drawing.Drawing2D

Public Class MainClass

 Shared Sub Main()
    Dim form1 As Form1 = new Form1
    Application.Run(form1)
 End Sub
 

End Class Public Class Form1

 Inherits System.Windows.Forms.Form
 Public Sub New()
   MyBase.New()
   Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
   Me.ClientSize = New System.Drawing.Size(504, 629)
   Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
   Me.Text = "Form1"
 End Sub
 Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
   Dim R1 As New Rectangle(10, 10, 40, 40)
   e.Graphics.SmoothingMode = SmoothingMode.HighQuality
   e.Graphics.ResetTransform()
   e.Graphics.TranslateTransform(200.0F, 50.0F)
   e.Graphics.DrawArc(Pens.DarkBlue, R1, 40, 160)
 End Sub

End Class


 </source>