using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
using Tango.RemoteDesktop.Frames;
namespace Tango.RemoteDesktop
{
///
/// Represents a screen capture frame for holding the original bitmap and difference frame.
///
/// The type of the frame.
///
///
public class ScreenCaptureFrame : RasterFrame, IDisposable where TFrame : IFrame
{
private TFrame _diffFrame;
///
/// Initializes a new instance of the class.
///
/// The bitmap.
public ScreenCaptureFrame(Bitmap bitmap) : base(bitmap)
{
}
///
/// Initializes a new instance of the class.
///
/// The bitmap.
/// The difference frame.
public ScreenCaptureFrame(Bitmap bitmap, TFrame diffFrame) : this(bitmap)
{
_diffFrame = diffFrame;
}
///
/// Gets a value indicating whether a difference frame is available.
///
public bool DifferenceAvailable
{
get { return _diffFrame != null; }
}
///
/// Gets or sets the number differences.
///
public uint DifferenceCount { get; set; }
///
/// Returns the difference frame.
///
///
/// No difference is available at this point. Please use the 'DifferenceAvailable' property before attempting to get the difference.
public TFrame ToDifference()
{
if (!DifferenceAvailable)
{
throw new InvalidOperationException("No difference is available at this point. Please use the 'DifferenceAvailable' property before attempting to get the difference.");
}
return _diffFrame;
}
///
/// Releases unmanaged and - optionally - managed resources.
///
public override void Dispose()
{
base.Dispose();
if (_diffFrame != null)
{
_diffFrame.Dispose();
}
}
}
}