Click here to Skip to main content
15,883,458 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Can ChatGPT be used to document VBA Code Pin
YSLGuru5-Apr-23 8:31
YSLGuru5-Apr-23 8:31 
AnswerRe: Can ChatGPT be used to document VBA Code Pin
YSLGuru5-Apr-23 6:37
YSLGuru5-Apr-23 6:37 
Questionvb.net - how do I add a row in a datagridview to an existing object? Pin
Member 130653743-Apr-23 21:54
Member 130653743-Apr-23 21:54 
AnswerRe: vb.net - how do I add a row in a datagridview to an existing object? Pin
Richard MacCutchan3-Apr-23 22:36
mveRichard MacCutchan3-Apr-23 22:36 
QuestionProperties on Custom Control Pin
robert1131-Mar-23 20:29
robert1131-Mar-23 20:29 
AnswerRe: Properties on Custom Control Pin
Ralf Meier1-Apr-23 0:05
mveRalf Meier1-Apr-23 0:05 
AnswerRe: Properties on Custom Control Pin
Ralf Meier1-Apr-23 0:13
mveRalf Meier1-Apr-23 0:13 
GeneralRe: Properties on Custom Control Pin
robert111-Apr-23 9:33
robert111-Apr-23 9:33 
AnswerRe: Properties on Custom Control Pin
Ralf Meier1-Apr-23 10:16
mveRalf Meier1-Apr-23 10:16 
GeneralRe: Properties on Custom Control Pin
robert111-Apr-23 12:05
robert111-Apr-23 12:05 
Appreciate your help

here is complete class i am using.
again, my 1st attempt, picking up knowledge from this group!
VB.NET
Imports System.ComponentModel
Imports System.Drawing.Drawing2D

Public Class NewPictureBox
    Inherits PictureBox

    Public Sub New()

        Size = New Size(100, 100)
        SizeMode = PictureBoxSizeMode.Zoom

        Me.m_properties = New TextLocation(Me)
        Me.m_captiontext = New TextLocation(Me)
        Me.m_captionx = New TextLocation(Me)
        Me.m_captiony = New TextLocation(Me)

        'Borders Fields
        Me.m_borderSizeField = New TextLocation(Me)
        Me.m_borderColorField = New TextLocation(Me)
        Me.m_borderColor2Field = New TextLocation(Me)
        Me.m_borderLineStyleField = New TextLocation(Me)
        Me.m_borderCapStyleField = New TextLocation(Me)
        Me.m_gradientAngleField = New TextLocation(Me)
    End Sub

    <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
    Public ReadOnly Property Properties() As TextLocation
        Get
            Return Me.m_properties
        End Get
    End Property

    Friend Sub NotifyStateChanged(source As TextLocation, propertyName As String)
        Me.Invalidate()
        Debug.WriteLine("UIListBox: State changed.")
    End Sub

    'Overridden methods
    Protected Overrides Sub OnResize(ByVal e As EventArgs)
        MyBase.OnResize(e)
        Size = New Size(Width, Width)
    End Sub

    Protected Overrides Sub OnPaint(ByVal pe As PaintEventArgs)
        MyBase.OnPaint(pe)
        'Fields
        Dim graph = pe.Graphics
        Dim rectContourSmooth = Rectangle.Inflate(ClientRectangle, -1, -1)
        Dim rectBorder = Rectangle.Inflate(rectContourSmooth, -m_borderSizeField, -m_borderSizeField)
        Dim smoothSize = If(m_borderSizeField > 0, m_borderSizeField * 3, 1)
        Dim newText = m_captiontext

        Using borderGColor = New LinearGradientBrush(rectBorder, m_borderColorField, m_borderColor2Field, m_gradientAngleField)

            Using pathRegion = New GraphicsPath()

                Using penSmooth = New Pen(Parent.BackColor, smoothSize)

                    Using penBorder = New Pen(borderGColor, m_borderSizeField)
                        graph.SmoothingMode = SmoothingMode.AntiAlias
                        penBorder.DashStyle = m_borderLineStyleField
                        penBorder.DashCap = m_borderCapStyleField
                        pathRegion.AddEllipse(rectContourSmooth)
                        'Set rounded region 
                        Region = New Region(pathRegion)

                        graph.DrawString(m_captiontext, New Font("Segoe UI", 12, FontStyle.Regular), New SolidBrush(Color.Black), m_captionx.X, m_captionx.Y, StringFormat.GenericDefault)
                        'Drawing
                        graph.DrawEllipse(penSmooth, rectContourSmooth) 'Draw contour smoothing
                        If m_borderSizeField > 0 Then graph.DrawEllipse(penBorder, rectBorder) 'Draw border
                    End Using
                End Using
            End Using
        End Using

    End Sub

    Private m_properties As TextLocation
    Private m_captiontext As TextLocation
    Private m_captionx As TextLocation
    Private m_captiony As TextLocation

    'Borders Fields
    Private m_borderSizeField As TextLocation
    Private m_borderColorField As TextLocation
    Private m_borderColor2Field As TextLocation
    Private m_borderLineStyleField As TextLocation
    Private m_borderCapStyleField As TextLocation
    Private m_gradientAngleField As TextLocation
End Class

<ToolboxItem(False)>
Public Class TextLocation
    Inherits Component

    Private m_captiontext As String = "label"
    Private m_captionx As New Point(50.0F, 10.0F)
    'Fields
    Private m_borderSizeField As Integer = 2
    Private m_borderColorField As Color = Color.Blue
    Private m_borderColor2Field As Color = Color.RoyalBlue
    Private m_borderLineStyleField As DashStyle = DashStyle.Solid
    Private m_borderCapStyleField As DashCap = DashCap.Flat
    Private m_gradientAngleField As Single = 50.0F

    Public Sub New(picturebox As NewPictureBox)

        'Borders
        'Fields
        Me.m_borderSizeField = m_borderSizeField
        Me.m_borderColorField = m_borderColorField
        Me.m_borderColor2Field = m_borderColor2Field
        Me.m_borderLineStyleField = m_borderLineStyleField
        Me.m_borderCapStyleField = m_borderCapStyleField

    End Sub

    <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
    Public Property Caption As String
        Get
            Return m_captiontext
        End Get
        Set(ByVal Value As String)
            m_captiontext = Value
        End Set
    End Property

    <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
    Property CaptionLocation As Point
        Get
            Return m_captionx

        End Get
        Set(ByVal Value As Point)
            m_captionx = Value
        End Set
    End Property

    <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
    Public Property BorderSize As Integer
        Get
            Return m_borderSizeField
        End Get
        Set(ByVal value As Integer)
            m_borderSizeField = value
            'still need to make this work
            'Invalidate()
        End Set
    End Property

    <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
    Public Property BorderColor As Color
        Get
            Return m_borderColorField
        End Get
        Set(ByVal value As Color)
            m_borderColorField = value
            'Invalidate()
        End Set
    End Property

    <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
    Public Property BorderColor2 As Color
        Get
            Return m_borderColor2Field
        End Get
        Set(ByVal value As Color)
            m_borderColor2Field = value
            'Invalidate()
        End Set
    End Property

    <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
    Public Property BorderLineStyle As DashStyle
        Get
            Return m_borderLineStyleField
        End Get
        Set(ByVal value As DashStyle)
            m_borderLineStyleField = value
            'Invalidate()
        End Set
    End Property

    <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
    Public Property BorderCapStyle As DashCap
        Get
            Return m_borderCapStyleField
        End Get
        Set(ByVal value As DashCap)
            m_borderCapStyleField = value
            'Invalidate()
        End Set
    End Property

    <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
    Public Property GradientAngle As Single
        Get
            Return m_gradientAngleField
        End Get
        Set(ByVal value As Single)
            m_gradientAngleField = value
            'Invalidate()
        End Set

    End Property

End Class
Thanks again!
GeneralRe: Properties on Custom Control Pin
Ralf Meier1-Apr-23 22:46
mveRalf Meier1-Apr-23 22:46 
AnswerRe: Properties on Custom Control Pin
Ralf Meier1-Apr-23 23:29
mveRalf Meier1-Apr-23 23:29 
GeneralRe: Properties on Custom Control Pin
robert112-Apr-23 2:15
robert112-Apr-23 2:15 
GeneralRe: Properties on Custom Control Pin
Ralf Meier2-Apr-23 2:20
mveRalf Meier2-Apr-23 2:20 
GeneralRe: Properties on Custom Control Pin
Ralf Meier2-Apr-23 2:23
mveRalf Meier2-Apr-23 2:23 
GeneralRe: Properties on Custom Control Pin
robert112-Apr-23 2:32
robert112-Apr-23 2:32 
GeneralRe: Properties on Custom Control Pin
Ralf Meier2-Apr-23 3:12
mveRalf Meier2-Apr-23 3:12 
GeneralRe: Properties on Custom Control Pin
robert112-Apr-23 4:33
robert112-Apr-23 4:33 
GeneralRe: Properties on Custom Control Pin
Ralf Meier2-Apr-23 5:19
mveRalf Meier2-Apr-23 5:19 
GeneralMessage Closed Pin
2-Apr-23 5:36
robert112-Apr-23 5:36 
SuggestionRe: Properties on Custom Control Pin
Ralf Meier2-Apr-23 5:42
mveRalf Meier2-Apr-23 5:42 
GeneralRe: Properties on Custom Control Pin
Eddy Vluggen1-Apr-23 12:20
professionalEddy Vluggen1-Apr-23 12:20 
GeneralRe: Properties on Custom Control Pin
robert111-Apr-23 12:34
robert111-Apr-23 12:34 
GeneralRe: Properties on Custom Control Pin
Eddy Vluggen1-Apr-23 13:13
professionalEddy Vluggen1-Apr-23 13:13 
GeneralRe: Properties on Custom Control Pin
robert111-Apr-23 13:47
robert111-Apr-23 13:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.