Code:
Private TextBottom As String
Private _StatusImage As Image
Public Property Text_Bottom() As String
Get
Return TextBottom
End Get
Set(ByVal value As String)
TextBottom = value
End Set
End Property
<Category("Appearance"), Description("Gets or sets the Background image.")> <Browsable(True)>
Public Property StatusImage() As Image
Get
Return _StatusImage
End Get
Set(ByVal value As Image)
_StatusImage = value
Me.Refresh()
End Set
End Property
'Used to paint the control according to how the properties are set
Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs)
With e.Graphics
.FillRectangle(_BackColorBrush, 0, 0, Me.Width, Me.Height)
.SmoothingMode = SmoothingMode.AntiAlias
Dim textWidth As Integer = CInt(.MeasureString(Me.Text, Me.Font).Width)
Dim textHeight As Integer = CInt(.MeasureString(Me.Text, Me.Font).Height)
Dim rec As New Rectangle(0, CInt(textHeight / 2), Me.Width - 1, Me.Height - 1 - CInt(textHeight))
Using gfxPath As New GraphicsPath
If Me.GroupPanelShape = PanelType.Rounded Then
Dim rad As Integer = 14
gfxPath.AddArc(rec.Right - (rad), rec.Y, rad, rad, 270, 90)
gfxPath.AddArc(rec.Right - (rad), rec.Bottom - (rad), rad, rad, 0, 90)
gfxPath.AddArc(rec.X, rec.Bottom - (rad), rad, rad, 90, 90)
gfxPath.AddArc(rec.X, rec.Y, rad, rad, 180, 90)
gfxPath.CloseFigure()
Else
gfxPath.AddRectangle(rec)
End If
.FillPath(_PanelBrush, gfxPath)
If Me.BackgroundPanelImage IsNot Nothing Then
DrawBackImage(e.Graphics, gfxPath, CInt(textHeight / 2))
End If
If Me.DrawGroupBorder Then .DrawPath(_BorderPen, gfxPath)
End Using
If textWidth > 0 And textHeight > 0 Then
Dim trec As New Rectangle(CInt(Me.Width / 16), 0, Me.Width - 15 - CInt(Me.Width / 16), textHeight + 2)
Using gfxPath As New GraphicsPath
Dim rad As Integer = 6
gfxPath.AddArc(trec.Right - (rad), trec.Y, rad, rad, 270, 90)
gfxPath.AddArc(trec.Right - (rad), trec.Bottom - (rad), rad, rad, 0, 90)
gfxPath.AddArc(trec.X, trec.Bottom - (rad), rad, rad, 90, 90)
gfxPath.AddArc(trec.X, trec.Y, rad, rad, 180, 90)
gfxPath.CloseFigure()
.FillPath(_TextBackBrush, gfxPath)
.DrawPath(_TextBorderPen, gfxPath)
End Using
Using sf As New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center, .Trimming = StringTrimming.EllipsisCharacter, .FormatFlags = StringFormatFlags.NoWrap}
.DrawString(Me.Text, Me.Font, _TextBrush, trec, sf)
End Using
' <------------------------------------------my stuff
' adds the bottom box
trec = New Rectangle((Me.Width / 16), Me.Height - (textHeight + 3), Me.Width - 15 - (Me.Width / 16), textHeight + 2)
Using gfxPath As New GraphicsPath
Dim rad As Integer = 6
gfxPath.AddArc(trec.Right - (rad), trec.Y, rad, rad, 270, 90)
gfxPath.AddArc(trec.Right - (rad), trec.Bottom - (rad), rad, rad, 0, 90)
gfxPath.AddArc(trec.X, trec.Bottom - (rad), rad, rad, 90, 90)
gfxPath.AddArc(trec.X, trec.Y, rad, rad, 180, 90)
gfxPath.CloseFigure()
.FillPath(_TextBackBrush, gfxPath)
.DrawPath(_TextBorderPen, gfxPath)
End Using
Using sf As New StringFormat With {.Alignment = StringAlignment.Center, .LineAlignment = StringAlignment.Center, .Trimming = StringTrimming.EllipsisCharacter, .FormatFlags = StringFormatFlags.NoWrap}
.DrawString(Me.TextBottom, Me.Font, _TextBrush, trec, sf)
End Using
End If
' trying to add the png
If Me._StatusImage IsNot Nothing Then
Dim pngrec As New Rectangle(50, 50, 22, 22)
Using gfxPath As New GraphicsPath
gfxPath.AddRectangle(pngrec)
DrawSmallPng(e.Graphics, gfxPath, 16)
End Using
End If
End With
End Sub
Private Sub DrawSmallPng(ByVal g As Graphics, ByVal grxpath As GraphicsPath, ByVal topoffset As Integer)
Using bm As New Bitmap(StatusImage.Width, StatusImage.Height)
Using grx As Graphics = Graphics.FromImage(bm)
grx.DrawImage(Me.StatusImage, CInt(Me.Width / 2), CInt(Me.Height / 2), 16, 16)
End Using
End Using
End Sub
' <------------------------------------------my stuff end
Can anyone please advise me on whats going wrong.