diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-03-02 23:30:34 +0200 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-03-02 23:30:34 +0200 |
| commit | 0dcd742a3c35527386a93e1b1ef761c2aeff8308 (patch) | |
| tree | d5adb3fee35e73af95fa5d68b5316d25522471de /Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureFrame.cs | |
| parent | 1a7fb274158f8a0e279aef26206a65fefac8c4c3 (diff) | |
| download | Tango-0dcd742a3c35527386a93e1b1ef761c2aeff8308.tar.gz Tango-0dcd742a3c35527386a93e1b1ef761c2aeff8308.zip | |
Implemented Tango.RemoteDesktop.
Implemented png 8 bit quantization.
Implemented RasterFrame bounds clipping.
Refactored VectorFrame to use indexed colors.
Diffstat (limited to 'Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureFrame.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureFrame.cs | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureFrame.cs b/Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureFrame.cs new file mode 100644 index 000000000..75e7a961f --- /dev/null +++ b/Software/Visual_Studio/Tango.RemoteDesktop/ScreenCaptureFrame.cs @@ -0,0 +1,91 @@ +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 +{ + /// <summary> + /// Represents a screen capture frame for holding the original bitmap and difference frame. + /// </summary> + /// <typeparam name="TFrame">The type of the frame.</typeparam> + /// <seealso cref="Tango.RemoteDesktop.Frames.RasterFrame" /> + /// <seealso cref="System.IDisposable" /> + public class ScreenCaptureFrame<TFrame> : RasterFrame, IDisposable where TFrame : IFrame + { + private TFrame _diffFrame; + + /// <summary> + /// Initializes a new instance of the <see cref="ScreenCaptureFrame{TFrame}"/> class. + /// </summary> + /// <param name="bitmap">The bitmap.</param> + public ScreenCaptureFrame(Bitmap bitmap) : base(bitmap) + { + + } + + /// <summary> + /// Initializes a new instance of the <see cref="ScreenCaptureFrame{TFrame}"/> class. + /// </summary> + /// <param name="bitmap">The bitmap.</param> + /// <param name="diffFrame">The difference frame.</param> + public ScreenCaptureFrame(Bitmap bitmap, TFrame diffFrame) : this(bitmap) + { + _diffFrame = diffFrame; + } + + /// <summary> + /// Gets a value indicating whether a difference frame is available. + /// </summary> + public bool DifferenceAvailable + { + get { return _diffFrame != null; } + } + + /// <summary> + /// Gets or sets a value indicating whether the difference frame is available and contains any differences. + /// </summary> + private bool _hasDifference; + public bool HasDifference + { + get + { + return DifferenceAvailable && _hasDifference; + } + set { _hasDifference = value; } + } + + /// <summary> + /// Returns the difference frame. + /// </summary> + /// <returns></returns> + /// <exception cref="InvalidOperationException">No difference is available at this point. Please use the 'DifferenceAvailable' property before attempting to get the difference.</exception> + 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; + } + + /// <summary> + /// Releases unmanaged and - optionally - managed resources. + /// </summary> + public override void Dispose() + { + base.Dispose(); + + if (_diffFrame != null) + { + _diffFrame.Dispose(); + } + } + } +} |
