VB.Net/2D

Материал из VB Эксперт
Перейти к: навигация, поиск

Demonstrating various font settings

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

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

End Class

Public Class FrmFonts

  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()
     "
     "frmFonts
     "
     Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
     Me.ClientSize = New System.Drawing.Size(496, 117)
     Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
     Me.Name = "frmFonts"
     Me.Text = "Fonts"
  End Sub
  1. End Region
  Protected Overrides Sub OnPaint( _
     ByVal paintEvent As PaintEventArgs)
     Dim graphicsObject As Graphics = paintEvent.Graphics
     Dim brush As SolidBrush = New SolidBrush(Color.DarkBlue)
     Dim style As FontStyle = FontStyle.Bold
     Dim arial As Font = New Font(New FontFamily("Arial"), 12, style)
     graphicsObject.DrawString(arial.Name & " 12 point bold.",arial, brush, 10, 10)
     style = FontStyle.Regular
     Dim timesNewRoman As Font = New Font("Times New Roman", 12, style)
     graphicsObject.DrawString(timesNewRoman.Name &" 12 point plain.", timesNewRoman, brush, 10, 30)
     style = FontStyle.Bold Or FontStyle.Italic
     Dim courierNew As Font = New Font("Courier New",16, style)
     graphicsObject.DrawString(courierNew.Name & " 16 point bold and italic.", courierNew, brush, 10, 54)
     style = FontStyle.Strikeout
     Dim tahoma As Font = New Font("Tahoma", 18, style)
     graphicsObject.DrawString(tahoma.Name & " 18 point strikeout.", tahoma, brush, 10, 75)
     
  End Sub

End Class

      </source>


Displaying font metric information

<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 FrmFontMetrics()
       Application.Run(myform)
  End Sub " Main

End Class

Public Class FrmFontMetrics

  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()
     "
     "frmFontMetrics
     "
     Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
     Me.ClientSize = New System.Drawing.Size(920, 253)
     Me.Name = "frmFontMetrics"
     Me.Text = "Metrics"
  End Sub
  1. End Region
  Protected Overrides Sub OnPaint( _
   ByVal paintEvent As PaintEventArgs)
     Dim graphicsObject As Graphics = paintEvent.Graphics
     Dim brush As SolidBrush = New SolidBrush(Color.Red)
     Dim pen As Pen = New Pen(brush, Convert.ToSingle(2.5))
     " Arial font metrics
     Dim arial As Font = New Font("Arial", 12)
     Dim family As FontFamily = arial.FontFamily
     Dim sanSerif As Font = New Font("Microsoft Sans Serif", _
        14, FontStyle.Italic)
     pen.Color = brush.Color
     brush.Color = Color.DarkBlue
     " display Arial font metrics
     graphicsObject.DrawString("Current Font: " & arial.ToString, _
        arial, brush, 10, 10)
     graphicsObject.DrawString("Ascent: " & _
        family.GetCellAscent(FontStyle.Regular), arial, brush, _
         10, 30)
     graphicsObject.DrawString("Descent: " & _
        family.GetCellDescent(FontStyle.Regular), arial, brush, _
        10, 50)
     graphicsObject.DrawString("Height: " & family.GetEmHeight _
        (FontStyle.Regular), arial, brush, 10, 70)
     graphicsObject.DrawString("Leading: " & _
        family.GetLineSpacing(FontStyle.Regular), arial, brush, _
        10, 90)
  End Sub  " OnPaint

End Class

      </source>


Draw Character Outline

<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_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       Me.ResizeRedraw = True
   End Sub
   Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
       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

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>


Font Metrics Illustration

<source lang="vbnet"> Imports System Imports System.Windows.Forms Imports System.Drawing Imports System.Drawing.Drawing2D Imports System.Drawing.Text Imports System.Drawing.Imaging Imports System.Runtime.InteropServices 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.SuspendLayout()
   "
   "Form1
   "
   Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
   Me.ClientSize = New System.Drawing.Size(492, 273)
   Me.MaximizeBox = False
   Me.MinimizeBox = False
   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 ff As FontFamily = New FontFamily("Arial Black")
   Dim fnt As Font = New Font(ff, 75, FontStyle.Regular, GraphicsUnit.Pixel)
   Dim G As Graphics = Me.CreateGraphics()
   G.SmoothingMode = SmoothingMode.AntiAlias
   G.TextRenderingHint = TextRenderingHint.AntiAlias
   Dim LineSpace As Int32 = CInt(ff.GetLineSpacing(fnt.Style) * _
                         fnt.Size / ff.GetEmHeight(fnt.Style))
   Dim Descent As Int32 = CInt(ff.GetCellDescent(fnt.Style) * _
                         fnt.Size / ff.GetEmHeight(fnt.Style))
   Dim Ascent As Int32 = CInt(ff.GetCellAscent(fnt.Style) * _
                         fnt.Size / ff.GetEmHeight(fnt.Style))
   Dim BaseLineStart As Point = New Point(15, CInt(Me.Height * 3 / 5))
   Dim BaseLineEnd As Point = New Point(Me.Width - 15, CInt(Me.Height * 3 / 5))
   Dim StringPoint As Point = New Point(75, CInt(BaseLineStart.Y - Ascent))
   G.Clear(Color.AliceBlue)
   G.DrawString("A j Q", fnt, Brushes.Blue, Point.op_Implicit(StringPoint))
   G.DrawLine(Pens.Black, BaseLineStart, BaseLineEnd)
   Dim LineSize As Size = New Size(0, LineSpace)
   Dim AscentSize As Size = New Size(0, Ascent)
   Dim DescentSize As Size = New Size(0, Descent)
   G.DrawLine(Pens.Black, Point.op_Subtraction(BaseLineStart, LineSize), _
                          Point.op_Subtraction(BaseLineEnd, LineSize))
   G.DrawLine(Pens.Red, Point.op_Subtraction(BaseLineStart, AscentSize), _
                          Point.op_Subtraction(BaseLineEnd, AscentSize))
   G.DrawLine(Pens.DarkGreen, Point.op_Addition(BaseLineStart, DescentSize), _
                                Point.op_Addition(BaseLineEnd, DescentSize))
   Dim AnnoFont As Font = New Font("Arial", 10)
   G.DrawString("Line Space = " + LineSpace.ToString(), AnnoFont, _
     Brushes.Black, _
     20, _
     CInt(BaseLineStart.Y - LineSpace - 12))
   G.DrawString("Ascent = " + Ascent.ToString(), AnnoFont, _
     Brushes.Red, _
     250, _
     CInt(BaseLineStart.Y - Ascent - 12))
   G.DrawString("Descent = " + Descent.ToString(), AnnoFont, _
     Brushes.DarkGreen, _
     350, _
     CInt(BaseLineStart.Y + Descent / 8))
 End Sub

End Class

      </source>


Outline Fonts Demo

<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 OutlineFontsForm()
       Application.Run(myform)
   End Sub

End Class

Public Class OutlineFontsForm

   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()
       "
       "OutlineFontsForm
       "
       Me.AutoScaleBaseSize = New System.Drawing.Size(46, 109)
       Me.ClientSize = New System.Drawing.Size(292, 266)
       Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 72.0!)
       Me.Name = "OutlineFontsForm"
       Me.Text = "OutlineFontsForm"
   End Sub
  1. End Region
   Private Function GetStringPath(ByVal s As String, ByVal dpi As Single, ByVal rect As RectangleF, ByVal font As Font, ByVal format As StringFormat) As graphicspath
       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)
       Return path
   End Function
   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 = "String String String"
       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 = GetStringPath(s, dpi, rect, font, format)
       g.DrawPath(Pens.Black, path)
   End Sub

End Class

      </source>


Outline the Font Metrics

<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_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
       Me.ResizeRedraw = True
   End Sub
   Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint
       Dim txt As String = "www.vbex.ru"
       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
       Dim the_font As Font
       e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit
       the_font = New Font("Times New Roman", 80, FontStyle.Bold, GraphicsUnit.Pixel)
       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)
       Dim em_height As Integer = the_font.FontFamily.GetEmHeight(FontStyle.Bold)
       Dim em_height_pix As Single = the_font.Size
       Dim design_to_pixels As Single = the_font.Size / em_height
       Dim ascent As Integer = the_font.FontFamily.GetCellAscent(FontStyle.Bold)
       Dim ascent_pix As Single = ascent * design_to_pixels
       Dim descent As Integer = the_font.FontFamily.GetCellDescent(FontStyle.Bold)
       Dim descent_pix As Single = descent * design_to_pixels
       Dim cell_height_pix As Single = ascent_pix + descent_pix
       Dim internal_leading_pix As Single = cell_height_pix - em_height_pix
       Dim line_spacing As Integer = the_font.FontFamily.GetLineSpacing(FontStyle.Bold)
       Dim line_spacing_pix As Single = line_spacing * design_to_pixels
       Dim external_leading_pix As Single = line_spacing_pix - cell_height_pix
       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.Black, character_rect)
           e.Graphics.DrawLine(Pens.White, _
               character_rect.X, _
               character_rect.Y + internal_leading_pix, _
               character_rect.Right, _
               character_rect.Y + internal_leading_pix)
           e.Graphics.DrawLine(Pens.Yellow, _
               character_rect.X, _
               character_rect.Y + ascent_pix, _
               character_rect.Right, _
               character_rect.Y + ascent_pix)
           e.Graphics.DrawLine(Pens.Orange, _
               character_rect.X, _
               character_rect.Y + ascent_pix + descent_pix, _
               character_rect.Right, _
               character_rect.Y + ascent_pix + descent_pix)
           e.Graphics.FillRectangle(Brushes.Red, _
               character_rect.X, _
               character_rect.Y + ascent_pix + descent_pix, _
               character_rect.Width, _
               external_leading_pix)
           Console.WriteLine( _
               character_rect.X & ", " & _
               character_rect.Y + ascent_pix + descent_pix & ", " & _
               character_rect.Width & ", " & _
               external_leading_pix)
       Next rgn
       e.Graphics.DrawString(txt, the_font, Brushes.Black, _
           layout_rect, string_format)
   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>


Shadow Fonts Demo

<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 ShadowFontsForm()
       Application.Run(myform)
   End Sub

End Class Public Class ShadowFontsForm

   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()
       "
       "ShadowFontsForm
       "
       Me.AutoScaleBaseSize = New System.Drawing.Size(46, 109)
       Me.ClientSize = New System.Drawing.Size(292, 266)
       Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 72.0!)
       Me.Name = "ShadowFontsForm"
       Me.Text = "ShadowFontsForm"
   End Sub
  1. End Region
   Private Function GetStringPath(ByVal s As String, ByVal dpi As Single, ByVal rect As RectangleF, ByVal font As Font, ByVal format As StringFormat) As GraphicsPath
       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)
       Return path
   End Function
   Private Sub ShadowFontsForm_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 = "String String String String String"
       Dim offset As Single = 4
       Dim size As SizeF = New SizeF(Me.ClientRectangle.Width - offset, Me.ClientRectangle.Height - offset)
       Dim rectShadow As RectangleF = New RectangleF(offset, offset, size.Width, size.Height)
       Dim rect As RectangleF = New RectangleF(0, 0, size.Width, size.Height)
       Dim font As Font = Me.Font
       Dim format As StringFormat = StringFormat.GenericTypographic
       Dim dpi As Single = g.DpiY
       Dim pathShadow As GraphicsPath = GetStringPath(s, dpi, rectShadow, font, format)
       Dim path As GraphicsPath = GetStringPath(s, dpi, rect, font, format)
       g.FillPath(Brushes.Black, pathShadow)
       g.FillPath(Brushes.Red, path)
   End Sub

End Class

      </source>


Use Default Frame Font

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

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 Me.Paint
       e.Graphics.DrawString("www.vbex.ru", Me.Font, Brushes.Black, 10, 100)
   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 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(194, 117)
       Me.Name = "Form1"
       Me.Text = "Form1"
       Me.ResumeLayout(False)
   End Sub

End Class

      </source>