当前位置: 首页>>代码示例>>C#>>正文


C# DataObject.GetDataPresent方法代码示例

本文整理汇总了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)");
		}
开发者ID:dfr0,项目名称:moon,代码行数:23,代码来源:DataObjectTest.cs

示例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);
     }
 }
开发者ID:ychost,项目名称:uest-pcs,代码行数:15,代码来源:MainWindow.xaml.cs

示例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);
 }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:14,代码来源:SequenceDesignerViewModelTests.cs

示例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);
 }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:14,代码来源:SequenceDesignerViewModelTests.cs

示例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;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:17,代码来源:CutCopyPasteHelper.cs


注:本文中的System.Windows.DataObject.GetDataPresent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。