[vb.net] 문자 회전해서 그리기(drawstring rotate text) > vb.net

본문 바로가기

vb.net

[기타] [vb.net] 문자 회전해서 그리기(drawstring rotate text)

회원사진
하나를하더라도최선을
2019-08-13 14:04 8,487 0

본문



d6ce8667faeebf6f79d58a10832186f5_1565672734_424.png


Imports System.Drawing.Drawing2D
Public Class Form1
    Dim Label1 As myLabel
    Dim Label2 As myLabel
    Dim Label3 As myLabel
    Dim myLabels As New List(Of myLabel)
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        Label1 = New myLabel("Label1"New Point(5050))
        myLabels.Add(Label1)
        Label2 = New myLabel("Label2"New Point(100100), 45)
        myLabels.Add(Label2)
        Label3 = New myLabel("Label3"New Point(100100), -45New Font("Arial"18), Color.Blue)
        myLabels.Add(Label3)
    End Sub
    Private Sub Form1_Paint(sender As Object, e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        For Each Lbl As myLabel In myLabels
            Lbl.Draw(e.Graphics)
        Next
    End Sub
End Class

Public Class myLabel
    Public Property Text As String
    Public Property Location As Point
    Public Property Angle As Integer
    Public Property Font As Font
    Public Property ForeColour As Color
    Public Sub New(Text As String, Location As Point)
        Me.New(Text, Location, 0New Font("Arial"10), Color.Black)
    End Sub
    Public Sub New(Text As String, Location As Point, Angle As Integer)
        Me.New(Text, Location, Angle, New Font("Arial"10), Color.Black)
    End Sub
    Public Sub New(Text As String, Location As Point, Angle As Integer, Font As Font)
        Me.New(Text, Location, Angle, Font, Color.Black)
    End Sub
    Public Sub New(Text As String, Location As Point, Angle As Integer, Font As Font, ForeColour As Color)
        Me.Text = Text
        Me.Location = Location
        Me.Angle = Angle
        Me.Font = Font
        Me.ForeColour = ForeColour
    End Sub
    Public Sub Draw(g As Graphics)
        Dim State As GraphicsState = g.Save
        g.TranslateTransform(Location.X, Location.Y)
        g.RotateTransform(Angle)
        Using Brsh As New SolidBrush(ForeColour)
            g.DrawString(Text, Font, Brsh, New Point(00))
        End Using
        g.Restore(State)
    End Sub
End Class

댓글목록0

등록된 댓글이 없습니다.
게시판 전체검색