wx.DataObjectGeneric Class Reference

Inheritance diagram for wx.DataObjectGeneric:

wx.DataObjectCustom wx.DataObjectSimple wx.DataObject wx.Object

List of all members.

Public Member Functions

 DataObjectGeneric (object data)

Properties

override byte[] ByteData [get, set]
object Data [get]


Detailed Description

A generic wrapper of .NET data (that can be serialized by the Xml serialize - default constructor is required and all properties to be serialized need to have getters and setters). This will use the full class name of the object as format identifier.

Simply create an instance of this wrapping a serializable object and pass it to a drop source or hte clipboard.

        public class SerializableObject
        {
           ...
           // serializable objects must have a public standard ctor
           public SerializableObject()
           {
              ...
           }
           
           // the standard Xml serializer will be used. this serializer
           // exclusively reads public properties on properties and sets them
           // on deserialization. thus, all properties must have public getter 
           // and setter.
           int ASampleProperty
           {
               get { ... }
               set { ... }
           }
        }
        ....
        class ...
        {
           ...
           void CopyToClipboard(SerializableObject obj)
           {
                wx.Clipboard.TheClipboard.Open();
                try
                {
                    wx.Clipboard.TheClipboard.Open();
                    wx.Clipboard.TheClipboard.SetData(new DataObjectGeneric(obj));
                }
                finally
                {
                    wx.Clipboard.TheClipboard.Close();
                }
           }
           
           SerializableObject CopyFromClipboard()
           {
                wx.Clipboard.TheClipboard.Open();
                try
                {
                    wx.Clipboard.TheClipboard.Open();
                    DataObjectGeneric result=new DataObjectGeneric(new SerializableObject());
                    
                    if (wx.Clipboard.TheClipboard.GetData(result))
                        return result.Data as SerializableObject;
                    else
                        return null;
                }
                finally
                {
                    wx.Clipboard.TheClipboard.Close();
                }
           }
        }

Constructor & Destructor Documentation

wx.DataObjectGeneric.DataObjectGeneric ( object  data  ) 

Creates a new instance wrapping the provided data. The data MUST be non-null and serializable.

Parameters:
data 


Property Documentation

override byte [] wx.DataObjectGeneric.ByteData [get, set]

Get or set the serialization of the contained data.

Reimplemented from wx.DataObjectCustom.

object wx.DataObjectGeneric.Data [get]


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