System.Windows.Forms.IDataObject.GetFormats()

Here are the examples of the csharp api class System.Windows.Forms.IDataObject.GetFormats() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

28 Examples 7

1. Example

Project: OpenLiveWriter
Source File: OleDataObjectHelper.cs
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;
            }
        }

2. Example

Project: OpenLiveWriter
Source File: TextData.cs
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;
        }

3. Example

Project: SystemEx
Source File: OleDropData.cs
public string[] GetFormats()
        {
            return this.underlyingDataObject.GetFormats();
        }

4. Example

Project: duality
Source File: ConversionData.cs
string[] IDataObject.GetFormats()
		{
			return this.data.GetFormats();
		}

5. Example

Project: ClearCanvas
Source File: DragDropObject.cs
public string[] GetFormats()
		{
			return _dataObject.GetFormats();
		}

6. Example

Project: WzComparerR2
Source File: MainForm.cs
private void ribbonBar3_DragEnter(object sender, DragEventArgs e)
        {
            string[] types = e.Data.GetFormats();
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                e.Effect = DragDropEffects.Move;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }

7. Example

Project: OpenLiveWriter
Source File: DataObjectBase.cs
public string[] GetFormats()
        {
            Validate();
            return m_dataObject.GetFormats();
        }

8. Example

Project: OpenLiveWriter
Source File: FileItemFromFileContents.cs
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);
        }

9. Example

Project: OpenLiveWriter
Source File: LightWeightHTMLDocumentData.cs
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;

        }

10. Example

Project: OpenLiveWriter
Source File: InlineEditField.cs
public static bool EditFieldAcceptsData()
        {

            IDataObject clipboard = Clipboard.GetDataObject();

            string[] formats = clipboard.GetFormats();

            foreach (string format in formats)
            {
                switch (format)
                {
                    case "HTML Format":
                    case "System.String":
                    case "Text":
                    case "UnicodeText":
                        return true;
                }
            }
            return false;
        }

11. Example

Project: PowerPointLabs
Source File: ClipboardUtil.cs
public static bool IsClipboardEmpty()
        {
            IDataObject clipboardData = Clipboard.GetDataObject();
            return clipboardData == null || clipboardData.GetFormats().Length == 0;
        }

12. Example

Project: ShareX
Source File: ClipboardHelper.cs
public static List<string> GetFormats(IDataObject dataObj)
        {
            string[] formats = null;

            if (dataObj != null)
            {
                formats = dataObj.GetFormats();
            }
            if (formats != null)
            {
                LOG.DebugFormat("Got clipboard formats: {0}", String.Join(",", formats));
                return new List<string>(formats);
            }
            return new List<string>();
        }

13. Example

Project: ShareX
Source File: ClipboardHelper.cs
public static List<string> GetFormats(IDataObject dataObj)
        {
            string[] formats = null;

            if (dataObj != null)
            {
                formats = dataObj.GetFormats();
            }
            if (formats != null)
            {
                LOG.DebugFormat("Got clipboard formats: {0}", String.Join(",", formats));
                return new List<string>(formats);
            }
            return new List<string>();
        }

14. Example

Project: ClearCanvas
Source File: BindingTreeView.cs
private object GetDragDropData(DragEventArgs e)
        {
            IDataObject dao = e.Data;
            string[] formats = dao.GetFormats();

            // use any available format, since we are assuming the data is in-process
            return formats.Length > 0 ? dao.GetData(formats[0]) : null;
        }

15. Example

Project: HOPE
Source File: VisualizerController.cs
protected void DragEnterEvent(object sender, DragEventArgs args)
		{
			if (args.Data.GetFormats().Contains("FileDrop"))
			{
				args.Effect = DragDropEffects.Copy;
			}
			else
			{
				args.Effect = DragDropEffects.None;
			}
		}

16. Example

Project: samschanneledit
Source File: ListViewDragAndDrop.cs
protected override void OnDragEnter(DragEventArgs drgevent)
    {
      base.OnDragEnter(drgevent);

      if (DragAndDropEnabled)
      {
        int len = drgevent.Data.GetFormats().Length - 1;
        int i;
        for (i = 0; i <= len; i++)
          if (drgevent.Data.GetFormats()[i].Equals("System.Windows.Forms.ListView+SelectedListViewItemCollection"))
            drgevent.Effect = DragDropEffects.Move;
      }
    }

17. Example

Project: JSon-Editor
Source File: JsonTreeView.cs
private static JTokenTreeNode GetDragDropSourceNode(DragEventArgs e)
        {
            return e.Data.GetData(e.Data.GetFormats().FirstOrDefault(), true) as JTokenTreeNode;
        }

18. Example

Project: tcp-gecko-dotnet
Source File: codecontroller.cs
private void codeOutput_DragEnter(object sender, DragEventArgs e)
        {
            UpdateCode();
            codeOutput.Click -= codeOutput_SelectedIndexChanged;
            int len = e.Data.GetFormats().Length - 1;
            int i;
            for (i = 0; i <= len; i++)
            {
                if (e.Data.GetFormats()[i].Equals("System.Windows.Forms.ListView+SelectedListViewItemCollection"))
                {
                    //The data from the drag source is moved to the target.	
                    e.Effect = DragDropEffects.Move;
                }
            }

        }

19. Example

Project: ArnoldSimulator
Source File: GraphControl.cs
protected override void OnDragEnter(DragEventArgs drgevent)
		{
			base.OnDragEnter(drgevent);
			dragNode = null;

			foreach (var name in drgevent.Data.GetFormats())
			{
				var node = drgevent.Data.GetData(name) as Node;
				if (node != null)
				{
					if (AddNode(node))
					{
						dragNode = node;

						drgevent.Effect = DragDropEffects.Copy;
					}
					return;
				}
			}
		}

20. Example

Project: KeeThief
Source File: ClipboardContents.cs
private void GetDataPriv(bool bSimpleOnly)
		{
			if(bSimpleOnly)
			{
				if(ClipboardUtil.ContainsText())
					m_strText = ClipboardUtil.GetText();
			}
			else // Advanced backup
			{
				m_vContents = new List<KeyValuePair<string, object>>();

				IDataObject idoClip = Clipboard.GetDataObject();
				foreach(string strFormat in idoClip.GetFormats())
				{
					KeyValuePair<string, object> kvp =
						new KeyValuePair<string, object>(strFormat,
						idoClip.GetData(strFormat));

					m_vContents.Add(kvp);
				}
			}
		}

21. Example

Project: WzComparerR2
Source File: MainForm.cs
private void advTree1_DragEnter(object sender, DragEventArgs e)
        {
            string[] types = e.Data.GetFormats();
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
                foreach (string file in files)
                {
                    if (Path.GetExtension(file) != ".wz")
                    {
                        e.Effect = DragDropEffects.None;
                        return;
                    }
                }
                e.Effect = DragDropEffects.Move;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }

22. Example

Project: Graph
Source File: GraphControl.cs
protected override void OnDragEnter(DragEventArgs drgevent)
		{
			base.OnDragEnter(drgevent);
			dragNode = null;

			foreach (var name in drgevent.Data.GetFormats())
			{
				var node = drgevent.Data.GetData(name) as Node;
				if (node != null)
				{
					if (AddNode(node))
					{
						dragNode = node;

						drgevent.Effect = DragDropEffects.Copy;
					}
					return;
				}
			}
		}

23. Example

Project: XmlNotepad
Source File: Commands.cs
public static TreeData GetData()
        {
            try
            {
                IDataObject data = Clipboard.GetDataObject();
                try
                {
                    if (data.GetDataPresent(typeof(TreeData)))
                    {
                        return data.GetData(typeof(TreeData)) as TreeData;
                    }
                    foreach (string format in data.GetFormats())
                    {
                        if (format.ToUpper().StartsWith("XML"))
                        {
                            MemoryStream raw = data.GetData(format) as MemoryStream;
                            return new TreeData(raw);
                        }
                    }
                }
                catch (Exception)
                {
                }
                if (data.GetDataPresent(typeof(string)))
                {
                    string xml = data.GetData(typeof(string)).ToString();
                    // We don't want to actually parse the XML at this point, 
                    // because we don't have the namespace context yet.
                    // So we just sniff the XML to determine the node type.
                    return new TreeData(xml);
                }
            }
            catch (System.Runtime.InteropServices.ExternalException)
            {
            }
            catch (System.Threading.ThreadStateException)
            {
            }
            return null;
        }

24. Example

Project: RatioMaster.NET
Source File: RM.cs
internal void Form1_DragEnter(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop) || e.Data.GetDataPresent(DataFormats.Text) || e.Data.GetFormats().ToString().Equals("System.String[]"))
            {
                e.Effect = DragDropEffects.All;
            }
            else
            {
                e.Effect = DragDropEffects.None;
            }
        }

25. Example

Project: OpenLiveWriter
Source File: HTMLData.cs
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;
        }

26. Example

Project: GRBL-Plotter
Source File: MainForm.cs
private void loadFromClipboard()
        {   string svg_format1 = "image/x-inkscape-svg";
          /n ..... /n //View Source file for more details /n }

27. Example

Project: HOPE
Source File: VisualizerController.cs
protected void DragDropEvent(object sender, DragEventArgs args)
		{
			bool once = true;
			bool rec/n ..... /n //View Source file for more details /n }

28. Example

Project: Alferd-Spritesheet-Unpacker
Source File: MainForm.cs
private void MainPanel_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
        {
     /n ..... /n //View Source file for more details /n }