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


C# IDataObject.GetData方法代码示例

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


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

示例1: LimitDragDropOptions

        public bool LimitDragDropOptions(IDataObject data)
        {
            var formats = data.GetFormats();
            if(!formats.Any())
            {
                return true;
            }


            var modelItemString = formats.FirstOrDefault(s => s.IndexOf("ModelItemsFormat", StringComparison.Ordinal) >= 0);
            if(!String.IsNullOrEmpty(modelItemString))
            {
                var innnerObjectData = data.GetData(modelItemString);
                var modelList = innnerObjectData as List<ModelItem>;
                if(modelList != null && modelList.Count > 1)
                {
                    if(modelList.FirstOrDefault(c => c.ItemType == typeof(FlowDecision) || c.ItemType == typeof(FlowSwitch<string>)) != null)
                    {
                        return false;
                    }
                }
            }

            modelItemString = formats.FirstOrDefault(s => s.IndexOf("ModelItemFormat", StringComparison.Ordinal) >= 0);
            if(String.IsNullOrEmpty(modelItemString))
            {
                modelItemString = formats.FirstOrDefault(s => s.IndexOf("WorkflowItemTypeNameFormat", StringComparison.Ordinal) >= 0);
                if(String.IsNullOrEmpty(modelItemString))
                {
                    return true;
                }
            }
            var objectData = data.GetData(modelItemString);
            return DropPointOnDragEnter(objectData);
        }
开发者ID:FerdinandOlivier,项目名称:Warewolf-ESB,代码行数:35,代码来源:DropEnabledActivityDesignerUtils.cs

示例2: GetImageUrl

        static string GetImageUrl(IDataObject data)
        {
            var fileDrops = (string[])data.GetData(DataFormats.FileDrop);
            if (fileDrops?.Length >= 1) return fileDrops[0];

            var text = (string)data.GetData(DataFormats.UnicodeText);
            return text;
        }
开发者ID:sakapon,项目名称:Samples-2016,代码行数:8,代码来源:MainWindow.xaml.cs

示例3: GetDataFilePath

        public static string GetDataFilePath(IDataObject data) {
            string fileName = null;
            string[] fileNames = (string[]) data.GetData(DataFormats.FileDrop);
            if ( (fileNames != null) && (fileNames.Length > 0) ) {
                fileName = fileNames[0];
            } else {
                fileName = (string) data.GetData("UnicodeText");
            }

            return fileName;
        }
开发者ID:ctsyolin,项目名称:ieunit,代码行数:11,代码来源:CommonUtil.cs

示例4: 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

示例5: ProcessFileNames

        private void ProcessFileNames(IDataObject obj, string format)
        {
            try
            {
                var fileNames = obj.GetData(format, true) as string[];

                var fileName = fileNames.FirstOrDefault();

                if (fileName != null)
                {
                    var file = File.ReadAllBytes(fileName);



                    using (var ms = new System.IO.MemoryStream(file))
                    {
                        var image = new BitmapImage();
                        image.BeginInit();
                        image.CacheOption = BitmapCacheOption.OnLoad; // here
                        image.StreamSource = ms;
                        image.EndInit();
                        ViewModel.Model.SquareDraft = image;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.GetType().Name, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
开发者ID:BlackSwanBay,项目名称:SteamPaver,代码行数:30,代码来源:TileView.xaml.cs

示例6: DoPaste

        // Retrieves the text from the IDataObject instance.
        // Then create a textbox with the text data. 
        protected override void DoPaste(IDataObject dataObject) 
        {
            ElementList = new List<UIElement>(); 

            // Get the string from the data object.
            string text = dataObject.GetData(DataFormats.UnicodeText, true) as string;
 
            if ( String.IsNullOrEmpty(text) )
            { 
                // OemText can be retrieved as CF_TEXT. 
                text = dataObject.GetData(DataFormats.Text, true) as string;
            } 

            if ( !String.IsNullOrEmpty(text) )
            {
                // Now, create a text box and set the text to it. 
                TextBox textBox = new TextBox();
 
                textBox.Text = text; 
                textBox.TextWrapping = TextWrapping.Wrap;
 
                // Add the textbox to the internal array list.
                ElementList.Add(textBox);
            }
 
        }
开发者ID:sjyanxin,项目名称:WPFSource,代码行数:28,代码来源:TextClipboardData.cs

示例7: Create

        /// <summary>
        /// Attempts to create a new HTMLData.  This can return null if the DataObject
        /// couldn't be created based upon the IDataObject.
        /// </summary>
        /// <param name="iDataObject">The IDataObject from which to create the HTML Data Object</param>
        /// <returns>The HTMLData, null if it couldn't be created.</returns>
        public static HTMLData Create(IDataObject iDataObject)
        {
            string[] loser = iDataObject.GetFormats();

            if (OleDataObjectHelper.GetDataPresentSafe(iDataObject, DataFormats.Html))
            {

                try
                {
                    HTMLData data = new HTMLData(iDataObject, null);
                    return string.IsNullOrEmpty(data.HTML) ? null : data;
                }
                catch (FormatException)
                {
                    // EML files with HTML inside of them report that they are HTML
                    // However, when we try to read the format, we have problems reading it
                    // So we will skip loading html that we cannot load
                    return null;
                }

            }
            else if (HtmlDocumentClassFormatPresent(iDataObject))
            {
                return new HTMLData(iDataObject, (IHTMLDocument2)iDataObject.GetData(typeof(HTMLDocumentClass)));
            }
            else
                return null;
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:34,代码来源:HTMLData.cs

示例8: Drop

		public override void Drop(IDataObject data, int index, DropEffect finalEffect)
		{
			try {
				string insertText = (data.GetData(typeof(string[])) as string[])
					.Aggregate((text, part) => text += part);
				ITextAnchor marker;
				int length = 0;
				if (index == this.Children.Count) {
					if (index == 0)
						marker = null;
					else
						marker = (this.Children[index - 1] as XamlOutlineNode).EndMarker;
					if (marker == null) {
						marker = this.EndMarker;
						length = -1; // move backwards
					} else {
						length = 2 + (this.Children[index - 1] as XamlOutlineNode).elementName.Length;
					}
				} else
					marker = (this.Children[index] as XamlOutlineNode).Marker;
				
				int offset = marker.Offset + length;
				Editor.Document.Insert(offset, insertText);
			} catch (Exception ex) {
				throw ex;
			}
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:27,代码来源:XamlOutlineNode.cs

示例9: 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

示例10: CloneClipboard

        private IDataObject CloneClipboard(IDataObject obj)
        {
            if (obj == null)
                return null;

            string[] formats = obj.GetFormats();
            if (formats.Length == 0)
                return null;

            IDataObject newObj = new DataObject();
            
            foreach (string format in formats)
            {
				if (format.Contains("EnhancedMetafile")) //Ignore this. Cannot be processed in .NET
					continue;

				object o = obj.GetData(format);

                if (o != null)
                {
                    newObj.SetData(o);
                }
            }

            return newObj;
        }
开发者ID:killbug2004,项目名称:WSProf,代码行数:26,代码来源:ClipboardSnapshot.cs

示例11: ExtractElement

 public virtual UIElement ExtractElement(IDataObject obj)
 {
     string xamlString = obj.GetData(supportedFormat) as string;
     XmlReader reader = XmlReader.Create(new StringReader(xamlString));
     UIElement elt = XamlReader.Load(reader) as UIElement;
     return elt;
 }
开发者ID:atombender,项目名称:learning,代码行数:7,代码来源:DropTargetBase.cs

示例12: CanDrop

		public override DropEffect CanDrop(IDataObject data, DropEffect requestedEffect)
		{
			var paths = data.GetData(typeof(string[])) as string[];
			if (paths != null) {
				return requestedEffect == DropEffect.Link ? DropEffect.Move : requestedEffect;
			}
			return DropEffect.None;
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:8,代码来源:FolderNode.cs

示例13: OnDropCompleted

		public void OnDropCompleted(IDataObject obj, Point dropPoint)
		{
			string serializedObject = obj.GetData(SupportedFormat.Name) as string;
			XmlReader reader = XmlReader.Create(new StringReader(serializedObject));
			UIElement elt = XamlReader.Load(reader) as UIElement;

			(TargetUI as Panel).Children.Add(elt);
		}
开发者ID:ssickles,项目名称:archive,代码行数:8,代码来源:DefaultDropTargetAdvisor.cs

示例14: CanDropDataObject

 protected virtual bool CanDropDataObject(IDataObject dataObj)
 {
     if (dataObj != null)
     {
         if (dataObj is ComponentDataObjectWrapper)
         {
             object[] draggingObjects = this.GetDraggingObjects(dataObj, true);
             if (draggingObjects == null)
             {
                 return false;
             }
             bool flag = true;
             for (int i = 0; flag && (i < draggingObjects.Length); i++)
             {
                 flag = (flag && (draggingObjects[i] is IComponent)) && this.client.IsDropOk((IComponent) draggingObjects[i]);
             }
             return flag;
         }
         try
         {
             object data = dataObj.GetData(DataFormat, false);
             if (data == null)
             {
                 return false;
             }
             IDesignerSerializationService service = (IDesignerSerializationService) this.GetService(typeof(IDesignerSerializationService));
             if (service == null)
             {
                 return false;
             }
             ICollection is2 = service.Deserialize(data);
             if (is2.Count > 0)
             {
                 bool flag2 = true;
                 foreach (object obj3 in is2)
                 {
                     if (obj3 is IComponent)
                     {
                         flag2 = flag2 && this.client.IsDropOk((IComponent) obj3);
                         if (!flag2)
                         {
                             return flag2;
                         }
                     }
                 }
                 return flag2;
             }
         }
         catch (Exception exception)
         {
             if (System.Windows.Forms.ClientUtils.IsCriticalException(exception))
             {
                 throw;
             }
         }
     }
     return false;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:58,代码来源:OleDragDropHandler.cs

示例15: GetDropData

		public object GetDropData(IDataObject obj)
		{
			string serializedObject = obj.GetData(SupportedFormat.Name) as string;
			if (string.IsNullOrEmpty(serializedObject))
				return null;

			XmlReader reader = XmlReader.Create(new StringReader(serializedObject));
			return XamlReader.Load(reader) as UIElement;
		}
开发者ID:ssickles,项目名称:archive,代码行数:9,代码来源:DefaultDropTargetAdvisor.cs


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