System.Windows.Forms.Clipboard.GetDataObject()

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

135 Examples 7

1. Example

View license
protected override void ProcessOnStatusPasteCommand(System.ComponentModel.Design.MenuCommand cmd)
        {
            base.ProcessOnStatusPasteCommand(cmd);

            if (!cmd.Enabled && this.SingleSelection is ElementListCompartment)
            {
                var compartment = (ElementListCompartment)this.SingleSelection;
                ShapeElement pasteTarget = compartment.ParentShape;

                System.Windows.Forms.IDataObject data = System.Windows.Forms.Clipboard.GetDataObject();

                if (pasteTarget != null && this.ElementOperations.CanMerge(pasteTarget, data))
                {
                    cmd.Enabled = true;
                }
            }
        }

2. Example

View license
protected override void ProcessOnMenuPasteCommand()
        {
            if (this.SingleSelection is ElementListCompartment)
            {
                var compartment = (ElementListCompartment)this.SingleSelection;
                ShapeElement pasteTarget = compartment.ParentShape;

                System.Windows.Forms.IDataObject data = System.Windows.Forms.Clipboard.GetDataObject();

                if (pasteTarget != null && this.ElementOperations.CanMerge(pasteTarget, data))
                {
                    using (Transaction t = pasteTarget.Store.TransactionManager.BeginTransaction("paste"))
                    {
                        this.ElementOperations.Merge(pasteTarget, data);
                        t.Commit();
                    }
                }
            }
            else
            {
                base.ProcessOnMenuPasteCommand();
            }
        }

3. Example

View license
protected override void ProcessOnStatusPasteCommand(System.ComponentModel.Design.MenuCommand cmd)
        {
            base.ProcessOnStatusPasteCommand(cmd);

            if (!cmd.Enabled && this.SingleSelection is ElementListCompartment)
            {
                var compartment = (ElementListCompartment)this.SingleSelection;
                ShapeElement pasteTarget = compartment.ParentShape;

                System.Windows.Forms.IDataObject data = System.Windows.Forms.Clipboard.GetDataObject();

                if (pasteTarget != null && this.ElementOperations.CanMerge(pasteTarget, data))
                {
                    cmd.Enabled = true;
                }
            }
        }

4. Example

View license
protected override void ProcessOnMenuPasteCommand()
        {
            if (this.SingleSelection is ElementListCompartment)
            {
                var compartment = (ElementListCompartment)this.SingleSelection;
                ShapeElement pasteTarget = compartment.ParentShape;

                System.Windows.Forms.IDataObject data = System.Windows.Forms.Clipboard.GetDataObject();

                if (pasteTarget != null && this.ElementOperations.CanMerge(pasteTarget, data))
                {
                    using (Transaction t = pasteTarget.Store.TransactionManager.BeginTransaction("paste"))
                    {
                        this.ElementOperations.Merge(pasteTarget, data);
                        t.Commit();
                    }
                }
            }
            else
            {
                base.ProcessOnMenuPasteCommand();
            }
        }

5. Example

View license
protected override void ProcessOnStatusPasteCommand(System.ComponentModel.Design.MenuCommand cmd)
        {
            base.ProcessOnStatusPasteCommand(cmd);

            if (!cmd.Enabled && this.SingleSelection is ElementListCompartment)
            {
                var compartment = (ElementListCompartment)this.SingleSelection;
                ShapeElement pasteTarget = compartment.ParentShape;

                System.Windows.Forms.IDataObject data = System.Windows.Forms.Clipboard.GetDataObject();

                if (pasteTarget != null && this.ElementOperations.CanMerge(pasteTarget, data))
                {
                    cmd.Enabled = true;
                }
            }
        }

6. Example

View license
protected override void ProcessOnMenuPasteCommand()
        {
            if (this.SingleSelection is ElementListCompartment)
            {
                var compartment = (ElementListCompartment)this.SingleSelection;
                ShapeElement pasteTarget = compartment.ParentShape;

                System.Windows.Forms.IDataObject data = System.Windows.Forms.Clipboard.GetDataObject();

                if (pasteTarget != null && this.ElementOperations.CanMerge(pasteTarget, data))
                {
                    using (Transaction t = pasteTarget.Store.TransactionManager.BeginTransaction("paste"))
                    {
                        this.ElementOperations.Merge(pasteTarget, data);
                        t.Commit();
                    }
                }
            }
            else
            {
                base.ProcessOnMenuPasteCommand();
            }
        }

7. Example

Project: fdotoolbox
Source File: ClipboardWrapper.cs
View license
public static IDataObject GetDataObject()
		{
			// retry 2 times should be enough for read access
			try {
				return Clipboard.GetDataObject();
			} catch (ExternalException) {
				try {
					return Clipboard.GetDataObject();
				} catch (ExternalException) {
					return new DataObject();
				}
			}
		}

8. Example

Project: naps2
Source File: FProfiles.cs
View license
private void contextMenuStrip_Opening(object sender, System.ComponentModel.CancelEventArgs e)
        {
            var ido = Clipboard.GetDataObject();
            var canPaste = ido != null && ido.GetDataPresent(typeof (DirectProfileTransfer).FullName);
            if (SelectedProfile == null)
            {
                if (canPaste)
                {
                    foreach (ToolStripItem item in contextMenuStrip.Items)
                    {
                        if (item != ctxPaste)
                        {
                            item.Visible = false;
                        }
                    }
                    ctxPaste.Enabled = true;
                }
                else
                {
                    e.Cancel = true;
                }
            }
            else
            {
                foreach (ToolStripItem item in contextMenuStrip.Items)
                {
                    item.Visible = true;
                }
                ctxSetDefault.Enabled = !SelectedProfile.IsDefault;
                ctxEdit.Enabled = true;
                ctxDelete.Enabled = !SelectedProfile.IsLocked;
                ctxCopy.Enabled = true;
                ctxPaste.Enabled = canPaste;
            }
        }

9. Example

Project: tesvsnip
Source File: MainView.cs
View license
internal static T GetClipboardData<T>() where T : class
        {
            if (Settings.Default.UseWindowsClipboard)
            {
                var od = System.Windows.Forms.Clipboard.GetDataObject();
                if (od != null)
                {
                    var clip = od.GetData(typeof (T).FullName);
                    return clip as T;
                }

                return default(T);
            }

            return s_clipboard as T;
        }

10. Example

Project: tesvsnip
Source File: MainView.cs
View license
internal static bool HasClipboardData()
        {
            if (Settings.Default.UseWindowsClipboard)
            {
                var od = System.Windows.Forms.Clipboard.GetDataObject();
                return od != null && od.GetDataPresent("TESVSnip");
            }

            return Clipboard != null;
        }

11. Example

Project: tesvsnip
Source File: MainView.cs
View license
internal static bool HasClipboardData<T>()
        {
            if (Settings.Default.UseWindowsClipboard)
            {
                var od = System.Windows.Forms.Clipboard.GetDataObject();
                return od != null && od.GetDataPresent(typeof (T).FullName);
            }

            return Clipboard is T;
        }

12. Example

Project: falloutsnip
Source File: MainView.Selection.cs
View license
internal static T GetClipboardData<T>() where T : class
        {
            if (Settings.Default.UseWindowsClipboard)
            {
                var od = System.Windows.Forms.Clipboard.GetDataObject();
                if (od != null)
                {
                    var clip = od.GetData(typeof(T).FullName);
                    return clip as T;
                }

                return default(T);
            }

            return s_clipboard as T;
        }

13. Example

Project: falloutsnip
Source File: MainView.Selection.cs
View license
internal static bool HasClipboardData()
        {
            if (Settings.Default.UseWindowsClipboard)
            {
                var od = System.Windows.Forms.Clipboard.GetDataObject();
                return od != null && od.GetDataPresent("FalloutSnip");
            }

            return Clipboard != null;
        }

14. Example

Project: falloutsnip
Source File: MainView.Selection.cs
View license
internal static bool HasClipboardData<T>()
        {
            if (Settings.Default.UseWindowsClipboard)
            {
                var od = System.Windows.Forms.Clipboard.GetDataObject();
                return od != null && od.GetDataPresent(typeof(T).FullName);
            }

            return Clipboard is T;
        }

15. Example

Project: My-FyiReporting
Source File: RdlDesigner.cs
View license
private void menuEdit_Popup(object sender, EventArgs ea)
        {
            MDIChild mc = this.Ac/n ..... /n //View Source file for more details /n }

16. Example

Project: OpenLiveWriter
Source File: WebImageSource.cs
View license
private void _imageUrl_Paste(object sender, TextBoxWithPaste.PasteEventArgs eventArgs)
        {
            //special case...image on clipboard
            if (_webImageUrl.Text.Trim() == String.Empty)
            {
                DataObjectMeister dataObject = new DataObjectMeister(Clipboard.GetDataObject());
                if (dataObject.HTMLData != null && dataObject.HTMLData.OnlyImagePath != null)
                {
                    _webImageUrl.Text = dataObject.HTMLData.OnlyImagePath;
                }
            }
            PopulatePreviewBox();
            _webImageUrl.SelectAll();
        }

17. Example

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

18. Example

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

19. Example

Project: Asm4GCN
Source File: FrmMain.cs
View license
private void pasteToolStripButton_Click(object sender, EventArgs e)
        {
            // Source: http://msdn.microsoft.com/en-us/library/system.windows.forms.textboxbase.copy(v=vs.110).aspx
            if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text) == true)
            {
                if (lastSelectedTextControl.SelectionLength > 0)
                        lastSelectedTextControl.SelectionStart = lastSelectedTextControl.SelectionStart 
                            + lastSelectedTextControl.SelectionLength;
                lastSelectedTextControl.Paste();
            }
        }

20. Example

Project: duality
Source File: ProjectFolderView.cs
View license
protected bool ClipboardCanPasteNodes(TreeNodeAdv baseNode)
		{
			DataObject data = Clipboard.GetDataObject() as DataObject;
			return data != null && data.ContainsFileDropList();
		}

21. Example

Project: dp2
Source File: ClipboardUtil.cs
View license
public static string GetClipboardText()
        {
            IDataObject ido = Clipboard.GetDataObject();
            if (ido.GetDataPresent(DataFormats.UnicodeText) == false)
                return "";
            return (string)ido.GetData(DataFormats.UnicodeText);
        }

22. Example

Project: NSMB-Editor
Source File: HexBox.cs
View license
public bool CanPaste()
		{
			if (ReadOnly || !this.Enabled) return false;

			if(_byteProvider == null || !_byteProvider.SupportsInsertBytes())
				return false;

			if(!_byteProvider.SupportsDeleteBytes() && _selectionLength > 0)
				return false;

			IDataObject da = Clipboard.GetDataObject();
			if(da.GetDataPresent("BinaryData"))
				return true;
			else if(da.GetDataPresent(typeof(string)))
				return true;
			else
				return false;
		}

23. Example

Project: tesvsnip
Source File: MainView.cs
View license
internal static object GetClipboardData()
        {
            if (Settings.Default.UseWindowsClipboard)
            {
                var od = System.Windows.Forms.Clipboard.GetDataObject();
                if (od != null)
                {
                    var cliptype = od.GetData("TESVSnip");
                    if (cliptype is string)
                    {
                        return od.GetData(cliptype.ToString());
                    }
                }

                return null;
            }

            return s_clipboard;
        }

24. Example

Project: tesvsnip
Source File: HexBox.cs
View license
public bool CanPaste()
        {
            if (ReadOnly || !Enabled) return false;

            if (_byteProvider == null || !_byteProvider.SupportsInsertBytes())
                return false;

            if (!_byteProvider.SupportsDeleteBytes() && _selectionLength > 0)
                return false;

            IDataObject da = Clipboard.GetDataObject();
            if (da.GetDataPresent("BinaryData"))
                return true;
            else if (da.GetDataPresent(typeof (string)))
                return true;
            else
                return false;
        }

25. Example

Project: falloutsnip
Source File: MainView.Selection.cs
View license
internal static object GetClipboardData()
        {
            if (Settings.Default.UseWindowsClipboard)
            {
                var od = System.Windows.Forms.Clipboard.GetDataObject();
                if (od != null)
                {
                    var cliptype = od.GetData("FalloutSnip");
                    if (cliptype is string)
                    {
                        return od.GetData(cliptype.ToString());
                    }
                }

                return null;
            }

            return s_clipboard;
        }

26. Example

Project: falloutsnip
Source File: HexBox.cs
View license
public bool CanPaste()
        {
            if (ReadOnly || !Enabled) return false;

            if (_byteProvider == null || !_byteProvider.SupportsInsertBytes())
                return false;

            if (!_byteProvider.SupportsDeleteBytes() && _selectionLength > 0)
                return false;

            IDataObject da = Clipboard.GetDataObject();
            if (da.GetDataPresent("BinaryData"))
                return true;
            else if (da.GetDataPresent(typeof (string)))
                return true;
            else
                return false;
        }

27. Example

Project: fomm
Source File: HexBox.cs
View license
public bool CanPaste()
    {
      if (ReadOnly || !Enabled)
      {
        return false;
      }

      if (_byteProvider == null || !_byteProvider.SupportsInsertBytes())
      {
        return false;
      }

      if (!_byteProvider.SupportsDeleteBytes() && _selectionLength > 0)
      {
        return false;
      }

      var da = Clipboard.GetDataObject();
      if (da.GetDataPresent("BinaryData"))
      {
        return true;
      }

      if (da.GetDataPresent(typeof (string)))
      {
        return true;
      }
      return false;
    }

28. Example

View license
public bool FilterMessage(ref Message m)
        {
            if (!enabled)
            {
         /n ..... /n //View Source file for more details /n }

29. Example

Project: NBTExplorer
Source File: HexBox.cs
View license
public bool CanPaste()
		{
			if (ReadOnly || !this.Enabled) return false;

			if(_byteProvider == null || !_byteProvider.SupportsInsertBytes())
				return false;

			if(!_byteProvider.SupportsDeleteBytes() && _selectionLength > 0)
				return false;

			IDataObject da = Clipboard.GetDataObject();
			if(da.GetDataPresent("BinaryData"))
				return true;
			else if(da.GetDataPresent(typeof(string)))
				return true;
			else
				return false;
		}

30. Example

Project: Pyramid
Source File: TextAreaClipboardHandler.cs
View license
public void Paste(object sender, EventArgs e)
		{
			if (!textArea.EnableCutOrPaste) {
				return;
			}
			// Clipboard.GetDataObject may throw an exception...
			for (int i = 0;; i++) {
				try {
					IDataObject data = Clipboard.GetDataObject();
					if (data == null)
						return;
					bool fullLine = data.GetDataPresent(LineSelectedType);
					if (data.GetDataPresent(DataFormats.UnicodeText)) {
						string text = (string)data.GetData(DataFormats.UnicodeText);
						if (text.Length > 0) {
							textArea.Document.UndoStack.StartUndoGroup();
							try {
								if (textArea.SelectionManager.HasSomethingSelected) {
									textArea.Caret.Position = textArea.SelectionManager.SelectionCollection[0].StartPosition;
									textArea.SelectionManager.RemoveSelectedText();
								}
								if (fullLine) {
									int col = textArea.Caret.Column;
									textArea.Caret.Column = 0;
									if (!textArea.IsReadOnly(textArea.Caret.Offset))
										textArea.InsertString(text);
									textArea.Caret.Column = col;
								} else {
									// textArea.EnableCutOrPaste already checked readonly for this case
									textArea.InsertString(text);
								}
							} finally {
								textArea.Document.UndoStack.EndUndoGroup();
							}
						}
					}
					return;
				} catch (ExternalException) {
					// GetDataObject does not provide RetryTimes parameter
					if (i > 5) throw;
				}
			}
		}

31. Example

Project: lphant
Source File: FormDownloads.cs
View license
private void buttonPasteeLink_Click(object sender, System.EventArgs e)
		{
			string elink="";
			IDataObject iData = Clipboard.GetDataObject();
			if(iData.GetDataPresent(DataFormats.Text)) 
			{
				elink=(String)iData.GetData(DataFormats.Text);
				if (elink!="")
					krnGateway.DownloadElink(elink,false);
			}
		}

32. Example

View license
public static T GetFromClipboard()
        {
            T retrievedObj = null;
            var dataObj = Clipboard.GetDataObject();
            var format = typeof(T).FullName;
            if (dataObj.GetDataPresent(format))
            {
                retrievedObj = dataObj.GetData(format) as T;
            }
            return retrievedObj;
        }

33. Example

View license
public static T GetFromClipboard()
        {
            T retrievedObj = null;
            IDataObject dataObj = Clipboard.GetDataObject();            
            string format = typeof(T).FullName;
            if (dataObj.GetDataPresent(format))
            {
                retrievedObj = dataObj.GetData(format) as T;                
            }
            return retrievedObj;
        }

34. Example

Project: My-FyiReporting
Source File: DesignCtl.cs
View license
private void menuContext_Popup(object sender, EventArgs e)
		{
			var bEnable = _DrawPanel.SelectedCount > 0;

			MenuDefaultCopy.Enabled = bEnable;
			MenuDefaultDelete.Enabled = bEnable;

			var al = new List<XmlNode>();

			var iData = Clipboard.GetDataObject();

			if (iData == null)
				bEnable = false;
			else if (iData.GetDataPresent(al.GetType()))
				bEnable = true;
			else if (iData.GetDataPresent(DataFormats.Text)) 
				bEnable = true;
			else if (iData.GetDataPresent(DataFormats.Bitmap)) 
				bEnable = true;
			else
				bEnable = false;

			MenuDefaultPaste.Enabled = bEnable;
			MenuChartPaste.Enabled = bEnable;
			MenuGridPaste.Enabled = bEnable;
			MenuMatrixPaste.Enabled = bEnable;
			MenuSubreportPaste.Enabled = bEnable;
			MenuTablePaste.Enabled = bEnable;
		}

35. Example

Project: My-FyiReporting
Source File: RdlDesigner.cs
View license
private void menuEditPaste_Click(object sender, System.EventArgs ea)
        {
            if (this.ctlEditTextbox != null && ctlEditTextbox.Focused)
            {
                ctlEditTextbox.Paste();
                return;
            }

            RdlEditPreview e = GetEditor();
            if (e == null)
                return;

            if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text) == true ||
                Clipboard.GetDataObject().GetDataPresent(DataFormats.Bitmap) == true)
                e.Paste();
        }

36. Example

Project: My-FyiReporting
Source File: DesignXmlDraw.cs
View license
public bool CanPaste()
        {
            if (MapDoc == null)
                return false;

            IDataObject iData = Clipboard.GetDataObject();
            if (iData == null)
                return false;
            if (!iData.GetDataPresent(DataFormats.Text))
                return false;
            // Build the xml string in case it is a straight pasting of text
            string t = (string)iData.GetData(DataFormats.Text);
            if (!(t.StartsWith("<MapItems>") && t.EndsWith("</MapItems>")))
                return false;

            return true;
        }

37. Example

Project: ME3Explorer
Source File: HexBox.cs
View license
public bool CanPaste()
        {
            if (ReadOnly || !this.Enabled) return false;

            if (_byteProvider == null || !_byteProvider.SupportsInsertBytes())
                return false;

            if (!_byteProvider.SupportsDeleteBytes() && _selectionLength > 0)
                return false;

            IDataObject da = Clipboard.GetDataObject();
            if (da.GetDataPresent("BinaryData"))
                return true;
            else if (da.GetDataPresent(typeof(string)))
                return true;
            else
                return false;
        }

38. Example

Project: mwinapi
Source File: MainForm.cs
View license
private void fetchClipboardEntry(bool allowDuplicate)
        {
            IDataObject ido = Clipboard.GetDataObject();
            ClipboardEntry ce = new ClipboardEntry(ido);
            byte[] serialized = ce.Serialize();
            byte[] reserialized = new ClipboardEntry(ce.Serialize(), "").Serialize();
            if (!ArrayEquals(serialized, reserialized))
            {
                MessageBox.Show("Warning: Unserializable clipboard entry detected");
            }
            if (!allowDuplicate && clips.Items.Count > 0 &&
                ArrayEquals(serialized, ((ClipboardEntry)clips.Items[0].Tag).Serialize()))
            {
                return;
            }
            string key = "image" + (counter++);
            previewImages.Images.Add(key, ce.PreviewImage);

            ListViewItem lvi = new ListViewItem(ce.Caption, previewImages.Images.IndexOfKey(key));
            lvi.Tag = ce;
            clips.Items.Insert(0, lvi);
        }

39. Example

Project: OpenLiveWriter
Source File: HtmlEditorControl.cs
View license
private void PasteOverSelection(IHtmlEditorSelection selection)
        {
            if (!IsValidCo/n ..... /n //View Source file for more details /n }

40. Example

Project: Be.HexEditor
Source File: HexBox.cs
View license
public bool CanPaste()
		{
			if (ReadOnly || !this.Enabled) return false;

			if (_byteProvider == null || !_byteProvider.SupportsInsertBytes())
				return false;

			if (!_byteProvider.SupportsDeleteBytes() && _selectionLength > 0)
				return false;

			IDataObject da = Clipboard.GetDataObject();
			if (da.GetDataPresent("BinaryData"))
				return true;
			else if (da.GetDataPresent(typeof(string)))
				return true;
			else
				return false;
		}

41. Example

Project: poderosa
Source File: ExtendPastePlugin.cs
View license
public bool CanExecute(ICommandTarget target) {
            IPoderosaView view;
            ITerminalSession session;

            if (!GetViewAndSession(target, out view, out session)) return false;
            var clipboardData = Clipboard.GetDataObject();
            if (!clipboardData.GetDataPresent("Text")) return false;

            return true;
        }

42. Example

Project: poderosa
Source File: CopyPaste.cs
View license
private string GetClipboardText() {
            var clipboardData = Clipboard.GetDataObject();
            if (clipboardData != null) {
                if (clipboardData.GetDataPresent(DataFormats.UnicodeText)) {
                    return clipboardData.GetData(DataFormats.UnicodeText) as string;
                }
                if (clipboardData.GetDataPresent(DataFormats.Text)) {
                    return clipboardData.GetData(DataFormats.Text) as string;
                }
            }
            return null;
        }

43. Example

Project: poderosa
Source File: CopyPaste.cs
View license
public bool CanExecute(ICommandTarget target) {
            IPoderosaView view;
            ITerminalSession session;
            if (!GetViewAndSession(target, out view, out session))
                return false;
            var clipboardData = Clipboard.GetDataObject();
            if (clipboardData == null || (
                       !clipboardData.GetDataPresent(DataFormats.UnicodeText)
                    && !clipboardData.GetDataPresent(DataFormats.Text))) {
                return false;
            }
            return true;
        }

44. Example

View license
private static void GetHtmlFromClipboard(
			out string htmlCode,
			out byte[] originalBuffer )
		{
			originalBuffer = GetHtmlFromDataObject( Clipboard.GetDataObject() );
			htmlCode = Encoding.UTF8.GetString( originalBuffer );
		}

45. Example

Project: winauth
Source File: WinAuthForm.cs
View license
public object GetClipboardData(Type format)
		{
			bool clipRetry = false;
			do
			{
				try
				{
					IDataObject clipdata = Clipboard.GetDataObject();
					return (clipdata != null ? clipdata.GetData(format) : null);
				}
				catch (ExternalException)
				{
					// only show an error the first time
					clipRetry = (MessageBox.Show(this, strings.ClipboardInUse,
						WinAuthMain.APPLICATION_NAME,
						MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.Yes);
				}
			}
			while (clipRetry == true);

			return null;
		}

46. Example

View license
public void Paste()
    {
      if (!_textArea.EnableCutOrPaste)
        return;

      // Clipboard/n ..... /n //View Source file for more details /n }

47. Example

Project: Open-Exam-Suite
Source File: UI.cs
View license
private void Paste(object sender, EventArgs e)
        {
            if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
            {
                if (txt_question_text.SelectionLength > 0)
                {
                    if (MessageBox.Show("Do you want to paste over current selection?", "Confirmation", MessageBoxButtons.YesNo) == DialogResult.No)
                        txt_question_text.SelectionStart = txt_question_text.SelectionStart + txt_question_text.SelectionLength;
                }
                txt_question_text.Paste();
            }
        }

48. Example

Project: naps2
Source File: FDesktop.cs
View license
private void PasteImages()
        {
            var ido = Clipboard.GetDataObject();
            if (ido == null)
            {
                return;
            }
            if (ido.GetDataPresent(typeof(DirectImageTransfer).FullName))
            {
                var data = (DirectImageTransfer)ido.GetData(typeof(DirectImageTransfer).FullName);
                ImportDirect(data, true);
            }
        }

49. Example

Project: naps2
Source File: FProfiles.cs
View license
private void ctxPaste_Click(object sender, EventArgs e)
        {
            if (appConfigManager.Config.NoUserProfiles && profileManager.Profiles.Any(x => x.IsLocked))
            {
                return;
            }
            var ido = Clipboard.GetDataObject();
            if (ido == null)
            {
                return;
            }
            if (ido.GetDataPresent(typeof(DirectProfileTransfer).FullName))
            {
                var data = (DirectProfileTransfer)ido.GetData(typeof(DirectProfileTransfer).FullName);
                AddProfile(data.ScanProfile);
            }
        }

50. Example

Project: dp2
Source File: WebCamera.cs
View license
public Image Capture()
        {
            showVideo.SendMessage(this.lwndC, 0x41e, 0, 0);
            IDataObject obj1 = Clipboard.GetDataObject();
            if (obj1.GetDataPresent(typeof(Bitmap)))
            {
                return (Image)obj1.GetData(typeof(Bitmap));
            }

            return null;
        }