using System.ComponentModel;
using System.Runtime.Serialization;
using System.Xml;
using System.Xml.Serialization;
namespace System.Drawing
{
[Serializable]
public class SColor : ISerializable
{
#region Eigenschaften
[XmlIgnore]
public Color Color { get; set; }
[Browsable(false)]
[XmlElement]
public int XmlColor {
get { return Color != Color.Empty ? Color.ToArgb() : 0; }
set { Color = Color.FromArgb(value); }
}
#endregion Eigenschaften
#region Konstruktoren
public SColor()
{
Color = Color.Empty;
}
public SColor(Color color)
{
Color = color;
}
public SColor(SerializationInfo info, StreamingContext context)
{
Color = Color.FromArgb((int)info.GetValue(nameof(XmlColor), typeof(int)));
}
#endregion Konstruktoren
#region ISerializable
public void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue(nameof(XmlColor), Color.ToArgb());
}
#endregion ISerializable
#region Implizite Konvertierung
public static implicit operator Color(SColor color)
{
return color != null ? color.Color : Color.Empty;
}
public static implicit operator SColor(Color color)
{
return new SColor(color);
}
#endregion Implizite Konvertierung
}
}
Comments