Skip to content

Commit e6202d8

Browse files
committed
Added Updated-events
1 parent 1702415 commit e6202d8

File tree

3 files changed

+47
-2
lines changed

3 files changed

+47
-2
lines changed

ScreenCapture/DirectX/DX11ScreenCapture.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using System.Runtime.InteropServices;
55
using System.Threading;
6+
using ScreenCapture.Events;
67
using SharpGen.Runtime;
78
using Vortice.Direct3D;
89
using Vortice.Direct3D11;
@@ -15,7 +16,7 @@
1516
namespace ScreenCapture
1617
{
1718
// ReSharper disable once InconsistentNaming
18-
public class DX11ScreenCapture : IScreenCapture
19+
public sealed class DX11ScreenCapture : IScreenCapture
1920
{
2021
#region Constants
2122

@@ -51,6 +52,12 @@ public class DX11ScreenCapture : IScreenCapture
5152

5253
#endregion
5354

55+
#region Events
56+
57+
public event EventHandler<ScreenCaptureUpdatedEventArgs>? Updated;
58+
59+
#endregion
60+
5461
#region Constructors
5562

5663
public DX11ScreenCapture(IDXGIFactory1 factory, Display display)
@@ -120,6 +127,12 @@ public bool CaptureScreen()
120127
}
121128
catch { /**/ }
122129

130+
try
131+
{
132+
Updated?.Invoke(this, new ScreenCaptureUpdatedEventArgs(result));
133+
}
134+
catch { /**/ }
135+
123136
return result;
124137
}
125138
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using System;
2+
3+
namespace ScreenCapture.Events
4+
{
5+
public class ScreenCaptureUpdatedEventArgs : EventArgs
6+
{
7+
#region Properties & Fields
8+
9+
public bool IsSuccessful { get; set; }
10+
11+
#endregion
12+
13+
#region Constructors
14+
15+
public ScreenCaptureUpdatedEventArgs(bool isSuccessful)
16+
{
17+
this.IsSuccessful = isSuccessful;
18+
}
19+
20+
#endregion
21+
}
22+
}

ScreenCapture/Model/CaptureZone.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace ScreenCapture
1+
using System;
2+
3+
namespace ScreenCapture
24
{
35
public sealed class CaptureZone
46
{
@@ -30,6 +32,12 @@ public sealed class CaptureZone
3032

3133
#endregion
3234

35+
#region Events
36+
37+
public event EventHandler? Updated;
38+
39+
#endregion
40+
3341
#region Constructors
3442

3543
public CaptureZone(int id, int x, int y, int width, int height, int downscaleLevel, int unscaledWidth, int unscaledHeight, int captureWidth, int captureHeight, int bufferWidth, int bufferHeight, byte[] buffer)
@@ -61,6 +69,8 @@ public void SetUpdated()
6169
{
6270
IsUpdateRequested = false;
6371
BlackBars.InvalidateCache();
72+
73+
Updated?.Invoke(this, new EventArgs());
6474
}
6575

6676
public override int GetHashCode() => Id;

0 commit comments

Comments
 (0)