Click here to Skip to main content
15,886,075 members
Home / Discussions / Visual Basic
   

Visual Basic

 
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 
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 
OK ... changes made ...
I have deleted all unnecessary content and added all needed content to make it work - you should carefully take a look on it ...!!!
Also the Designer now will store all the changes at the properties inside the class. Perhaps, for later use, you should find a better name for it ... Wink | ;)

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
    End Sub

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

    Private Sub Properties_Changed() Handles m_properties.Changed
        Me.Invalidate()
    End Sub

    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_properties.BorderSize, -m_properties.BorderSize)
        Dim smoothSize = If(m_properties.BorderSize > 0, m_properties.BorderSize * 3, 1)
        Dim newText = m_properties.Caption

        Using borderGColor = New LinearGradientBrush(rectBorder, m_properties.BorderColor, m_properties.BorderColor2, m_properties.GradientAngle)

            Using pathRegion = New GraphicsPath()

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

                    Using penBorder = New Pen(borderGColor, m_properties.BorderSize)
                        graph.SmoothingMode = SmoothingMode.AntiAlias
                        penBorder.DashStyle = m_properties.BorderLineStyle
                        penBorder.DashCap = m_properties.BorderCapStyle
                        pathRegion.AddEllipse(rectContourSmooth)
                        'Set rounded region 
                        Region = New Region(pathRegion)

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

    End Sub

End Class


<TypeConverter(GetType(ExpandableObjectConverter))>
Public Class TextLocation
 
     Public Property Caption As String
        Get
            Return m_captiontext
        End Get
        Set(ByVal Value As String)
            m_captiontext = Value
            OnValueChanged()
        End Set
    End Property
    Private m_captiontext As String = "label"

    Overrides Function toString() As String
        Return "<" & m_captiontext & ">"
    End Function

     Property CaptionLocation As Point
        Get
            Return m_captionx

        End Get
        Set(ByVal Value As Point)
            m_captionx = Value
            OnValueChanged()
        End Set
    End Property
    Private m_captionx As New Point(50.0F, 10.0F)

    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
            OnValueChanged()
        End Set
    End Property
    Private m_borderSizeField As Integer = 2

    Public Property BorderColor As Color
        Get
            Return m_borderColorField
        End Get
        Set(ByVal value As Color)
            m_borderColorField = value
            OnValueChanged()
        End Set
    End Property
    Private m_borderColorField As Color = Color.Blue

     Public Property BorderColor2 As Color
        Get
            Return m_borderColor2Field
        End Get
        Set(ByVal value As Color)
            m_borderColor2Field = value
            OnValueChanged()
        End Set
    End Property
    Private m_borderColor2Field As Color = Color.RoyalBlue

    Public Property BorderLineStyle As DashStyle
        Get
            Return m_borderLineStyleField
        End Get
        Set(ByVal value As DashStyle)
            m_borderLineStyleField = value
            OnValueChanged()
        End Set
    End Property
    Private m_borderLineStyleField As DashStyle = DashStyle.Solid

    Public Property BorderCapStyle As DashCap
        Get
            Return m_borderCapStyleField
        End Get
        Set(ByVal value As DashCap)
            m_borderCapStyleField = value
            OnValueChanged()
        End Set
    End Property
    Private m_borderCapStyleField As DashCap = DashCap.Flat

    Public Property GradientAngle As Single
        Get
            Return m_gradientAngleField
        End Get
        Set(ByVal value As Single)
            m_gradientAngleField = value
            OnValueChanged()
        End Set
    End Property
    Private m_gradientAngleField As Single = 50.0F

    Private Sub OnValueChanged()
        RaiseEvent Changed()
    End Sub

    Public Event Changed()

    Overrides Function toString() As String
        Return "<" & "..." & ">"
    End Function

End Class

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 
GeneralRe: Properties on Custom Control Pin
robert111-Apr-23 14:19
robert111-Apr-23 14:19 
PraiseRe: Properties on Custom Control Pin
Eddy Vluggen1-Apr-23 15:04
professionalEddy Vluggen1-Apr-23 15:04 
GeneralRe: Properties on Custom Control Pin
Ralf Meier1-Apr-23 22:56
mveRalf Meier1-Apr-23 22:56 
GeneralRe: Properties on Custom Control Pin
Eddy Vluggen1-Apr-23 23:57
professionalEddy Vluggen1-Apr-23 23:57 

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.