-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update to non-prerelease version of Microsoft.CsWin32
- Loading branch information
Showing
10 changed files
with
146 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Techsola.InstantReplay/InstantReplayCamera.CompositionRenderer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
using System; | ||
using Techsola.InstantReplay.Native; | ||
using Windows.Win32; | ||
|
||
namespace Techsola.InstantReplay | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using Windows.Win32; | ||
using Windows.Win32.Graphics.Gdi; | ||
|
||
namespace Techsola.InstantReplay.Native; | ||
|
||
// Workaround for https://github.com/microsoft/CsWin32/issues/209 | ||
internal sealed class DeleteDCSafeHandle : SafeHandle | ||
{ | ||
public DeleteDCSafeHandle(IntPtr handle) : base(invalidHandleValue: IntPtr.Zero, ownsHandle: true) | ||
{ | ||
SetHandle(handle); | ||
} | ||
|
||
public override bool IsInvalid => handle == IntPtr.Zero; | ||
|
||
protected override bool ReleaseHandle() | ||
{ | ||
return (bool)PInvoke.DeleteDC((HDC)handle); | ||
} | ||
} |
32 changes: 15 additions & 17 deletions
32
src/Techsola.InstantReplay/Native/WindowDeviceContextSafeHandle.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,27 @@ | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using System.Runtime.Versioning; | ||
using Windows.Win32; | ||
using Windows.Win32.Foundation; | ||
using Windows.Win32.Graphics.Gdi; | ||
|
||
namespace Techsola.InstantReplay.Native | ||
namespace Techsola.InstantReplay.Native; | ||
|
||
// Workaround for https://github.com/microsoft/CsWin32/issues/209 | ||
internal sealed class WindowDeviceContextSafeHandle : SafeHandle | ||
{ | ||
// Workaround for https://github.com/microsoft/CsWin32/issues/209 | ||
internal sealed class WindowDeviceContextSafeHandle : DeleteDCSafeHandle | ||
public WindowDeviceContextSafeHandle(HWND hWnd, IntPtr handle) | ||
: base(invalidHandleValue: IntPtr.Zero, ownsHandle: true) | ||
{ | ||
public WindowDeviceContextSafeHandle(HWND hWnd, IntPtr handle) | ||
: base(handle) | ||
{ | ||
HWnd = hWnd; | ||
} | ||
HWnd = hWnd; | ||
SetHandle(handle); | ||
} | ||
|
||
public HWND HWnd { get; } | ||
public HWND HWnd { get; } | ||
|
||
protected override bool ReleaseHandle() => ReleaseDC(HWnd, handle); | ||
public override bool IsInvalid => handle == IntPtr.Zero; | ||
|
||
/// <summary> | ||
/// <seealso href="https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-releasedc"/> | ||
/// </summary> | ||
[SupportedOSPlatform("windows")] | ||
[DllImport("user32.dll")] | ||
private static extern bool ReleaseDC(HWND hWnd, IntPtr hDC); | ||
protected override bool ReleaseHandle() | ||
{ | ||
return PInvoke.ReleaseDC(HWnd, (HDC)handle) == 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters