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


C# IDataObject.GetFormats方法代码示例

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


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

示例1: OnClipboardUpdated

 // Protected
 protected override void OnClipboardUpdated(EventArgs e)
 {
     if(AF.Count>0)AF.Clear();
     DataObject=Clipboard.GetDataObject();
     string[] ClipboardFormats=DataObject.GetFormats(true);
     if(ClipboardFormats.Length>0)
     Empty=false;
     else
     {
     Empty=true;
     goto exit;
     }
     if(SF==null)
     {
     foreach(string format in ClipboardFormats)
     AF.Add(format);
     }
     else
     {
     for(int i= 0;i<SF.Count;i++)
     if
     (
     Array.IndexOf<string>(ClipboardFormats,SF[i])!=-1
     )
     AF.Add(SF[i]);
     }
     exit:base.OnClipboardUpdated(e);
 }
开发者ID:DP458,项目名称:Clipboard_Watcher,代码行数:29,代码来源:ClipboardListener.cs

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

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

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

示例5: FilesDropData

        public FilesDropData(IDataObject dataObject)
        {
            _dataObject = dataObject;

            var formats = _dataObject.GetFormats();

            _isValid = false;

            foreach (var format in formats)
            {
                switch (format)
                {
                    case "FileDrop":
                    case "FileGroupDescriptor":
                    case "FileGroupDescriptorW":
                        _isValid = true;
                        break;
                }

                if (_isValid)
                    break;
            }

            _parsed = !_isValid;
        }
开发者ID:pvginkel,项目名称:SystemEx,代码行数:25,代码来源:FilesDropData.cs

示例6: IsFileDrop

 static bool IsFileDrop(IDataObject d)
 {
     foreach (string str in d.GetFormats())
     {
         if (str == DataFormats.FileDrop)
             return true;
     }
     return false;
 }
开发者ID:1vanK,项目名称:Constructor-2,代码行数:9,代码来源:Преобразователь2.cs

示例7: button1_Click

        private void button1_Click(object sender, System.EventArgs e)
        {
            ido = Clipboard.GetDataObject();

            try
            {
                string datastr = ido.GetData(comboBox1.Text).ToString();
                if (datastr == "System.IO.MemoryStream") throw new Exception();
                textBox2.Text = datastr;
            }
            catch
            {

                var data = (MemoryStream)ido.GetData(comboBox1.Text);

                if (data == null)
                {
                    textBox2.Text = "No \"" + comboBox1.Text + "\" on Clipboard\r\nAvailable formats:\r\n";
                    for (var i = 0; i < ido.GetFormats().Length; i++)
                    {
                        textBox2.Text += ido.GetFormats()[i] + " " + ido.GetFormats()[i].GetType();
                        textBox2.Text += "\r\n";
                    }

                }
                else
                {
                    string mathMl;
                    using (data)
                    {
                        using (var sr = new StreamReader(data))
                        {
                            mathMl = sr.ReadToEnd();
                        }
                    }

                    textBox2.Text = mathMl.Replace("><", ">\r\n<");
                }
                // good, for text
                //textBox2.Text = (string)ido.GetData(DataFormats.UnicodeText);
            }
        }
开发者ID:madcapsoftware,项目名称:web-xslt,代码行数:42,代码来源:Form1.cs

示例8: foreach

 IDataObjectMapper IDataObjectMappingService.GetDataObjectMapper(IDataObject dataObj, string toDataFormat)
 {
     IDataObjectMapper dataObjectMapper = null;
     foreach (string str in dataObj.GetFormats())
     {
         dataObjectMapper = ((IDataObjectMappingService) this).GetDataObjectMapper(str, toDataFormat);
         if (dataObjectMapper != null)
         {
             return dataObjectMapper;
         }
     }
     return null;
 }
开发者ID:ikvm,项目名称:webmatrix,代码行数:13,代码来源:DataObjectMappingService.cs

示例9: Select

        public IDropHandler Select(IDataObject data)
        {
            Contract.Requires(data != null);

            IDropHandler handler = null;
            foreach (string format in data.GetFormats()) {
                if (_handlers.TryGetValue(format, out handler)) {
                    break;
                }
            }

            return handler;
        }
开发者ID:bifrost-dev,项目名称:Bifrost.CalibreConverter,代码行数:13,代码来源:DropHandlers.cs

示例10: Create

        public static LightWeightHTMLDocumentData Create(IDataObject iDataObject)
        {
            string[] loser = iDataObject.GetFormats();

            if (OleDataObjectHelper.GetDataPresentSafe(iDataObject, LightWeightHTMLDataObject.LIGHTWEIGHTHTMLDOCUMENTFORMAT))
            {
                LightWeightHTMLDocument document = (LightWeightHTMLDocument)iDataObject.GetData(LightWeightHTMLDataObject.LIGHTWEIGHTHTMLDOCUMENTFORMAT);
                return new LightWeightHTMLDocumentData(document);
            }
            else
                return null;

        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:13,代码来源:LightWeightHTMLDocumentData.cs

示例11: CanCreateFrom

        /// <summary>
        /// Does the passed data object have this format?
        /// </summary>
        /// <param name="dataObject">data object</param>
        /// <returns>true if the data object has the format, otherwise false</returns>
        public bool CanCreateFrom(IDataObject dataObject)
        {
            // GetDataPresent is not always a reliable indicator of what data is
            // actually available. For Outlook Express, if you call GetDataPresent on
            // FileGroupDescriptor it returns false however if you actually call GetData
            // you will get the FileGroupDescriptor! Therefore, we are going to
            // enumerate the available formats and check that list rather than
            // checking GetDataPresent
            ArrayList formats = new ArrayList(dataObject.GetFormats());

            // check for FileContents
            return (formats.Contains(DataFormatsEx.FileGroupDescriptorFormat) ||
                    formats.Contains(DataFormatsEx.FileGroupDescriptorWFormat))
                   && formats.Contains(DataFormatsEx.FileContentsFormat);
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:20,代码来源:FileItemFromFileContents.cs

示例12: Create

        /// <summary>
        /// Creates a TextData from an IDataObject
        /// </summary>
        /// <param name="iDataObject">The IDataObject from which to create a TextData</param>
        /// <returns>The TextData, null if no TextData could be created.</returns>
        public static TextData Create(IDataObject iDataObject)
        {
            // Note: Using getData or getDataPresent here will sometimes return text
            // even when the text isn't in the list of formats exposed by getFormats
            foreach (string format in iDataObject.GetFormats())
            {
                if (format == DataFormats.UnicodeText || format == DataFormats.Text || format == DataFormats.StringFormat)
                {
                    // Suppress the text from an outlook data object, the text is useless
                    if (OleDataObjectHelper.GetDataPresentSafe(iDataObject, OUTLOOK_FORMAT_IGNORE_TEXT))
                        return null;

                    return new TextData(iDataObject);
                }
            }
            return null;
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:22,代码来源:TextData.cs

示例13: FromDataObject

        /// <summary>
        /// Gets an item from a data object.
        /// </summary>
        public static Item FromDataObject(IDataObject Object)
        {
            string[] formats = Object.GetFormats();

            string text = Object.GetData("Text") as string;
            if (text != null)
            {
                return new StringItem(text);
            }

            string[] file = (Object.GetData("FileNameW") as string[]) ?? (Object.GetData("FileName") as string[]);
            if (file != null && file.Length == 1)
            {
                return new StandardFileItem(file[0]);
            }

            return null;
        }
开发者ID:dzamkov,项目名称:DUIP,代码行数:21,代码来源:Item.cs

示例14: GetDataPresentSafe

        public static bool GetDataPresentSafe(IDataObject obj, string format)
        {
            try
            {
                if (obj == null)
                    return false;

                string[] formats = obj.GetFormats();

                if (formats == null)
                    return false;

                return ArrayHelper.SearchForIndexOf(formats, format, (a, b) => a == b) != -1;
            }
            catch (Exception)
            {
                return false;
            }
        }
开发者ID:gmilazzoitag,项目名称:OpenLiveWriter,代码行数:19,代码来源:OleDataObjectHelper.cs

示例15: TryExtractImageDataFromHtml

 internal static async Task<ExtractedImageData> TryExtractImageDataFromHtml(IDataObject data, ProcessingTaskMonitor processingTaskMonitor, long taskMonitorPanel)
 {
     string[] formats = data.GetFormats();
     if (!formats.Contains("text/html"))
     {
         return new ExtractedImageData { Success = false };
     }
     var obj = data.GetData("text/html");
     string html = string.Empty;
     if (obj is string)
     {
         html = (string)obj;
     }
     else if (obj is MemoryStream)
     {
         MemoryStream ms = (MemoryStream)obj;
         byte[] buffer = new byte[ms.Length];
         ms.Read(buffer, 0, (int)ms.Length);
         if (buffer[1] == (byte)0)  // Detecting unicode
         {
             html = System.Text.Encoding.Unicode.GetString(buffer);
         }
         else
         {
             html = System.Text.Encoding.ASCII.GetString(buffer);
         }
     }
     Uri imageUri;
     if (TryExtractImageUri(html, out imageUri))
     {
         processingTaskMonitor.SetPanelText(taskMonitorPanel, "Uploading image from web...");
         var imageData = await TryExtractImageDataFromUri(imageUri);
         processingTaskMonitor.SetPanelText(taskMonitorPanel, "Uploaded");
         return imageData;
     }
     else
     {
         return new ExtractedImageData { Success = false };
     }
 }
开发者ID:AndrewShepherd,项目名称:Drawception-Helper,代码行数:40,代码来源:DragDropUtils.cs


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