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


C# IDataObject.GetDataPresent方法代码示例

本文整理汇总了C#中IDataObject.GetDataPresent方法的典型用法代码示例。如果您正苦于以下问题:C# IDataObject.GetDataPresent方法的具体用法?C# IDataObject.GetDataPresent怎么用?C# IDataObject.GetDataPresent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDataObject的用法示例。


在下文中一共展示了IDataObject.GetDataPresent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AppendData

        public void AppendData(ref IDataObject data, MouseEventArgs e)
        {
            if (!(this.list.InputHitTest(e.GetPosition(e.OriginalSource as UIElement)) is ListBox)
                && !(this.list.InputHitTest(e.GetPosition(e.OriginalSource as UIElement)) is ScrollViewer)
                && !(e.OriginalSource is Thumb))
            {
                object o = this.list.SelectedItem;

                // This is cheating .. just for an example's sake..
                Debug.Assert(!data.GetDataPresent(DataFormats.Text));

                if (o.GetType() == typeof(XmlElement))
                {
                    data.SetData(DataFormats.Text, ((XmlElement)o).OuterXml);
                }
                else
                {
                    data.SetData(DataFormats.Text, o.ToString());
                }

                Debug.Assert(!data.GetDataPresent(o.GetType().ToString()));

                data.SetData(o.GetType().ToString(), o);
            }
            else
            {
                data = null;
            }
        }
开发者ID:cipjota,项目名称:Chronos,代码行数:29,代码来源:ListBoxDragDropDataProvider.cs

示例2: CanConvertFrom

        public static bool CanConvertFrom(IDataObject data)
        {
            if (data == null)
                return false;

            if (data.GetDataPresent(typeof(WordListEntries)) || data.GetDataPresent(typeof(TranslationPair[])))
                return true;

            var r = FromDelimitedText(GetText(data));
            return r != null && r.Items.Count > 0;
        }
开发者ID:lehoaian,项目名称:szotar,代码行数:11,代码来源:WordListEntries.cs

示例3: IsValidDataObject

        public bool IsValidDataObject(IDataObject obj)
        {
            bool result = false;

            var elt = (FrameworkElement)this.TargetUI;

            var storeItemVM = elt.DataContext as StoreItemViewModelBase;
            //var channelVM = elt.DataContext as ChannelViewModel;

            if (storeItemVM != null)
            {
                if (obj.GetDataPresent(typeof(StoreItemViewModelBase[])))
                {
                    var data = (StoreItemViewModelBase[])obj.GetData(typeof(StoreItemViewModelBase[]));

                    result = data != null && data.Length > 0;
                    //.Any(droppedStoreItemVM => !channelListVM.Contains(droppedChannelVM));
                }
            }
            //else if (channelVM != null)
            //{
            //    if (obj.GetDataPresent(typeof(ChannelViewModel[])))
            //    {
            //        var data = (ChannelViewModel[])obj.GetData(typeof(ChannelViewModel[]));

            //        result = data
            //            .Any(droppedChannelVM => channelVM != droppedChannelVM);
            //    }
            //}

            return result;
        }
开发者ID:ChristinaKarandasheva,项目名称:qwerty,代码行数:32,代码来源:StoreItemDropTargetAdvisor.cs

示例4: DataObjectPastingEventArgs

        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        #region Constructors

        /// <summary>
        /// Creates a DataObjectPastingEvent.
        /// This object created by editors executing a Copy/Paste
        /// and Drag/Drop comands.
        /// </summary>
        /// <param name="dataObject">
        /// DataObject extracted from the Clipboard and intended
        /// for using in pasting.
        /// </param>
        /// <param name="isDragDrop">
        /// A flag indicating whether this operation is part of drag/drop.
        /// Pasting event is fired on drop.
        /// </param>
        /// <param name="formatToApply">
        /// String identifying a format an editor has choosen
        /// as a candidate for applying in Paste operation.
        /// An application can change this choice after inspecting
        /// the content of data object.
        /// </param>
        public DataObjectPastingEventArgs(IDataObject dataObject, bool isDragDrop, string formatToApply) //
            : base(System.Windows.DataObject.PastingEvent, isDragDrop)
        {
            if (dataObject == null)
            {
                throw new ArgumentNullException("dataObject");
            }

            if (formatToApply == null)
            {
                throw new ArgumentNullException("formatToApply");
            }

            if (formatToApply == string.Empty)
            {
                throw new ArgumentException(SR.Get(SRID.DataObject_EmptyFormatNotAllowed));
            }

            if (!dataObject.GetDataPresent(formatToApply))
            {
                throw new ArgumentException(SR.Get(SRID.DataObject_DataFormatNotPresentOnDataObject, formatToApply));
            }

            _originalDataObject = dataObject;
            _dataObject = dataObject;
            _formatToApply = formatToApply;
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:54,代码来源:DataObjectPastingEventArgs.cs

示例5: GetNodesFromDataObject

 public static OutlinerNode[] GetNodesFromDataObject(IDataObject dragData)
 {
     if (dragData.GetDataPresent(typeof(OutlinerNode[])))
         return (OutlinerNode[])dragData.GetData(typeof(OutlinerNode[]));
     else
         return null;
 }
开发者ID:Pjanssen,项目名称:Outliner,代码行数:7,代码来源:DragDropHandler.cs

示例6: SupportsDataObject

 protected override bool SupportsDataObject(IServiceProvider serviceProvider, IDataObject dataObject)
 {
     if (!base.SupportsDataObject(serviceProvider, dataObject))
     {
         return dataObject.GetDataPresent(CodeWizard.CodeWizardDataFormat);
     }
     return true;
 }
开发者ID:ikvm,项目名称:webmatrix,代码行数:8,代码来源:CodeDocumentLanguage.cs

示例7: IsValidDataObject

        public bool IsValidDataObject(IDataObject Object, Point dropPoint)
        {
            ProfileExplorerTreeItem dropTarget = GetExplorerTreeItem(_targetTreeView, dropPoint);
            if (dropTarget != null)
            {
                if (Object.GetDataPresent("Helios.Trigger") && dropTarget.ItemType.HasFlag(ProfileExplorerTreeItemType.Action))
                {
                    return true;
                }

                if (Object.GetDataPresent("Helios.Action") && dropTarget.ItemType.HasFlag(ProfileExplorerTreeItemType.Trigger))
                {
                    return true;
                }
            }
            return false;
        }
开发者ID:Heliflyer,项目名称:helios,代码行数:17,代码来源:BindingsDragDropAdvisor.cs

示例8: API_ResultItemDropEvent

 void API_ResultItemDropEvent(Result result, IDataObject dropObject, DragEventArgs e)
 {
     if (dropObject.GetDataPresent(DataFormats.FileDrop))
     {
         HanldeFilesDrop(result, dropObject);
     }
     e.Handled = true;
 }
开发者ID:WELL-E,项目名称:Wox,代码行数:8,代码来源:FolderPlugin.cs

示例9: PasteContentData

 internal static bool PasteContentData(InputBox inputBox, IDataObject iDataObject)
 {
     TextData data = TryGetText(iDataObject);
     if (!data.ContainsData)
     {
         if (iDataObject.GetDataPresent(DataFormats.Bitmap, true))
         {
             inputBox.Paste(iDataObject);
             return true;
         }
         return false;
     }
     inputBox.TempFlowDocument.Blocks.Clear();
     TextRange range = null;
     if (data.Format == BamaDataFormat)
     {
         object obj2 = XamlReader.Parse(data.Data);
         if (obj2 is Block)
         {
             inputBox.TempFlowDocument.Blocks.Add(obj2 as Block);
         }
         else if (obj2 is Inline)
         {
             Span span = new Span(inputBox.TempFlowDocument.ContentStart, inputBox.TempFlowDocument.ContentEnd)
             {
                 Inlines = { obj2 as Span }
             };
         }
         range = new TextRange(inputBox.TempFlowDocument.ContentStart, inputBox.TempFlowDocument.ContentEnd);
         range.ClearAllProperties();
         inputBox.Selection.Text = "";
         Span newspan = new Span(inputBox.Selection.Start, inputBox.Selection.End);
         ReplaceControls.AddBlocksToSpan(inputBox.TempFlowDocument, newspan);
         inputBox.CaretPosition = newspan.ElementEnd.GetInsertionPosition(LogicalDirection.Forward);
     }
     else
     {
         range = new TextRange(inputBox.TempFlowDocument.ContentStart, inputBox.TempFlowDocument.ContentEnd);
         using (MemoryStream stream = new MemoryStream())
         {
             using (StreamWriter writer = new StreamWriter(stream))
             {
                 writer.Write(data.Data);
                 writer.Flush();
                 stream.Position = 0L;
                 range.Load(stream, data.Format);
             }
         }
         range.ClearAllProperties();
         inputBox.Selection.Text = "";
         Span span3 = new Span(inputBox.Selection.Start, inputBox.Selection.End);
         ReplaceControls.AddBlocksToSpan(inputBox.TempFlowDocument, span3);
         inputBox.CaretPosition = span3.ElementEnd.GetInsertionPosition(LogicalDirection.Forward);
     }
     inputBox.TempFlowDocument.Blocks.Clear();
     return true;
 }
开发者ID:QuocHuy7a10,项目名称:Arianrhod,代码行数:57,代码来源:ClipboardMgr.cs

示例10: GetText

        private string GetText(IDataObject dataObject)
        {
            if(dataObject.GetDataPresent(DataFormats.UnicodeText))
            {
                var text = dataObject.GetData(DataFormats.UnicodeText);
                return text?.ToString() ?? "";

            }
            return "";
        }
开发者ID:finalstream,项目名称:ExplorerWindowCleaner,代码行数:10,代码来源:ClipboardHistoryItem.cs

示例11: GetList

		/// <summary>
		/// Gets the list of <see cref="FileDrop"/> from the specified <see cref="IDataObject"/>. Includes objects dragged from Explorer and Outlook.
		/// </summary>
		/// <param name="data">The <see cref="IDataObject"/>.</param>
		/// <returns>The list of <see cref="FileDrop"/> from the specified <see cref="IDataObject"/>.</returns>
		public static List<FileDrop> GetList(IDataObject data)
		{
			List<FileDrop> list = new List<FileDrop>();

			if (data != null)
			{
				if (data.GetDataPresent("FileDrop"))
				{
					string[] fileNames = data.GetData("FileDrop") as string[];

					if (fileNames != null && fileNames.Length > 0)
					{
						foreach (string fileName in fileNames)
						{
							list.Add(new FileDrop(fileName));
						}
					}
				}
				else if (data.GetDataPresent("FileGroupDescriptor"))
				{
					Stream stream = (Stream)data.GetData("FileGroupDescriptor");
					byte[] fileGroupDescriptor = new byte[512];
					stream.Read(fileGroupDescriptor, 0, 512);

					// build the filename from the FileGroupDescriptor block
					StringBuilder fileName = new StringBuilder();
					for (int i = 76; fileGroupDescriptor[i] != 0; i++)
					{
						fileName.Append(Convert.ToChar(fileGroupDescriptor[i]));
					}
					stream.Close();

					MemoryStream ms = (MemoryStream)data.GetData("FileContents", true);
					byte[] fileBytes = new byte[ms.Length];
					ms.Position = 0;
					ms.Read(fileBytes, 0, (int)ms.Length);

					list.Add(new FileDrop(fileName.ToString(), fileBytes));
				}
			}

			return list;
		}
开发者ID:neurocache,项目名称:ilSFV,代码行数:48,代码来源:FileDrop.cs

示例12: GetTextFromDataObject

 protected override string GetTextFromDataObject(IDataObject dataObject, IServiceProvider serviceProvider)
 {
     if (dataObject.GetDataPresent(CodeWizard.CodeWizardDataFormat))
     {
         string codeWizardTypeName = dataObject.GetData(CodeWizard.CodeWizardDataFormat).ToString();
         CodeWizardHost host = new CodeWizardHost(serviceProvider);
         return host.RunCodeWizard(codeWizardTypeName, this.CodeDomProvider);
     }
     return base.GetTextFromDataObject(dataObject, serviceProvider);
 }
开发者ID:ikvm,项目名称:webmatrix,代码行数:10,代码来源:CodeDocumentLanguage.cs

示例13: GetTextFromDataObject

 protected override string GetTextFromDataObject(IDataObject dataObject, IServiceProvider serviceProvider)
 {
     if (dataObject.GetDataPresent(DataFormats.Text))
     {
         return base.GetTextFromDataObject(dataObject, serviceProvider);
     }
     if (!dataObject.GetDataPresent(DataFormats.Html))
     {
         return string.Empty;
     }
     string str = dataObject.GetData(DataFormats.Html).ToString();
     int index = str.IndexOf("<!--StartFragment-->");
     int num2 = str.LastIndexOf("<!--EndFragment-->");
     if ((index != -1) && (num2 != -1))
     {
         index += 20;
         str = str.Substring(index, num2 - index);
     }
     return str;
 }
开发者ID:ikvm,项目名称:webmatrix,代码行数:20,代码来源:HtmlDocumentLanguage.cs

示例14: Create

        /// <summary>
        /// Creates a URLData based upon an IDataObject
        /// </summary>
        /// <param name="iDataObject">The IDataObject from which to create the URLData</param>
        /// <returns>The URLData, null if no URLData could be created</returns>
        public static URLData Create(IDataObject iDataObject)
        {
            // WinLive Bug 198371: Look at rolling the fix for WinLive 182698 into the OleDataObjectHelper.GetDataPresentSafe method
            // For now, we keep the changes targeted.
            bool canGetDataPresentDirectlyFromIDataObject = false;

            try
            {
                canGetDataPresentDirectlyFromIDataObject = iDataObject.GetDataPresent(DataFormatsEx.URLFormat) &&
                                                           iDataObject.GetDataPresent(DataFormatsEx.FileGroupDescriptorWFormat);
            }
            catch (Exception e)
            {
                Debug.Fail(e.ToString());
            }

            // Validate required format
            // WinLive Bug 182698: Assert when pasting a hyperlink from IE
            if (canGetDataPresentDirectlyFromIDataObject &&
                OleDataObjectHelper.GetDataPresentSafe(iDataObject, DataFormatsEx.URLFormat) &&
                OleDataObjectHelper.GetDataPresentSafe(iDataObject, DataFormatsEx.FileGroupDescriptorWFormat))
                return new URLData(iDataObject);
            else
            {
                //check to see if the dataObject contains a single .url file,
                //if so, create the URLData from that.
                FileData fileData = FileData.Create(iDataObject);
                if (fileData != null && fileData.Files.Length == 1)
                {
                    string filePath = fileData.Files[0].ContentsPath;
                    if (PathHelper.IsPathUrlFile(filePath))
                    {
                        URLData urlData = new URLData(iDataObject, UrlHelper.GetUrlFromShortCutFile(filePath), Path.GetFileNameWithoutExtension(filePath));
                        urlData.DateCreated = File.GetCreationTime(filePath);
                        urlData.DateModified = File.GetLastWriteTime(filePath);
                        return urlData;
                    }
                }
            }
            return null;
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:46,代码来源:URLData.cs

示例15: GetFromWindowsClipboard

 /// <summary>
 /// 
 /// </summary>
 /// <returns>null if data isn't in this format</returns>
 public static SerializableUniverse GetFromWindowsClipboard(IDataObject dataBlob)
 {
     SerializableUniverse retVal = null;
     if (dataBlob.GetDataPresent(typeof(SerializableUniverse)))
     {
         // someday, we might worry about this
         // System.Runtime.InteropServices.COMException
         // but not now
         retVal = (SerializableUniverse)dataBlob.GetData(typeof(SerializableUniverse));
     }
     return retVal;
 }
开发者ID:TheProjecter,项目名称:thekbase,代码行数:16,代码来源:LocalClipboard.cs


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