Added Updated-events

This commit is contained in:
Darth Affe 2021-05-21 21:02:13 +02:00
parent 1702415aa0
commit e6202d88b5
3 changed files with 47 additions and 2 deletions

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
using ScreenCapture.Events;
using SharpGen.Runtime; using SharpGen.Runtime;
using Vortice.Direct3D; using Vortice.Direct3D;
using Vortice.Direct3D11; using Vortice.Direct3D11;
@ -15,7 +16,7 @@ using Usage = Vortice.Direct3D11.Usage;
namespace ScreenCapture namespace ScreenCapture
{ {
// ReSharper disable once InconsistentNaming // ReSharper disable once InconsistentNaming
public class DX11ScreenCapture : IScreenCapture public sealed class DX11ScreenCapture : IScreenCapture
{ {
#region Constants #region Constants
@ -51,6 +52,12 @@ namespace ScreenCapture
#endregion #endregion
#region Events
public event EventHandler<ScreenCaptureUpdatedEventArgs>? Updated;
#endregion
#region Constructors #region Constructors
public DX11ScreenCapture(IDXGIFactory1 factory, Display display) public DX11ScreenCapture(IDXGIFactory1 factory, Display display)
@ -120,6 +127,12 @@ namespace ScreenCapture
} }
catch { /**/ } catch { /**/ }
try
{
Updated?.Invoke(this, new ScreenCaptureUpdatedEventArgs(result));
}
catch { /**/ }
return result; return result;
} }
} }

View File

@ -0,0 +1,22 @@
using System;
namespace ScreenCapture.Events
{
public class ScreenCaptureUpdatedEventArgs : EventArgs
{
#region Properties & Fields
public bool IsSuccessful { get; set; }
#endregion
#region Constructors
public ScreenCaptureUpdatedEventArgs(bool isSuccessful)
{
this.IsSuccessful = isSuccessful;
}
#endregion
}
}

View File

@ -1,4 +1,6 @@
namespace ScreenCapture using System;
namespace ScreenCapture
{ {
public sealed class CaptureZone public sealed class CaptureZone
{ {
@ -30,6 +32,12 @@
#endregion #endregion
#region Events
public event EventHandler? Updated;
#endregion
#region Constructors #region Constructors
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) 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 @@
{ {
IsUpdateRequested = false; IsUpdateRequested = false;
BlackBars.InvalidateCache(); BlackBars.InvalidateCache();
Updated?.Invoke(this, new EventArgs());
} }
public override int GetHashCode() => Id; public override int GetHashCode() => Id;