VB.Net Tutorial/2D Graphics/GraphicsPath
Версия от 16:40, 26 мая 2010; (обсуждение)
Содержание
- 1 Add arcs to GraphicsPath
- 2 Add Beziers to GraphicsPath
- 3 Add Rectangle to GraphicsPath
- 4 Add string and two ellipses to a GraphicsPath
- 5 Add string to GraphicsPath
- 6 Close a Path
- 7 Create a Graphics path
- 8 Draw path
- 9 Flattened Ellipse
- 10 Getting GraphicsPath Properties
- 11 GraphicPath FillMode.Alternate
- 12 GraphicPath FillMode.Winding
- 13 GraphicPath TextRegion
- 14 Use GraphicsPath to create Text outline
Add arcs to GraphicsPath
Imports System.Drawing.Text
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class GraphicsPathAddArc
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
Public Class Form1
Inherits System.Windows.Forms.Form
#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
Me.SetStyle(ControlStyles.ResizeRedraw, True)
Me.SetStyle(ControlStyles.DoubleBuffer, True)
Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
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 = "Form1"
End Sub
#End Region
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics = e.Graphics
Dim width As Integer = Me.ClientRectangle.Width
Dim height As Integer = Me.ClientRectangle.Height
Dim rect As Rectangle = New Rectangle(10, 10, width - 20, height - 20)
Dim format As StringFormat = New StringFormat()
format.Alignment = StringAlignment.Center
format.LineAlignment = StringAlignment.Center
Dim diameter As Integer = 100
Dim arcRect As Rectangle = New Rectangle(rect.Location, New Size(diameter, diameter))
Dim path As GraphicsPath = New GraphicsPath()
path.AddArc(arcRect, 180, 90)
arcRect.X = rect.Right - diameter
path.AddArc(arcRect, 270, 90)
arcRect.Y = rect.Bottom - diameter
path.AddArc(arcRect, 0, 90)
arcRect.X = rect.Left
path.AddArc(arcRect, 90, 90)
path.CloseFigure()
g.FillPath(Brushes.Yellow, path)
g.DrawPath(Pens.Black, path)
End Sub
End Class
Add Beziers to GraphicsPath
Imports System.Drawing.Text
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class GraphicsPathAddBeziers
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
Public Class Form1
Inherits System.Windows.Forms.Form
#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
Me.SetStyle(ControlStyles.ResizeRedraw, True)
Me.SetStyle(ControlStyles.DoubleBuffer, True)
Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
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 = "Form1"
End Sub
#End Region
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics = e.Graphics
Dim width As Integer = Me.ClientRectangle.Width
Dim height As Integer = Me.ClientRectangle.Height
Dim rect As Rectangle = New Rectangle(10, 10, width - 20, height - 20)
Dim format As StringFormat = New StringFormat()
format.Alignment = StringAlignment.Center
format.LineAlignment = StringAlignment.Center
Dim path As GraphicsPath = New GraphicsPath()
path.AddBeziers(New Point() {New Point(25, height - 25), New Point(width - 25, height - 25), New Point(25, 25), New Point(width - 25, 25)})
path.CloseFigure()
g.FillPath(Brushes.Yellow, path)
g.DrawPath(Pens.Black, path)
End Sub
End Class
Add Rectangle to GraphicsPath
Imports System.Drawing.Drawing2D
Imports System.Drawing
Imports System.Windows.Forms
public class GraphicsPathAddRectangle
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
Public Class Form1
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 thePath As Drawing2D.GraphicsPath
thePath = New Drawing2D.GraphicsPath
thePath.AddRectangle( New Rectangle(2, 3, 10, 10))
thePath.AddRectangle( New Rectangle(200, 30, 10, 10))
canvas.FillPath(Brushes.Blue, thePath)
End Sub
Private Sub Form1_Resize(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Resize
Me.Refresh()
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(515, 459)
Me.DoubleBuffered = True
Me.Name = "Form1"
Me.Text = "Using a Path"
Me.ResumeLayout(False)
End Sub
End Class
Add string and two ellipses to a GraphicsPath
Imports System.Drawing.Text
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class GraphicsPathAddStringTwoELlipses
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
Public Class Form1
Inherits System.Windows.Forms.Form
#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
Me.SetStyle(ControlStyles.ResizeRedraw, True)
Me.SetStyle(ControlStyles.DoubleBuffer, True)
Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
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 = "Form1"
End Sub
#End Region
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics = e.Graphics
Dim width As Integer = Me.ClientRectangle.Width
Dim height As Integer = Me.ClientRectangle.Height
Dim rect As Rectangle = New Rectangle(10, 10, width - 20, height - 20)
Dim path As GraphicsPath = New GraphicsPath()
Dim holeRadius As Integer = 50
path.AddEllipse(rect)
Dim centerPoint As Point = New Point(rect.Left + rect.Width / 2, rect.Top + rect.Height / 2)
Dim holeRect As Rectangle = New Rectangle(centerPoint.X - holeRadius, centerPoint.Y - holeRadius, holeRadius * 2, holeRadius * 2)
path.AddEllipse(holeRect)
Dim format As StringFormat = New StringFormat()
format.Alignment = StringAlignment.Center
format.LineAlignment = StringAlignment.Center
path.AddString("www.vbex.ru", Me.Font.FontFamily, CInt(Me.Font.Style), 60, RectangleF.op_Implicit(rect), format)
g.FillPath(Brushes.Yellow, path)
g.DrawPath(Pens.Black, path)
End Sub
End Class
Add string to GraphicsPath
Imports System.Drawing.Text
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class GraphicsPathAddString
public Shared Sub Main
Application.Run(New Form1)
End Sub
End class
Public Class Form1
Inherits System.Windows.Forms.Form
#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
Me.SetStyle(ControlStyles.ResizeRedraw, True)
Me.SetStyle(ControlStyles.DoubleBuffer, True)
Me.SetStyle(ControlStyles.AllPaintingInWmPaint, True)
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 = "Form1"
End Sub
#End Region
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics = e.Graphics
Dim width As Integer = Me.ClientRectangle.Width
Dim height As Integer = Me.ClientRectangle.Height
Dim rect As Rectangle = New Rectangle(10, 10, width - 20, height - 20)
Dim format As StringFormat = New StringFormat()
format.Alignment = StringAlignment.Center
format.LineAlignment = StringAlignment.Center
Dim path As GraphicsPath = New GraphicsPath()
Dim emSize As Single = 120
path.AddString("www.vbex.ru", font.FontFamily, CInt(font.Style), emSize, rect, format)
g.FillPath(Brushes.Yellow, path)
g.DrawPath(Pens.Black, path)
End Sub
End Class
Close a Path
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class SubPath
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 path As New GraphicsPath
Dim pts As Point() = {New Point(40, 80), New Point(50, 70), New Point(70, 90), New Point(100, 120), New Point(80, 120)}
path.StartFigure()
path.AddArc(250, 80, 100, 50, 30, -180)
path.AddLine(180, 220, 320, 80)
path.CloseFigure()
path.StartFigure()
path.AddLine(50, 20, 5, 90)
path.AddLine(50, 150, 150, 180)
path.AddCurve(pts, 5)
path.CloseAllFigures()
path.StartFigure()
path.AddLine(200, 230, 250, 200)
path.AddLine(200, 230, 250, 270)
g.DrawPath(New Pen(Color.FromArgb(255, 255, 0, 0), 2), path)
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
Create a Graphics path
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class CreateAGraphicsPath
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)
g.SmoothingMode = SmoothingMode.AntiAlias
" Create a Graphics path
Dim path As New GraphicsPath
" Add two lines, a rectangle, and
" an ellipse
path.AddLine(20, 20, 200, 20)
path.AddLine(20, 20, 20, 200)
path.AddRectangle(New Rectangle(30, 30, 100, 100))
path.AddEllipse(New Rectangle(50, 50, 60, 60))
" Draw path
Dim redPen As New Pen(Color.Red, 2)
g.DrawPath(redPen, path)
g.FillPath(New SolidBrush(Color.Black), path)
" Dispose
redPen.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
Draw path
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class DrawPath
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(Brushes.Red, 3)
Dim rect As New Rectangle(70, 15, 50, 50)
Dim path As New GraphicsPath
path.AddArc(20, 150, 200, 100, 0, 180)
path.AddLine(20, 40, 220, 190)
path.AddLine(20, 220, 320, 20)
path.AddRectangle(rect)
path.AddEllipse(250, 200, 50, 50)
g.DrawPath(redPen, path)
" 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
Flattened Ellipse
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class PathFlatten
public Shared Sub Main
Application.Run(New PathAndRegionForm)
End Sub
End class
Public Class PathAndRegionForm
Inherits System.Windows.Forms.Form
#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 = "PathAndRegionForm"
End Sub
#End Region
Private Sub PathAndRegionForm_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
Dim g As Graphics = e.Graphics
Dim rect As RectangleF = New RectangleF(0, 0, Me.ClientSize.Width / 2.0F, Me.ClientSize.Height)
Dim path As GraphicsPath = New GraphicsPath()
path.AddEllipse(rect)
path.Flatten(New Matrix(), 13.0F)
g.FillPath(Brushes.Green, path)
Dim region As Region = New Region(path)
g.FillRegion(Brushes.Red, region)
End Sub
End Class
Getting GraphicsPath Properties
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class GettingGraphicsPathProperties
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 greenPen As New Pen(Brushes.Green, 3)
Dim path As New GraphicsPath
Dim rect As New Rectangle(20, 20, 200, 100)
path.AddLine(20, 30, 150, 70)
path.AddArc(10, 10, 100, 50, 0, 180)
path.AddRectangle(rect)
g.DrawPath(greenPen, path)
" Getting GraphicsPath properties
Console.WriteLine(path.FillMode)
Console.WriteLine(path.PathData)
Console.WriteLine(path.PathPoints)
Console.WriteLine(path.PathTypes)
Console.WriteLine(path.PointCount)
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
GraphicPath FillMode.Alternate
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.Math
public class GraphicPathFillModeAlternate
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)
" Generate star points.
Dim cx As Integer = Me.ClientSize.Width \ 2
Dim cy As Integer = Me.ClientSize.Height \ 2
Dim radius As Integer = CInt(cy * 0.9)
Dim star_pts(4) As Point
Dim angle As Double = -PI / 2
For i As Integer = 0 To 4
star_pts(i).X = cx + CInt(radius * Cos(angle))
star_pts(i).Y = cy + CInt(radius * Sin(angle))
angle += 4 * PI / 5
Next i
Dim star_path As New GraphicsPath
star_path.AddPolygon(star_pts)
star_path.FillMode = FillMode.Alternate
e.Graphics.FillPath(Brushes.White, star_path)
e.Graphics.DrawPath(Pens.Black, star_path)
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
GraphicPath FillMode.Winding
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports System.Math
public class GraphicPathFillModeWinding
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)
" Generate star points.
Dim cx As Integer = Me.ClientSize.Width \ 2
Dim cy As Integer = Me.ClientSize.Height \ 2
Dim radius As Integer = CInt(cy * 0.9)
Dim star_pts(4) As Point
Dim angle As Double = -PI / 2
For i As Integer = 0 To 4
star_pts(i).X = cx + CInt(radius * Cos(angle))
star_pts(i).Y = cy + CInt(radius * Sin(angle))
angle += 4 * PI / 5
Next i
Dim star_path As New GraphicsPath
star_path.AddPolygon(star_pts)
star_path.FillMode = FillMode.Winding
e.Graphics.FillPath(Brushes.White, star_path)
e.Graphics.DrawPath(Pens.Black, star_path)
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
GraphicPath TextRegion
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class GraphicPathTextRegion
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 = "Path"
Dim graphics_path As New GraphicsPath
graphics_path.AddString(txt, _
New FontFamily("Times New Roman"), _
FontStyle.Bold, 150, _
New Point(0, 0), _
New StringFormat)
Dim origin As Point = Me.PointToScreen(New Point(0, 0))
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias
e.Graphics.TranslateTransform(Me.Left - origin.X, Me.Top - origin.Y)
e.Graphics.FillPath(Brushes.White, graphics_path)
e.Graphics.DrawPath(New Pen(Color.Black, 5), graphics_path)
Me.Region = New Region(graphics_path)
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
Use GraphicsPath to create Text outline
Imports System
Imports System.Drawing
Imports System.Collections
Imports System.ruponentModel
Imports System.Windows.Forms
Imports System.Globalization
Imports System.Drawing.Drawing2D
public class GraphicsMeasureStringRectangle
public Shared Sub Main
Application.Run(New OutlineFontsForm)
End Sub
End class
Public Class OutlineFontsForm
Inherits System.Windows.Forms.Form
Public Sub New()
MyBase.New()
InitializeComponent()
End Sub
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
Private components As System.ruponentModel.IContainer
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.AutoScaleBaseSize = New System.Drawing.Size(46, 109)
Me.ClientSize = New System.Drawing.Size(800, 266)
Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 72.0!)
End Sub
Private Sub OutlineFontsForm_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 = "www.vbex.ru"
Dim rect As RectangleF = RectangleF.op_Implicit(Me.ClientRectangle)
Dim font As Font = Me.Font
Dim format As StringFormat = StringFormat.GenericTypographic
Dim dpi As Single = g.DpiY
Dim path As GraphicsPath = New GraphicsPath()
Dim emSize As Single = dpi * font.SizeInPoints / 72
path.AddString(s, font.FontFamily, CInt(font.Style), emSize, rect, format)
g.DrawPath(Pens.Black, path)
End Sub
End Class