System.Windows.Forms.Clipboard.ContainsData(string)

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

16 Examples 7

1. Example

Project: IronAHK
Source File: Environment.cs
View license
public static void ClipWait(double timeout, bool type)
        {
            int frequency = 100, time = (int)(timeout * 1000);

            for (int i = 0; i < time; i += frequency)
            {
                if ((!type && Clipboard.ContainsText()) || Clipboard.ContainsData(DataFormats.WaveAudio))
                {
                    ErrorLevel = 0;
                    return;
                }
                System.Threading.Thread.Sleep(frequency);
            }

            ErrorLevel = 1;
        }

2. Example

Project: noterium
Source File: TextClipper.cs
View license
private string GetActiveWindowsTextSelection()
        {
            // Obtain the handle of the active window.
            //IntPtr handle = GetForegroundWindow();
            //SendCtrlC(handle);

            if (Clipboard.ContainsData(DataFormats.Html))
            {
                var html = (string) Clipboard.GetData(DataFormats.Html);

                var output = ClipboardHtmlHelper.ParseString(html);

                if (!string.IsNullOrWhiteSpace(output.Source))
                {
                    return string.Format("<a href=\"{0}\">{0}</a><br /><br />{1}", output.Source, output.Html);
                }
                return output.Html;
            }

            return Clipboard.GetText();
        }

3. Example

View license
private void PasteClipboard()
		{
			try
			{
				if (Clipboard.ContainsData("ws.model.columncollection"))
				{
					var document = new XmlDocument();
					document.LoadXml((string)Clipboard.GetData("ws.model.columncollection"));
					foreach (XmlNode node in document.DocumentElement.SelectNodes("column"))
					{
						this.PasteColumn(node);
					}
					this.OnItemChanged(this, new System.EventArgs());
				}
				else if (Clipboard.ContainsData("ws.model.column"))
				{
					var document = new XmlDocument();
					document.LoadXml((string)Clipboard.GetData("ws.model.column"));
					this.PasteColumn(document.DocumentElement);
					this.OnItemChanged(this, new System.EventArgs());
				}

			}
			catch (Exception ex)
			{
				throw;
			}
		}

4. Example

View license
private void PasteMenuClick(object sender, System.EventArgs e)
		{
			try
			{
				if (Clipboard.ContainsData("ws.model.storedprocedurecolumn"))
				{
					var document = new XmlDocument();
					document.LoadXml((string)Clipboard.GetData("ws.model.storedprocedurecolumn"));

					var newItem = ((CustomStoredProcedureColumnCollection)this.Object).Add();
					var id = newItem.Id;
					newItem.XmlLoad(document.DocumentElement);
					newItem.SetId(id);
					newItem.SetKey(Guid.NewGuid().ToString());
					newItem.Name = "[" + newItem.Name + "]";
					this.OnItemChanged(this, new System.EventArgs());
				}
			}
			catch (Exception ex)
			{
				throw;
			}
		}

5. Example

Project: ecsharp
Source File: DiagramControl.cs
View license
[Command(null, "Paste")]
		public bool Paste(bool run = true)
		{
			if (Clipboard.ContainsData("DiagramDocument"))
			{
				if (run)
				{
					var buf = Clipboard.GetData("DiagramDocument") as byte[];
					if (buf != null)
						PasteAndSelect(new MemoryStream(buf), VectorT.Zero);
				}
				return true;
			}
			else if (Clipboard.ContainsText())
			{
				if (run)
				{
					var text = Clipboard.GetText();

					DoOrUndo act = null;
					if (_focusShape != null && (act = _focusShape.AppendTextAction(text)) != null)
						_doc.UndoStack.Do(act, true);
					else
					{
						var textBox = new TextBox(new BoundingBox<Coord>(0, 0, 300, 200))
						{
							Text = text,
							TextJustify = LLTextShape.JustifyMiddleCenter,
							BoxType = BoxType.Borderless,
							Style = BoxStyle
						};
						_doc.AddShape(textBox);
					}
				}
				return true;
			}
			return false;
		}

6. Example

Project: KeeThief
Source File: ClipboardUtil.cs
View license
public static bool ContainsData(string strFormat)
		{
			if(!NativeLib.IsUnix()) return Clipboard.ContainsData(strFormat);

			if(string.IsNullOrEmpty(strFormat)) { Debug.Assert(false); return false; }
			if((strFormat == DataFormats.CommaSeparatedValue) ||
				(strFormat == DataFormats.Html) || (strFormat == DataFormats.OemText) ||
				(strFormat == DataFormats.Rtf) || (strFormat == DataFormats.Text) ||
				(strFormat == DataFormats.UnicodeText))
				return ContainsText();

			string strData = GetText();
			return StrUtil.IsDataUri(strData, ClipFmtToMimeType(strFormat));
		}

7. Example

View license
private void PasteMenuClick(object sender, System.EventArgs e)
		{
			try
			{
				if (Clipboard.Con/n ..... /n //View Source file for more details /n }

8. Example

View license
private void PasteClipboard()
		{
			try
			{
				var customStoredProcedureCollection = (CustomStoredProcedureCollection)this.Object;
				if (Clipboard.ContainsData("ws.model.storedprocedurecollection"))
				{
					var document = new XmlDocument();
					document.LoadXml((string)Clipboard.GetData("ws.model.storedprocedurecollection"));
					foreach (XmlNode node in document.DocumentElement.SelectNodes("z"))
					{
						var tableNode = node.SelectSingleNode("storedprocedure");
						var columnListNode = node.SelectSingleNode("columnList");
						var parameterListNode = node.SelectSingleNode("parameterList");
						this.PasteTable(customStoredProcedureCollection, tableNode, columnListNode, parameterListNode);
					}
					this.OnItemChanged(this, new System.EventArgs());
				}
				else if (Clipboard.ContainsData("ws.model.storedprocedure"))
				{
					var document = new XmlDocument();
					document.LoadXml((string)Clipboard.GetData("ws.model.storedprocedure"));
					this.PasteTable(customStoredProcedureCollection,
						document.DocumentElement.SelectSingleNode("storedprocedure"),
						document.DocumentElement.SelectSingleNode("columnList"),
						document.DocumentElement.SelectSingleNode("parameterList"));
					this.OnItemChanged(this, new System.EventArgs());
				}

			}
			catch (Exception ex)
			{
				throw;
			}
		}

9. Example

View license
private void PasteClipboard()
		{
			try
			{
				var customViewCollection = (CustomViewCollection)this.Object;
				if (Clipboard.ContainsData("ws.model.viewcollection"))
				{
					var document = new XmlDocument();
					document.LoadXml((string)Clipboard.GetData("ws.model.viewcollection"));
					foreach (XmlNode node in document.DocumentElement.SelectNodes("z"))
					{
						var viewNode = node.SelectSingleNode("view");
						var columnListNode = node.SelectSingleNode("columnList");
						this.PasteTable(customViewCollection, viewNode, columnListNode);
					}
					this.OnItemChanged(this, new System.EventArgs());
				}
				else if (Clipboard.ContainsData("ws.model.view"))
				{
					var document = new XmlDocument();
					document.LoadXml((string)Clipboard.GetData("ws.model.view"));
					this.PasteTable(customViewCollection,
						document.DocumentElement.SelectSingleNode("view"),
						document.DocumentElement.SelectSingleNode("columnList"));
					this.OnItemChanged(this, new System.EventArgs());
				}

			}
			catch (Exception ex)
			{
				throw;
			}
		}

10. Example

View license
private void PasteClipboard()
		{
			try
			{
				var tableCollection = (TableCollection)this.Object;
				if (Clipboard.ContainsData("ws.model.tablecollection"))
				{
					var document = new XmlDocument();
					document.LoadXml((string)Clipboard.GetData("ws.model.tablecollection"));
					foreach (XmlNode node in document.DocumentElement.SelectNodes("z"))
					{
						var tableNode = node.SelectSingleNode("table");
						var columnListNode = node.SelectSingleNode("columnList");
						this.PasteTable(tableCollection, tableNode, columnListNode);
					}
					this.OnItemChanged(this, new System.EventArgs());
				}
				else if (Clipboard.ContainsData("ws.model.table"))
				{
					var document = new XmlDocument();
					document.LoadXml((string)Clipboard.GetData("ws.model.table"));
					this.PasteTable(tableCollection,
						document.DocumentElement.SelectSingleNode("table"),
						document.DocumentElement.SelectSingleNode("columnList"));
					this.OnItemChanged(this, new System.EventArgs());
				}

			}
			catch (Exception ex)
			{
				throw;
			}
		}

11. Example

Project: Dithering
Source File: ClipboardHelpers.cs
View license
public static Bitmap GetImage()
    {
      Bitmap result;

      // http://csharphelper.com/blog/2014/09/paste-a-png-format-image-with-a-transparent-background-from-the-clipboard-in-c/

      result = null;

      try
      {
        if (Clipboard.ContainsData(PngFormat))
        {
          object data;

          data = Clipboard.GetData(PngFormat);

          if (data != null)
          {
            Stream stream;

            stream = data as MemoryStream;

            if (stream == null)
            {
              byte[] buffer;

              buffer = data as byte[];

              if (buffer != null)
              {
                stream = new MemoryStream(buffer);
              }
            }

            if (stream != null)
            {
              result = Image.FromStream(stream).Copy();

              stream.Dispose();
            }
          }
        }

        if (result == null)
        {
          result = (Bitmap)Clipboard.GetImage();
        }
      }
      catch (Exception ex)
      {
        MessageBox.Show(string.Format("Failed to obtain image. {0}", ex.GetBaseException().Message), "Paste Image", MessageBoxButtons.OK, MessageBoxIcon.Error);
      }

      return result;
    }

12. Example

Project: scada
Source File: FrmTable.cs
View license
public void CellPaste()
        {
            DataGridViewCell cell = dataGridView.CurrentCell;
    /n ..... /n //View Source file for more details /n }

13. Example

Project: HaSuite
Source File: InputHandler.cs
View license
private void parentBoard_ShortcutKeyPressed(Board selectedBoard, bool ctrl, bool shift, bool alt, Ke/n ..... /n //View Source file for more details /n }

14. Example

Project: winforms
Source File: BitmaskEditorTemplate.cs
View license
public void OnKeyDown(KeyEventArgs e)
		{
			if (e.KeyCode == Keys.ControlKey)
				this.EmitInvalidate();

			if (e.KeyCode == Keys.Return || e.KeyCode == Keys.Right || (e.KeyCode == Keys.Down && e.Control))
			{
				this.ShowDropDown();
				e.Handled = true;
			}
			else if (e.Control && e.KeyCode == Keys.C)
			{
				DataObject data = new DataObject();
				data.SetText(this.bitmaskStr);
				data.SetData(ClipboardDataFormat, this.bitmask);
				Clipboard.SetDataObject(data);
				e.Handled = true;
			}
			else if (e.Control && e.KeyCode == Keys.V)
			{
				bool success = false;
				ulong pasteValue = 0; 
				if (Clipboard.ContainsData(ClipboardDataFormat))
				{
					pasteValue = (ulong)Clipboard.GetData(ClipboardDataFormat);
					success = true;
				}
				else if (Clipboard.ContainsText())
				{
					string[] pasteObj = Clipboard.GetText().Split(new [] { ", " }, StringSplitOptions.RemoveEmptyEntries);
					foreach (string p in pasteObj)
					{
						if (p == null) continue;
						BitmaskItem item = this.dropdownItems.FirstOrDefault(obj => obj != null && p == obj.ToString());
						if (item != null)
						{
							pasteValue |= item.Value;
							success = true;
						}
					}
				}
				if (success)
				{
					this.bitmask = pasteValue;
					this.bitmaskStr = this.DefaultValueStringGenerator(this.bitmask);
					this.EmitInvalidate();
					this.EmitEdited(this.bitmask);
				}
				else
					System.Media.SystemSounds.Beep.Play();
				e.Handled = true;
			}
		}

15. Example

Project: winforms
Source File: ComboBoxEditorTemplate.cs
View license
public void OnKeyDown(KeyEventArgs e)
		{
			if (e.KeyCode == Keys.ControlKey)
				this.EmitInvalida/n ..... /n //View Source file for more details /n }

16. Example

View license
public void OnKeyDown(KeyEventArgs e)
		{
			if (e.KeyCode == Keys.ControlKey)
				this.EmitInvalida/n ..... /n //View Source file for more details /n }