227 lines
6.8 KiB
VB.net
227 lines
6.8 KiB
VB.net
|
|
Public Class MyLabel
|
|
Public TextValue As String = "[tindevil@Nate.com]"
|
|
Public TextFont As New Font("HY견고딕", 30)
|
|
|
|
Dim v장평 As Int16 = 100
|
|
Dim v장높이 As Int16 = 100
|
|
|
|
Dim v설명 As String = vbNullString
|
|
Dim v전경색 As Color = Color.Black
|
|
Dim v회전 As Int16 = 0
|
|
|
|
Private v_공백 As Int16 = 0 '//공백
|
|
Private V_CB As CheckBox
|
|
|
|
Public Repeat As Short = 0 '//반복출력횟수
|
|
Public RepeatX As Single '//반복출력시 x변위
|
|
Public RepeatY As Single '//반복출력시 y변위
|
|
|
|
Public Pattern As String
|
|
Public DIV As String
|
|
|
|
|
|
Public Sub New()
|
|
|
|
' 이 호출은 Windows Form 디자이너에 필요합니다.
|
|
InitializeComponent()
|
|
'Me.BackColor = Color.Transparent
|
|
' InitializeComponent() 호출 뒤에 초기화 코드를 추가하십시오.
|
|
|
|
End Sub
|
|
|
|
<System.ComponentModel.Description("글자사이의 공백 수")> _
|
|
Public Property CheckBox() As CheckBox
|
|
Get
|
|
Return V_CB
|
|
End Get
|
|
Set(ByVal value As CheckBox)
|
|
V_CB = value
|
|
Me.Invalidate()
|
|
End Set
|
|
End Property
|
|
|
|
<System.ComponentModel.Description("글자사이의 공백 수")> _
|
|
Public Property 공백() As Int16
|
|
Get
|
|
Return v_공백
|
|
End Get
|
|
Set(ByVal value As Int16)
|
|
v_공백 = value
|
|
Me.Invalidate()
|
|
End Set
|
|
End Property
|
|
|
|
Public Function 최종문자() As String
|
|
If v_공백 = 0 Then Return TextValue.Trim
|
|
Dim z As New System.Text.StringBuilder
|
|
For Each A As Char In TextValue.ToCharArray
|
|
z.Append(A.ToString & Space(v_공백))
|
|
Next
|
|
Return (z.ToString.Trim())
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' 컨트롤의 장평을 설정합니다 기본값=100
|
|
''' </summary>
|
|
''' <value></value>
|
|
''' <returns></returns>
|
|
''' <remarks></remarks>
|
|
<DefaultValue(100), Description("컨트롤의 장평을 설정합니다. 기본=100%")> _
|
|
Public Property 장평() As Int16
|
|
Get
|
|
Return v장평
|
|
End Get
|
|
Set(ByVal value As Int16)
|
|
v장평 = value
|
|
Me.Invalidate()
|
|
End Set
|
|
End Property
|
|
|
|
<DefaultValue(100), Description("컨트롤의 글자너비를 설정합니다. 기본=100%")> _
|
|
Public Property 회전() As Int16
|
|
Get
|
|
Return v회전
|
|
End Get
|
|
Set(ByVal value As Int16)
|
|
v회전 = value
|
|
Me.Invalidate()
|
|
End Set
|
|
End Property
|
|
|
|
|
|
<DefaultValue(100), Description("컨트롤의 글자너비를 설정합니다. 기본=100%")> _
|
|
Public Property 장높이() As Int16
|
|
Get
|
|
Return v장높이
|
|
End Get
|
|
Set(ByVal value As Int16)
|
|
v장높이 = value
|
|
Me.Invalidate()
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Public Function GetSize(Optional ByVal NewFont As Font = Nothing) As SizeF
|
|
If NewFont Is Nothing Then NewFont = TextFont
|
|
Return TextRenderer.MeasureText(최종문자, NewFont)
|
|
End Function
|
|
|
|
|
|
''' <summary>
|
|
''' 컨트롤의 설명을 집어넣습니다.
|
|
''' </summary>
|
|
''' <value></value>
|
|
''' <returns></returns>
|
|
''' <remarks></remarks>
|
|
<System.ComponentModel.Description("컨트롤의 설명입니다")> _
|
|
Property 설명() As String
|
|
Get
|
|
If v설명 = vbNullString Then Return Me.Name.ToString
|
|
Return v설명
|
|
End Get
|
|
Set(ByVal value As String)
|
|
v설명 = value
|
|
End Set
|
|
End Property
|
|
|
|
Public Property MyForeColor() As Color
|
|
Get
|
|
Return v전경색
|
|
End Get
|
|
Set(ByVal value As Color)
|
|
v전경색 = value
|
|
Me.Invalidate()
|
|
End Set
|
|
End Property
|
|
|
|
<System.ComponentModel.Description("표시할 문자를 설정합니다.길이는 1입니다")> _
|
|
Public Property MyText() As String
|
|
Get
|
|
Return TextValue
|
|
End Get
|
|
Set(ByVal value As String)
|
|
TextValue = value
|
|
Me.Invalidate()
|
|
End Set
|
|
End Property
|
|
|
|
<System.ComponentModel.Description("텍스트의 폰트타입을 설정합니다")> _
|
|
Public Property MyFont() As Font
|
|
Get
|
|
Return TextFont
|
|
End Get
|
|
Set(ByVal value As Font)
|
|
TextFont = value
|
|
Me.Invalidate()
|
|
End Set
|
|
End Property
|
|
|
|
|
|
Public Function GetImage() As Bitmap
|
|
Dim Br As New SolidBrush(v전경색)
|
|
Me.Height = GetSize.Height * (v장높이 / 100)
|
|
Me.Width = GetSize.Width * (v장평 / 100)
|
|
Dim Bmp As New Bitmap(Me.Width, Me.Height, Me.CreateGraphics)
|
|
Dim G As Graphics = Graphics.FromImage(Bmp)
|
|
|
|
G.ScaleTransform((v장평 / 100), (v장높이 / 100))
|
|
G.DrawString(TextValue, TextFont, Br, 0, 0)
|
|
G.Dispose()
|
|
Return Bmp
|
|
End Function
|
|
|
|
|
|
Protected Overrides Sub OnPaint(ByVal pe As System.Windows.Forms.PaintEventArgs)
|
|
Dim Br As New SolidBrush(v전경색)
|
|
Dim LastText As String = ""
|
|
Dim Idx As Integer = 0
|
|
|
|
|
|
Dim Z As New System.Drawing.StringFormat()
|
|
Z.FormatFlags = StringFormatFlags.MeasureTrailingSpaces
|
|
|
|
If v장평 = 100 AndAlso v장높이 = 100 Then '//장평미적용 문자로 처리
|
|
Me.Width = GetSize.Width
|
|
Me.Height = GetSize.Height
|
|
LastText = 최종문자()
|
|
|
|
' Dim A As New Font("굴림", 20, FontStyle.Regular, GraphicsUnit.Display, &H1, True)
|
|
pe.Graphics.DrawString(LastText, TextFont, Br, 0, 0, Z)
|
|
'pe.Graphics.DrawString(LastText, A, Br, 0, 0)
|
|
Else
|
|
Me.Height = GetSize.Height * (v장높이 / 100)
|
|
Me.Width = GetSize.Width * (v장평 / 100)
|
|
Dim Bmp As New Bitmap(Me.Width, Me.Height, pe.Graphics)
|
|
Dim G As Graphics = Graphics.FromImage(Bmp)
|
|
|
|
If v회전 <> 0 Then
|
|
'G.ResetTransform()
|
|
'G.TranslateTransform(-Me.Width, -Me.Height, Drawing2D.MatrixOrder.Append)
|
|
'G.RotateTransform(v회전, Drawing2D.MatrixOrder.Append)
|
|
'G.TranslateTransform(Me.Width, Me.Height, Drawing2D.MatrixOrder.Append)
|
|
|
|
G.TranslateTransform(-Me.Width, -Me.Height, Drawing2D.MatrixOrder.Append)
|
|
G.RotateTransform(v회전, Drawing2D.MatrixOrder.Append)
|
|
G.TranslateTransform(Me.Width, Me.Height, Drawing2D.MatrixOrder.Append)
|
|
End If
|
|
'G.TranslateTransform(Me.Width / 2, Me.Height / 2, Drawing2D.MatrixOrder.Append)
|
|
G.ScaleTransform((v장평 / 100), (v장높이 / 100))
|
|
G.DrawString(TextValue, TextFont, Br, 0, 0)
|
|
G.Dispose()
|
|
pe.Graphics.DrawImage(Bmp, 0, 0) ', CInt(GetSize.Width * (v장평 / 100)), GetSize.Height)
|
|
End If
|
|
|
|
End Sub
|
|
|
|
|
|
Private Sub RotateAt(ByVal gr As Graphics, ByVal cx As Integer, ByVal cy As Integer, ByVal angle As Single)
|
|
gr.ResetTransform()
|
|
gr.TranslateTransform(-cx, -cy, Drawing2D.MatrixOrder.Append)
|
|
gr.RotateTransform(angle, Drawing2D.MatrixOrder.Append)
|
|
gr.TranslateTransform(cx, cy, Drawing2D.MatrixOrder.Append)
|
|
End Sub
|
|
|
|
|
|
End Class
|