Game Development Reference
In-Depth Information
public int TestInteger
{
get { return testInteger; }
set { testInteger = value; }
}
public override string ToString()
{
return string.Format(“TestString:{0}, TestInteger{1}”,
testString,
testInteger);
}
}
Custom data requires a unique format descriptor, which is created with the fol-
lowing line of code.
dataFormat = DataFormats.GetFormat(typeof(CustomData).FullName);
The simple data object has a static constructor that sets the static dataFormat prop-
erty so that the format can easily be plugged into the storage operation of the
Clipboard.
The following code shows how to copy the CustomData object to the Clipboard.
CustomData data = new CustomData();
data.TestString = “This is a test”;
data.TestInteger = 12345;
IDataObject dataObject = new DataObject();
dataObject.SetData(format, true, data);
Clipboard.SetDataObject(dataObject, true);
Similarly, the following code shows how to retrieve the CustomData object from the
Clipboard.
IDataObject dataObject = Clipboard.GetDataObject();
CustomData data = null;
if (dataObject.GetDataPresent(CustomData.DataFormat.Name))
{
data = (CustomData)dataObject.GetData(CustomData.DataFormat.Name);
}
Search Nedrilad ::




Custom Search