{
get
{
- return GetDeviceCaps(Interop.Gdi32.DeviceCapability.BITSPIXEL, 1) > 1;
+ // If the printer supports color printing, the return value is 1; otherwise, the return value is zero.
+ // The pointerToBuffer parameter is not used.
+ return DeviceCapabilities(
+ capability: SafeNativeMethods.DC_COLORDEVICE,
+ pointerToBuffer: IntPtr.Zero,
+ defaultValue: 0) == 1;
}
}
}
}
- [ActiveIssue("https://github.com/dotnet/runtime/issues/22221", TestPlatforms.AnyUnix)]
- [ConditionalFact(Helpers.AnyInstalledPrinters, Helpers.IsDrawingSupported)]
+ [PlatformSpecific(TestPlatforms.Windows)]
+ [ConditionalFact(typeof(PrinterSettingsTests), nameof(CanTestSetHdevmode_IntPtr_Success))]
public void SupportsColor_ReturnsExpected()
{
- var printerSettings = new PrinterSettings();
- bool supportsColor = printerSettings.SupportsColor;
+ // XPS and PDF printers support color.
+ // docs.microsoft.com/en-us/windows-hardware/drivers/print/improved-color-printing
+ var printerSettings = new PrinterSettings() { PrinterName = GetNameOfTestPrinterSuitableForDevModeTesting() };
+ Assert.True(printerSettings.SupportsColor);
}
[Theory]
private static readonly string[] s_TestPrinterNames =
{
- // Our method of testing this api requires a printer that supports multi-copy printing, collating and duplex settings. Not all printers
+ // Our method of testing some apis requires a printer that supports multi-copy printing, collating, color and duplex settings. Not all printers
// support these so rather than trust the machine running the test to have configured such a printer as the default, use the name of
// a known compliant printer that ships with Windows 10.
"Microsoft Print to PDF",