161 lines
		
	
	
		
			5.3 KiB
		
	
	
	
		
			VB.net
		
	
	
	
	
	
			
		
		
	
	
			161 lines
		
	
	
		
			5.3 KiB
		
	
	
	
		
			VB.net
		
	
	
	
	
	
| Public Class YkCtl
 | |
|     Structure SM
 | |
|         Private vStyle As Drawing2D.HatchStyle
 | |
|         Private vwidth As Single, vHeight As Single
 | |
|         Private vFColor As Color
 | |
|         Private vBColor As Color
 | |
| 
 | |
|         Property Style() As Drawing2D.HatchStyle
 | |
|             Get
 | |
|                 Return Me.vStyle
 | |
|             End Get
 | |
|             Set(ByVal value As Drawing2D.HatchStyle)
 | |
|                 Me.vStyle = value
 | |
|             End Set
 | |
|         End Property
 | |
|         Property Width() As Single
 | |
|             Get
 | |
|                 Return Me.vwidth
 | |
|             End Get
 | |
|             Set(ByVal value As Single)
 | |
|                 Me.vwidth = value
 | |
|             End Set
 | |
|         End Property
 | |
|         Property Height() As Single
 | |
|             Get
 | |
|                 Return Me.vHeight
 | |
|             End Get
 | |
|             Set(ByVal value As Single)
 | |
|                 Me.vHeight = value
 | |
|             End Set
 | |
|         End Property
 | |
|         Property FColor() As Color
 | |
|             Get
 | |
|                 Return Me.vFColor
 | |
|             End Get
 | |
|             Set(ByVal value As Color)
 | |
|                 Me.vFColor = value
 | |
|             End Set
 | |
|         End Property
 | |
|         Property BColor() As Color
 | |
|             Get
 | |
|                 Return Me.vBColor
 | |
|             End Get
 | |
|             Set(ByVal value As Color)
 | |
|                 Me.vBColor = value
 | |
|             End Set
 | |
|         End Property
 | |
|     End Structure
 | |
| 
 | |
|     Dim vMFilltype(0) As SM
 | |
|     Dim vVertical As Boolean = True
 | |
|     Dim vMaxWidth As Single = Me.Width  '//총너비
 | |
| 
 | |
|     Property MaxSize() As Single
 | |
|         Get
 | |
|             Return (vMaxWidth)
 | |
|         End Get
 | |
|         Set(ByVal value As Single)
 | |
|             Me.vMaxWidth = value
 | |
|             Me.Refresh()
 | |
|         End Set
 | |
|     End Property
 | |
| 
 | |
|     Property Vertical() As Boolean  '//그림이 세로형태?
 | |
|         Get
 | |
|             Return (vVertical)
 | |
|         End Get
 | |
|         Set(ByVal value As Boolean)
 | |
|             Me.vVertical = value
 | |
|             Me.Refresh()
 | |
|             ' MsgBox(value)
 | |
| 
 | |
|         End Set
 | |
|     End Property
 | |
| 
 | |
|     Property M1FillType() As SM()
 | |
|         Get
 | |
|             Return (Me.vMFilltype)
 | |
|         End Get
 | |
|         Set(ByVal value As SM())
 | |
|             Me.vMFilltype = value
 | |
|             Me.Refresh()
 | |
|             '  MsgBox("sdf")
 | |
|         End Set
 | |
|     End Property
 | |
| 
 | |
|     Private Sub UserControl1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
 | |
|         If Me.vMFilltype Is Nothing OrElse Me.MaxSize <= 0 Then Return
 | |
|         Dim G As Graphics = e.Graphics
 | |
| 
 | |
|         Dim Rect As Rectangle
 | |
|         Dim W As Single
 | |
|         ' If Me.MaxWidth <> 0 Then
 | |
|         For i As Integer = 0 To Me.M1FillType.GetUpperBound(0)  '//갯수만큼 돈다
 | |
|             '//해당 사각형의 Rectangle 을 생성
 | |
|             If i = 0 Then
 | |
|                 If Me.Vertical Then
 | |
|                     W = Me.Width / Me.MaxSize * Me.M1FillType(i).Width
 | |
|                     Rect = New Rectangle(0, 5, W, Me.Height - 10)
 | |
|                 Else
 | |
|                     W = Me.Height / Me.MaxSize * Me.M1FillType(i).Width
 | |
|                     Rect = New Rectangle(5, 0, Me.Width - 10, W)
 | |
|                 End If
 | |
|             Else
 | |
|                 If Me.Vertical Then
 | |
|                     W = Me.Width / Me.MaxSize * Me.M1FillType(i).Width
 | |
|                     Rect = New Rectangle(GetWidth(i), 5, W, Me.Height - 10)
 | |
|                 Else
 | |
|                     W = Me.Height / Me.MaxSize * Me.M1FillType(i).Width
 | |
|                     Rect = New Rectangle(5, GetWidth(i), Me.Width - 10, W)
 | |
|                 End If
 | |
| 
 | |
|             End If
 | |
| 
 | |
|             Try
 | |
|                 Dim B As New System.Drawing.Drawing2D.HatchBrush(Me.M1FillType(i).Style, Me.M1FillType(i).FColor, Me.M1FillType(i).BColor)
 | |
|                 G.FillRectangle(B, Rect)
 | |
|             Catch ex As Exception
 | |
| 
 | |
|             End Try
 | |
|         Next
 | |
| 
 | |
|         For i As Integer = 0 To Me.M1FillType.GetUpperBound(0)  '//갯수만큼 돈다
 | |
|             If Vertical Then
 | |
|                 If i = 0 Then
 | |
|                     W = Me.Width / Me.MaxSize * Me.M1FillType(i).Width
 | |
|                     Rect = New Rectangle(0, 5, W, Me.Height - 10)
 | |
|                 Else
 | |
|                     W = Me.Width / Me.MaxSize * Me.M1FillType(i).Width
 | |
|                     Rect = New Rectangle(GetWidth(i), 5, W, Me.Height - 10)
 | |
|                 End If
 | |
|                 If i <> 0 Then ' AndAlso i <> Me.M1FillType.GetUpperBound(0) Then
 | |
|                     G.DrawLine(New Pen(Color.Black), Rect.X, 5, Rect.X, Me.Height - 5)
 | |
|                 End If
 | |
|             Else
 | |
|                 If i = 0 Then
 | |
|                     W = Me.Height / Me.MaxSize * Me.M1FillType(i).Width
 | |
|                     Rect = New Rectangle(5, 0, Me.Width - 10, W)
 | |
|                 Else
 | |
|                     W = Me.Height / Me.MaxSize * Me.M1FillType(i).Width
 | |
|                     Rect = New Rectangle(5, GetWidth(i), Me.Width - 10, W)
 | |
|                 End If
 | |
|                 If i <> 0 Then 'AndAlso i <> Me.M1FillType.GetUpperBound(0) Then
 | |
|                     G.DrawLine(New Pen(Color.Black), 5, Rect.Y, Me.Width - 5, Rect.Y)
 | |
|                 End If
 | |
|             End If
 | |
|         Next
 | |
|         G.DrawRectangle(New Pen(Color.Black), New Rectangle(0, 0, Me.Width - 2, Me.Height - 2))
 | |
|         G.Dispose()
 | |
|     End Sub
 | |
| 
 | |
|     Private Function GetWidth(ByVal idx As Integer) As Single
 | |
|         Dim Retval As Single = 0
 | |
|         For i As Integer = 0 To idx - 1
 | |
| 
 | |
|             Retval += IIf(Me.Vertical = True, Me.Width, Me.Height) / Me.MaxSize * Me.M1FillType(i).Width
 | |
|         Next
 | |
|         Return Retval
 | |
|     End Function
 | |
| End Class
 | 
