Click here to Skip to main content
15,301,841 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hey, I'm trying to create my own Style Manager to manage all my controls and thei're color shemes. I've created a Class Named AccentColor to save all properties in a generic List(Of XY)... My Problem is that I don't get the values I've added in the designer...

That's my code:

VB.NET
Imports System.ComponentModel
Imports System.Drawing
Imports System.Windows.Forms

Partial Class Style_Manager
    Protected Property _AccentColors As New List(Of AccentColor)
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Content)>
    Public Property AccentColors As List(Of AccentColor)
        Get
            If _AccentColors Is Nothing Then
                _AccentColors = New List(Of AccentColor)
            End If

            Return _AccentColors
        End Get

        Set

        End Set
    End Property

    Protected Function ShouldSerializeAccentColors() As Boolean
        Return AccentColors.Count > 0
    End Function

    Public Function ExclusionExist() As Boolean
        Return _AccentColors.Count > 0
    End Function
End Class


<TypeConverter(GetType(AccentColor))>
Public Class AccentColor

    Protected _Control As Control
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Category("General")>
    Public Property Control As Control
        Get
            Return _Control
        End Get

        Set(value As Control)
            _Control = value
        End Set
    End Property

    Protected _ApplyOnChilds As Boolean
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Category("General")>
    Public Property ApplyOnChilds As Boolean
        Get
            Return _ApplyOnChilds
        End Get

        Set(value As Boolean)
            _ApplyOnChilds = value
        End Set
    End Property


    Protected _Name As String
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Category("General")>
    Public Property Name As String
        Get
            If Control IsNot Nothing AndAlso _Name = Nothing Then
                _Name = Control.Name & ": Style"
            End If
            Return _Name
        End Get

        Set(value As String)
            If Control IsNot Nothing AndAlso value = Nothing Then
                _Name = Control.Name & ": Style"
            Else
                _Name = value
            End If
        End Set
    End Property


    Protected _AccentColor As Color
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Category("Style")>
    Public Property AccentColor As Color
        Get
            Return _AccentColor
        End Get

        Set(value As Color)
            _AccentColor = value
        End Set
    End Property

    Protected _SecondColor As Color
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Category("Style")>
    Public Property SecondColor As Color
        Get
            Return _SecondColor
        End Get

        Set(value As Color)
            _SecondColor = value
        End Set
    End Property

    Protected _HoverColor As Color
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Category("Style")>
    Public Property HoverColor As Color
        Get
            Return _HoverColor
        End Get

        Set(value As Color)
            _HoverColor = value
        End Set
    End Property

    Protected _ForeColor As Color
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Category("Style")>
    Public Property ForeColor As Color
        Get
            Return _ForeColor
        End Get

        Set(value As Color)
            _ForeColor = value
        End Set
    End Property

    Protected _BackColor As Color
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Category("Style")>
    Public Property BackColor As Color
        Get
            Return _BackColor
        End Get

        Set(value As Color)
            _BackColor = value
        End Set
    End Property



    Protected _UseAccentColor As Boolean = True
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Category("Settings"), DefaultValue(True)>
    Public Property UseAccentColor As Boolean
        Get
            Return _UseAccentColor
        End Get

        Set(value As Boolean)
            _UseAccentColor = value
        End Set
    End Property

    Protected _UseSecondColor As Boolean
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Category("Settings"), DefaultValue(False)>
    Public Property UseSecondColor As Boolean
        Get
            Return _UseSecondColor
        End Get

        Set(value As Boolean)
            _UseSecondColor = value
        End Set
    End Property

    Protected _UseHoverColor As Boolean
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Category("Settings"), DefaultValue(False)>
    Public Property UseHoverColor As Boolean
        Get
            Return _UseHoverColor
        End Get

        Set(value As Boolean)
            _UseHoverColor = value
        End Set
    End Property

    Protected _UseForeColor As Boolean = True
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Category("Settings"), DefaultValue(True)>
    Public Property UseForeColor As Boolean
        Get
            Return _UseForeColor
        End Get

        Set(value As Boolean)
            _UseForeColor = value
        End Set
    End Property

    Protected _UseBackColor As Boolean = True
    <DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Category("Settings"), DefaultValue(True)>
    Public Property UseBackColor As Boolean
        Get
            Return _UseBackColor
        End Get

        Set(value As Boolean)
            _UseBackColor = value
        End Set
    End Property


    Public Sub New()
        Name = ""
        Control = Nothing
        AccentColor = Color.Empty
    End Sub

    Public Overrides Function ToString() As String
        Return Name
    End Function
End Class


What I have tried:

I've searched the web and changed the Protected properties to private properties, but nothing helped
Posted
Comments
Ralf Meier 18-Jul-21 16:01pm
   
How do you get access to the Controls of your Form ?
And how do you think that your class could get it ?
How do you instance this class ?
Richard Deeming 19-Jul-21 4:41am
   
All of your AccentColor properties are DesignerSerializationVisibility.Hidden; even if the designer generated a list of instances of this class, they will all be empty.
Electro_Attacks 19-Jul-21 5:10am
   
Ohh my god, thx a lot, never felt so stupid xD

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month