<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.vbex.ru/index.php?action=history&amp;feed=atom&amp;title=VB.Net_Tutorial%2F2D_Graphics%2FMeasure_String</id>
		<title>VB.Net Tutorial/2D Graphics/Measure String - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.vbex.ru/index.php?action=history&amp;feed=atom&amp;title=VB.Net_Tutorial%2F2D_Graphics%2FMeasure_String"/>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net_Tutorial/2D_Graphics/Measure_String&amp;action=history"/>
		<updated>2026-04-05T12:59:39Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net_Tutorial/2D_Graphics/Measure_String&amp;diff=3383&amp;oldid=prev</id>
		<title> в 16:40, 26 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net_Tutorial/2D_Graphics/Measure_String&amp;diff=3383&amp;oldid=prev"/>
				<updated>2010-05-26T16:40:30Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 16:40, 26 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.vbex.ru/index.php?title=VB.Net_Tutorial/2D_Graphics/Measure_String&amp;diff=3384&amp;oldid=prev</id>
		<title>Admin: 1 версия</title>
		<link rel="alternate" type="text/html" href="http://www.vbex.ru/index.php?title=VB.Net_Tutorial/2D_Graphics/Measure_String&amp;diff=3384&amp;oldid=prev"/>
				<updated>2010-05-26T12:55:16Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Measure string and draw rectangle around string==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;Imports System&lt;br /&gt;
Imports System.Drawing&lt;br /&gt;
Imports System.Collections&lt;br /&gt;
Imports System.ruponentModel&lt;br /&gt;
Imports System.Windows.Forms&lt;br /&gt;
Imports System.Globalization&lt;br /&gt;
&lt;br /&gt;
public class GraphicsMeasureStringRectangle&lt;br /&gt;
   public Shared Sub Main&lt;br /&gt;
        Application.Run(New Form1)&lt;br /&gt;
   End Sub&lt;br /&gt;
End class&lt;br /&gt;
Public Class Form1&lt;br /&gt;
    Inherits System.Windows.Forms.Form&lt;br /&gt;
    Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint&lt;br /&gt;
        Dim g As Graphics = e.Graphics&lt;br /&gt;
        Dim s As String = &amp;quot;a multi-line string:&amp;quot; &amp;amp; vbCrLf &amp;amp; &amp;quot;line 2&amp;quot; &amp;amp; vbCrLf &amp;amp; &amp;quot;line 3&amp;quot;&lt;br /&gt;
        Dim y As Single = 0&lt;br /&gt;
        Dim arrPens As Pen() = New Pen() {Pens.Red, Pens.Green, Pens.Blue}&lt;br /&gt;
        Dim line As String&lt;br /&gt;
        For Each line In s.Split(vbCrLf)&lt;br /&gt;
            Dim width As Single = ClientRectangle.Width&lt;br /&gt;
            Dim height As Single = ClientRectangle.Height - y&lt;br /&gt;
            Dim layoutRect As RectangleF = New RectangleF(0, y, width, height)&lt;br /&gt;
            Dim format As StringFormat = New StringFormat(StringFormatFlags.NoWrap Or StringFormatFlags.DisplayFormatControl)&lt;br /&gt;
            g.DrawString(line, Me.Font, Brushes.Black, layoutRect, format)&lt;br /&gt;
            Dim size As SizeF = g.MeasureString(line, Me.Font, layoutRect.Size, format)&lt;br /&gt;
            g.DrawRectangle(arrPens(CInt(y / Me.Font.GetHeight(g))), 0, y, size.Width, size.Height)&lt;br /&gt;
            y = y + Me.Font.GetHeight(g)&lt;br /&gt;
        Next&lt;br /&gt;
    End Sub&lt;br /&gt;
&lt;br /&gt;
    Public Sub New()&lt;br /&gt;
        MyBase.New()&lt;br /&gt;
        InitializeComponent()&lt;br /&gt;
    End Sub&lt;br /&gt;
    Private components As System.ruponentModel.IContainer&lt;br /&gt;
    &amp;lt;System.Diagnostics.DebuggerStepThrough()&amp;gt; Private Sub InitializeComponent()&lt;br /&gt;
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)&lt;br /&gt;
        Me.ClientSize = New System.Drawing.Size(20, 60)&lt;br /&gt;
        Me.Name = &amp;quot;Form1&amp;quot;&lt;br /&gt;
        Me.Text = &amp;quot;Form1&amp;quot;&lt;br /&gt;
        Me.Font = New System.Drawing.Font(&amp;quot;Microsoft Sans Serif&amp;quot;, 14.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Measure string and draw string==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;vbnet&amp;quot;&amp;gt;Imports System.Drawing&lt;br /&gt;
Imports System.Drawing.Drawing2D&lt;br /&gt;
Imports System.Windows.Forms&lt;br /&gt;
public class MeasureString&lt;br /&gt;
   public Shared Sub Main&lt;br /&gt;
        Application.Run(New Form1)&lt;br /&gt;
   End Sub&lt;br /&gt;
End class&lt;br /&gt;
Public Class Form1&lt;br /&gt;
    Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint&lt;br /&gt;
        Dim textArea As SizeF&lt;br /&gt;
        Dim linePen As Pen&lt;br /&gt;
        Dim largeFont As Font&lt;br /&gt;
        Dim fontRatio As Single&lt;br /&gt;
        Dim ascentSize As Single&lt;br /&gt;
        Dim descentSize As Single&lt;br /&gt;
        Dim emSize As Single&lt;br /&gt;
        Dim cellHeight As Single&lt;br /&gt;
        Dim internalLeading As Single&lt;br /&gt;
        Dim externalLeading As Single&lt;br /&gt;
        e.Graphics.TextRenderingHint = Drawing.Text.TextRenderingHint.AntiAlias&lt;br /&gt;
        largeFont = New Font(&amp;quot;Times New Roman&amp;quot;, 96, FontStyle.Regular)&lt;br /&gt;
        fontRatio = largeFont.Height / largeFont.FontFamily.GetLineSpacing(FontStyle.Regular)&lt;br /&gt;
        textArea = e.Graphics.MeasureString(&amp;quot;AbcJgp&amp;quot;, largeFont)&lt;br /&gt;
        e.Graphics.DrawString(&amp;quot;AbcJgp&amp;quot;, largeFont, Brushes.Black, 0, 0)&lt;br /&gt;
        linePen = New Pen(Color.Gray, 1)&lt;br /&gt;
        linePen.DashStyle = Drawing2D.DashStyle.Dash&lt;br /&gt;
        ascentSize = largeFont.FontFamily.GetCellAscent(FontStyle.Regular) * fontRatio&lt;br /&gt;
        descentSize = largeFont.FontFamily.GetCellDescent(FontStyle.Regular) * fontRatio&lt;br /&gt;
        emSize = largeFont.FontFamily.GetEmHeight(FontStyle.Regular) * fontRatio&lt;br /&gt;
        cellHeight = ascentSize + descentSize&lt;br /&gt;
        internalLeading = cellHeight - emSize&lt;br /&gt;
        externalLeading = (largeFont.FontFamily.GetLineSpacing(FontStyle.Regular) * fontRatio) - cellHeight&lt;br /&gt;
        e.Graphics.DrawLine(linePen, 0, 0, textArea.Width, 0)&lt;br /&gt;
        e.Graphics.DrawLine(linePen, 0, textArea.Height, textArea.Width, textArea.Height)&lt;br /&gt;
        e.Graphics.DrawLine(linePen, 0, ascentSize, textArea.Width, ascentSize)&lt;br /&gt;
        e.Graphics.DrawLine(linePen, 0, ascentSize + descentSize, textArea.Width, ascentSize + descentSize)&lt;br /&gt;
        linePen.Dispose()&lt;br /&gt;
        largeFont.Dispose()&lt;br /&gt;
        e.Graphics.ResetTransform()&lt;br /&gt;
    End Sub&lt;br /&gt;
End Class&lt;br /&gt;
&lt;br /&gt;
&amp;lt;Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()&amp;gt; _&lt;br /&gt;
Partial Class Form1&lt;br /&gt;
    Inherits System.Windows.Forms.Form&lt;br /&gt;
    &amp;quot;Form overrides dispose to clean up the component list.&lt;br /&gt;
    &amp;lt;System.Diagnostics.DebuggerNonUserCode()&amp;gt; _&lt;br /&gt;
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)&lt;br /&gt;
        If disposing AndAlso components IsNot Nothing Then&lt;br /&gt;
            components.Dispose()&lt;br /&gt;
        End If&lt;br /&gt;
        MyBase.Dispose(disposing)&lt;br /&gt;
    End Sub&lt;br /&gt;
    &amp;quot;Required by the Windows Form Designer&lt;br /&gt;
    Private components As System.ruponentModel.IContainer&lt;br /&gt;
    &amp;quot;NOTE: The following procedure is required by the Windows Form Designer&lt;br /&gt;
    &amp;quot;It can be modified using the Windows Form Designer.  &lt;br /&gt;
    &amp;quot;Do not modify it using the code editor.&lt;br /&gt;
    &amp;lt;System.Diagnostics.DebuggerStepThrough()&amp;gt; _&lt;br /&gt;
    Private Sub InitializeComponent()&lt;br /&gt;
        Me.PictureBox1 = New System.Windows.Forms.PictureBox&lt;br /&gt;
        CType(Me.PictureBox1, System.ruponentModel.ISupportInitialize).BeginInit()&lt;br /&gt;
        Me.SuspendLayout()&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;PictureBox1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.PictureBox1.BackColor = System.Drawing.Color.White&lt;br /&gt;
        Me.PictureBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle&lt;br /&gt;
        Me.PictureBox1.Location = New System.Drawing.Point(8, 8)&lt;br /&gt;
        Me.PictureBox1.Name = &amp;quot;PictureBox1&amp;quot;&lt;br /&gt;
        Me.PictureBox1.Size = New System.Drawing.Size(550, 224)&lt;br /&gt;
        Me.PictureBox1.TabIndex = 0&lt;br /&gt;
        Me.PictureBox1.TabStop = False&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        &amp;quot;Form1&lt;br /&gt;
        &amp;quot;&lt;br /&gt;
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)&lt;br /&gt;
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font&lt;br /&gt;
        Me.ClientSize = New System.Drawing.Size(600, 242)&lt;br /&gt;
        Me.Controls.Add(Me.PictureBox1)&lt;br /&gt;
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle&lt;br /&gt;
        Me.MaximizeBox = False&lt;br /&gt;
        Me.Name = &amp;quot;Form1&amp;quot;&lt;br /&gt;
        Me.Text = &amp;quot;Measuring Text&amp;quot;&lt;br /&gt;
        CType(Me.PictureBox1, System.ruponentModel.ISupportInitialize).EndInit()&lt;br /&gt;
        Me.ResumeLayout(False)&lt;br /&gt;
    End Sub&lt;br /&gt;
    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox&lt;br /&gt;
End Class&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>