http://vbex.ru/index.php?title=VB.Net/2D&feed=atom&action=historyVB.Net/2D - История изменений2024-03-28T16:55:38ZИстория изменений этой страницы в викиMediaWiki 1.30.0http://vbex.ru/index.php?title=VB.Net/2D&diff=172&oldid=prev в 16:40, 26 мая 20102010-05-26T16:40:06Z<p></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<tr style="vertical-align: top;" lang="ru">
<td colspan="1" style="background-color: white; color:black; text-align: center;">← Предыдущая</td>
<td colspan="1" style="background-color: white; color:black; text-align: center;">Версия 16:40, 26 мая 2010</td>
</tr><tr><td colspan="2" style="text-align: center;" lang="ru"><div class="mw-diff-empty">(нет различий)</div>
</td></tr></table>http://vbex.ru/index.php?title=VB.Net/2D&diff=173&oldid=prevAdmin: 1 версия2010-05-26T12:42:07Z<p>1 версия</p>
<p><b>Новая страница</b></p><div>* [[VB.Net/2D/Arc | Arc]]<br />
* [[VB.Net/2D/Area Combination | Area Combination]]<br />
* [[VB.Net/2D/Arrow | Arrow]]<br />
* [[VB.Net/2D/Bezier | Bezier]]<br />
* [[VB.Net/2D/Bitmap | Bitmap]]<br />
* [[VB.Net/2D/Bmp | Bmp]]<br />
* [[VB.Net/2D/Brush | Brush]]<br />
* [[VB.Net/2D/Clip | Clip]]<br />
* [[VB.Net/2D/Color | Color]]<br />
* [[VB.Net/2D/Curve | Curve]]<br />
* [[VB.Net/2D/Drag Draw | Drag Draw]]<br />
* [[VB.Net/2D/Draw Image | Draw Image]]<br />
* [[VB.Net/2D/Draw String | Draw String]]<br />
* [[VB.Net/2D/Ellipse | Ellipse]]<br />
* [[VB.Net/2D/Fill Mode | Fill Mode]]<br />
* [[VB.Net/2D/Gif | Gif]]<br />
* [[VB.Net/2D/Gradient | Gradient]]<br />
* [[VB.Net/2D/Graphic Path | Graphic Path]]<br />
* [[VB.Net/2D/Graphic State | Graphic State]]<br />
* [[VB.Net/2D/Graphics Path Iterator | Graphics Path Iterator]]<br />
* [[VB.Net/2D/Hatch Brush | Hatch Brush]]<br />
* [[VB.Net/2D/Icon | Icon]]<br />
* [[VB.Net/2D/Image | Image]]<br />
* [[VB.Net/2D/Image Animator | Image Animator]]<br />
* [[VB.Net/2D/Image File | Image File]]<br />
* [[VB.Net/2D/Interpolation Mode | Interpolation Mode]]<br />
* [[VB.Net/2D/JPG | JPG]]<br />
* [[VB.Net/2D/Line | Line]]<br />
* [[VB.Net/2D/Line Alignment | Line Alignment]]<br />
* [[VB.Net/2D/Line Compound | Line Compound]]<br />
* [[VB.Net/2D/Line Dash | Line Dash]]<br />
* [[VB.Net/2D/Line Join | Line Join]]<br />
* [[VB.Net/2D/Line Smooth Mode | Line Smooth Mode]]<br />
* [[VB.Net/2D/LineCaps | LineCaps]]<br />
* [[VB.Net/2D/Matrix | Matrix]]<br />
* [[VB.Net/2D/PNG | PNG]]<br />
* [[VB.Net/2D/Paint Size | Paint Size]]<br />
* [[VB.Net/2D/Path String | Path String]]<br />
* [[VB.Net/2D/PathGradientBrush | PathGradientBrush]]<br />
* [[VB.Net/2D/Pen | Pen]]<br />
* [[VB.Net/2D/Pen Alignment | Pen Alignment]]<br />
* [[VB.Net/2D/Pen Join | Pen Join]]<br />
* [[VB.Net/2D/Pie | Pie]]<br />
* [[VB.Net/2D/Ploygon | Ploygon]]<br />
* [[VB.Net/2D/Public | Public]]<br />
* [[VB.Net/2D/Rectangle | Rectangle]]<br />
* [[VB.Net/2D/Region | Region]]<br />
* [[VB.Net/2D/Rotate | Rotate]]<br />
* [[VB.Net/2D/Scale | Scale]]<br />
* [[VB.Net/2D/Shape | Shape]]<br />
* [[VB.Net/2D/Shear | Shear]]<br />
* [[VB.Net/2D/Smooth | Smooth]]<br />
* [[VB.Net/2D/Star | Star]]<br />
* [[VB.Net/2D/String Format Paint | String Format Paint]]<br />
* [[VB.Net/2D/String Trim Paint | String Trim Paint]]<br />
* [[VB.Net/2D/Text Contrast | Text Contrast]]<br />
* [[VB.Net/2D/Text Layout | Text Layout]]<br />
* [[VB.Net/2D/Text Rendering Hint | Text Rendering Hint]]<br />
* [[VB.Net/2D/Texture | Texture]]<br />
* [[VB.Net/2D/Texture Brush | Texture Brush]]<br />
* [[VB.Net/2D/Tiff | Tiff]]<br />
* [[VB.Net/2D/Transform | Transform]]<br />
* [[VB.Net/2D/Translate | Translate]]<br />
* [[VB.Net/2D/Wmf | Wmf]]<br />
* [[VB.Net/2D/ttf File | ttf File]]<br />
<br />
==Demonstrating various font settings==<br />
<br />
<br />
<br />
<source lang="vbnet"><br />
Imports System<br />
Imports System.Drawing<br />
Imports System.Windows.Forms<br />
Public Class MainClass<br />
Shared Sub Main()<br />
Dim myform As Form = New FrmFonts()<br />
Application.Run(myform)<br />
End Sub " Main<br />
End Class<br />
<br />
Public Class FrmFonts<br />
Inherits System.Windows.Forms.Form<br />
#Region " Windows Form Designer generated code "<br />
Public Sub New()<br />
MyBase.New()<br />
"This call is required by the Windows Form Designer.<br />
InitializeComponent()<br />
"Add any initialization after the InitializeComponent() call<br />
End Sub<br />
"Form overrides dispose to clean up the component list.<br />
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)<br />
If disposing Then<br />
If Not (components Is Nothing) Then<br />
components.Dispose()<br />
End If<br />
End If<br />
MyBase.Dispose(disposing)<br />
End Sub<br />
"Required by the Windows Form Designer<br />
Private components As System.ruponentModel.Container<br />
"NOTE: The following procedure is required by the Windows Form Designer<br />
"It can be modified using the Windows Form Designer. <br />
"Do not modify it using the code editor.<br />
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()<br />
"<br />
"frmFonts<br />
"<br />
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)<br />
Me.ClientSize = New System.Drawing.Size(496, 117)<br />
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D<br />
Me.Name = "frmFonts"<br />
Me.Text = "Fonts"<br />
End Sub<br />
#End Region<br />
Protected Overrides Sub OnPaint( _<br />
ByVal paintEvent As PaintEventArgs)<br />
Dim graphicsObject As Graphics = paintEvent.Graphics<br />
Dim brush As SolidBrush = New SolidBrush(Color.DarkBlue)<br />
Dim style As FontStyle = FontStyle.Bold<br />
Dim arial As Font = New Font(New FontFamily("Arial"), 12, style)<br />
graphicsObject.DrawString(arial.Name & " 12 point bold.",arial, brush, 10, 10)<br />
style = FontStyle.Regular<br />
Dim timesNewRoman As Font = New Font("Times New Roman", 12, style)<br />
graphicsObject.DrawString(timesNewRoman.Name &" 12 point plain.", timesNewRoman, brush, 10, 30)<br />
style = FontStyle.Bold Or FontStyle.Italic<br />
Dim courierNew As Font = New Font("Courier New",16, style)<br />
graphicsObject.DrawString(courierNew.Name & " 16 point bold and italic.", courierNew, brush, 10, 54)<br />
style = FontStyle.Strikeout<br />
Dim tahoma As Font = New Font("Tahoma", 18, style)<br />
graphicsObject.DrawString(tahoma.Name & " 18 point strikeout.", tahoma, brush, 10, 75)<br />
<br />
End Sub<br />
End Class <br />
<br />
</source><br />
<br />
<br />
==Displaying font metric information==<br />
<br />
<br />
<br />
<source lang="vbnet"><br />
Imports System<br />
Imports System.Drawing<br />
Imports System.Windows.Forms<br />
Imports System.Drawing.Text<br />
Public Class MainClass<br />
Shared Sub Main()<br />
Dim myform As Form = New FrmFontMetrics()<br />
Application.Run(myform)<br />
End Sub " Main<br />
End Class<br />
<br />
Public Class FrmFontMetrics<br />
Inherits System.Windows.Forms.Form<br />
#Region " Windows Form Designer generated code "<br />
Public Sub New()<br />
MyBase.New()<br />
"This call is required by the Windows Form Designer.<br />
InitializeComponent()<br />
"Add any initialization after the InitializeComponent() call<br />
End Sub<br />
"Form overrides dispose to clean up the component list.<br />
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)<br />
If disposing Then<br />
If Not (components Is Nothing) Then<br />
components.Dispose()<br />
End If<br />
End If<br />
MyBase.Dispose(disposing)<br />
End Sub<br />
"Required by the Windows Form Designer<br />
Private components As System.ruponentModel.Container<br />
"NOTE: The following procedure is required by the Windows Form Designer<br />
"It can be modified using the Windows Form Designer. <br />
"Do not modify it using the code editor.<br />
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()<br />
"<br />
"frmFontMetrics<br />
"<br />
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)<br />
Me.ClientSize = New System.Drawing.Size(920, 253)<br />
Me.Name = "frmFontMetrics"<br />
Me.Text = "Metrics"<br />
End Sub<br />
#End Region<br />
Protected Overrides Sub OnPaint( _<br />
ByVal paintEvent As PaintEventArgs)<br />
Dim graphicsObject As Graphics = paintEvent.Graphics<br />
Dim brush As SolidBrush = New SolidBrush(Color.Red)<br />
Dim pen As Pen = New Pen(brush, Convert.ToSingle(2.5))<br />
" Arial font metrics<br />
Dim arial As Font = New Font("Arial", 12)<br />
Dim family As FontFamily = arial.FontFamily<br />
Dim sanSerif As Font = New Font("Microsoft Sans Serif", _<br />
14, FontStyle.Italic)<br />
pen.Color = brush.Color<br />
brush.Color = Color.DarkBlue<br />
" display Arial font metrics<br />
graphicsObject.DrawString("Current Font: " & arial.ToString, _<br />
arial, brush, 10, 10)<br />
graphicsObject.DrawString("Ascent: " & _<br />
family.GetCellAscent(FontStyle.Regular), arial, brush, _<br />
10, 30)<br />
graphicsObject.DrawString("Descent: " & _<br />
family.GetCellDescent(FontStyle.Regular), arial, brush, _<br />
10, 50)<br />
graphicsObject.DrawString("Height: " & family.GetEmHeight _<br />
(FontStyle.Regular), arial, brush, 10, 70)<br />
graphicsObject.DrawString("Leading: " & _<br />
family.GetLineSpacing(FontStyle.Regular), arial, brush, _<br />
10, 90)<br />
End Sub " OnPaint<br />
End Class <br />
<br />
</source><br />
<br />
<br />
==Draw Character Outline==<br />
<br />
<br />
<br />
<br />
<source lang="vbnet"><br />
Imports System.Drawing.Drawing2D<br />
Imports System<br />
Imports System.Drawing.Text<br />
Imports System.Drawing<br />
Imports System.Windows.Forms<br />
Imports System.Math<br />
Public Class MainClass<br />
Shared Sub Main()<br />
Dim form1 As Form = New Form1()<br />
Application.Run(form1)<br />
End Sub <br />
End Class<br />
<br />
Public Class Form1<br />
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
Me.ResizeRedraw = True<br />
End Sub<br />
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint<br />
Dim txt As String = "www.vbex.ru"<br />
Dim the_font As New Font("Times New Roman", 50, _<br />
FontStyle.Bold, GraphicsUnit.Pixel)<br />
Dim layout_rect As New RectangleF(0, 0, _<br />
Me.ClientSize.Width, Me.ClientSize.Height)<br />
Dim string_format As New StringFormat<br />
string_format.LineAlignment = StringAlignment.Center<br />
string_format.Alignment = StringAlignment.Center<br />
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit<br />
Dim character_ranges(txt.Length - 1) As CharacterRange<br />
For i As Integer = 0 To txt.Length - 1<br />
character_ranges(i) = New CharacterRange(i, 1)<br />
Next i<br />
string_format.SetMeasurableCharacterRanges(character_ranges)<br />
Dim character_regions() As Region = _<br />
e.Graphics.MeasureCharacterRanges(txt, _<br />
the_font, layout_rect, string_format)<br />
For Each rgn As Region In character_regions<br />
Dim character_bounds As RectangleF = rgn.GetBounds(e.Graphics)<br />
Dim character_rect As Rectangle = _<br />
Rectangle.Round(character_bounds)<br />
e.Graphics.DrawRectangle(Pens.White, character_rect)<br />
Next rgn<br />
e.Graphics.DrawString(txt, the_font, Brushes.Black, _<br />
layout_rect, string_format)<br />
End Sub<br />
End Class<br />
<br />
<br />
<Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _<br />
Partial Public Class Form1<br />
Inherits System.Windows.Forms.Form<br />
"Form overrides dispose to clean up the component list.<br />
<System.Diagnostics.DebuggerNonUserCode()> _<br />
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)<br />
If disposing AndAlso components IsNot Nothing Then<br />
components.Dispose()<br />
End If<br />
MyBase.Dispose(disposing)<br />
End Sub<br />
"Required by the Windows Form Designer<br />
Private components As System.ruponentModel.IContainer<br />
"NOTE: The following procedure is required by the Windows Form Designer<br />
"It can be modified using the Windows Form Designer. <br />
"Do not modify it using the code editor.<br />
<System.Diagnostics.DebuggerStepThrough()> _<br />
Private Sub InitializeComponent()<br />
Me.SuspendLayout()<br />
"<br />
"Form1<br />
"<br />
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)<br />
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font<br />
Me.ClientSize = New System.Drawing.Size(200, 200)<br />
Me.Name = "Form1"<br />
Me.Text = ""<br />
Me.ResumeLayout(False)<br />
End Sub<br />
End Class<br />
<br />
<br />
</source><br />
<br />
<br />
==Font Metrics Illustration==<br />
<br />
<br />
<br />
<source lang="vbnet"><br />
Imports System<br />
Imports System.Windows.Forms<br />
Imports System.Drawing<br />
Imports System.Drawing.Drawing2D<br />
Imports System.Drawing.Text<br />
Imports System.Drawing.Imaging<br />
Imports System.Runtime.InteropServices<br />
Public Class MainClass<br />
Shared Sub Main()<br />
Dim form1 As Form1 = new Form1<br />
Application.Run(form1)<br />
End Sub<br />
<br />
End Class<br />
<br />
<br />
Public Class Form1<br />
Inherits System.Windows.Forms.Form<br />
#Region " Windows Form Designer generated code "<br />
Public Sub New()<br />
MyBase.New()<br />
"This call is required by the Windows Form Designer.<br />
InitializeComponent()<br />
"Add any initialization after the InitializeComponent() call<br />
End Sub<br />
"Form overrides dispose to clean up the component list.<br />
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)<br />
If disposing Then<br />
If Not (components Is Nothing) Then<br />
components.Dispose()<br />
End If<br />
End If<br />
MyBase.Dispose(disposing)<br />
End Sub<br />
"Required by the Windows Form Designer<br />
Private components As System.ruponentModel.IContainer<br />
"NOTE: The following procedure is required by the Windows Form Designer<br />
"It can be modified using the Windows Form Designer. <br />
"Do not modify it using the code editor.<br />
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()<br />
Me.SuspendLayout()<br />
"<br />
"Form1<br />
"<br />
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)<br />
Me.ClientSize = New System.Drawing.Size(492, 273)<br />
Me.MaximizeBox = False<br />
Me.MinimizeBox = False<br />
Me.Name = "Form1"<br />
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen<br />
Me.Text = "Form1"<br />
Me.ResumeLayout(False)<br />
End Sub<br />
#End Region<br />
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)<br />
Dim ff As FontFamily = New FontFamily("Arial Black")<br />
Dim fnt As Font = New Font(ff, 75, FontStyle.Regular, GraphicsUnit.Pixel)<br />
Dim G As Graphics = Me.CreateGraphics()<br />
G.SmoothingMode = SmoothingMode.AntiAlias<br />
G.TextRenderingHint = TextRenderingHint.AntiAlias<br />
Dim LineSpace As Int32 = CInt(ff.GetLineSpacing(fnt.Style) * _<br />
fnt.Size / ff.GetEmHeight(fnt.Style))<br />
Dim Descent As Int32 = CInt(ff.GetCellDescent(fnt.Style) * _<br />
fnt.Size / ff.GetEmHeight(fnt.Style))<br />
Dim Ascent As Int32 = CInt(ff.GetCellAscent(fnt.Style) * _<br />
fnt.Size / ff.GetEmHeight(fnt.Style))<br />
Dim BaseLineStart As Point = New Point(15, CInt(Me.Height * 3 / 5))<br />
Dim BaseLineEnd As Point = New Point(Me.Width - 15, CInt(Me.Height * 3 / 5))<br />
Dim StringPoint As Point = New Point(75, CInt(BaseLineStart.Y - Ascent))<br />
G.Clear(Color.AliceBlue)<br />
G.DrawString("A j Q", fnt, Brushes.Blue, Point.op_Implicit(StringPoint))<br />
G.DrawLine(Pens.Black, BaseLineStart, BaseLineEnd)<br />
Dim LineSize As Size = New Size(0, LineSpace)<br />
Dim AscentSize As Size = New Size(0, Ascent)<br />
Dim DescentSize As Size = New Size(0, Descent)<br />
G.DrawLine(Pens.Black, Point.op_Subtraction(BaseLineStart, LineSize), _<br />
Point.op_Subtraction(BaseLineEnd, LineSize))<br />
G.DrawLine(Pens.Red, Point.op_Subtraction(BaseLineStart, AscentSize), _<br />
Point.op_Subtraction(BaseLineEnd, AscentSize))<br />
G.DrawLine(Pens.DarkGreen, Point.op_Addition(BaseLineStart, DescentSize), _<br />
Point.op_Addition(BaseLineEnd, DescentSize))<br />
Dim AnnoFont As Font = New Font("Arial", 10)<br />
G.DrawString("Line Space = " + LineSpace.ToString(), AnnoFont, _<br />
Brushes.Black, _<br />
20, _<br />
CInt(BaseLineStart.Y - LineSpace - 12))<br />
G.DrawString("Ascent = " + Ascent.ToString(), AnnoFont, _<br />
Brushes.Red, _<br />
250, _<br />
CInt(BaseLineStart.Y - Ascent - 12))<br />
G.DrawString("Descent = " + Descent.ToString(), AnnoFont, _<br />
Brushes.DarkGreen, _<br />
350, _<br />
CInt(BaseLineStart.Y + Descent / 8))<br />
End Sub<br />
End Class<br />
<br />
</source><br />
<br />
<br />
==Outline Fonts Demo==<br />
<br />
<br />
<br />
<source lang="vbnet"><br />
Imports System<br />
Imports System.ruponentModel<br />
Imports System.Windows.Forms<br />
Imports System.Data<br />
Imports System.Configuration<br />
Imports System.Drawing<br />
Imports System.Drawing.Drawing2D<br />
Imports System.Drawing.Text<br />
Imports System.Globalization<br />
Imports System.Text<br />
Imports System.Collections<br />
Public Class MainClass<br />
Shared Sub Main()<br />
Dim myform As Form = New OutlineFontsForm()<br />
Application.Run(myform)<br />
End Sub<br />
End Class<br />
<br />
Public Class OutlineFontsForm<br />
Inherits System.Windows.Forms.Form<br />
#Region " Windows Form Designer generated code "<br />
Public Sub New()<br />
MyBase.New()<br />
"This call is required by the Windows Form Designer.<br />
InitializeComponent()<br />
"Add any initialization after the InitializeComponent() call<br />
End Sub<br />
"Form overrides dispose to clean up the component list.<br />
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)<br />
If disposing Then<br />
If Not (components Is Nothing) Then<br />
components.Dispose()<br />
End If<br />
End If<br />
MyBase.Dispose(disposing)<br />
End Sub<br />
"Required by the Windows Form Designer<br />
Private components As System.ruponentModel.IContainer<br />
"NOTE: The following procedure is required by the Windows Form Designer<br />
"It can be modified using the Windows Form Designer. <br />
"Do not modify it using the code editor.<br />
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()<br />
"<br />
"OutlineFontsForm<br />
"<br />
Me.AutoScaleBaseSize = New System.Drawing.Size(46, 109)<br />
Me.ClientSize = New System.Drawing.Size(292, 266)<br />
Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 72.0!)<br />
Me.Name = "OutlineFontsForm"<br />
Me.Text = "OutlineFontsForm"<br />
End Sub<br />
#End Region<br />
<br />
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<br />
Dim path As GraphicsPath = New GraphicsPath()<br />
Dim emSize As Single = dpi * font.SizeInPoints / 72<br />
path.AddString(s, font.FontFamily, CInt(font.Style), emSize, rect, format)<br />
Return path<br />
End Function<br />
<br />
Private Sub OutlineFontsForm_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint<br />
Dim g As Graphics = e.Graphics<br />
Dim s As String = "String String String"<br />
Dim rect As RectangleF = RectangleF.op_Implicit(Me.ClientRectangle)<br />
Dim font As Font = Me.Font<br />
Dim format As StringFormat = StringFormat.GenericTypographic<br />
Dim dpi As Single = g.DpiY<br />
Dim path As GraphicsPath = GetStringPath(s, dpi, rect, font, format)<br />
g.DrawPath(Pens.Black, path)<br />
End Sub<br />
End Class<br />
<br />
</source><br />
<br />
<br />
==Outline the Font Metrics==<br />
<br />
<br />
<br />
<source lang="vbnet"><br />
Imports System.Drawing.Drawing2D<br />
Imports System<br />
Imports System.Drawing.Text<br />
Imports System.Drawing<br />
Imports System.Windows.Forms<br />
Imports System.Math<br />
Public Class MainClass<br />
Shared Sub Main()<br />
Dim form1 As Form = New Form1()<br />
Application.Run(form1)<br />
End Sub <br />
End Class<br />
<br />
Public Class Form1<br />
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load<br />
Me.ResizeRedraw = True<br />
End Sub<br />
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint<br />
Dim txt As String = "www.vbex.ru"<br />
Dim layout_rect As New RectangleF(0, 0, _<br />
Me.ClientSize.Width, Me.ClientSize.Height)<br />
Dim string_format As New StringFormat<br />
string_format.LineAlignment = StringAlignment.Center<br />
string_format.Alignment = StringAlignment.Center<br />
Dim the_font As Font<br />
e.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit<br />
the_font = New Font("Times New Roman", 80, FontStyle.Bold, GraphicsUnit.Pixel)<br />
<br />
Dim character_ranges(txt.Length - 1) As CharacterRange<br />
For i As Integer = 0 To txt.Length - 1<br />
character_ranges(i) = New CharacterRange(i, 1)<br />
Next i<br />
string_format.SetMeasurableCharacterRanges(character_ranges)<br />
Dim character_regions() As Region = _<br />
e.Graphics.MeasureCharacterRanges(txt, _<br />
the_font, layout_rect, string_format)<br />
Dim em_height As Integer = the_font.FontFamily.GetEmHeight(FontStyle.Bold)<br />
Dim em_height_pix As Single = the_font.Size<br />
Dim design_to_pixels As Single = the_font.Size / em_height<br />
Dim ascent As Integer = the_font.FontFamily.GetCellAscent(FontStyle.Bold)<br />
Dim ascent_pix As Single = ascent * design_to_pixels<br />
Dim descent As Integer = the_font.FontFamily.GetCellDescent(FontStyle.Bold)<br />
Dim descent_pix As Single = descent * design_to_pixels<br />
Dim cell_height_pix As Single = ascent_pix + descent_pix<br />
Dim internal_leading_pix As Single = cell_height_pix - em_height_pix<br />
Dim line_spacing As Integer = the_font.FontFamily.GetLineSpacing(FontStyle.Bold)<br />
Dim line_spacing_pix As Single = line_spacing * design_to_pixels<br />
Dim external_leading_pix As Single = line_spacing_pix - cell_height_pix<br />
For Each rgn As Region In character_regions<br />
Dim character_bounds As RectangleF = rgn.GetBounds(e.Graphics)<br />
Dim character_rect As Rectangle = _<br />
Rectangle.Round(character_bounds)<br />
e.Graphics.DrawRectangle(Pens.Black, character_rect)<br />
e.Graphics.DrawLine(Pens.White, _<br />
character_rect.X, _<br />
character_rect.Y + internal_leading_pix, _<br />
character_rect.Right, _<br />
character_rect.Y + internal_leading_pix)<br />
e.Graphics.DrawLine(Pens.Yellow, _<br />
character_rect.X, _<br />
character_rect.Y + ascent_pix, _<br />
character_rect.Right, _<br />
character_rect.Y + ascent_pix)<br />
e.Graphics.DrawLine(Pens.Orange, _<br />
character_rect.X, _<br />
character_rect.Y + ascent_pix + descent_pix, _<br />
character_rect.Right, _<br />
character_rect.Y + ascent_pix + descent_pix)<br />
e.Graphics.FillRectangle(Brushes.Red, _<br />
character_rect.X, _<br />
character_rect.Y + ascent_pix + descent_pix, _<br />
character_rect.Width, _<br />
external_leading_pix)<br />
Console.WriteLine( _<br />
character_rect.X & ", " & _<br />
character_rect.Y + ascent_pix + descent_pix & ", " & _<br />
character_rect.Width & ", " & _<br />
external_leading_pix)<br />
Next rgn<br />
e.Graphics.DrawString(txt, the_font, Brushes.Black, _<br />
layout_rect, string_format)<br />
End Sub<br />
End Class<br />
<br />
<br />
<Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _<br />
Partial Public Class Form1<br />
Inherits System.Windows.Forms.Form<br />
"Form overrides dispose to clean up the component list.<br />
<System.Diagnostics.DebuggerNonUserCode()> _<br />
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)<br />
If disposing AndAlso components IsNot Nothing Then<br />
components.Dispose()<br />
End If<br />
MyBase.Dispose(disposing)<br />
End Sub<br />
"Required by the Windows Form Designer<br />
Private components As System.ruponentModel.IContainer<br />
"NOTE: The following procedure is required by the Windows Form Designer<br />
"It can be modified using the Windows Form Designer. <br />
"Do not modify it using the code editor.<br />
<System.Diagnostics.DebuggerStepThrough()> _<br />
Private Sub InitializeComponent()<br />
Me.SuspendLayout()<br />
"<br />
"Form1<br />
"<br />
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)<br />
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font<br />
Me.ClientSize = New System.Drawing.Size(200, 200)<br />
Me.Name = "Form1"<br />
Me.Text = ""<br />
Me.ResumeLayout(False)<br />
End Sub<br />
End Class<br />
<br />
<br />
</source><br />
<br />
<br />
==Shadow Fonts Demo==<br />
<br />
<br />
<br />
<source lang="vbnet"><br />
Imports System<br />
Imports System.ruponentModel<br />
Imports System.Windows.Forms<br />
Imports System.Data<br />
Imports System.Configuration<br />
Imports System.Drawing<br />
Imports System.Drawing.Drawing2D<br />
Imports System.Drawing.Text<br />
Imports System.Globalization<br />
Imports System.Text<br />
Imports System.Collections<br />
Public Class MainClass<br />
Shared Sub Main()<br />
Dim myform As Form = New ShadowFontsForm()<br />
Application.Run(myform)<br />
End Sub<br />
End Class<br />
Public Class ShadowFontsForm<br />
Inherits System.Windows.Forms.Form<br />
#Region " Windows Form Designer generated code "<br />
Public Sub New()<br />
MyBase.New()<br />
"This call is required by the Windows Form Designer.<br />
InitializeComponent()<br />
"Add any initialization after the InitializeComponent() call<br />
End Sub<br />
"Form overrides dispose to clean up the component list.<br />
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)<br />
If disposing Then<br />
If Not (components Is Nothing) Then<br />
components.Dispose()<br />
End If<br />
End If<br />
MyBase.Dispose(disposing)<br />
End Sub<br />
"Required by the Windows Form Designer<br />
Private components As System.ruponentModel.IContainer<br />
"NOTE: The following procedure is required by the Windows Form Designer<br />
"It can be modified using the Windows Form Designer. <br />
"Do not modify it using the code editor.<br />
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()<br />
"<br />
"ShadowFontsForm<br />
"<br />
Me.AutoScaleBaseSize = New System.Drawing.Size(46, 109)<br />
Me.ClientSize = New System.Drawing.Size(292, 266)<br />
Me.Font = New System.Drawing.Font("Microsoft Sans Serif", 72.0!)<br />
Me.Name = "ShadowFontsForm"<br />
Me.Text = "ShadowFontsForm"<br />
End Sub<br />
#End Region<br />
<br />
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<br />
Dim path As GraphicsPath = New GraphicsPath()<br />
Dim emSize As Single = dpi * font.SizeInPoints / 72<br />
path.AddString(s, font.FontFamily, CInt(font.Style), emSize, rect, format)<br />
Return path<br />
End Function<br />
<br />
Private Sub ShadowFontsForm_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles MyBase.Paint<br />
Dim g As Graphics = e.Graphics<br />
Dim s As String = "String String String String String"<br />
Dim offset As Single = 4<br />
Dim size As SizeF = New SizeF(Me.ClientRectangle.Width - offset, Me.ClientRectangle.Height - offset)<br />
Dim rectShadow As RectangleF = New RectangleF(offset, offset, size.Width, size.Height)<br />
Dim rect As RectangleF = New RectangleF(0, 0, size.Width, size.Height)<br />
Dim font As Font = Me.Font<br />
Dim format As StringFormat = StringFormat.GenericTypographic<br />
Dim dpi As Single = g.DpiY<br />
Dim pathShadow As GraphicsPath = GetStringPath(s, dpi, rectShadow, font, format)<br />
Dim path As GraphicsPath = GetStringPath(s, dpi, rect, font, format)<br />
g.FillPath(Brushes.Black, pathShadow)<br />
g.FillPath(Brushes.Red, path)<br />
End Sub<br />
End Class<br />
<br />
</source><br />
<br />
<br />
==Use Default Frame Font==<br />
<br />
<br />
<br />
<source lang="vbnet"><br />
Imports System<br />
Imports System.Runtime.InteropServices<br />
Imports System.Drawing<br />
Imports System.ruponentModel<br />
Imports System.Windows.Forms<br />
<br />
Public Class MainClass<br />
<br />
Shared Sub Main(ByVal args As String())<br />
Dim myform As Form = New Form1()<br />
Application.Run(myform)<br />
End Sub<br />
End Class<br />
Public Class Form1<br />
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint<br />
e.Graphics.DrawString("www.vbex.ru", Me.Font, Brushes.Black, 10, 100)<br />
End Sub<br />
End Class<br />
<br />
<Global.Microsoft.VisualBasic.rupilerServices.DesignerGenerated()> _<br />
Partial Public Class Form1<br />
Inherits System.Windows.Forms.Form<br />
"Form overrides dispose to clean up the component list.<br />
<System.Diagnostics.DebuggerNonUserCode()> _<br />
Protected Overrides Sub Dispose(ByVal disposing As Boolean)<br />
If disposing AndAlso components IsNot Nothing Then<br />
components.Dispose()<br />
End If<br />
MyBase.Dispose(disposing)<br />
End Sub<br />
"Required by the Windows Form Designer<br />
Private components As System.ruponentModel.IContainer<br />
"NOTE: The following procedure is required by the Windows Form Designer<br />
"It can be modified using the Windows Form Designer. <br />
"Do not modify it using the code editor.<br />
<System.Diagnostics.DebuggerStepThrough()> _<br />
Private Sub InitializeComponent()<br />
Me.SuspendLayout()<br />
"<br />
"Form1<br />
"<br />
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)<br />
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font<br />
Me.ClientSize = New System.Drawing.Size(194, 117)<br />
Me.Name = "Form1"<br />
Me.Text = "Form1"<br />
Me.ResumeLayout(False)<br />
End Sub<br />
End Class<br />
<br />
</source></div>Admin