Public Member Functions | |
DataObjectCustom (IntPtr wxObject) | |
Protected Member Functions | |
override void | CallDTor () |
DataObjectCustom (DataFormat format) | |
Properties | |
abstract byte[] | ByteData [get, set] |
Overload this to define the data that is contained. | |
DataFormat | Format [get, set] |
Notice that this is still an abstract base class and cannot be used but should be derived from.
Refer to DataObjectGeneric for a builtin support of custom data obejct formats.
Consider as an sample implementation the class wx.NetMacros.GeneratorDataObject, that you may use to drag&drop or copy&paste object as wx.NetMacros. This implementation benefits from the fact that instances of wx.NetMacros.Generator can be serialized/deserialized by the System.Xml.Serialization.XmlSerializer.
public class GeneratorDataObject : DataObjectCustom { Generator _data; public GeneratorDataObject(Generator data) : base(new DataFormat("wxnet/generator-expr")) { this._data = data; } public Generator Data { get { return this._data; } } public override byte[] ByteData { get { if (this._data == null) return new byte[0]; using (System.IO.MemoryStream sw = new System.IO.MemoryStream()) { using (System.Xml.XmlTextWriter writer = new System.Xml.XmlTextWriter(sw, System.Text.Encoding.UTF8)) { writer.Formatting = System.Xml.Formatting.None; System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(Generator)); serializer.Serialize(writer, this._data); } return sw.GetBuffer(); } } set { if (value.Length == 0) this._data = null; else { using (System.IO.MemoryStream sr = new System.IO.MemoryStream(value)) using (System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader("", sr)) { System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(typeof(Generator)); this._data = (Generator)serializer.Deserialize(reader); } } } } }
wx.DataObjectCustom.DataObjectCustom | ( | IntPtr | wxObject | ) |
wx.DataObjectCustom.DataObjectCustom | ( | DataFormat | format | ) | [protected] |
Use this CTor when creating instances of sub-classes.
format | The format of the data contained by this object. |
override void wx.DataObjectCustom.CallDTor | ( | ) | [protected, virtual] |
abstract byte [] wx.DataObjectCustom.ByteData [get, set] |
Overload this to define the data that is contained.
Reimplemented in wx.DataObjectGeneric, wx.NetMacros.GeneratorDataObject, and wx.VisualComponent.SizerWindowDataObject.
DataFormat wx.DataObjectCustom.Format [get, set] |
Get or set the data format of the contained data.