Compare commits

...

4 Commits

9 changed files with 264 additions and 43 deletions

View File

@ -5084,7 +5084,9 @@ public static partial class NCrypt
/// </summary>
public NCryptBuffer[] pBuffers
{
#pragma warning disable CA2021 // Do not call Enumerable.Cast<T> or Enumerable.OfType<T> with incompatible types
get => _pBuffers.ToIEnum<_NCryptBuffer>((int)cBuffers).Cast<NCryptBuffer>().ToArray();
#pragma warning restore CA2021 // Do not call Enumerable.Cast<T> or Enumerable.OfType<T> with incompatible types
set
{
((IDisposable)this).Dispose();

View File

@ -659,7 +659,9 @@ public static partial class Gdi32
throw new ArgumentException($"The supplied type cannot be enumerated by this function.");
var l = new List<IntPtr>();
EnumObjects(hdc, ev, EnumProc);
#pragma warning disable CA2021 // Do not call Enumerable.Cast<T> or Enumerable.OfType<T> with incompatible types
return l.Cast<T>();
#pragma warning restore CA2021 // Do not call Enumerable.Cast<T> or Enumerable.OfType<T> with incompatible types
int EnumProc(IntPtr Arg1, IntPtr Arg2)
{

View File

@ -2156,6 +2156,16 @@ public static partial class Kernel32
[CorrespondingType(typeof(STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR))]
StorageAccessAlignmentProperty,
/// <summary>
/// Indicates that the caller is querying for the seek penalty descriptor, DEVICE_SEEK_PENALTY_DESCRIPTOR.
/// <para>
/// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This value is not supported before Windows 7 and Windows
/// Server 2008 R2.
/// </para>
/// </summary>
[CorrespondingType(typeof(DEVICE_SEEK_PENALTY_DESCRIPTOR))]
StorageDeviceSeekPenaltyProperty,
/// <summary>
/// Indicates that the caller is querying for the trim descriptor, DEVICE_TRIM_DESCRIPTOR. Windows Server 2008, Windows Vista,
/// Windows Server 2003 and Windows XP: This value is not supported before Windows 7 and Windows Server 2008 R2.
@ -2163,6 +2173,23 @@ public static partial class Kernel32
[CorrespondingType(typeof(DEVICE_TRIM_DESCRIPTOR))]
StorageDeviceTrimProperty,
/// <summary>Reserved for system use.</summary>
StorageDeviceWriteAggregationProperty,
/// <summary>Reserved for system use.</summary>
StorageDeviceDeviceTelemetryProperty,
/// <summary>
/// Indicates that the caller is querying for the logical block provisioning property. Data is returned using the
/// DEVICE_LB_PROVISIONING_DESCRIPTOR structure.
/// <para>
/// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This value is not supported before Windows 7 and Windows
/// Server 2008 R2.
/// </para>
/// </summary>
[CorrespondingType(typeof(DEVICE_LB_PROVISIONING_DESCRIPTOR))]
StorageDeviceLBProvisioningProperty,
/// <summary>
/// Indicates that the caller is querying for the device power descriptor. Data is returned using the DEVICE_POWER_DESCRIPTOR
/// structure. Windows 7, Windows Server 2008 R2, Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This
@ -2171,6 +2198,17 @@ public static partial class Kernel32
[CorrespondingType(typeof(DEVICE_POWER_DESCRIPTOR))]
StorageDevicePowerProperty,
/// <summary>
/// Indicates that the caller is querying for the copy offload parameters property. Data is returned using the
/// DEVICE_COPY_OFFLOAD_DESCRIPTOR structure.
/// <para>
/// Windows Server 2008, Windows Vista, Windows Server 2003 and Windows XP: This value is not supported before Windows 7 and Windows
/// Server 2008 R2.
/// </para>
/// </summary>
[CorrespondingType(typeof(DEVICE_COPY_OFFLOAD_DESCRIPTOR))]
StorageDeviceCopyOffloadProperty,
/// <summary>Reserved for system use.</summary>
StorageDeviceResiliencyProperty,
@ -2282,7 +2320,10 @@ public static partial class Kernel32
StorageDeviceSelfEncryptionProperty = 64,
/// <summary>Provides identification info for a storage device that can be physically replaced with a Field Replacement Unit (FRU).</summary>
StorageFruIdProperty
StorageFruIdProperty,
/// <summary/>
StorageStackProperty
}
/// <summary>

View File

@ -2107,21 +2107,47 @@ public static partial class User32
public static extern int DrawTextEx(HDC hdc, StringBuilder lpchText, int cchText, in RECT lprc, DrawTextFlags format, [Optional] DRAWTEXTPARAMS? lpdtp);
/// <summary>
/// The GetDC function retrieves a handle to a device context (DC) for the client area of a specified window or for the entire
/// <para>
/// The <c>GetDC</c> function retrieves a handle to a device context (DC) for the client area of a specified window or for the entire
/// screen. You can use the returned handle in subsequent GDI functions to draw in the DC. The device context is an opaque data
/// structure, whose values are used internally by GDI.
/// </para>
/// <para>
/// The GetDCEx function is an extension to <c>GetDC</c>, which gives an application more control over how and whether clipping occurs in
/// the client area.
/// </para>
/// </summary>
/// <param name="ptr">
/// A handle to the window whose DC is to be retrieved. If this value is NULL, GetDC retrieves the DC for the entire screen.
/// <param name="hWnd">
/// A handle to the window whose DC is to be retrieved. If this value is <c>NULL</c>, <c>GetDC</c> retrieves the DC for the entire screen.
/// </param>
/// <returns>
/// If the function succeeds, the return value is a handle to the DC for the specified window's client area. If the function fails,
/// the return value is NULL.
/// <para>If the function succeeds, the return value is a handle to the DC for the specified window's client area.</para>
/// <para>If the function fails, the return value is <c>NULL</c>.</para>
/// </returns>
// https://msdn.microsoft.com/en-us/library/windows/desktop/dd144871(v=vs.85).aspx
[DllImport(Lib.User32, SetLastError = false, ExactSpelling = true)]
[PInvokeData("Winuser.h", MSDNShortId = "dd144871")]
public static extern SafeHDC GetDC([In, Optional] HWND ptr);
/// <remarks>
/// <para>
/// The <c>GetDC</c> function retrieves a common, class, or private DC depending on the class style of the specified window. For class
/// and private DCs, <c>GetDC</c> leaves the previously assigned attributes unchanged. However, for common DCs, <c>GetDC</c> assigns
/// default attributes to the DC each time it is retrieved. For example, the default font is System, which is a bitmap font. Because of
/// this, the handle to a common DC returned by <c>GetDC</c> does not tell you what font, color, or brush was used when the window was
/// drawn. To determine the font, call GetTextFace.
/// </para>
/// <para>Note that the handle to the DC can only be used by a single thread at any one time.</para>
/// <para>
/// After painting with a common DC, the ReleaseDC function must be called to release the DC. Class and private DCs do not have to be
/// released. <c>ReleaseDC</c> must be called from the same thread that called <c>GetDC</c>. The number of DCs is limited only by
/// available memory.
/// </para>
/// <para>Examples</para>
/// <para>For an example, see Drawing with the Mouse.</para>
/// </remarks>
// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getdc
// HDC GetDC( [in] HWND hWnd );
[PInvokeData("winuser.h", MSDNShortId = "NF:winuser.GetDC")]
public static SafeReleaseHDC GetDC([In, Optional] HWND hWnd) => new(GetDCInternal(hWnd), hWnd);
[DllImport(Lib.User32, SetLastError = false, EntryPoint = "GetDC")]
private static extern IntPtr GetDCInternal([In, Optional] HWND hWnd);
/// <summary>
/// <para>
@ -3159,4 +3185,36 @@ After:
/// </summary>
public uint uiLengthDrawn;
}
/// <summary>A SafeHandle to track DC handles retrieved via <see cref="GetDC"/>.</summary>
public class SafeReleaseHDC : SafeHANDLE
{
private readonly HWND hWnd;
/// <summary>
/// Initializes a new instance of the <see cref="SafeReleaseHDC" /> class and assigns an existing handle.
/// </summary>
/// <param name="preexistingHandle">An <see cref="IntPtr" /> object that represents the pre-existing handle to use.</param>
/// <param name="hwnd">A handle to the window whose DC is to be retrieved. If this value is NULL, GetDC retrieves the DC for the entire screen.</param>
/// <param name="ownsHandle"><see langword="true" /> to reliably release the handle during the finalization phase; otherwise, <see langword="false" /> (not recommended).</param>
public SafeReleaseHDC(IntPtr preexistingHandle, HWND hwnd = default, bool ownsHandle = true) : base(preexistingHandle, ownsHandle) => hWnd = hwnd;
private SafeReleaseHDC(HWND hwnd = default) : base() => hWnd = hwnd;
/// <summary>A NULL value for this handle.</summary>
public static readonly SafeReleaseHDC Null = new(IntPtr.Zero, default, false);
/// <summary>Performs an implicit conversion from <see cref="SafeReleaseHDC"/> to <see cref="HDC"/>.</summary>
/// <param name="h">The safe handle instance.</param>
/// <returns>The result of the conversion.</returns>
public static implicit operator HDC(SafeReleaseHDC h) => h.handle;
/// <summary>Creates a context into which a graphics object is selected.</summary>
/// <param name="hObject">The graphics object to select.</param>
/// <returns>A selection context for the graphics object.</returns>
public GdiObjectContext SelectObject(HGDIOBJ hObject) => new(handle, hObject);
/// <inheritdoc/>
protected override bool InternalReleaseHandle() => ReleaseDC(hWnd, handle);
}
}

View File

@ -254,6 +254,30 @@ public static partial class User32
RIDEV_REMOVE = 0x00000001,
}
/// <summary>
/// Specifies what data will be returned in <c>pData</c> with <see cref="GetRawInputDeviceInfo(HANDLE, RIDI, IntPtr, ref uint)"/>.
/// </summary>
[PInvokeData("winuser.h")]
public enum RIDI
{
/// <summary>pData is a PHIDP_PREPARSED_DATA pointer to a buffer for a top-level collection's preparsed data.</summary>
RIDI_PREPARSEDDATA = 0x20000005,
/// <summary>
/// pData points to a string that contains the device interface name.
/// <para>
/// If this device is opened with Shared Access Mode then you can call CreateFile with this name to open a HID collection and use
/// returned handle for calling ReadFile to read input reports and WriteFile to send output reports.
/// </para>
/// <para>For more information, see Opening HID Collections and Handling HID Reports.</para>
/// <para>For this uiCommand only, the value in pcbSize is the character count (not the byte count).</para>
/// </summary>
RIDI_DEVICENAME = 0x20000007,
/// <summary>pData points to an <see cref="RID_DEVICE_INFO"/> structure.</summary>
RIDI_DEVICEINFO = 0x2000000b,
}
/// <summary>The type of raw input.</summary>
[PInvokeData("winuser.h")]
public enum RIM_TYPE
@ -448,55 +472,129 @@ public static partial class User32
/// </param>
/// <param name="uiCommand">
/// <para>Type: <c>UINT</c></para>
/// <para>Specifies what data will be returned in pData. This parameter can be one of the following values.</para>
/// <para>Specifies what data will be returned in <c>pData</c>. This parameter can be one of the following values.</para>
/// <list type="table">
/// <listheader>
/// <term>Value</term>
/// <term>Meaning</term>
/// <description>Value</description>
/// <description>Meaning</description>
/// </listheader>
/// <item>
/// <term>RIDI_DEVICENAME 0x20000007</term>
/// <term>
/// pData points to a string that contains the device name. For this uiCommand only, the value in pcbSize is the character count
/// (not the byte count).
/// </term>
/// <description><c>RIDI_PREPARSEDDATA</c> 0x20000005</description>
/// <description><c>pData</c> is a PHIDP_PREPARSED_DATA pointer to a buffer for a top-level collection's preparsed data.</description>
/// </item>
/// <item>
/// <term>RIDI_DEVICEINFO 0x2000000b</term>
/// <term>pData points to an RID_DEVICE_INFO structure.</term>
/// <description><c>RIDI_DEVICENAME</c> 0x20000007</description>
/// <description>
/// <c>pData</c> points to a string that contains the device interface name. If this device is opened with Shared Access Mode then you
/// can call CreateFile with this name to open a HID collection and use returned handle for calling ReadFile to read input reports and
/// WriteFile to send output reports. For more information, see Opening HID Collections and Handling HID Reports. For this
/// <c>uiCommand</c> only, the value in <c>pcbSize</c> is the character count (not the byte count).
/// </description>
/// </item>
/// <item>
/// <term>RIDI_PREPARSEDDATA 0x20000005</term>
/// <term>pData points to the previously parsed data.</term>
/// <description><c>RIDI_DEVICEINFO</c> 0x2000000b</description>
/// <description><c>pData</c> points to an RID_DEVICE_INFO structure.</description>
/// </item>
/// </list>
/// </param>
/// <param name="pData">
/// <para>Type: <c>LPVOID</c></para>
/// <para>
/// A pointer to a buffer that contains the information specified by uiCommand. If uiCommand is <c>RIDI_DEVICEINFO</c>, set the
/// <c>cbSize</c> member of RID_DEVICE_INFO to before calling <c>GetRawInputDeviceInfo</c>.
/// </para>
/// <para>A pointer to a buffer that contains the information specified by <c>uiCommand</c>.</para>
/// <para>If <c>uiCommand</c> is <c>RIDI_DEVICEINFO</c>, set the <c>cbSize</c> member of RID_DEVICE_INFO to before calling <c>GetRawInputDeviceInfo</c>.</para>
/// </param>
/// <param name="pcbSize">
/// <para>Type: <c>PUINT</c></para>
/// <para>The size, in bytes, of the data in pData.</para>
/// <para>The size, in bytes, of the data in <c>pData</c>.</para>
/// </param>
/// <returns>
/// <para>Type: <c>UINT</c></para>
/// <para>If successful, this function returns a non-negative number indicating the number of bytes copied to pData.</para>
/// <para>If successful, this function returns a non-negative number indicating the number of bytes copied to <c>pData</c>.</para>
/// <para>
/// If pData is not large enough for the data, the function returns -1. If pData is <c>NULL</c>, the function returns a value of
/// zero. In both of these cases, pcbSize is set to the minimum size required for the pData buffer.
/// If <c>pData</c> is not large enough for the data, the function returns -1. If <c>pData</c> is <c>NULL</c>, the function returns a
/// value of zero. In both of these cases, <c>pcbSize</c> is set to the minimum size required for the <c>pData</c> buffer.
/// </para>
/// <para>Call GetLastError to identify any other errors.</para>
/// </returns>
// https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getrawinputdeviceinfoa UINT GetRawInputDeviceInfoA(
// HANDLE hDevice, UINT uiCommand, LPVOID pData, PUINT pcbSize );
/// <remarks>
/// <para>Note</para>
/// <para>
/// The winuser.h header defines GetRawInputDeviceInfo as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not
/// encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for
/// Function Prototypes.
/// </para>
/// </remarks>
// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getrawinputdeviceinfoa
// UINT GetRawInputDeviceInfoA( [in, optional] HANDLE hDevice, [in] UINT uiCommand, [in, out, optional] LPVOID pData, [in, out] PUINT pcbSize );
[PInvokeData("winuser.h", MSDNShortId = "NF:winuser.GetRawInputDeviceInfoA")]
[DllImport(Lib.User32, SetLastError = true, CharSet = CharSet.Auto)]
[PInvokeData("winuser.h", MSDNShortId = "")]
public static extern uint GetRawInputDeviceInfo(HANDLE hDevice, uint uiCommand, [Optional] IntPtr pData, ref uint pcbSize);
/// <summary>Retrieves information about the raw input device.</summary>
/// <param name="hDevice">
/// <para>Type: <c>HANDLE</c></para>
/// <para>A handle to the raw input device. This comes from the <c>hDevice</c> member of RAWINPUTHEADER or from GetRawInputDeviceList.</para>
/// </param>
/// <param name="uiCommand">
/// <para>Type: <c>UINT</c></para>
/// <para>Specifies what data will be returned in <c>pData</c>. This parameter can be one of the following values.</para>
/// <list type="table">
/// <listheader>
/// <description>Value</description>
/// <description>Meaning</description>
/// </listheader>
/// <item>
/// <description><c>RIDI_PREPARSEDDATA</c> 0x20000005</description>
/// <description><c>pData</c> is a PHIDP_PREPARSED_DATA pointer to a buffer for a top-level collection's preparsed data.</description>
/// </item>
/// <item>
/// <description><c>RIDI_DEVICENAME</c> 0x20000007</description>
/// <description>
/// <c>pData</c> points to a string that contains the device interface name. If this device is opened with Shared Access Mode then you
/// can call CreateFile with this name to open a HID collection and use returned handle for calling ReadFile to read input reports and
/// WriteFile to send output reports. For more information, see Opening HID Collections and Handling HID Reports. For this
/// <c>uiCommand</c> only, the value in <c>pcbSize</c> is the character count (not the byte count).
/// </description>
/// </item>
/// <item>
/// <description><c>RIDI_DEVICEINFO</c> 0x2000000b</description>
/// <description><c>pData</c> points to an RID_DEVICE_INFO structure.</description>
/// </item>
/// </list>
/// </param>
/// <param name="pData">
/// <para>Type: <c>LPVOID</c></para>
/// <para>A pointer to a buffer that contains the information specified by <c>uiCommand</c>.</para>
/// <para>If <c>uiCommand</c> is <c>RIDI_DEVICEINFO</c>, set the <c>cbSize</c> member of RID_DEVICE_INFO to before calling <c>GetRawInputDeviceInfo</c>.</para>
/// </param>
/// <param name="pcbSize">
/// <para>Type: <c>PUINT</c></para>
/// <para>The size, in bytes, of the data in <c>pData</c>.</para>
/// </param>
/// <returns>
/// <para>Type: <c>UINT</c></para>
/// <para>If successful, this function returns a non-negative number indicating the number of bytes copied to <c>pData</c>.</para>
/// <para>
/// If <c>pData</c> is not large enough for the data, the function returns -1. If <c>pData</c> is <c>NULL</c>, the function returns a
/// value of zero. In both of these cases, <c>pcbSize</c> is set to the minimum size required for the <c>pData</c> buffer.
/// </para>
/// <para>Call GetLastError to identify any other errors.</para>
/// </returns>
/// <remarks>
/// <para>Note</para>
/// <para>
/// The winuser.h header defines GetRawInputDeviceInfo as an alias which automatically selects the ANSI or Unicode version of this
/// function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not
/// encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for
/// Function Prototypes.
/// </para>
/// </remarks>
// https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getrawinputdeviceinfoa
// UINT GetRawInputDeviceInfoA( [in, optional] HANDLE hDevice, [in] UINT uiCommand, [in, out, optional] LPVOID pData, [in, out] PUINT pcbSize );
[PInvokeData("winuser.h", MSDNShortId = "NF:winuser.GetRawInputDeviceInfoA")]
[DllImport(Lib.User32, SetLastError = true, CharSet = CharSet.Auto)]
public static extern uint GetRawInputDeviceInfo(HANDLE hDevice, RIDI uiCommand, [Optional] IntPtr pData, ref uint pcbSize);
/// <summary>Enumerates the raw input devices attached to the system.</summary>
/// <param name="pRawInputDeviceList">
/// <para>Type: <c>PRAWINPUTDEVICELIST</c></para>

View File

@ -21,6 +21,26 @@ public partial class User32Tests
TestContext.WriteLine($"{array[i].dwID} = {array[i].dwWant} / {array[i].dwBlock}");
}
[Test]
public void GetRawInputDeviceInfoTest()
{
uint nDev = 0;
Assert.That(GetRawInputDeviceList(null, ref nDev, (uint)Marshal.SizeOf(typeof(RAWINPUTDEVICELIST))), ResultIs.Not.Value(uint.MaxValue));
Assert.That(nDev, Is.GreaterThan(0));
RAWINPUTDEVICELIST[] devs = new RAWINPUTDEVICELIST[(int)nDev];
Assert.That(nDev = GetRawInputDeviceList(devs, ref nDev, (uint)Marshal.SizeOf(typeof(RAWINPUTDEVICELIST))), ResultIs.Not.Value(uint.MaxValue));
Assert.That(nDev, Is.GreaterThan(0));
for (int i = 0; i < nDev; i++)
{
uint sz = 0;
Assert.That(GetRawInputDeviceInfo(devs[i].hDevice, RIDI.RIDI_DEVICENAME, default, ref sz), ResultIs.Value(0));
SafeLPTSTR data = new((int)sz + 1);
Assert.That(GetRawInputDeviceInfo(devs[i].hDevice, RIDI.RIDI_DEVICENAME, data, ref sz), Is.GreaterThan(0));
TestContext.WriteLine($"{data}");
}
}
[Test]
public void WinTest()
{

View File

@ -35,7 +35,7 @@ public class ShellDataObject : DataObject
/// <summary>Initializes a new instance of the <see cref="ShellDataObject"/> class.</summary>
/// <param name="items">A list of ShellItem instances.</param>
public ShellDataObject(IEnumerable<ShellItem> items) : base((items as ShellItemArray ?? new ShellItemArray(items)).ToDataObject())
public ShellDataObject(IEnumerable<ShellItem> items) : base((items as ShellItemArray ?? new ShellItemArray(items)).ToDataObject()!)
{
}
@ -58,7 +58,7 @@ public class ShellDataObject : DataObject
/// </summary>
public System.Globalization.CultureInfo Culture
{
get => base.GetDataPresent(DataFormats.Locale) ? new((int)base.GetData(DataFormats.Locale, false)) : System.Globalization.CultureInfo.CurrentCulture;
get => base.GetDataPresent(DataFormats.Locale) ? new((int)base.GetData(DataFormats.Locale, false)!) : System.Globalization.CultureInfo.CurrentCulture;
set => base.SetData(DataFormats.Locale, false, value.LCID);
}
@ -74,7 +74,7 @@ public class ShellDataObject : DataObject
/// <value><see langword="true"/> if the data object is within a drag-and-drop loop; otherwise, <see langword="false"/>.</value>
public bool InDragLoop
{
get => base.GetDataPresent(ShellClipboardFormat.CFSTR_INDRAGLOOP) && (int)base.GetData(ShellClipboardFormat.CFSTR_INDRAGLOOP, false) != 0;
get => base.GetDataPresent(ShellClipboardFormat.CFSTR_INDRAGLOOP) && (int)base.GetData(ShellClipboardFormat.CFSTR_INDRAGLOOP, false)! != 0;
set => base.SetData(ShellClipboardFormat.CFSTR_INDRAGLOOP, false, value ? 1 : 0);
}
@ -109,7 +109,7 @@ public class ShellDataObject : DataObject
/// <value>Specifies whether its preferred method of data transfer is move or copy.</value>
public DragDropEffects PreferredDropEffect
{
get => base.GetDataPresent(ShellClipboardFormat.CFSTR_PREFERREDDROPEFFECT) ? (DragDropEffects)(int)base.GetData(ShellClipboardFormat.CFSTR_PREFERREDDROPEFFECT, false) : 0;
get => base.GetDataPresent(ShellClipboardFormat.CFSTR_PREFERREDDROPEFFECT) ? (DragDropEffects)(int)base.GetData(ShellClipboardFormat.CFSTR_PREFERREDDROPEFFECT, false)! : 0;
set => base.SetData(ShellClipboardFormat.CFSTR_PREFERREDDROPEFFECT, false, (int)value);
}
@ -124,7 +124,7 @@ public class ShellDataObject : DataObject
/// <value>The CLSID.</value>
public Guid TargetClsid
{
get => base.GetDataPresent(ShellClipboardFormat.CFSTR_TARGETCLSID) ? (Guid)base.GetData(ShellClipboardFormat.CFSTR_TARGETCLSID, false) : default;
get => base.GetDataPresent(ShellClipboardFormat.CFSTR_TARGETCLSID) ? (Guid)base.GetData(ShellClipboardFormat.CFSTR_TARGETCLSID, false)! : default;
set => base.SetData(ShellClipboardFormat.CFSTR_TARGETCLSID, false, value);
}
@ -187,7 +187,7 @@ public class ShellDataObject : DataObject
case ShellClipboardFormat.CFSTR_SHELLIDLIST:
return GetShellIdList() ?? new ShellItemArray();
}
return base.GetData(format, autoConvert);
return base.GetData(format, autoConvert)!;
}
/// <summary>Retrieves the data associated with the specified data format at the specified index.</summary>
@ -272,7 +272,7 @@ public class ShellDataObject : DataObject
/// <param name="data">The data.</param>
/// <returns></returns>
/// <exception cref="ArgumentException">Data value must be of type DROPDESCRIPTION., nameof(data)</exception>
public override void SetData(string format, object data)
public override void SetData(string format, object? data)
{
if (format == ShellClipboardFormat.CFSTR_DROPDESCRIPTION)
{

View File

@ -242,7 +242,7 @@ public class ShellBrowser : UserControl, IWin32Window, IShellBrowser, Shell32.IS
/// </summary>
[Bindable(false), Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public override Image BackgroundImage => base.BackgroundImage;
public override Image BackgroundImage => base.BackgroundImage!;
/// <inheritdoc/>
protected override Size DefaultSize => new(200, 150);
@ -614,7 +614,7 @@ public class ShellBrowser : UserControl, IWin32Window, IShellBrowser, Shell32.IS
{
var forward = (keyData & Keys.Shift) != Keys.Shift;
Parent.SelectNextControl(ActiveControl, forward: forward, tabStopOnly: true, nested: true, wrap: true);
Parent!.SelectNextControl(ActiveControl, forward: forward, tabStopOnly: true, nested: true, wrap: true);
return true;
}

View File

@ -10,7 +10,7 @@ public partial class ThumbnailToolbarButton
private string key = string.Empty;
private bool useIntegerIndex = true;
public virtual int ActualIndex => useIntegerIndex ? Index : (ImageList is null ? -1 : ImageList.Images.IndexOfKey(Key));
public virtual int ActualIndex => useIntegerIndex ? Index : (ImageList is null ? -1 : ImageList.Images.IndexOfKey(Key ?? ""));
public virtual ImageList? ImageList { get; set; }