Here are the examples of the csharp api class System.Windows.Forms.DataObject.SetData(string, object) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
41 Examples
0
1. Example
View licenseprivate void SetDataPriv() { if(m_strText != null) ClipboardUtil.Copy(m_strText, false, false, null, null, IntPtr.Zero); else if(m_vContents != null) { DataObject dObj = new DataObject(); foreach(KeyValuePair<string, object> kvp in m_vContents) dObj.SetData(kvp.Key, kvp.Value); ClipboardUtil.Clear(); Clipboard.SetDataObject(dObj); } }
0
2. Example
View licensepublic 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; }
0
3. Example
View licensepublic static void CopyToClipboard(string plainText) { var dataObject = new DataObject(); dataObject.SetData(DataFormats.Text, plainText); dataObject.SetData(DataFormats.UnicodeText, plainText); Clipboard.SetDataObject(dataObject, true); }
0
4. Example
View licenseprotected 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())); }
0
5. Example
View licenseprotected 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())); }
0
6. Example
View licenseprivate void Copy() { // Instantiate the data object. DataObject dataObject = new DataObject(); // Set a Text format with the selected entries string. dataObject.SetData(DataFormats.Text, SelectedEntriesString()); // Finally, set the data object on the clipboard. Clipboard.SetDataObject(dataObject, true); }
0
7. Example
View licenseprotected 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())); }
0
8. Example
View licenseinternal static void SetClipboardData(object value) { if (Settings.Default.UseWindowsClipboard) { var cloneable = value as ICloneable; if (cloneable != null) { var ido = new DataObject(); var srFormat = value.GetType().FullName; ido.SetData(srFormat, cloneable.Clone()); ido.SetData("TESVSnip", srFormat); System.Windows.Forms.Clipboard.Clear(); System.Windows.Forms.Clipboard.SetDataObject(ido, true); } } else { s_clipboard = value; } }
0
9. Example
View licenseinternal static void SetClipboardData(object value) { if (Settings.Default.UseWindowsClipboard) { var cloneable = value as ICloneable; if (cloneable != null) { var ido = new DataObject(); var srFormat = value.GetType().FullName; ido.SetData(srFormat, cloneable.Clone()); ido.SetData("FalloutSnip", srFormat); System.Windows.Forms.Clipboard.Clear(); System.Windows.Forms.Clipboard.SetDataObject(ido, true); } } else { s_clipboard = value; } }
0
10. Example
View licenseprivate static DataObject new_data_object(string html, string plain) { html = html ?? String.Empty; var fragment = html_data_string(html); if (Environment.Version.Major < 4 && html.Length != Encoding.UTF8.GetByteCount(html)) fragment = Encoding.Default.GetString(Encoding.UTF8.GetBytes(fragment)); var dataObject = new DataObject(); dataObject.SetData(DataFormats.Html, fragment); dataObject.SetData(DataFormats.Text, plain); dataObject.SetData(DataFormats.UnicodeText, plain); return dataObject; }
0
11. Example
View licensepublic override object GetData(string format, bool autoConvert) { if (format == DataFormats.Bitmap || format == typeof(Bitmap).FullName) { PrepareImageFile(); base.SetData(DataFormats.Bitmap, this.FileName); } else if (format == DataFormats.FileDrop || format == "FileName" || format == "FileNameW") { PrepareImageFile(); base.SetData(DataFormats.FileDrop, new string[] { this.FileName }); } else if (format == QQ_RichEdit_Format) { PrepareImageFile(); byte[] buffer = Encoding.Default.GetBytes(GetQQRichFormatString()); this.SetData(QQ_RichEdit_Format, new MemoryStream(buffer)); } else if (format == QQ_Unicode_RichEdit_Format) { PrepareImageFile(); byte[] buffer = Encoding.Unicode.GetBytes(GetQQRichFormatString()); this.SetData(QQ_Unicode_RichEdit_Format, new MemoryStream(buffer)); } return base.GetData(format, autoConvert); }
0
12. Example
View licensepublic static DataObject CreateDataObject(string html, string plainText) { html = html ?? String.Empty; var htmlFragment = GetHtmlDataString(html); // re-encode the string so it will work correctly (fixed in CLR 4.0) if (Environment.Version.Major < 4 && html.Length != Encoding.UTF8.GetByteCount(html)) htmlFragment = Encoding.Default.GetString(Encoding.UTF8.GetBytes(htmlFragment)); var dataObject = new DataObject(); dataObject.SetData(DataFormats.Html, htmlFragment); dataObject.SetData(DataFormats.Text, plainText); dataObject.SetData(DataFormats.UnicodeText, plainText); return dataObject; }
0
13. Example
View licensepublic static DataObject CreateDataObject(string html, string plainText) { html = html ?? String.Empty; var htmlFragment = GetHtmlDataString(html); // re-encode the string so it will work correctly (fixed in CLR 4.0) if (Environment.Version.Major < 4 && html.Length != Encoding.UTF8.GetByteCount(html)) htmlFragment = Encoding.Default.GetString(Encoding.UTF8.GetBytes(htmlFragment)); var dataObject = new DataObject(); dataObject.SetData(DataFormats.Html, htmlFragment); dataObject.SetData(DataFormats.Text, plainText); dataObject.SetData(DataFormats.UnicodeText, plainText); return dataObject; }
0
14. Example
View licenseobject IDataObject.GetData(string format, bool autoConvert) { bool isCached = this.dataCache.GetDataPresent(format, autoConvert) || this.dataCache.GetWrappedDataPresent(format); if (!isCached) { object obj; if (this.data.GetDataPresent(format, autoConvert)) obj = this.data.GetData(format, autoConvert); else if (this.data.GetWrappedDataPresent(format)) obj = this.data.GetWrappedData(format); else obj = null; if (obj != null) this.dataCache.SetData(format, obj); } return this.dataCache.GetData(format, autoConvert); }
0
15. Example
View licenseprotected override void OnMouseMove(MouseEventArgs mea) { // Update the popup only if the image selection has changed if (ClientRectangle.Contains(new Point(mea.X, mea.Y))) { if (EnableDragDrop && _bIsMouseDown) { int nImage = _nCoordY * _nColumns + _nCoordX; DataObject data = new DataObject(); data.SetData(DataFormats.Text, nImage.ToString()); data.SetData(DataFormats.Bitmap, _imageList.Images[nImage]); DragDropEffects dde = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Move); _bIsMouseDown = false; } if ((mea.X / _nItemWidth != _nCoordX) || (mea.Y / _nItemHeight != _nCoordY)) { _nCoordX = mea.X / _nItemWidth; _nCoordY = mea.Y / _nItemHeight; Invalidate(); } } else { _nCoordX = -1; _nCoordY = -1; Invalidate(); } base.OnMouseMove(mea); }
0
16. Example
View licensepublic virtual object Copy() { // copy selected text in the selected annotation?/n ..... /n //View Source file for more details /n }
0
17. Example
View licensebool 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; } }
0
18. Example
View licenseprotected void ClipboardCutNodes(IEnumerable<TreeNodeAdv> nodes) { DataObject data = new DataObject(); this.AppendNodesToData(data, nodes); Clipboard.SetDataObject(data, true); byte[] moveEffect = new byte[] {2, 0, 0, 0}; MemoryStream dropEffect = new MemoryStream(); dropEffect.Write(moveEffect, 0, moveEffect.Length); data.SetData("Preferred DropEffect", dropEffect); Clipboard.Clear(); Clipboard.SetDataObject(data); }
0
19. Example
View licensepublic void Copy() { if (!CanCopy()) return; // put bytes into buffer var buffer = new byte[_selectionLength]; int id = -1; for (long i = _bytePos; i < _bytePos + _selectionLength; i++) { id++; buffer[id] = _byteProvider.ReadByte(i); } var da = new DataObject(); // set string buffer clipbard data string sBuffer = Encoding.Instance.GetString(buffer, 0, buffer.Length); da.SetData(typeof (string), sBuffer); //set memorystream (BinaryData) clipboard data var ms = new MemoryStream(buffer, 0, buffer.Length, false, true); da.SetData("BinaryData", ms); Clipboard.SetDataObject(da, true); UpdateCaret(); ScrollByteIntoView(); Invalidate(); }
0
20. Example
View licensepublic void Copy() { if (!CanCopy()) return; // put bytes into buffer var buffer = new byte[_selectionLength]; int id = -1; for (long i = _bytePos; i < _bytePos + _selectionLength; i++) { id++; buffer[id] = _byteProvider.ReadByte(i); } var da = new DataObject(); // set string buffer clipbard data string sBuffer = Encoding.Instance.GetString(buffer, 0, buffer.Length); da.SetData(typeof (string), sBuffer); //set memorystream (BinaryData) clipboard data var ms = new MemoryStream(buffer, 0, buffer.Length, false, true); da.SetData("BinaryData", ms); Clipboard.SetDataObject(da, true); UpdateCaret(); ScrollByteIntoView(); Invalidate(); }
0
21. Example
View licenseprivate void CutFile() { try { if (GlobalSetting.IsImageError || !File.Exists(GlobalSetting.ImageList.GetFileName(GlobalSetting.CurrentIndex))) { return; } } catch { return; } GlobalSetting.StringClipboard = new StringCollection(); GlobalSetting.StringClipboard.Add(GlobalSetting.ImageList.GetFileName(GlobalSetting.CurrentIndex)); byte[] moveEffect = new byte[] { 2, 0, 0, 0 }; MemoryStream dropEffect = new MemoryStream(); dropEffect.Write(moveEffect, 0, moveEffect.Length); DataObject data = new DataObject(); data.SetFileDropList(GlobalSetting.StringClipboard); data.SetData("Preferred DropEffect", dropEffect); Clipboard.Clear(); Clipboard.SetDataObject(data, true); DisplayTextMessage( string.Format(GlobalSetting.LangPack.Items["frmMain._CutFileText"], GlobalSetting.StringClipboard.Count), 1000); }
0
22. Example
View licenseprivate void CutMultiFiles() { try { if (GlobalSetting.IsImageError || !File.Exists(GlobalSetting.ImageList.GetFileName(GlobalSetting.CurrentIndex))) { return; } } catch { return; } //get filename string filename = GlobalSetting.ImageList.GetFileName(GlobalSetting.CurrentIndex); //exit if duplicated filename if (GlobalSetting.StringClipboard.IndexOf(filename) != -1) { return; } //add filename to clipboard GlobalSetting.StringClipboard.Add(filename); byte[] moveEffect = new byte[] { 2, 0, 0, 0 }; MemoryStream dropEffect = new MemoryStream(); dropEffect.Write(moveEffect, 0, moveEffect.Length); DataObject data = new DataObject(); data.SetFileDropList(GlobalSetting.StringClipboard); data.SetData("Preferred DropEffect", dropEffect); Clipboard.Clear(); Clipboard.SetDataObject(data, true); DisplayTextMessage( string.Format(GlobalSetting.LangPack.Items["frmMain._CutFileText"], GlobalSetting.StringClipboard.Count), 1000); }
0
23. Example
View licensepublic static void ClipboardSetHyperlink(string link, string name) { // HTML format which works fine with any Office product const string html = @"Version:0.9 StartHTML:<<<<<<<1 EndHTML:<<<<<<<2 StartFragment:<<<<<<<3 EndFragment:<<<<<<<4 SourceURL: {0} <html> <body> <!--StartFragment--> <a href='{0}'>{1}</a> <!--EndFragment--> </body> </html>"; var dataObj = new DataObject("Preferred DropEffect", DragDropEffects.Move); // "Cut" file to clipboard dataObj.SetData(DataFormats.Text, link); dataObj.SetData(DataFormats.UnicodeText, link); // Add HTML format and .URL as a file dataObj.SetData(DataFormats.Html, string.Format(html, link, name)); var tempPath = Path.Combine(Path.GetTempPath(), name + ContentType.KeyVaultLink.ToExtension()); File.WriteAllText(tempPath, $"[InternetShortcut]\r\nURL={link}\r\nIconIndex=47\r\nIconFile=%SystemRoot%\\system32\\SHELL32.dll"); var sc = new StringCollection(); sc.Add(tempPath); dataObj.SetFileDropList(sc); Clipboard.SetDataObject(dataObj, true); }
0
24. Example
View licensepublic void Copy() { if (!CanCopy()) { return; } // put bytes into buffer var buffer = new byte[_selectionLength]; var id = -1; for (var i = _bytePos; i < _bytePos + _selectionLength; i++) { id++; buffer[id] = _byteProvider.ReadByte(i); } var da = new DataObject(); // set string buffer clipbard data var sBuffer = Encoding.ASCII.GetString(buffer, 0, buffer.Length); da.SetData(typeof (string), sBuffer); //set memorystream (BinaryData) clipboard data var ms = new MemoryStream(buffer, 0, buffer.Length, false, true); da.SetData("BinaryData", ms); Clipboard.SetDataObject(da, true); UpdateCaret(); ScrollByteIntoView(); Invalidate(); }
0
25. Example
View licensepublic static void WriteToClipboard(this Bitmap BMP, bool PreserveTransparency = true) { if (PreserveTransparency) { using (var pngStream = new MemoryStream()) { BMP.Save(pngStream, ImageFormat.Png); var pngClipboardData = new DataObject("PNG", pngStream); using (var whiteS = new Bitmap(BMP.Width, BMP.Height, PixelFormat.Format24bppRgb)) { using (var graphics = Graphics.FromImage(whiteS)) { graphics.Clear(Color.White); graphics.DrawImage(BMP, 0, 0, BMP.Width, BMP.Height); } // Add fallback for applications that don't support PNG from clipboard (eg. Photoshop or Paint) pngClipboardData.SetData(DataFormats.Bitmap, whiteS); Clipboard.Clear(); Clipboard.SetDataObject(pngClipboardData, true); } } } else Clipboard.SetImage(BMP); }
0
26. Example
View licensepublic static void WriteToClipboard(this Bitmap BMP, bool PreserveTransparency = true) { if (PreserveTransparency) { using (var pngStream = new MemoryStream()) { BMP.Save(pngStream, ImageFormat.Png); var pngClipboardData = new DataObject("PNG", pngStream); using (var whiteS = new Bitmap(BMP.Width, BMP.Height, PixelFormat.Format24bppRgb)) { using (var graphics = Graphics.FromImage(whiteS)) { graphics.Clear(Color.White); graphics.DrawImage(BMP, 0, 0, BMP.Width, BMP.Height); } // Add fallback for applications that don't support PNG from clipboard (eg. Photoshop or Paint) pngClipboardData.SetData(DataFormats.Bitmap, whiteS); Clipboard.Clear(); Clipboard.SetDataObject(pngClipboardData, true); } } } else Clipboard.SetImage(BMP); }
0
27. Example
View licensepublic static void CopyToClipboard(string htmlFragment, string title, Uri sourceUrl) { /n ..... /n //View Source file for more details /n }
0
28. Example
View licensepublic void Copy() { if(!CanCopy()) return; // put bytes into buffer byte[] buffer = GetCopyData(); DataObject da = new DataObject(); // set string buffer clipbard data string sBuffer = System.Text.Encoding.ASCII.GetString(buffer, 0, buffer.Length); da.SetData(typeof(string), sBuffer); //set memorystream (BinaryData) clipboard data System.IO.MemoryStream ms = new System.IO.MemoryStream(buffer, 0, buffer.Length, false, true); da.SetData("BinaryData", ms); Clipboard.SetDataObject(da, true); UpdateCaret(); ScrollByteIntoView(); Invalidate(); OnCopied(EventArgs.Empty); }
0
29. Example
View licensepublic void CopyHex() { if (!CanCopy()) return; // put bytes into buffer byte[] buffer = GetCopyData(); DataObject da = new DataObject(); // set string buffer clipbard data string hexString = ConvertBytesToHex(buffer); ; da.SetData(typeof(string), hexString); //set memorystream (BinaryData) clipboard data System.IO.MemoryStream ms = new System.IO.MemoryStream(buffer, 0, buffer.Length, false, true); da.SetData("BinaryData", ms); Clipboard.SetDataObject(da, true); UpdateCaret(); ScrollByteIntoView(); Invalidate(); OnCopiedHex(EventArgs.Empty); }
0
30. Example
View licensepublic void Copy() { if(!CanCopy()) return; // put bytes into buffer byte[] buffer = GetCopyData(); DataObject da = new DataObject(); // set string buffer clipbard data string sBuffer = System.Text.Encoding.ASCII.GetString(buffer, 0, buffer.Length); da.SetData(typeof(string), sBuffer); //set memorystream (BinaryData) clipboard data System.IO.MemoryStream ms = new System.IO.MemoryStream(buffer, 0, buffer.Length, false, true); da.SetData("BinaryData", ms); Clipboard.SetDataObject(da, true); UpdateCaret(); ScrollByteIntoView(); Invalidate(); OnCopied(EventArgs.Empty); }
0
31. Example
View licensepublic void CopyHex() { if (!CanCopy()) return; // put bytes into buffer byte[] buffer = GetCopyData(); DataObject da = new DataObject(); // set string buffer clipbard data string hexString = ConvertBytesToHex(buffer); ; da.SetData(typeof(string), hexString); //set memorystream (BinaryData) clipboard data System.IO.MemoryStream ms = new System.IO.MemoryStream(buffer, 0, buffer.Length, false, true); da.SetData("BinaryData", ms); Clipboard.SetDataObject(da, true); UpdateCaret(); ScrollByteIntoView(); Invalidate(); OnCopiedHex(EventArgs.Empty); }
0
32. Example
View licensepublic void CopyHex() { if (!CanCopy()) return; // put bytes into buffer byte[] buffer = GetCopyData(); DataObject da = new DataObject(); // set string buffer clipbard data string hexString = ConvertBytesToHex(buffer); ; da.SetData(typeof(string), hexString); //set memorystream (BinaryData) clipboard data System.IO.MemoryStream ms = new System.IO.MemoryStream(buffer, 0, buffer.Length, false, true); da.SetData("BinaryData", ms); Clipboard.SetDataObject(da, true); UpdateCaret(); ScrollByteIntoView(); Invalidate(); OnCopiedHex(EventArgs.Empty); }
0
33. Example
View licensepublic void Copy() { if (!CanCopy()) return; // put bytes into buffer byte[] buffer = GetCopyData(); DataObject da = new DataObject(); // set string buffer clipbard data string sBuffer = System.Text.Encoding.ASCII.GetString(buffer, 0, buffer.Length); da.SetData(typeof(string), sBuffer); //set memorystream (BinaryData) clipboard data System.IO.MemoryStream ms = new System.IO.MemoryStream(buffer, 0, buffer.Length, false, true); da.SetData("BinaryData", ms); Clipboard.SetDataObject(da, true); UpdateCaret(); ScrollByteIntoView(); Invalidate(); OnCopied(EventArgs.Empty); }
0
34. Example
View licensepublic void CopyHex() { if (!CanCopy()) return; // put bytes into buffer byte[] buffer = GetCopyData(); DataObject da = new DataObject(); // set string buffer clipbard data string hexString = ConvertBytesToHex(buffer); ; da.SetData(typeof(string), hexString); //set memorystream (BinaryData) clipboard data System.IO.MemoryStream ms = new System.IO.MemoryStream(buffer, 0, buffer.Length, false, true); da.SetData("BinaryData", ms); Clipboard.SetDataObject(da, true); UpdateCaret(); ScrollByteIntoView(); Invalidate(); OnCopiedHex(EventArgs.Empty); }
0
35. Example
View license[Command(null, "Copy")] public bool Copy(bool run = true) { if (_selectedShapes.Count == 0) return false; if (run) { var buf = SerializeSelected(); var data = new DataObject(); data.SetData("DiagramDocument", buf.ToArray()); var sortedShapes = _selectedShapes.OrderBy(s => { var c = s.BBox.Center(); return c.Y + c.X / 10; }); var text = StringExt.Join("\n\n", sortedShapes .Select(s => s.PlainText()).Where(t => !string.IsNullOrEmpty(t))); if (!string.IsNullOrEmpty(text)) data.SetText(text); // Crazy Clipboard deletes data by default on app exit! // need 'true' parameter to prevent loss of data on exit Clipboard.SetDataObject(data, true); } return true; }
0
36. Example
View licensepublic void Copy() { if (!CanCopy()) return; // put bytes into buffer byte[] buffer = GetCopyData(); DataObject da = new DataObject(); // set string buffer clipbard data string sBuffer = ""; if (_keyInterpreter == _ki && buffer.Length < 2000) { for (int i = 0; i < buffer.Length; i++) { sBuffer += buffer[i].ToString("x2"); } } else { sBuffer = System.Text.Encoding.ASCII.GetString(buffer, 0, buffer.Length); } da.SetData(typeof(string), sBuffer); //set memorystream (BinaryData) clipboard data System.IO.MemoryStream ms = new System.IO.MemoryStream(buffer, 0, buffer.Length, false, true); da.SetData("BinaryData", ms); Clipboard.SetDataObject(da, true); UpdateCaret(); ScrollByteIntoView(); Invalidate(); OnCopied(EventArgs.Empty); }
0
37. Example
View licensepublic 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; } } }
0
38. Example
View licensepublic 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; } }
0
39. Example
View licensepublic void OnKeyDown(KeyEventArgs e) { if (e.KeyCode == Keys.ControlKey) this.EmitInvalida/n ..... /n //View Source file for more details /n }
0
40. Example
View licensepublic void OnKeyDown(KeyEventArgs e) { if (e.KeyCode == Keys.ControlKey) this.EmitInvalida/n ..... /n //View Source file for more details /n }
0
41. Example
View licenseinternal static void CaptureWindow(ref ScreenshotTask data) { IntPtr start = Win/n ..... /n //View Source file for more details /n }