Skip to content

Commit

Permalink
Add method RecreateDirect2DCanvas
Browse files Browse the repository at this point in the history
MessageToImageLibrary 0.1.2
  • Loading branch information
watfordjc committed Sep 7, 2020
1 parent e2a57f8 commit 7d1dd73
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
8 changes: 4 additions & 4 deletions Direct2DWrapper/Resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,0,1,1
PRODUCTVERSION 0,0,1,1
FILEVERSION 0,0,1,2
PRODUCTVERSION 0,0,1,2
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x3L
Expand All @@ -69,12 +69,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "John Cook"
VALUE "FileDescription", "Wrapper for Direct2D"
VALUE "FileVersion", "0.0.1.1"
VALUE "FileVersion", "0.0.1.2"
VALUE "InternalName", "Direct2DWrapper"
VALUE "LegalCopyright", "Copyright (C) John Cook 2020"
VALUE "OriginalFilename", "Direct2DWrapper.dll"
VALUE "ProductName", "MessageToImageLibrary"
VALUE "ProductVersion", "0.0.1.1"
VALUE "ProductVersion", "0.0.1.2"
END
END
BLOCK "VarFileInfo"
Expand Down
23 changes: 23 additions & 0 deletions MessageToImageLibrary/MessagePanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,29 @@ public void CreateDirect2DCanvas(SizeU canvasSize, ref Direct2DPointers direct2D
Marshal.ThrowExceptionForHR(UnsafeNativeMethods.CreateRenderTarget(ref Direct2DCanvas));
}

public void RecreateDirect2DCanvas()
{
// Release brushes from old render target
ReleaseAllBrushes();
// Release text layouts from old render target
UnsafeNativeMethods.ReleaseTextLayout(headerTextLayout);
UnsafeNativeMethods.ReleaseTextLayout(subHeaderTextLayout);
UnsafeNativeMethods.ReleaseTextLayout(displayNameTextLayout);
UnsafeNativeMethods.ReleaseTextLayout(usernameTextLayout);
UnsafeNativeMethods.ReleaseTextLayout(messageTextTextLayout);
UnsafeNativeMethods.ReleaseTextLayout(timeTextLayout);
UnsafeNativeMethods.ReleaseTextLayout(sharerDisplayNameTextLayout);
UnsafeNativeMethods.ReleaseTextLayout(sharerUsernameTextLayout);
UnsafeNativeMethods.ReleaseTextLayout(headerTextLayout);
UnsafeNativeMethods.ReleaseTextLayout(headerTextLayout);
// Release old render target
UnsafeNativeMethods.ReleaseRenderTarget(Direct2DCanvas);
// Create replacement render target
Marshal.ThrowExceptionForHR(UnsafeNativeMethods.CreateRenderTarget(ref Direct2DCanvas));
// Wipe replacement render target with background colour
WipeCanvas(true, true);
}

public void SetFont(CanvasElement canvasElement, FontSettings fontSettings)
{
switch (canvasElement)
Expand Down
2 changes: 1 addition & 1 deletion MessageToImageLibrary/MessageToImageLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
<Platforms>AnyCPU;x64;x86</Platforms>
<Version>0.1.1</Version>
<Version>0.1.2</Version>
<Authors>John Cook</Authors>
<Company>John Cook</Company>
<Description>A test/sample C# solution with an ordinary (non-MFC) C++ DLL project.</Description>
Expand Down

0 comments on commit 7d1dd73

Please sign in to comment.