System.Windows.Forms.DataObject.SetData(object)

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

41 Examples 7

1. Example

Project: sharpshell
Source File: CopyPathDataHandler.cs
View license
protected override DataObject GetData()
        {
            //  Create a data object.
            var dataObject = new DataObject();

            //  Set the path as the data.
            dataObject.SetData(DataFormats.UnicodeText, SelectedItemPath);

            //  Return the data object.
            return dataObject;
        }

2. Example

View license
public static IDataObject CreateFrom(IHTMLElement element, string editorId)
        {
            // create a new new data object
            DataObject dataObject = new DataObject();

            //add internal format
            if (element != null)
            {
                dataObject.SetData(INTERNAL_SMART_CONTENT_DATAFORMAT, element.id);
                dataObject.SetData(INSTANCE_ID_DATAFORMAT, editorId);
            }

            // return the data object
            return dataObject;
        }

3. Example

Project: PowerPointLabs
Source File: ColorPane.cs
View license
private void StartDragDrop(object sender)
        {
            DataObject colorObject = new DataObject();
            colorObject.SetData(((Panel)sender).BackColor);
            DoDragDrop(colorObject, DragDropEffects.All);
        }

4. Example

Project: duality
Source File: ProjectFolderView.cs
View license
protected void AppendNodesToData(DataObject data, IEnumerable<TreeNodeAdv> nodes)
		{
			data.SetData(nodes.ToArray());
			data.SetContentRefs(
				from c in nodes
				where c.Tag is ResourceNode
				select (c.Tag as ResourceNode).ResLink as IContentRef);
			data.SetFiles(
				from c in nodes
				where c.Tag is NodeBase && !ContentProvider.IsDefaultContentPath((c.Tag as NodeBase).NodePath)
				select (c.Tag as NodeBase).NodePath);
		}

5. Example

Project: Bulk-Crap-Uninstaller
Source File: DragSource.cs
View license
public void CreateTextFormats() {
            IList<OLVColumn> columns = this.IncludeHiddenCol/n ..... /n //View Source file for more details /n }

6. Example

Project: P8Coder
Source File: FastColoredTextBox.cs
View license
protected virtual void OnCreateClipboardData(DataObject data)
        {
            var exp = new ExportToHTML();
            exp.UseBr = false;
            exp.UseNbsp = false;
            exp.UseStyleTag = true;
            string html = "<pre>" + exp.GetHtml(Selection.Clone()) + "</pre>";

            data.SetData(DataFormats.UnicodeText, true, Selection.Text);
            data.SetData(DataFormats.Html, PrepareHtmlForClipboard(html));
            data.SetData(DataFormats.Rtf, new ExportToRTF().GetRtf(Selection.Clone()));
        }

7. Example

Project: dash-core
Source File: FastColoredTextBox.cs
View license
protected virtual void OnCreateClipboardData(DataObject data)
        {
            var exp = new ExportToHTML();
            exp.UseBr = false;
            exp.UseNbsp = false;
            exp.UseStyleTag = true;
            string html = "<pre>" + exp.GetHtml(Selection.Clone()) + "</pre>";

            data.SetData(DataFormats.UnicodeText, true, Selection.Text);
            data.SetData(DataFormats.Html, PrepareHtmlForClipboard(html));
            data.SetData(DataFormats.Rtf, new ExportToRTF().GetRtf(Selection.Clone()));
        }

8. Example

Project: ynoteclassic
Source File: FastColoredTextBox.cs
View license
protected virtual void OnCreateClipboardData(DataObject data)
		{
			var exp = new ExportToHTML();
			exp.UseBr = false;
			exp.UseNbsp = false;
			exp.UseStyleTag = true;
			string html = "<pre>" + exp.GetHtml(Selection.Clone()) + "</pre>";

			data.SetData(DataFormats.UnicodeText, true, Selection.Text);
			data.SetData(DataFormats.Html, PrepareHtmlForClipboard(html));
			data.SetData(DataFormats.Rtf, new ExportToRTF().GetRtf(Selection.Clone()));
		}

9. Example

Project: ClearCanvas
Source File: GalleryView.cs
View license
private void OnItemDrag(object sender, ItemDragEventArgs e)
		{
			// Only allow dragging of one item at a time, so deselect all other items
			foreach (ListViewItem lvi in _listView.Items)
			{
				if (lvi != e.Item)
					lvi.Selected = false;
			}

			ListViewItem draggedItem = (ListViewItem) e.Item;
			var galleryItem = (IGalleryItem) draggedItem.Tag;

			DataObject data = new DataObject();
			if (DragOutside)
			{
				data.SetData(galleryItem.Item);
				data.SetText(galleryItem.Item.ToString(), TextDataFormat.UnicodeText);
			}

			// allow event listeners to specify additional formats
			var galleryItemDragEventArgs = new GalleryItemDragEventArgs(galleryItem);
			OnItemDrag(galleryItemDragEventArgs);
			foreach (var additionalData in galleryItemDragEventArgs.AdditionalDataFormats)
				data.SetData(additionalData);

			// in order for drag reorder to work, we do this last to ensure that the ListViewItem format is always our item
			if (DragReorder)
			{
				data.SetData(draggedItem);
			}

			_listView.DoDragDrop(data, DragDropEffects.Move);
		}

10. Example

Project: WsdlUI
Source File: TextAreaMouseHandler.cs
View license
void TextAreaMouseMove(object sender, MouseEventArgs e)
		{
			textArea.mousepos = e.Location;

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

11. Example

Project: Pyramid
Source File: TextAreaMouseHandler.cs
View license
void TextAreaMouseMove(object sender, MouseEventArgs e)
		{
			textArea.mousepos = e.Location;

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

12. Example

Project: fdotoolbox
Source File: TextAreaMouseHandler.cs
View license
void TextAreaMouseMove(object sender, MouseEventArgs e)
		{
			Point mousepos = textArea.mousepos;

			// honour the starting selection strategy
			switch (textArea.SelectionManager.selectFrom.where)
			{
				case WhereFrom.Gutter:
					//moveGutter(sender, e);
					ExtendSelectionToMouse();
					break;

				case WhereFrom.TArea:
					break;

			}
			textArea.ShowHiddenCursor(false);
			if (dodragdrop) {
				dodragdrop = false;
				return;
			}
			
			doubleclick = false;
			textArea.mousepos = new Point(e.X, e.Y);
			
			if (clickedOnSelectedText) {
				if (Math.Abs(mousedownpos.X - mousepos.X) >= SystemInformation.DragSize.Width / 2 ||
				    Math.Abs(mousedownpos.Y - mousepos.Y) >= SystemInformation.DragSize.Height / 2)
				{
					clickedOnSelectedText = false;
					ISelection selection = textArea.SelectionManager.GetSelectionAt(textArea.Caret.Offset);
					if (selection != null) {
						string text = selection.SelectedText;
						if (text != null && text.Length > 0) {
							DataObject dataObject = new DataObject ();
							dataObject.SetData(DataFormats.UnicodeText, true, text);
							dataObject.SetData(selection);
							dodragdrop = true;
							textArea.DoDragDrop(dataObject, DragDropEffects.All);
						}
					}
				}
				
				return;
			}
			
			if (e.Button == MouseButtons.Left) {
				if (gotmousedown && textArea.SelectionManager.selectFrom.where == WhereFrom.TArea)
				{
					ExtendSelectionToMouse();
				}
			}
		}

13. Example

View license
public void CreateTextFormats() {

            OLVExporter exporter = this.CreateExporter();

            // Put both the text and html versions onto the clipboard.
            // For some reason, SetText() with UnicodeText doesn't set the basic CF_TEXT format,
            // but using SetData() does.
            //this.SetText(sbText.ToString(), TextDataFormat.UnicodeText);
            this.SetData(exporter.ExportTo(OLVExporter.ExportFormat.TabSeparated));
            string exportTo = exporter.ExportTo(OLVExporter.ExportFormat.CSV);
            if (!String.IsNullOrEmpty(exportTo))
                this.SetText(exportTo, TextDataFormat.CommaSeparatedValue);
            this.SetText(ConvertToHtmlFragment(exporter.ExportTo(OLVExporter.ExportFormat.HTML)), TextDataFormat.Html);
        }

14. Example

Project: ecsharp
Source File: TextAreaMouseHandler.cs
View license
void TextAreaMouseMove(object sender, MouseEventArgs e)
		{
			textArea.mousepos = e.Location;

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

15. Example

View license
void TextAreaMouseMove(object sender, MouseEventArgs e)
		{
			textArea.mousepos = e.Location;

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

16. Example

View license
void TextAreaMouseMove(object sender, MouseEventArgs e)
		{
			textArea.mousepos = e.Location;

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

17. Example

Project: WsdlUI
Source File: TextAreaClipboardHandler.cs
View license
bool CopyTextToClipboard(string stringToCopy, bool asLine)
		{
			if (stringToCopy.Length > 0) {
				DataObject dataObject = new DataObject();
				dataObject.SetData(DataFormats.UnicodeText, true, stringToCopy);
				if (asLine) {
					MemoryStream lineSelected = new MemoryStream(1);
					lineSelected.WriteByte(1);
					dataObject.SetData(LineSelectedType, false, lineSelected);
				}
				// Default has no highlighting, therefore we don't need RTF output
				if (textArea.Document.HighlightingStrategy.Name != "Default") {
					dataObject.SetData(DataFormats.Rtf, RtfWriter.GenerateRtf(textArea));
				}
				OnCopyText(new CopyTextEventArgs(stringToCopy));
				
				SafeSetClipboard(dataObject);
				return true;
			} else {
				return false;
			}
		}

18. Example

Project: Pyramid
Source File: TextAreaClipboardHandler.cs
View license
bool CopyTextToClipboard(string stringToCopy, bool asLine)
		{
			if (stringToCopy.Length > 0) {
				DataObject dataObject = new DataObject();
				dataObject.SetData(DataFormats.UnicodeText, true, stringToCopy);
				if (asLine) {
					MemoryStream lineSelected = new MemoryStream(1);
					lineSelected.WriteByte(1);
					dataObject.SetData(LineSelectedType, false, lineSelected);
				}
				// Default has no highlighting, therefore we don't need RTF output
				if (textArea.Document.HighlightingStrategy.Name != "Default") {
					dataObject.SetData(DataFormats.Rtf, RtfWriter.GenerateRtf(textArea));
				}
				OnCopyText(new CopyTextEventArgs(stringToCopy));
				
				SafeSetClipboard(dataObject);
				return true;
			} else {
				return false;
			}
		}

19. Example

Project: logwizard
Source File: OLVDataObject.cs
View license
public void CreateTextFormats() {

            OLVExporter exporter = this.CreateExporter();

            // Put both the text and html versions onto the clipboard.
            // For some reason, SetText() with UnicodeText doesn't set the basic CF_TEXT format,
            // but using SetData() does.
            //this.SetText(sbText.ToString(), TextDataFormat.UnicodeText);
            this.SetData(exporter.ExportTo(OLVExporter.ExportFormat.TabSeparated));
            string exportTo = exporter.ExportTo(OLVExporter.ExportFormat.CSV);
            if (!String.IsNullOrEmpty(exportTo))
                this.SetText(exportTo, TextDataFormat.CommaSeparatedValue);
            this.SetText(ConvertToHtmlFragment(exporter.ExportTo(OLVExporter.ExportFormat.HTML)), TextDataFormat.Html);
        }

20. Example

View license
bool CopyTextToClipboard(string stringToCopy, bool asLine)
		{
			if (stringToCopy.Length > 0) {
				DataObject dataObject = new DataObject();
				dataObject.SetData(DataFormats.UnicodeText, true, stringToCopy);
				if (asLine) {
					MemoryStream lineSelected = new MemoryStream(1);
					lineSelected.WriteByte(1);
					dataObject.SetData(LineSelectedType, false, lineSelected);
				}
				// Default has no highlighting, therefore we don't need RTF output
				if (textArea.Document.HighlightingStrategy.Name != "Default") {
					dataObject.SetData(DataFormats.Rtf, RtfWriter.GenerateRtf(textArea));
				}
				OnCopyText(new CopyTextEventArgs(stringToCopy));
				
				SafeSetClipboard(dataObject);
				return true;
			} else {
				return false;
			}
		}

21. Example

View license
public static IDataObject SerializeActivitiesToDataObject(IServiceProvider serviceProvider, Activity[] activities)
        {
            if (serviceProvider == null)
                throw new ArgumentNullException("serviceProvider");

            if (activities == null)
                throw new ArgumentNullException("activities");

            // get component serialization service
            ComponentSerializationService css = (ComponentSerializationService)serviceProvider.GetService(typeof(ComponentSerializationService));
            if (css == null)
                throw new InvalidOperationException(SR.GetString(SR.General_MissingService, typeof(ComponentSerializationService).Name));

            // serialize all activities to the store
            SerializationStore store = css.CreateStore();
            using (store)
            {
                foreach (Activity activity in activities)
                    css.Serialize(store, activity);
            }

            // wrap it with clipboard style object
            Stream stream = new MemoryStream();
            BinaryFormatter formatter = new BinaryFormatter();
            formatter.Serialize(stream, store);
            stream.Seek(0, SeekOrigin.Begin);
            DataObject dataObject = new DataObject(CF_DESIGNER, stream);
            dataObject.SetData(CF_DESIGNERSTATE, Helpers.SerializeDesignersToStream(activities));
            return dataObject;
        }

22. Example

Project: SystemEx
Source File: OleDataObject.cs
View license
public override object GetData(string format, bool autoConvert)
        {
            if (String.Compare(format, Win32.NativeMethods.CFSTR_FILEDESCRIPTORW, StringComparison.OrdinalIgnoreCase) == 0 && m_SelectedItems != null)
            {
                base.SetData(Win32.NativeMethods.CFSTR_FILEDESCRIPTORW, GetFileDescriptor(m_SelectedItems));
            }
            else if (String.Compare(format, Win32.NativeMethods.CFSTR_FILECONTENTS, StringComparison.OrdinalIgnoreCase) == 0)
            {
                base.SetData(Win32.NativeMethods.CFSTR_FILECONTENTS, GetFileContents(m_SelectedItems, m_lindex));
            }
            else if (String.Compare(format, Win32.NativeMethods.CFSTR_PERFORMEDDROPEFFECT, StringComparison.OrdinalIgnoreCase) == 0)
            {
                //TODO: Cleanup routines after paste has been performed
            }
            return base.GetData(format, autoConvert);
        }

23. Example

Project: ecsharp
Source File: TextAreaClipboardHandler.cs
View license
bool CopyTextToClipboard(string stringToCopy, bool asLine)
		{
			if (stringToCopy.Length > 0) {
				DataObject dataObject = new DataObject();
				dataObject.SetData(DataFormats.UnicodeText, true, stringToCopy);
				if (asLine) {
					MemoryStream lineSelected = new MemoryStream(1);
					lineSelected.WriteByte(1);
					dataObject.SetData(LineSelectedType, false, lineSelected);
				}
				// Default has no highlighting, therefore we don't need RTF output
				if (textArea.Document.HighlightingStrategy.Name != "Default") {
					dataObject.SetData(DataFormats.Rtf, RtfWriter.GenerateRtf(textArea));
				}
				OnCopyText(new CopyTextEventArgs(stringToCopy));
				
				SafeSetClipboard(dataObject);
				return true;
			} else {
				return false;
			}
		}

24. Example

View license
bool CopyTextToClipboard(string stringToCopy, bool asLine)
		{
			if (stringToCopy.Length > 0) {
				DataObject dataObject = new DataObject();
				dataObject.SetData(DataFormats.UnicodeText, true, stringToCopy);
				if (asLine) {
					MemoryStream lineSelected = new MemoryStream(1);
					lineSelected.WriteByte(1);
					dataObject.SetData(LineSelectedType, false, lineSelected);
				}
				// Default has no highlighting, therefore we don't need RTF output
				if (textArea.Document.HighlightingStrategy.Name != "Default") {
					dataObject.SetData(DataFormats.Rtf, RtfWriter.GenerateRtf(textArea));
				}
				OnCopyText(new CopyTextEventArgs(stringToCopy));
				
				SafeSetClipboard(dataObject);
				return true;
			} else {
				return false;
			}
		}

25. Example

View license
bool CopyTextToClipboard(string stringToCopy, bool asLine)
		{
			if (stringToCopy.Length > 0) {
				DataObject dataObject = new DataObject();
				dataObject.SetData(DataFormats.UnicodeText, true, stringToCopy);
				if (asLine) {
					MemoryStream lineSelected = new MemoryStream(1);
					lineSelected.WriteByte(1);
					dataObject.SetData(LineSelectedType, false, lineSelected);
				}
				// Default has no highlighting, therefore we don't need RTF output
				if (textArea.Document.HighlightingStrategy.Name != "Default") {
					dataObject.SetData(DataFormats.Rtf, RtfWriter.GenerateRtf(textArea));
				}
				OnCopyText(new CopyTextEventArgs(stringToCopy));
				
				SafeSetClipboard(dataObject);
				return true;
			} else {
				return false;
			}
		}

26. Example

View license
bool CopyTextToClipboard(string stringToCopy, bool asLine)
    {
      if (stringToCopy.Length > 0)
      {
        DataObject dataObject = new DataObject();
        dataObject.SetData(DataFormats.UnicodeText, true, stringToCopy);
        if (asLine)
        {
          MemoryStream lineSelected = new MemoryStream(1);
          lineSelected.WriteByte(1);
          dataObject.SetData(LineSelectedType, false, lineSelected);
        }
        // Default has no highlighting, therefore we don't need RTF output
        if (_textArea.Document.HighlightingStrategy.Name != "Default")
        {
          dataObject.SetData(DataFormats.Rtf, RtfWriter.GenerateRtf(_textArea));
        }
        OnCopyText(new CopyTextEventArgs(stringToCopy));

        SafeSetClipboard(dataObject);
        return true;
      }
      else
      {
        return false;
      }
    }

27. Example

Project: SquareOne
Source File: TextAreaMouseHandler.cs
View license
void TextAreaMouseMove(object sender, MouseEventArgs e)
    {
      _textArea.MousePositionInternal /n ..... /n //View Source file for more details /n }

28. Example

Project: SquareOne
Source File: OLVDataObject.cs
View license
public void CreateTextFormats() {

            OLVExporter exporter = this.CreateExporter();

            // Put both the text and html versions onto the clipboard.
            // For some reason, SetText() with UnicodeText doesn't set the basic CF_TEXT format,
            // but using SetData() does.
            //this.SetText(sbText.ToString(), TextDataFormat.UnicodeText);
            this.SetData(exporter.ExportTo(OLVExporter.ExportFormat.TabSeparated));
            string exportTo = exporter.ExportTo(OLVExporter.ExportFormat.CSV);
            if (!String.IsNullOrEmpty(exportTo))
                this.SetText(exportTo, TextDataFormat.CommaSeparatedValue);
            this.SetText(ConvertToHtmlFragment(exporter.ExportTo(OLVExporter.ExportFormat.HTML)), TextDataFormat.Html);
        }

29. Example

Project: dp2
Source File: Global.cs
View license
public static void CopyLinesToClipboard(
            Form form,
            string strFormat,
      /n ..... /n //View Source file for more details /n }

30. Example

Project: MapViewer
Source File: OLVDataObject.cs
View license
public void CreateTextFormats() {

            OLVExporter exporter = this.CreateExporter();

            // Put both the text and html versions onto the clipboard.
            // For some reason, SetText() with UnicodeText doesn't set the basic CF_TEXT format,
            // but using SetData() does.
            //this.SetText(sbText.ToString(), TextDataFormat.UnicodeText);
            this.SetData(exporter.ExportTo(OLVExporter.ExportFormat.TabSeparated));
            string exportTo = exporter.ExportTo(OLVExporter.ExportFormat.CSV);
            if (!String.IsNullOrEmpty(exportTo))
                this.SetText(exportTo, TextDataFormat.CommaSeparatedValue);
            this.SetText(ConvertToHtmlFragment(exporter.ExportTo(OLVExporter.ExportFormat.HTML)), TextDataFormat.Html);
        }

31. Example

Project: SqlNexus
Source File: fmnexus.as.resource.cs
View license
private void ExportReport(ReportExportType exporttype, string filename)
        {
            string/n ..... /n //View Source file for more details /n }

32. Example

Project: SqlNexus
Source File: fmNexus.cs
View license
private void ExportReport(ReportExportType exporttype, string filename)
        {
            string/n ..... /n //View Source file for more details /n }

33. Example

Project: log2console
Source File: TextAreaMouseHandler.cs
View license
void TextAreaMouseMove(object sender, MouseEventArgs e)
		{
			textArea.mousepos = e.Location;

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

34. Example

Project: tesvsnip
Source File: OLVDataObject.cs
View license
public void CreateTextFormats()
        {
            IList<OLVColumn> columns = IncludeHidden/n ..... /n //View Source file for more details /n }

35. Example

Project: falloutsnip
Source File: OLVDataObject.cs
View license
public void CreateTextFormats()
        {
            IList<OLVColumn> columns = IncludeHidden/n ..... /n //View Source file for more details /n }

36. Example

Project: logwizard
Source File: DragSource.cs
View license
public void CreateTextFormats() {
            IList<OLVColumn> columns = this.IncludeHiddenCol/n ..... /n //View Source file for more details /n }

37. Example

Project: SquareOne
Source File: DragSource.cs
View license
public void CreateTextFormats() {
            IList<OLVColumn> columns = this.IncludeHiddenCol/n ..... /n //View Source file for more details /n }

38. Example

Project: MapViewer
Source File: DragSource.cs
View license
public void CreateTextFormats() {
            IList<OLVColumn> columns = this.IncludeHiddenCol/n ..... /n //View Source file for more details /n }

39. Example

Project: duality
Source File: SceneView.cs
View license
protected void AppendNodesToData(DataObject data, IEnumerable<TreeNodeAdv> nodes, bool guardRe/n ..... /n //View Source file for more details /n }

40. Example

View license
private void OnItemDrag(object sender, ItemDragEventArgs e)
		{
			List<IGalleryItem> list = n/n ..... /n //View Source file for more details /n }

41. Example

View license
public virtual void Copy()
        {
            Range selectionToRestore = null;
            if (Selection.IsEmpty)
            {
                selectionToRestore = Selection.Clone();
                Selection.Expand();
            }
            if (!Selection.IsEmpty)
            {
                var exp = new ExportToHTML();
                exp.UseBr = false;
                exp.UseNbsp = false;
                exp.UseStyleTag = true;
                string html = "<pre>" + exp.GetHtml(Selection.Clone()) + "</pre>";
                var data = new DataObject();
                data.SetData(DataFormats.UnicodeText, true, Selection.Text);
                data.SetData(DataFormats.Html, PrepareHtmlForClipboard(html));
                data.SetData(DataFormats.Rtf, new ExportToRTF().GetRtf(Selection.Clone()));
                //
                var thread = new Thread(() => SetClipboard(data));
                thread.SetApartmentState(ApartmentState.STA);
                thread.Start();
                thread.Join();

                if (selectionToRestore != null)
                {
                    Selection = selectionToRestore;
                }
            }
        }