本文整理汇总了C#中System.Windows.DataObject.GetDataPresent方法的典型用法代码示例。如果您正苦于以下问题:C# DataObject.GetDataPresent方法的具体用法?C# DataObject.GetDataPresent怎么用?C# DataObject.GetDataPresent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.DataObject
的用法示例。
在下文中一共展示了DataObject.GetDataPresent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Defaults
public void Defaults ()
{
DataObject dobj = new DataObject ();
Assert.Throws<SecurityException> (() => dobj.GetFormats (), "GetFormats ()");
Assert.Throws<SecurityException> (() => dobj.GetFormats (true), "GetFormats (true)");
Assert.Throws<SecurityException> (() => dobj.GetFormats (false), "GetFormats (false)");
Assert.Throws<SecurityException> (() => dobj.GetData (DataFormats.FileDrop), "GetData (string)");
Assert.Throws<SecurityException> (() => dobj.GetData (DataFormats.FileDrop, true), "GetData (string,true)");
Assert.Throws<SecurityException> (() => dobj.GetData (DataFormats.FileDrop, false), "GetData (string,false)");
Assert.Throws<SecurityException> (() => dobj.GetData (typeof(string)), "GetData (Type)");
Assert.Throws<SecurityException> (() => dobj.GetDataPresent (DataFormats.FileDrop), "GetDataPresent (string)");
Assert.Throws<SecurityException> (() => dobj.GetDataPresent (DataFormats.FileDrop, true), "GetDataPresent (string,true)");
Assert.Throws<SecurityException> (() => dobj.GetDataPresent (DataFormats.FileDrop, false), "GetDataPresent (string,false)");
Assert.Throws<SecurityException> (() => dobj.GetDataPresent (typeof (string)), "GetDataPresent (Type)");
Assert.Throws<SecurityException> (() => dobj.SetData (DataFormats.FileDrop), "SetData (string)");
Assert.Throws<SecurityException> (() => dobj.SetData (DataFormats.FileDrop, true), "SetData (string,true)");
Assert.Throws<SecurityException> (() => dobj.SetData (DataFormats.FileDrop, false), "SetData (string,false)");
Assert.Throws<SecurityException> (() => dobj.SetData (typeof (string)), "SetData (Type)");
}
示例2: cvs1Drop
private void cvs1Drop(object sender, DragEventArgs e) {
IDataObject data = new DataObject();
data = e.Data;
if (data.GetDataPresent(typeof(Rectangle))) {
Rectangle rect = new Rectangle();
rect = data.GetData(typeof(Rectangle)) as Rectangle;
//canvas2.Children.Remove(rect);
//canvas2.Children.Add(rect);
string rectXaml = XamlWriter.Save(rect);
StringReader stringReader = new StringReader(rectXaml);
XmlReader xmlReader = XmlReader.Create(stringReader);
UIElement clonedChild = (UIElement)XamlReader.Load(xmlReader);
canvas1.Children.Add(clonedChild);
}
}
示例3: DsfSequenceActivity
public void SequenceDesignerViewModel_SetModelItemForServiceTypes_DataHaveDataContextNotResourceModel_NothingAddedToDataObject()
{
//------------Setup for test--------------------------
var dsfSequenceActivity = new DsfSequenceActivity();
var dsfMultiAssignActivity = new DsfMultiAssignActivity();
dsfSequenceActivity.Activities.Add(dsfMultiAssignActivity);
var sequenceDesignerViewModel = new SequenceDesignerViewModel(CreateModelItem(dsfSequenceActivity));
var dataObject = new DataObject(GlobalConstants.ExplorerItemModelFormat, new TestDataWithContext());
//------------Execute Test---------------------------
sequenceDesignerViewModel.SetModelItemForServiceTypes(dataObject);
//------------Assert Results-------------------------
bool dataPresent = dataObject.GetDataPresent(DragDropHelper.ModelItemDataFormat);
Assert.IsFalse(dataPresent);
}
示例4: SequenceDesignerViewModel_SetModelItemForServiceTypes_Data_NothingAddedToDataObject
public void SequenceDesignerViewModel_SetModelItemForServiceTypes_Data_NothingAddedToDataObject()
{
//------------Setup for test--------------------------
var dsfSequenceActivity = new DsfSequenceActivity();
var dsfMultiAssignActivity = new DsfMultiAssignActivity();
dsfSequenceActivity.Activities.Add(dsfMultiAssignActivity);
var sequenceDesignerViewModel = new SequenceDesignerViewModel(CreateModelItem(dsfSequenceActivity));
var dataObject = new DataObject("Some Wrong Format", new object());
//------------Execute Test---------------------------
sequenceDesignerViewModel.SetModelItemForServiceTypes(dataObject);
//------------Assert Results-------------------------
bool dataPresent = dataObject.GetDataPresent(DragDropHelper.ModelItemDataFormat);
Assert.IsFalse(dataPresent);
}
示例5: GetTargetFrameworkFromClipboard
private static FrameworkName GetTargetFrameworkFromClipboard(DataObject dataObject)
{
Fx.Assert(dataObject != null, "dataObject should not be null");
FrameworkName clipboardFrameworkName = null;
if (dataObject.GetDataPresent(WorkflowClipboardFormat_TargetFramework))
{
clipboardFrameworkName = TryGetData(dataObject, WorkflowClipboardFormat_TargetFramework) as FrameworkName;
}
if (clipboardFrameworkName == null)
{
clipboardFrameworkName = FrameworkNameConstants.NetFramework40;
}
return clipboardFrameworkName;
}