Skip to content

Commit 7d1dd73

Browse files
committed
Add method RecreateDirect2DCanvas
MessageToImageLibrary 0.1.2
1 parent e2a57f8 commit 7d1dd73

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

Direct2DWrapper/Resource.rc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ END
5151
//
5252

5353
VS_VERSION_INFO VERSIONINFO
54-
FILEVERSION 0,0,1,1
55-
PRODUCTVERSION 0,0,1,1
54+
FILEVERSION 0,0,1,2
55+
PRODUCTVERSION 0,0,1,2
5656
FILEFLAGSMASK 0x3fL
5757
#ifdef _DEBUG
5858
FILEFLAGS 0x3L
@@ -69,12 +69,12 @@ BEGIN
6969
BEGIN
7070
VALUE "CompanyName", "John Cook"
7171
VALUE "FileDescription", "Wrapper for Direct2D"
72-
VALUE "FileVersion", "0.0.1.1"
72+
VALUE "FileVersion", "0.0.1.2"
7373
VALUE "InternalName", "Direct2DWrapper"
7474
VALUE "LegalCopyright", "Copyright (C) John Cook 2020"
7575
VALUE "OriginalFilename", "Direct2DWrapper.dll"
7676
VALUE "ProductName", "MessageToImageLibrary"
77-
VALUE "ProductVersion", "0.0.1.1"
77+
VALUE "ProductVersion", "0.0.1.2"
7878
END
7979
END
8080
BLOCK "VarFileInfo"

MessageToImageLibrary/MessagePanel.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,29 @@ public void CreateDirect2DCanvas(SizeU canvasSize, ref Direct2DPointers direct2D
136136
Marshal.ThrowExceptionForHR(UnsafeNativeMethods.CreateRenderTarget(ref Direct2DCanvas));
137137
}
138138

139+
public void RecreateDirect2DCanvas()
140+
{
141+
// Release brushes from old render target
142+
ReleaseAllBrushes();
143+
// Release text layouts from old render target
144+
UnsafeNativeMethods.ReleaseTextLayout(headerTextLayout);
145+
UnsafeNativeMethods.ReleaseTextLayout(subHeaderTextLayout);
146+
UnsafeNativeMethods.ReleaseTextLayout(displayNameTextLayout);
147+
UnsafeNativeMethods.ReleaseTextLayout(usernameTextLayout);
148+
UnsafeNativeMethods.ReleaseTextLayout(messageTextTextLayout);
149+
UnsafeNativeMethods.ReleaseTextLayout(timeTextLayout);
150+
UnsafeNativeMethods.ReleaseTextLayout(sharerDisplayNameTextLayout);
151+
UnsafeNativeMethods.ReleaseTextLayout(sharerUsernameTextLayout);
152+
UnsafeNativeMethods.ReleaseTextLayout(headerTextLayout);
153+
UnsafeNativeMethods.ReleaseTextLayout(headerTextLayout);
154+
// Release old render target
155+
UnsafeNativeMethods.ReleaseRenderTarget(Direct2DCanvas);
156+
// Create replacement render target
157+
Marshal.ThrowExceptionForHR(UnsafeNativeMethods.CreateRenderTarget(ref Direct2DCanvas));
158+
// Wipe replacement render target with background colour
159+
WipeCanvas(true, true);
160+
}
161+
139162
public void SetFont(CanvasElement canvasElement, FontSettings fontSettings)
140163
{
141164
switch (canvasElement)

MessageToImageLibrary/MessageToImageLibrary.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<TargetFramework>netcoreapp3.1</TargetFramework>
66
<UseWPF>true</UseWPF>
77
<Platforms>AnyCPU;x64;x86</Platforms>
8-
<Version>0.1.1</Version>
8+
<Version>0.1.2</Version>
99
<Authors>John Cook</Authors>
1010
<Company>John Cook</Company>
1111
<Description>A test/sample C# solution with an ordinary (non-MFC) C++ DLL project.</Description>

0 commit comments

Comments
 (0)