551 references to DataFormats
Microsoft.VisualBasic.Tests (8)
Microsoft\VisualBasic\MyServices\ClipboardProxyTests.cs (8)
10using DataFormats = System.Windows.Forms.DataFormats; 47clipboard.SetData(DataFormats.UnicodeText, data); 48clipboard.ContainsData(DataFormats.UnicodeText).Should().Be(System.Windows.Forms.Clipboard.ContainsData(DataFormats.UnicodeText)); 49clipboard.GetData(DataFormats.UnicodeText).Should().Be(System.Windows.Forms.Clipboard.GetData(DataFormats.UnicodeText)); 58clipboard.GetDataObject().GetData(DataFormats.UnicodeText).Should().Be(System.Windows.Forms.Clipboard.GetDataObject()?.GetData(DataFormats.UnicodeText));
System.Windows.Forms (132)
System\Windows\Forms\Controls\DataGridView\DataGridView.Methods.cs (7)
7136DataFormats.Html, 7137DataFormats.Text, 7138DataFormats.UnicodeText, 7139DataFormats.CommaSeparatedValue 7424if (string.Equals(format, DataFormats.Html, StringComparison.OrdinalIgnoreCase)) 7723if (string.Equals(format, DataFormats.Html, StringComparison.OrdinalIgnoreCase)) 8139if (string.Equals(format, DataFormats.Html, StringComparison.OrdinalIgnoreCase))
System\Windows\Forms\Controls\DataGridView\DataGridViewCell.cs (4)
1316if (string.Equals(format, DataFormats.Html, StringComparison.OrdinalIgnoreCase)) 1353bool csv = string.Equals(format, DataFormats.CommaSeparatedValue, StringComparison.OrdinalIgnoreCase); 1355string.Equals(format, DataFormats.Text, StringComparison.OrdinalIgnoreCase) || 1356string.Equals(format, DataFormats.UnicodeText, StringComparison.OrdinalIgnoreCase))
System\Windows\Forms\Controls\DataGridView\DataGridViewColumnHeaderCell.cs (4)
138if (string.Equals(format, DataFormats.Html, StringComparison.OrdinalIgnoreCase)) 171bool csv = string.Equals(format, DataFormats.CommaSeparatedValue, StringComparison.OrdinalIgnoreCase); 173string.Equals(format, DataFormats.Text, StringComparison.OrdinalIgnoreCase) || 174string.Equals(format, DataFormats.UnicodeText, StringComparison.OrdinalIgnoreCase))
System\Windows\Forms\Controls\DataGridView\DataGridViewRowHeaderCell.cs (4)
108if (string.Equals(format, DataFormats.Html, StringComparison.OrdinalIgnoreCase)) 143bool csv = string.Equals(format, DataFormats.CommaSeparatedValue, StringComparison.OrdinalIgnoreCase); 145string.Equals(format, DataFormats.Text, StringComparison.OrdinalIgnoreCase) || 146string.Equals(format, DataFormats.UnicodeText, StringComparison.OrdinalIgnoreCase))
System\Windows\Forms\Controls\RichTextBox\RichTextBox.cs (2)
1606public bool CanPaste(DataFormats.Format clipFormat) 2587public void Paste(DataFormats.Format clipFormat)
System\Windows\Forms\OLE\Clipboard.cs (24)
188/// Indicates whether there is data on the Clipboard in the <see cref="DataFormats.WaveAudio"/> format. 190public static bool ContainsAudio() => ContainsData(DataFormats.WaveAudioConstant); 203/// Indicates whether there is data on the Clipboard that is in the <see cref="DataFormats.FileDrop"/> format 206public static bool ContainsFileDropList() => ContainsData(DataFormats.FileDrop, autoConvert: true); 209/// Indicates whether there is data on the Clipboard that is in the <see cref="DataFormats.Bitmap"/> format 212public static bool ContainsImage() => ContainsData(DataFormats.Bitmap, autoConvert: true); 232public static Stream? GetAudioStream() => GetTypedDataIfAvailable<Stream>(DataFormats.WaveAudioConstant); 260/// The format of the data to retrieve. See the <see cref="DataFormats"/> class for a set of predefined data formats. 439if (GetTypedDataIfAvailable<string[]?>(DataFormats.FileDropConstant) is string[] strings) 453public static Image? GetImage() => GetTypedDataIfAvailable<Image>(DataFormats.Bitmap); 488/// Clears the <see cref="Clipboard"/> and then adds data in the <see cref="DataFormats.WaveAudio"/> format. 493/// Clears the <see cref="Clipboard"/> and then adds data in the <see cref="DataFormats.WaveAudio"/> format. 496SetDataObject(new DataObject(DataFormats.WaveAudioConstant, audioStream.OrThrowIfNull()), copy: true); 533/// and you are using a custom format or <see cref="DataFormats.Serializable"/>, 573/// Clears the Clipboard and then adds a collection of file names in the <see cref="DataFormats.FileDrop"/> format. 595SetDataObject(new DataObject(DataFormats.FileDropConstant, autoConvert: true, filePathsArray), copy: true); 599/// Clears the Clipboard and then adds an <see cref="Image"/> in the <see cref="DataFormats.Bitmap"/> format. 602SetDataObject(new DataObject(DataFormats.BitmapConstant, autoConvert: true, image.OrThrowIfNull()), copy: true); 622TextDataFormat.Text => DataFormats.Text, 623TextDataFormat.UnicodeText => DataFormats.UnicodeText, 624TextDataFormat.Rtf => DataFormats.Rtf, 625TextDataFormat.Html => DataFormats.Html, 626TextDataFormat.CommaSeparatedValue => DataFormats.CommaSeparatedValue, 627_ => DataFormats.UnicodeText,
System\Windows\Forms\OLE\DataObject.Composition.NativeToWinFormsAdapter.cs (12)
109DataFormats.TextConstant or DataFormats.RtfConstant or DataFormats.OemTextConstant => 111DataFormats.HtmlConstant => ReadUtf8StringFromHGLOBAL(hglobal), 112DataFormats.UnicodeTextConstant => ReadStringFromHGLOBAL(hglobal, unicode: true), 113DataFormats.FileDropConstant => ReadFileListFromHDROP((HDROP)(nint)hglobal), 302cfFormat = (ushort)DataFormats.GetFormat(format).Id, 362cfFormat = (ushort)DataFormats.GetFormat(format).Id, 415if (format != DataFormats.BitmapConstant) 422cfFormat = (ushort)DataFormats.GetFormat(format).Id, 601string name = DataFormats.GetFormat(formatEtc.cfFormat).Name; 657cfFormat = (ushort)(DataFormats.GetFormat(format).Id),
System\Windows\Forms\OLE\DataObject.Composition.WinFormsToNativeAdapter.cs (13)
51string formatName = DataFormats.GetFormat(pformatetcIn->cfFormat).Name; 113string format = DataFormats.GetFormat(pformatetc->cfFormat).Name; 149if (format.Equals(DataFormats.Bitmap) && data is Bitmap bitmap) 215if (!_dataObject.GetDataPresent(DataFormats.GetFormat(pformatetc->cfFormat).Name)) 248string formatName = DataFormats.GetFormat(pformatetc->cfFormat).Name; 309DataFormats.TextConstant or DataFormats.RtfConstant or DataFormats.OemTextConstant 311DataFormats.HtmlConstant 313DataFormats.UnicodeTextConstant 315DataFormats.FileDropConstant 321DataFormats.DibConstant when data is Image 326_ when format == DataFormats.SerializableConstant || data is ISerializable || data.GetType().IsSerializable
System\Windows\Forms\OLE\DataObject.cs (54)
117/// <param name="format">The format associated with the data. See <see cref="DataFormats"/> for predefined formats.</param> 128/// and you are using a custom format or <see cref="DataFormats.Serializable"/> 181|| format is DataFormats.TextConstant 182or DataFormats.UnicodeTextConstant 183or DataFormats.RtfConstant 184or DataFormats.HtmlConstant 185or DataFormats.OemTextConstant 186or DataFormats.FileDropConstant 202format is DataFormats.StringConstant 204or DataFormats.CsvConstant 205or DataFormats.DibConstant 206or DataFormats.DifConstant 207or DataFormats.LocaleConstant 208or DataFormats.PenDataConstant 209or DataFormats.RiffConstant 210or DataFormats.SymbolicLinkConstant 211or DataFormats.TiffConstant 212or DataFormats.WaveAudioConstant 213or DataFormats.BitmapConstant 214or DataFormats.EmfConstant 215or DataFormats.PaletteConstant 216or DataFormats.WmfConstant; 307public virtual bool ContainsAudio() => GetDataPresent(DataFormats.WaveAudioConstant, autoConvert: false); 309public virtual bool ContainsFileDropList() => GetDataPresent(DataFormats.FileDropConstant, autoConvert: true); 311public virtual bool ContainsImage() => GetDataPresent(DataFormats.BitmapConstant, autoConvert: true); 323public virtual Stream? GetAudioStream() => GetData(DataFormats.WaveAudio, autoConvert: false) as Stream; 328if (GetData(DataFormats.FileDropConstant, autoConvert: true) is string[] strings) 336public virtual Image? GetImage() => GetData(DataFormats.Bitmap, autoConvert: true) as Image; 351SetData(DataFormats.WaveAudioConstant, autoConvert: false, audioStream.OrThrowIfNull()); 357SetData(DataFormats.FileDropConstant, true, strings); 360public virtual void SetImage(Image image) => SetData(DataFormats.BitmapConstant, true, image.OrThrowIfNull()); 413DataFormats.TextConstant 414or DataFormats.UnicodeTextConstant 415or DataFormats.StringConstant 416or DataFormats.RtfConstant 417or DataFormats.HtmlConstant 418or DataFormats.OemTextConstant => typeof(string) == typeof(T), 420DataFormats.FileDropConstant 424DataFormats.BitmapConstant or BitmapFullName => 432TextDataFormat.UnicodeText => DataFormats.UnicodeTextConstant, 433TextDataFormat.Rtf => DataFormats.RtfConstant, 434TextDataFormat.Html => DataFormats.HtmlConstant, 435TextDataFormat.CommaSeparatedValue => DataFormats.CsvConstant, 436_ => DataFormats.UnicodeTextConstant, 445DataFormats.TextConstant or DataFormats.UnicodeTextConstant or DataFormats.StringConstant => 447DataFormats.StringConstant, 448DataFormats.UnicodeTextConstant, 449DataFormats.TextConstant 451DataFormats.FileDropConstant or CF_DEPRECATED_FILENAME or CF_DEPRECATED_FILENAMEW => 453DataFormats.FileDropConstant, 457DataFormats.BitmapConstant or BitmapFullName => 460DataFormats.BitmapConstant
System\Windows\Forms\OLE\DataObject.DataStore.cs (4)
96if (data is Bitmap && format.Equals(DataFormats.Dib)) 98format = autoConvert ? DataFormats.Bitmap : throw new NotSupportedException(SR.DataObjectDibNotSupported); 117&& !_mappedData.ContainsKey(DataFormats.Serializable)) 119SetData(DataFormats.Serializable, data);
System\Windows\Forms\OLE\DataObject.FormatEnumerator.cs (2)
46cfFormat = (short)(ushort)DataFormats.GetFormat(format).Id, 50tymed = format.Equals(DataFormats.Bitmap) ? ComTypes.TYMED.TYMED_GDI : ComTypes.TYMED.TYMED_HGLOBAL
System\Windows\Forms\OLE\DragDropHelper.cs (1)
233string formatName = DataFormats.GetFormat(format.cfFormat).Name;
System\Windows\Forms\OLE\ITypedDataObject.cs (1)
58/// A string that specifies what format to retrieve the data as. See the <see cref="DataFormats"/> class for
System.Windows.Forms.Design (1)
System\Windows\Forms\Design\OleDragDropHandler.ComponentDataObject.cs (1)
203return [NestedToolboxItemFormat, DataFormat, DataFormats.Serializable, ExtraInfoFormat];
System.Windows.Forms.Tests (366)
System\Windows\Forms\ClipboardTests.cs (10)
171Clipboard.GetData(DataFormats.WaveAudio).Should().BeOfType<MemoryStream>().Which.ToArray().Should().Equal(audioBytes); 173Clipboard.ContainsData(DataFormats.WaveAudio).Should().BeTrue(); 183Clipboard.GetData(DataFormats.WaveAudio).Should().BeNull(); 185Clipboard.ContainsData(DataFormats.WaveAudio).Should().BeTrue(); 203Clipboard.GetData(DataFormats.WaveAudio).Should().BeOfType<MemoryStream>().Which.ToArray().Should().Equal(audioBytes); 205Clipboard.ContainsData(DataFormats.WaveAudio).Should().BeTrue(); 215Clipboard.GetData(DataFormats.WaveAudio).Should().BeNull(); 217Clipboard.ContainsData(DataFormats.WaveAudio).Should().BeTrue(); 666dataObject.GetData(DataFormats.Text).Should().Be(testString); 1021cfFormat = (short)DataFormats.GetFormat("testFormat").Id,
System\Windows\Forms\DataFormatsTests.ClipboardTests.cs (3)
25DataFormats.Format result = DataFormats.GetFormat(id); 26Assert.Equal(result, DataFormats.GetFormat(id));
System\Windows\Forms\DataFormatsTests.cs (58)
13yield return new object[] { DataFormats.Bitmap, "Bitmap" }; 14yield return new object[] { DataFormats.CommaSeparatedValue, "Csv" }; 15yield return new object[] { DataFormats.Dib, "DeviceIndependentBitmap" }; 16yield return new object[] { DataFormats.Dif, "DataInterchangeFormat" }; 17yield return new object[] { DataFormats.EnhancedMetafile, "EnhancedMetafile" }; 18yield return new object[] { DataFormats.FileDrop, "FileDrop" }; 19yield return new object[] { DataFormats.Html, "HTML Format" }; 20yield return new object[] { DataFormats.Locale, "Locale" }; 21yield return new object[] { DataFormats.MetafilePict, "MetaFilePict" }; 22yield return new object[] { DataFormats.OemText, "OEMText" }; 23yield return new object[] { DataFormats.Palette, "Palette" }; 24yield return new object[] { DataFormats.PenData, "PenData" }; 25yield return new object[] { DataFormats.Riff, "RiffAudio" }; 26yield return new object[] { DataFormats.Rtf, "Rich Text Format" }; 27yield return new object[] { DataFormats.Serializable, "WindowsForms10PersistentObject" }; 28yield return new object[] { DataFormats.StringFormat, "System.String" }; 29yield return new object[] { DataFormats.SymbolicLink, "SymbolicLink" }; 30yield return new object[] { DataFormats.Text, "Text" }; 31yield return new object[] { DataFormats.Tiff, "TaggedImageFileFormat" }; 32yield return new object[] { DataFormats.UnicodeText, "UnicodeText" }; 33yield return new object[] { DataFormats.WaveAudio, "WaveAudio" }; 45yield return new object[] { DataFormats.Bitmap, "Bitmap", 2 }; 46yield return new object[] { DataFormats.Dib, "DeviceIndependentBitmap", 8 }; 47yield return new object[] { DataFormats.Dif, "DataInterchangeFormat", 5 }; 48yield return new object[] { DataFormats.EnhancedMetafile, "EnhancedMetafile", 14 }; 49yield return new object[] { DataFormats.FileDrop, "FileDrop", 15 }; 50yield return new object[] { DataFormats.Locale, "Locale", 16 }; 51yield return new object[] { DataFormats.MetafilePict, "MetaFilePict", 3 }; 52yield return new object[] { DataFormats.OemText, "OEMText", 7 }; 53yield return new object[] { DataFormats.Palette, "Palette", 9 }; 54yield return new object[] { DataFormats.PenData, "PenData", 10 }; 55yield return new object[] { DataFormats.Riff, "RiffAudio", 11 }; 56yield return new object[] { DataFormats.SymbolicLink, "SymbolicLink", 4 }; 57yield return new object[] { DataFormats.Text, "Text", 1 }; 58yield return new object[] { DataFormats.Tiff, "TaggedImageFileFormat", 6 }; 59yield return new object[] { DataFormats.UnicodeText, "UnicodeText", 13 }; 60yield return new object[] { DataFormats.WaveAudio, "WaveAudio", 12 }; 67DataFormats.Format result = DataFormats.GetFormat(format); 68Assert.Same(result, DataFormats.GetFormat(format.ToLowerInvariant())); 73Assert.Same(result, DataFormats.GetFormat(format)); 78yield return new object[] { DataFormats.CommaSeparatedValue, "Csv" }; 79yield return new object[] { DataFormats.Html, "HTML Format" }; 80yield return new object[] { DataFormats.Rtf, "Rich Text Format" }; 81yield return new object[] { DataFormats.Serializable, "WindowsForms10PersistentObject" }; 82yield return new object[] { DataFormats.StringFormat, "System.String" }; 90DataFormats.Format result = DataFormats.GetFormat(format); 91Assert.Same(result, DataFormats.GetFormat(format)); 92Assert.Same(result, DataFormats.GetFormat(format.ToLowerInvariant())); 102Assert.Same(result, DataFormats.GetFormat(result.Id)); 108Assert.Throws<ArgumentException>("format", () => DataFormats.GetFormat("")); 109Assert.Throws<ArgumentNullException>("format", () => DataFormats.GetFormat(null)); 121Assert.Throws<Win32Exception>(() => DataFormats.GetFormat(format)); 152DataFormats.Format result = DataFormats.GetFormat(id); 153Assert.Equal(result, DataFormats.GetFormat(id)); 164var format = new DataFormats.Format(name, id);
System\Windows\Forms\DataObjectExtensionsTests.cs (14)
20Action tryGetData2 = () => DataObjectExtensions.TryGetData<string>(dataObject: null!, DataFormats.Text, out _); 22Action tryGetData3 = () => DataObjectExtensions.TryGetData<string>(dataObject: null!, DataFormats.Dib, autoConvert: true, out _); 24Action tryGetData4 = () => DataObjectExtensions.TryGetData<string>(dataObject: null!, DataFormats.EmfConstant, autoConvert: false, out _); 26Action tryGetData5 = () => DataObjectExtensions.TryGetData<string>(dataObject: null!, DataFormats.UnicodeText, Resolver, autoConvert: true, out _); 28Action tryGetData6 = () => DataObjectExtensions.TryGetData<string>(dataObject: null!, DataFormats.Serializable, Resolver, autoConvert: false, out _); 47Action tryGetData = () => dataObject.TryGetData<string>(DataFormats.Text, out _); 57Action tryGetData = () => dataObject.TryGetData<string>(DataFormats.CommaSeparatedValue, autoConvert, out _); 67Action tryGetData = () => dataObject.TryGetData<string>(DataFormats.UnicodeText, Resolver, autoConvert, out _); 84dataObject.TryGetData(DataFormats.Dib, out Bitmap? bitmap).Should().BeFalse(); 93dataObject.TryGetData(DataFormats.Serializable, autoConvert, out Font? font).Should().BeFalse(); 102dataObject.TryGetData(DataFormats.SymbolicLink, Resolver, autoConvert, out DateTime? date).Should().BeFalse(); 118dataObject.TryGetData(DataFormats.Dib, out Bitmap? _).Should().BeFalse(); 127dataObject.TryGetData(DataFormats.FileDrop, autoConvert, out int? _).Should().BeFalse(); 136dataObject.TryGetData(DataFormats.SymbolicLink, Resolver, autoConvert, out DateTime? date).Should().BeFalse();
System\Windows\Forms\DataObjectTests.ClipboardTests.cs (22)
89theoryData.Add(format, null, format == DataFormats.FileDrop, format == DataFormats.Bitmap); 90theoryData.Add(format, "input", format == DataFormats.FileDrop, format == DataFormats.Bitmap); 120dataObject.ContainsAudio().Should().Be(format == DataFormats.WaveAudio); 123dataObject.ContainsText().Should().Be(format == DataFormats.UnicodeText); 124dataObject.ContainsText(TextDataFormat.Text).Should().Be(format == DataFormats.UnicodeText); 125dataObject.ContainsText(TextDataFormat.UnicodeText).Should().Be(format == DataFormats.UnicodeText); 126dataObject.ContainsText(TextDataFormat.Rtf).Should().Be(format == DataFormats.Rtf); 127dataObject.ContainsText(TextDataFormat.Html).Should().Be(format == DataFormats.Html); 128dataObject.ContainsText(TextDataFormat.CommaSeparatedValue).Should().Be(format == DataFormats.CommaSeparatedValue); 144theoryData.Add(format, autoConvert, null, format == DataFormats.FileDrop, format == DataFormats.Bitmap); 145theoryData.Add(format, autoConvert, "input", format == DataFormats.FileDrop, format == DataFormats.Bitmap); 180dataObject.ContainsAudio().Should().Be(format == DataFormats.WaveAudio); 183dataObject.ContainsText().Should().Be(format == DataFormats.UnicodeText); 184dataObject.ContainsText(TextDataFormat.Text).Should().Be(format == DataFormats.UnicodeText); 185dataObject.ContainsText(TextDataFormat.UnicodeText).Should().Be(format == DataFormats.UnicodeText); 186dataObject.ContainsText(TextDataFormat.Rtf).Should().Be(format == DataFormats.Rtf); 187dataObject.ContainsText(TextDataFormat.Html).Should().Be(format == DataFormats.Html); 188dataObject.ContainsText(TextDataFormat.CommaSeparatedValue).Should().Be(format == DataFormats.CommaSeparatedValue);
System\Windows\Forms\DataObjectTests.cs (246)
31DataFormats.CommaSeparatedValue, 32DataFormats.Dib, 33DataFormats.Dif, 34DataFormats.PenData, 35DataFormats.Riff, 36DataFormats.Tiff, 37DataFormats.WaveAudio, 38DataFormats.SymbolicLink, 39DataFormats.StringFormat, 40DataFormats.Bitmap, 41DataFormats.EnhancedMetafile, 42DataFormats.FileDrop, 43DataFormats.Html, 44DataFormats.MetafilePict, 45DataFormats.OemText, 46DataFormats.Palette, 47DataFormats.Rtf, 48DataFormats.Text, 49DataFormats.UnicodeText, 60DataFormats.Serializable, 80.Setup(o => o.GetDataPresent(DataFormats.WaveAudio, false)) 84mockDataObject.Verify(o => o.GetDataPresent(DataFormats.WaveAudio, false), Times.Once()); 103.Setup(o => o.GetDataPresent(DataFormats.FileDrop, true)) 107mockDataObject.Verify(o => o.GetDataPresent(DataFormats.FileDrop, true), Times.Once()); 126.Setup(o => o.GetDataPresent(DataFormats.Bitmap, true)) 130mockDataObject.Verify(o => o.GetDataPresent(DataFormats.Bitmap, true), Times.Once()); 169theoryData.Add(TextDataFormat.Text, DataFormats.UnicodeText, result); 170theoryData.Add(TextDataFormat.UnicodeText, DataFormats.UnicodeText, result); 171theoryData.Add(TextDataFormat.Rtf, DataFormats.Rtf, result); 172theoryData.Add(TextDataFormat.Html, DataFormats.Html, result); 173theoryData.Add(TextDataFormat.CommaSeparatedValue, DataFormats.CommaSeparatedValue, result); 228dataObject.SetData(DataFormats.WaveAudio, result); 241.Setup(o => o.GetData(DataFormats.WaveAudio, false)) 245mockDataObject.Verify(o => o.GetData(DataFormats.WaveAudio, false), Times.Once()); 422DataFormats.CommaSeparatedValue, 441string format = DataFormats.Bitmap; 453{ DataFormats.CommaSeparatedValue, true }, 455{ DataFormats.CommaSeparatedValue, false }, 477string format = DataFormats.Bitmap; 502string format = DataFormats.Bitmap; 656dataObject.SetData(DataFormats.FileDrop, result); 669.Setup(o => o.GetData(DataFormats.FileDrop, true)) 673mockDataObject.Verify(o => o.GetData(DataFormats.FileDrop, true), Times.Once()); 826dataObject.SetData(DataFormats.Bitmap, result); 839.Setup(o => o.GetData(DataFormats.Bitmap, true)) 843mockDataObject.Verify(o => o.GetData(DataFormats.Bitmap, true), Times.Once()); 866dataObject.SetData(DataFormats.UnicodeText, result); 896{ TextDataFormat.Text, DataFormats.UnicodeText, null, string.Empty }, 897{ TextDataFormat.Text, DataFormats.UnicodeText, new(), string.Empty }, 898{ TextDataFormat.Text, DataFormats.UnicodeText, string.Empty, string.Empty }, 899{ TextDataFormat.Text, DataFormats.UnicodeText, " ", " " }, 900{ TextDataFormat.Text, DataFormats.UnicodeText, "a", "a" }, 902{ TextDataFormat.UnicodeText, DataFormats.UnicodeText, null, string.Empty }, 903{ TextDataFormat.UnicodeText, DataFormats.UnicodeText, new(), string.Empty }, 904{ TextDataFormat.UnicodeText, DataFormats.UnicodeText, string.Empty, string.Empty }, 905{ TextDataFormat.UnicodeText, DataFormats.UnicodeText, " ", " " }, 906{ TextDataFormat.UnicodeText, DataFormats.UnicodeText, "a", "a" }, 908{ TextDataFormat.Rtf, DataFormats.Rtf, null, string.Empty }, 909{ TextDataFormat.Rtf, DataFormats.Rtf, new(), string.Empty }, 910{ TextDataFormat.Rtf, DataFormats.Rtf, string.Empty, string.Empty }, 911{ TextDataFormat.Rtf, DataFormats.Rtf, " ", " " }, 912{ TextDataFormat.Rtf, DataFormats.Rtf, "a", "a" }, 914{ TextDataFormat.Html, DataFormats.Html, null, string.Empty }, 915{ TextDataFormat.Html, DataFormats.Html, new(), string.Empty }, 916{ TextDataFormat.Html, DataFormats.Html, string.Empty, string.Empty }, 917{ TextDataFormat.Html, DataFormats.Html, " ", " " }, 918{ TextDataFormat.Html, DataFormats.Html, "a", "a" }, 920{ TextDataFormat.CommaSeparatedValue, DataFormats.CommaSeparatedValue, null, string.Empty }, 921{ TextDataFormat.CommaSeparatedValue, DataFormats.CommaSeparatedValue, new(), string.Empty }, 922{ TextDataFormat.CommaSeparatedValue, DataFormats.CommaSeparatedValue, string.Empty, string.Empty }, 923{ TextDataFormat.CommaSeparatedValue, DataFormats.CommaSeparatedValue, " ", " " }, 924{ TextDataFormat.CommaSeparatedValue, DataFormats.CommaSeparatedValue, "a", "a" }, 975dataObject.GetData(DataFormats.WaveAudio, autoConvert: true).Should().BeOfType<MemoryStream>().Subject.ToArray().Should().Equal(audioBytes); 976dataObject.GetData(DataFormats.WaveAudio, autoConvert: false).Should().BeOfType<MemoryStream>().Subject.ToArray().Should().Equal(audioBytes); 979dataObject.GetDataPresent(DataFormats.WaveAudio, autoConvert: true).Should().BeTrue(); 980dataObject.GetDataPresent(DataFormats.WaveAudio, autoConvert: false).Should().BeTrue(); 1004.Setup(o => o.SetData(DataFormats.WaveAudio, false, It.IsAny<MemoryStream>())) 1008mockDataObject.Verify(o => o.SetData(DataFormats.WaveAudio, false, It.IsAny<MemoryStream>()), Times.Once()); 1033dataObject.GetData(DataFormats.WaveAudio, autoConvert: true).Should().BeSameAs(audioStream); 1034dataObject.GetData(DataFormats.WaveAudio, autoConvert: false).Should().BeSameAs(audioStream); 1037dataObject.GetDataPresent(DataFormats.WaveAudio, autoConvert: true).Should().BeTrue(); 1038dataObject.GetDataPresent(DataFormats.WaveAudio, autoConvert: false).Should().BeTrue(); 1050.Setup(o => o.SetData(DataFormats.WaveAudio, false, audioStream)) 1053mockDataObject.Verify(o => o.SetData(DataFormats.WaveAudio, false, audioStream), Times.Once()); 1062.Setup(o => o.SetData(DataFormats.WaveAudio, false, audioStream)) 1066mockDataObject.Verify(o => o.SetData(DataFormats.WaveAudio, false, audioStream), Times.Once()); 1081{ new Mock<ISerializable>(MockBehavior.Strict).Object, DataFormats.Serializable } 1123dataObject.GetData(DataFormats.Serializable, autoConvert: false).Should().Be(data1); 1124dataObject.GetData(DataFormats.Serializable, autoConvert: true).Should().Be(data1); 1128dataObject.GetDataPresent(DataFormats.Serializable, autoConvert: false).Should().BeTrue(); 1129dataObject.GetDataPresent(DataFormats.Serializable, autoConvert: true).Should().BeTrue(); 1170theoryData.Add(format, null, format == DataFormats.FileDrop, format == DataFormats.Bitmap); 1171theoryData.Add(format, "input", format == DataFormats.FileDrop, format == DataFormats.Bitmap); 1201dataObject.ContainsAudio().Should().Be(format == DataFormats.WaveAudio); 1204dataObject.ContainsText().Should().Be(format == DataFormats.UnicodeText); 1205dataObject.ContainsText(TextDataFormat.Text).Should().Be(format == DataFormats.UnicodeText); 1206dataObject.ContainsText(TextDataFormat.UnicodeText).Should().Be(format == DataFormats.UnicodeText); 1207dataObject.ContainsText(TextDataFormat.Rtf).Should().Be(format == DataFormats.Rtf); 1208dataObject.ContainsText(TextDataFormat.Html).Should().Be(format == DataFormats.Html); 1209dataObject.ContainsText(TextDataFormat.CommaSeparatedValue).Should().Be(format == DataFormats.CommaSeparatedValue); 1213[InlineData(DataFormats.SerializableConstant, null)] 1214[InlineData(DataFormats.SerializableConstant, "input")] 1257dataObject.SetData(DataFormats.Dib, autoConvert: true, image); 1260dataObject.GetData(DataFormats.Bitmap, autoConvert: true).Should().BeSameAs(image); 1261dataObject.GetData(DataFormats.Bitmap, autoConvert: false).Should().BeSameAs(image); 1264dataObject.GetData(DataFormats.Dib, autoConvert: true).Should().BeNull(); 1265dataObject.GetData(DataFormats.Dib, autoConvert: false).Should().BeNull(); 1268dataObject.GetDataPresent(DataFormats.Bitmap, autoConvert: true).Should().BeTrue(); 1269dataObject.GetDataPresent(DataFormats.Bitmap, autoConvert: false).Should().BeTrue(); 1272dataObject.GetDataPresent(DataFormats.Dib, autoConvert: true).Should().BeFalse(); 1273dataObject.GetDataPresent(DataFormats.Dib, autoConvert: false).Should().BeFalse(); 1314theoryData.Add(format, autoConvert, null, format == DataFormats.FileDrop, format == DataFormats.Bitmap); 1315theoryData.Add(format, autoConvert, "input", format == DataFormats.FileDrop, format == DataFormats.Bitmap); 1350dataObject.ContainsAudio().Should().Be(format == DataFormats.WaveAudio); 1353dataObject.ContainsText().Should().Be(format == DataFormats.UnicodeText); 1354dataObject.ContainsText(TextDataFormat.Text).Should().Be(format == DataFormats.UnicodeText); 1355dataObject.ContainsText(TextDataFormat.UnicodeText).Should().Be(format == DataFormats.UnicodeText); 1356dataObject.ContainsText(TextDataFormat.Rtf).Should().Be(format == DataFormats.Rtf); 1357dataObject.ContainsText(TextDataFormat.Html).Should().Be(format == DataFormats.Html); 1358dataObject.ContainsText(TextDataFormat.CommaSeparatedValue).Should().Be(format == DataFormats.CommaSeparatedValue); 1366[InlineData(DataFormats.SerializableConstant, false, "input")] 1367[InlineData(DataFormats.SerializableConstant, false, null)] 1368[InlineData(DataFormats.SerializableConstant, true, "input")] 1369[InlineData(DataFormats.SerializableConstant, true, null)] 1394dataObject.ContainsAudio().Should().Be(format == DataFormats.WaveAudio); 1410dataObject.SetData(DataFormats.Dib, autoConvert: true, image); 1413dataObject.GetData(DataFormats.Bitmap, autoConvert: true).Should().BeSameAs(image); 1414dataObject.GetData(DataFormats.Bitmap, autoConvert: false).Should().BeSameAs(image); 1417dataObject.GetData(DataFormats.Dib, autoConvert: true).Should().BeNull(); 1418dataObject.GetData(DataFormats.Dib, autoConvert: false).Should().BeNull(); 1421dataObject.GetDataPresent(DataFormats.Bitmap, autoConvert: true).Should().BeTrue(); 1422dataObject.GetDataPresent(DataFormats.Bitmap, autoConvert: false).Should().BeTrue(); 1425dataObject.GetDataPresent(DataFormats.Dib, autoConvert: true).Should().BeFalse(); 1426dataObject.GetDataPresent(DataFormats.Dib, autoConvert: false).Should().BeFalse(); 1516((Action)(() => dataObject.SetData(DataFormats.Dib, false, new Bitmap(10, 10)))) 1534dataObject.GetData(DataFormats.FileDrop, autoConvert: true).Should().BeEquivalentTo(filePaths.Cast<string>()); 1535dataObject.GetData(DataFormats.FileDrop, autoConvert: false).Should().BeEquivalentTo(filePaths.Cast<string>()); 1542dataObject.GetDataPresent(DataFormats.FileDrop, autoConvert: true).Should().BeTrue(); 1543dataObject.GetDataPresent(DataFormats.FileDrop, autoConvert: false).Should().BeTrue(); 1559.Setup(o => o.SetData(DataFormats.FileDrop, true, It.IsAny<string[]>())) 1562mockDataObject.Verify(o => o.SetData(DataFormats.FileDrop, true, It.IsAny<string[]>()), Times.Once()); 1571.Setup(o => o.SetData(DataFormats.FileDrop, true, It.IsAny<string[]>())) 1575mockDataObject.Verify(o => o.SetData(DataFormats.FileDrop, true, It.IsAny<string[]>()), Times.Once()); 1594dataObject.GetData(DataFormats.Bitmap, autoConvert: true).Should().BeSameAs(image); 1595dataObject.GetData(DataFormats.Bitmap, autoConvert: false).Should().BeSameAs(image); 1598dataObject.GetData(DataFormats.Dib, autoConvert: true).Should().BeNull(); 1599dataObject.GetData(DataFormats.Dib, autoConvert: false).Should().BeNull(); 1602dataObject.GetDataPresent(DataFormats.Bitmap, autoConvert: true).Should().BeTrue(); 1603dataObject.GetDataPresent(DataFormats.Bitmap, autoConvert: false).Should().BeTrue(); 1606dataObject.GetDataPresent(DataFormats.Dib, autoConvert: true).Should().BeFalse(); 1607dataObject.GetDataPresent(DataFormats.Dib, autoConvert: false).Should().BeFalse(); 1620.Setup(o => o.SetData(DataFormats.Bitmap, true, image)) 1623mockDataObject.Verify(o => o.SetData(DataFormats.Bitmap, true, image), Times.Once()); 1633.Setup(o => o.SetData(DataFormats.Bitmap, true, image)) 1637mockDataObject.Verify(o => o.SetData(DataFormats.Bitmap, true, image), Times.Once()); 1662dataObject.GetData(DataFormats.UnicodeText, autoConvert: true).Should().BeSameAs(textData); 1663dataObject.GetData(DataFormats.UnicodeText, autoConvert: false).Should().BeSameAs(textData); 1664dataObject.GetData(DataFormats.Text, autoConvert: true).Should().BeSameAs(textData); 1665dataObject.GetData(DataFormats.Text, autoConvert: false).Should().BeNull(); 1666dataObject.GetData(DataFormats.StringFormat, autoConvert: true).Should().BeSameAs(textData); 1667dataObject.GetData(DataFormats.StringFormat, autoConvert: false).Should().BeNull(); 1668dataObject.GetData(DataFormats.Rtf, autoConvert: true).Should().BeNull(); 1669dataObject.GetData(DataFormats.Rtf, autoConvert: false).Should().BeNull(); 1670dataObject.GetData(DataFormats.Html, autoConvert: true).Should().BeNull(); 1671dataObject.GetData(DataFormats.Html, autoConvert: false).Should().BeNull(); 1672dataObject.GetData(DataFormats.CommaSeparatedValue, autoConvert: true).Should().BeNull(); 1673dataObject.GetData(DataFormats.CommaSeparatedValue, autoConvert: false).Should().BeNull(); 1676dataObject.GetDataPresent(DataFormats.UnicodeText, autoConvert: true).Should().BeTrue(); 1677dataObject.GetDataPresent(DataFormats.UnicodeText, autoConvert: false).Should().BeTrue(); 1678dataObject.GetDataPresent(DataFormats.Text, autoConvert: true).Should().BeFalse(); 1679dataObject.GetDataPresent(DataFormats.Text, autoConvert: false).Should().BeFalse(); 1680dataObject.GetDataPresent(DataFormats.StringFormat, autoConvert: true).Should().BeFalse(); 1681dataObject.GetDataPresent(DataFormats.StringFormat, autoConvert: false).Should().BeFalse(); 1682dataObject.GetDataPresent(DataFormats.Rtf, autoConvert: true).Should().BeFalse(); 1683dataObject.GetDataPresent(DataFormats.Rtf, autoConvert: false).Should().BeFalse(); 1684dataObject.GetDataPresent(DataFormats.Html, autoConvert: true).Should().BeFalse(); 1685dataObject.GetDataPresent(DataFormats.Html, autoConvert: false).Should().BeFalse(); 1686dataObject.GetDataPresent(DataFormats.CommaSeparatedValue, autoConvert: true).Should().BeFalse(); 1687dataObject.GetDataPresent(DataFormats.CommaSeparatedValue, autoConvert: false).Should().BeFalse(); 1711.Setup(o => o.SetData(DataFormats.UnicodeText, false, textData)) 1715mockDataObject.Verify(o => o.SetData(DataFormats.UnicodeText, false, textData), Times.Once()); 1741dataObject.GetData(DataFormats.UnicodeText, autoConvert: true).Should().Be(expectedUnicodeText); 1742dataObject.GetData(DataFormats.UnicodeText, autoConvert: false).Should().Be(expectedUnicodeText); 1743dataObject.GetData(DataFormats.Text, autoConvert: true).Should().Be(expectedUnicodeText); 1744dataObject.GetData(DataFormats.Text, autoConvert: false).Should().BeNull(); 1745dataObject.GetData(DataFormats.StringFormat, autoConvert: true).Should().Be(expectedUnicodeText); 1746dataObject.GetData(DataFormats.StringFormat, autoConvert: false).Should().BeNull(); 1747dataObject.GetData(DataFormats.Rtf, autoConvert: true).Should().Be(expectedRtfText); 1748dataObject.GetData(DataFormats.Rtf, autoConvert: false).Should().Be(expectedRtfText); 1749dataObject.GetData(DataFormats.Html, autoConvert: true).Should().Be(expectedHtmlText); 1750dataObject.GetData(DataFormats.Html, autoConvert: false).Should().Be(expectedHtmlText); 1751dataObject.GetData(DataFormats.CommaSeparatedValue, autoConvert: true).Should().Be(expectedCsvText); 1752dataObject.GetData(DataFormats.CommaSeparatedValue, autoConvert: false).Should().Be(expectedCsvText); 1755dataObject.GetDataPresent(DataFormats.UnicodeText, autoConvert: true).Should().Be(expectedUnicodeText is not null); 1756dataObject.GetDataPresent(DataFormats.UnicodeText, autoConvert: false).Should().Be(expectedUnicodeText is not null); 1757dataObject.GetDataPresent(DataFormats.Text, autoConvert: true).Should().BeFalse(); 1758dataObject.GetDataPresent(DataFormats.Text, autoConvert: false).Should().BeFalse(); 1759dataObject.GetDataPresent(DataFormats.StringFormat, autoConvert: true).Should().BeFalse(); 1760dataObject.GetDataPresent(DataFormats.StringFormat, autoConvert: false).Should().BeFalse(); 1761dataObject.GetDataPresent(DataFormats.Rtf, autoConvert: true).Should().Be(expectedRtfText is not null); 1762dataObject.GetDataPresent(DataFormats.Rtf, autoConvert: false).Should().Be(expectedRtfText is not null); 1763dataObject.GetDataPresent(DataFormats.Html, autoConvert: true).Should().Be(expectedHtmlText is not null); 1764dataObject.GetDataPresent(DataFormats.Html, autoConvert: false).Should().Be(expectedHtmlText is not null); 1765dataObject.GetDataPresent(DataFormats.CommaSeparatedValue, autoConvert: true).Should().Be(expectedCsvText is not null); 1766dataObject.GetDataPresent(DataFormats.CommaSeparatedValue, autoConvert: false).Should().Be(expectedCsvText is not null); 1774theoryData.Add(textData, TextDataFormat.Text, DataFormats.UnicodeText); 1775theoryData.Add(textData, TextDataFormat.UnicodeText, DataFormats.UnicodeText); 1776theoryData.Add(textData, TextDataFormat.Rtf, DataFormats.Rtf); 1777theoryData.Add(textData, TextDataFormat.Html, DataFormats.Html); 1778theoryData.Add(textData, TextDataFormat.CommaSeparatedValue, DataFormats.CommaSeparatedValue); 1841data.GetData(DataFormats.EnhancedMetafile).Should().BeNull(); 2024{ DataFormats.Bitmap, TYMED.TYMED_GDI }, 2025{ DataFormats.CommaSeparatedValue, TYMED.TYMED_HGLOBAL }, 2026{ DataFormats.Dib, TYMED.TYMED_HGLOBAL }, 2027{ DataFormats.Dif, TYMED.TYMED_HGLOBAL }, 2028{ DataFormats.EnhancedMetafile, TYMED.TYMED_HGLOBAL }, 2029{ DataFormats.FileDrop, TYMED.TYMED_HGLOBAL }, 2032{ DataFormats.Html, TYMED.TYMED_HGLOBAL }, 2033{ DataFormats.Locale, TYMED.TYMED_HGLOBAL }, 2034{ DataFormats.MetafilePict, TYMED.TYMED_HGLOBAL }, 2035{ DataFormats.OemText, TYMED.TYMED_HGLOBAL }, 2036{ DataFormats.Palette, TYMED.TYMED_HGLOBAL }, 2037{ DataFormats.PenData, TYMED.TYMED_HGLOBAL }, 2038{ DataFormats.Riff, TYMED.TYMED_HGLOBAL }, 2039{ DataFormats.Rtf, TYMED.TYMED_HGLOBAL }, 2040{ DataFormats.Serializable, TYMED.TYMED_HGLOBAL }, 2041{ DataFormats.StringFormat, TYMED.TYMED_HGLOBAL }, 2042{ DataFormats.SymbolicLink, TYMED.TYMED_HGLOBAL }, 2043{ DataFormats.Text, TYMED.TYMED_HGLOBAL }, 2044{ DataFormats.Tiff, TYMED.TYMED_HGLOBAL }, 2045{ DataFormats.UnicodeText, TYMED.TYMED_HGLOBAL }, 2046{ DataFormats.WaveAudio, TYMED.TYMED_HGLOBAL } 2084result[0].cfFormat.Should().Be(unchecked((short)(ushort)(DataFormats.GetFormat(format1).Id))); 2166.Returns(["Format1", DataFormats.Bitmap, "Format2"]); 2187result[0].cfFormat.Should().Be(unchecked((short)(ushort)(DataFormats.GetFormat("Format1").Id))); 2197result[0].cfFormat.Should().Be(unchecked((short)(ushort)(DataFormats.GetFormat("Format2").Id))); 2274result[0].cfFormat.Should().Be(unchecked((short)(ushort)(DataFormats.GetFormat(format1).Id))); 2371{ TextDataFormat.Rtf, (short)DataFormats.GetFormat(DataFormats.Rtf).Id }, 2372{ TextDataFormat.Html, (short)DataFormats.GetFormat(DataFormats.Html).Id } 2821DataObject native = new(DataFormats.Locale, value);
System\Windows\Forms\RichTextBoxTests.ClipboardTests.cs (6)
46richTextBox1.Paste(DataFormats.GetFormat(DataFormats.Text)); 58richTextBox1.Paste(DataFormats.GetFormat(DataFormats.Text)); 79richTextBox1.Paste(DataFormats.GetFormat(DataFormats.Rtf));
System\Windows\Forms\RichTextBoxTests.cs (7)
7841yield return new object[] { DataFormats.GetFormat(DataFormats.Palette), false }; 7842yield return new object[] { new DataFormats.Format("UnknownName", int.MaxValue), false }; 7847public void RichTextBox_CanPaste_Invoke_ReturnsExpected(DataFormats.Format format, bool expected) 7856public void RichTextBox_CanPaste_InvokeWithHandle_ReturnsExpected(DataFormats.Format format, bool expected) 7889Assert.Equal(expected, control.CanPaste(DataFormats.GetFormat(DataFormats.Text)));
System.Windows.Forms.TestUtilities (20)
DataObjectTestHelpers.cs (20)
16DataFormats.Text, 17DataFormats.UnicodeText, 18DataFormats.StringConstant, 19DataFormats.Rtf, 20DataFormats.Html, 21DataFormats.OemText, 22DataFormats.FileDrop, 29DataFormats.Serializable, 36DataFormats.CommaSeparatedValue, 37DataFormats.Dib, 38DataFormats.Dif, 39DataFormats.PenData, 40DataFormats.Riff, 41DataFormats.Tiff, 42DataFormats.WaveAudio, 43DataFormats.SymbolicLink, 44DataFormats.EnhancedMetafile, 45DataFormats.MetafilePict, 46DataFormats.Palette 51DataFormats.Bitmap,
System.Windows.Forms.UI.IntegrationTests (10)
DragDropTests.cs (10)
288if (e.Data?.GetDataPresent(DataFormats.Serializable) ?? false) 295if (e.Data?.GetDataPresent(DataFormats.Serializable) ?? false) 298data = (ListViewItem?)e.Data?.GetData(DataFormats.Serializable); 312data.SetData(DataFormats.Serializable, listViewItem); 1089DataObject data = new(DataFormats.FileDrop, dropFiles); 1107&& e.Data.GetDataPresent(DataFormats.FileDrop) 1108&& e.Data.GetData(DataFormats.FileDrop) is string[] fileNames 1122&& e.Data.GetDataPresent(DataFormats.FileDrop) 1123&& e.Data.GetData(DataFormats.FileDrop) is string[] fileNames 1149DataObject data = new(DataFormats.FileDrop, dropFiles);
TrimTest (3)
Form1.cs (3)
19if (e.Data is { } dataObject && dataObject.GetDataPresent(DataFormats.UnicodeText)) 27if (e.Data is { } dataObject && dataObject.GetDataPresent(DataFormats.UnicodeText)) 35if (e.Data is { } dataObject && dataObject.GetData(DataFormats.UnicodeText) is string text)
WinFormsControlsTest (11)
DragDrop.cs (11)
112if (e.Data.GetDataPresent(DataFormats.FileDrop) 113&& e.Data.GetData(DataFormats.FileDrop) is string[] files 159if (e.Data.GetDataPresent(DataFormats.FileDrop) 160&& e.Data.GetData(DataFormats.FileDrop) is string[] files 252else if (e.Data.GetDataPresent(DataFormats.FileDrop) 253&& e.Data.GetData(DataFormats.FileDrop) is string[] files 294else if (e.Data.GetDataPresent(DataFormats.FileDrop) 295&& e.Data.GetData(DataFormats.FileDrop) is string[] files 317if (e.Data.GetDataPresent(DataFormats.FileDrop) 346&& e.Data.GetDataPresent(DataFormats.FileDrop) 537DataObject data = new(DataFormats.FileDrop,