aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.RemoteDesktop/IScreenCaptureEngine.cs
blob: 6b5db2fbe13829b5dd53719a1fe2fe0a2bd129b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Tango.RemoteDesktop
{
    /// <summary>
    /// Represents a screen capture engine.
    /// </summary>
    /// <seealso cref="System.IDisposable" />
    public interface IScreenCaptureEngine : IDisposable
    {
        /// <summary>
        /// Gets or sets the screen capture method.
        /// </summary>
        ICaptureMethod CaptureMethod { get; set; }

        /// <summary>
        /// Gets or sets the screen capture region.
        /// </summary>
        CaptureRegion CaptureRegion { get; set; }

        /// <summary>
        /// Gets a value indicating whether this instance is currently capturing.
        /// </summary>
        bool IsStarted { get; }

        /// <summary>
        /// Gets or sets the frame rate per second.
        /// </summary>
        int FrameRate { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to include the cursor when capturing.
        /// </summary>
        bool CaptureCursor { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether to enable image comparison.
        /// </summary>
        bool EnableComparer { get; set; }

        /// <summary>
        /// Start capturing.
        /// </summary>
        void Start();

        /// <summary>
        /// Stop capturing.
        /// </summary>
        void Stop();
    }

    /// <summary>
    /// Represents a screen capture engine.
    /// </summary>
    /// <typeparam name="TFrame">The type of the frame.</typeparam>
    /// <seealso cref="System.IDisposable" />
    public interface IScreenCaptureEngine<TFrame> : IScreenCaptureEngine where TFrame : IFrame
    {
        /// <summary>
        /// Occurs when a new screen frame is available.
        /// </summary>
        event EventHandler<ScreenCaptureFrameReceivedEventArgs<TFrame>> FrameReceived;

        /// <summary>
        /// Gets or sets the bitmap comparer.
        /// </summary>
        IBitmapComparer<TFrame> Comparer { get; set; }
    }
}
RemoteVersion { get { return _remoteVersion; } set { _remoteVersion = value; RaisePropertyChangedAuto(); } } private PublishProgressEventArgs _publishArgs; public PublishProgressEventArgs PublishArgs { get { return _publishArgs; } set { _publishArgs = value; RaisePropertyChangedAuto(); } } public RelayCommand PublishCommand { get; set; } public MainWindowVM() { PublishCommand = new RelayCommand(Publish, () => Options.Email != null && Options.Password != null && Options.Comments != null && LocalVersion != null && RemoteVersion != null && IsFree); Options = SettingsManager.Default.GetOrCreate<PublisherSettings>().Options; _publisher = new MachineStudioPublisher(Options); _publisher.PublishProgress += _publisher_PublishProgress; Options.BasicInfoChanged += (_, __) => { InvalidateRelayCommands(); }; Options.EnvironmentChanged += (_, __) => UpdateVersions(); Options.BuidConfigChanged += (_, __) => UpdateVersions(); UpdateVersions(); } private void _publisher_PublishProgress(object sender, PublishProgressEventArgs e) { PublishArgs = e; } private async void UpdateVersions() { IsFree = false; LocalVersion = _publisher.GetLocalVersion(); RemoteVersion = await _publisher.GetRemoteVersion(); InvalidateRelayCommands(); IsFree = true; } private async void Publish() { SettingsManager.Default.Save(); if (!ShowQuestion("Did you remember to synchronize production database ?")) { return; } try { IsFree = false; await _publisher.Publish(); ShowInfo("Version published successfully."); UpdateVersions(); } catch (Exception ex) { ShowError(ex.FlattenMessage()); } finally { IsFree = true; } } private void ShowError(String error) { MessageBox.Show(error, "Machine Studio Publisher", MessageBoxButton.OK, MessageBoxImage.Error); } private void ShowInfo(String message) { MessageBox.Show(message, "Machine Studio Publisher", MessageBoxButton.OK, MessageBoxImage.Information); } private bool ShowQuestion(String message) { return MessageBox.Show(message, "Machine Studio Publisher", MessageBoxButton.YesNo, MessageBoxImage.Information) == MessageBoxResult.Yes; } } }