Question

I'm working with Windows Forms designer. It serializes properties of type Color as known name whenever possible. I need it to serialize such properties always as RGB, because I need it later for interop with other system, which can deserialize only from RGB values. Is there a way to serialize Color properties always as RGB values?

Was it helpful?

Solution

Here's how I solved a similar problem. Hope it helps.

  <System.Xml.Serialization.XmlIgnore()> _
  Public Property LineColor() As Color
     Get
        Return mLineColor
     End Get
     Set(ByVal value As Color)
        mLineColor = value
     End Set
  End Property

  Public Property LineColorArgbString() As String
     Get
        Return ColorAsString(mLineColor)
     End Get
     Set(ByVal value As String)
        mLineColor = ParseColorArgbString(value)
     End Set
  End Property
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top