Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

Screenshot.cs 2.0 KiB

pirms 8 mēnešiem
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. using System;
  2. using System.Runtime.Remoting;
  3. using System.Security.Permissions;
  4. namespace RenderHookAPI.Interface
  5. {
  6. public class Screenshot : MarshalByRefObject, IDisposable
  7. {
  8. Guid _requestId;
  9. public Guid RequestId
  10. {
  11. get
  12. {
  13. return _requestId;
  14. }
  15. }
  16. public ImageFormat Format { get; set; }
  17. public System.Drawing.Imaging.PixelFormat PixelFormat { get; set; }
  18. public int Stride { get; set; }
  19. public int Height { get; set; }
  20. public int Width { get; set; }
  21. byte[] _data;
  22. public byte[] Data
  23. {
  24. get
  25. {
  26. return _data;
  27. }
  28. }
  29. private bool _disposed;
  30. public Screenshot(Guid requestId, byte[] data)
  31. {
  32. _requestId = requestId;
  33. _data = data;
  34. }
  35. ~Screenshot()
  36. {
  37. Dispose(false);
  38. }
  39. public void Dispose()
  40. {
  41. Dispose(true);
  42. GC.SuppressFinalize(this);
  43. }
  44. protected virtual void Dispose(bool disposeManagedResources)
  45. {
  46. if (!_disposed)
  47. {
  48. if (disposeManagedResources)
  49. {
  50. Disconnect();
  51. }
  52. _disposed = true;
  53. }
  54. }
  55. /// <summary>
  56. /// Disconnects the remoting channel(s) of this object and all nested objects.
  57. /// </summary>
  58. private void Disconnect()
  59. {
  60. RemotingServices.Disconnect(this);
  61. }
  62. [SecurityPermissionAttribute(SecurityAction.Demand, Flags = SecurityPermissionFlag.Infrastructure)]
  63. public override object InitializeLifetimeService()
  64. {
  65. // Returning null designates an infinite non-expiring lease.
  66. // We must therefore ensure that RemotingServices.Disconnect() is called when
  67. // it's no longer needed otherwise there will be a memory leak.
  68. return null;
  69. }
  70. }
  71. }