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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media.Imaging;
using Tango.Core.Commands;
using Tango.Core.Threading;
using Tango.FSE.Common;
using Tango.FSE.Common.RemoteDesktop;
using Tango.RemoteDesktop.Frames;
using Tango.RemoteDesktop.Network;
namespace Tango.FSE.PPCConsole.ViewModels
{
public class RemoteDesktopViewVM : FSEViewModel
{
private BitmapSource _source;
public BitmapSource Source
{
get { return _source; }
set { _source = value; RaisePropertyChangedAuto(); }
}
public RelayCommand StartCommand { get; set; }
public RelayCommand StopCommand { get; set; }
public RemoteDesktopViewVM()
{
StartCommand = new RelayCommand(StartRemoteDesktop);
StopCommand = new RelayCommand(StopRemoteDesktop);
}
public override void OnApplicationStarted()
{
base.OnApplicationStarted();
RemoteDesktopProvider.FrameReceived += RemoteDesktopProvider_FrameReceived;
}
private async void StartRemoteDesktop()
{
try
{
await RemoteDesktopProvider.StartSession();
}
catch (Exception ex)
{
await NotificationProvider.ShowError($"Error starting remote desktop session.\n{ex.FlattenMessage()}");
}
}
private async void StopRemoteDesktop()
{
try
{
await RemoteDesktopProvider.EndSession();
}
catch (Exception ex)
{
await NotificationProvider.ShowError($"Error stopping remote desktop session.\n{ex.FlattenMessage()}");
}
}
private void RemoteDesktopProvider_FrameReceived(object sender, DesktopFrameReceivedEventArgs e)
{
Source = e.Source;
}
public override async Task<bool> OnApplicationLogout()
{
if (RemoteDesktopProvider.InSession)
{
if (await NotificationProvider.ShowWarningQuestion("The remote desktop session with the remote machine will be closed.\nAre you sure you want to log out?"))
{
await RemoteDesktopProvider.EndSession();
return true;
}
else
{
return false;
}
}
else
{
return true;
}
}
#region Mouse & Keyboard Handlers From View
public void OnMouseDown(MouseButton changedButton, System.Windows.Point point, System.Windows.Size size)
{
RemoteDesktopProvider.MouseDown(changedButton, point, size);
}
public void OnMouseUp(MouseButton changedButton, System.Windows.Point point, System.Windows.Size size)
{
RemoteDesktopProvider.MouseUp(changedButton, point, size);
}
public void OnMouseMove(System.Windows.Point point, System.Windows.Size size)
{
//RemoteDesktopProvider.MouseMove(point, size);
}
public void OnMouseDoubleClick(MouseButton changedButton, System.Windows.Point point, System.Windows.Size size)
{
RemoteDesktopProvider.MouseDoubleClick(changedButton, point, size);
}
public void OnKeyboardDown(Key key, bool ctrlDown, bool shitDown, bool altDown)
{
throw new NotImplementedException();
}
public void OnKeyboardUp(Key key, bool ctrlDown, bool shitDown, bool altDown)
{
throw new NotImplementedException();
}
#endregion
}
}
|