wx.DataObjectCustom Class Reference

Inheritance diagram for wx.DataObjectCustom:

wx.DataObjectSimple wx.DataObject wx.Object wx.DataObjectGeneric wx.NetMacros.GeneratorDataObject wx.VisualComponent.SizerWindowDataObject

List of all members.

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]


Detailed Description

This is the simplest possible implementation of the wx.DataObject class. The data object of (a class derived from) this class only supports one format, so the number of virtual functions to be implemented is reduced.

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);
                            }
                        }
                    }
                }
            }

Constructor & Destructor Documentation

wx.DataObjectCustom.DataObjectCustom ( IntPtr  wxObject  ) 

wx.DataObjectCustom.DataObjectCustom ( DataFormat  format  )  [protected]

Use this CTor when creating instances of sub-classes.

Parameters:
format The format of the data contained by this object.


Member Function Documentation

override void wx.DataObjectCustom.CallDTor (  )  [protected, virtual]

This will be called by Dispose() to delete the C++ object. Overload this if you have to use another DTor.

Reimplemented from wx.Object.


Property Documentation

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.


Manual of the wx.NET   (c) 2003-2011 the wx.NET project at   Get wx.NET at SourceForge.net. Fast, secure and Free Open Source software downloads