|
Imports System.Drawing.Drawing2D
Public Class Form1
Private Sub DrawReflectText(ByVal myText As String)
Dim g As Graphics = PictureBox1.CreateGraphics()
g.Clear(Color.Black)
Dim textSize As SizeF
Dim myBackBrush As Brush = Brushes.Gray
Dim myForeBrush As Brush = Brushes.White
Dim myFont As New Font(ComboBox1.SelectedItem.ToString, _
NumericUpDown1.Value, FontStyle.Regular)
Dim xLocation, yLocation As Single
Dim textHeight As Single
' Die erforderliche Größe ermitteln
textSize = g.MeasureString(myText, myFont)
' Positionen definieren
xLocation = (PictureBox1.Width - textSize.Width) / 2
yLocation = (PictureBox1.Height - textSize.Height) / 2
' Ursprung des Graphics-Objekts (0,0) neu festlegen
g.TranslateTransform(xLocation, yLocation)
textHeight = CInt(NumericUpDown1.Value * 1.5)
' Den Haupttext zeichnen.
g.DrawString(myText, myFont, myForeBrush, 0, -textHeight)
' Spiegeln
If RadioButton2.Checked Then
' Spiegeln um die y-Achse
g.ScaleTransform(1, -1.0F)
g.DrawString(myText, myFont, myBackBrush, 0, -textHeight)
Else
' Scheren und spiegeln
Dim myTransform As Matrix
myTransform = g.Transform
' Scheren um x-Wert
myTransform.Shear(-1, 0)
g.Transform = myTransform
' Spiegeln um die y-Achse
g.ScaleTransform(1, -1.0F)
g.DrawString(myText, myFont, myBackBrush, 0, -textHeight)
End If
g.Dispose()
End Sub
End Class
| |