blob: 3bc92fe15ec2e2ba32616961812d0a9a21f09cb8 (
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Documents;
using Tango.Core;
using Tango.Core.Commands;
using Tango.Logging;
using Tango.Stubs;
namespace Tango.MobileEM.UI.ViewModels
{
public class StubViewVM : ExtendedObject
{
private bool _running;
public RelayCommand RunCommand { get; set; }
public RelayCommand CancelCommand { get; set; }
public RelayCommand ClearCommand { get; set; }
public StubBase Stub { get; set; }
public AvailableStub AvailableStub { get; set; }
private String _response;
public String Response
{
get { return _response; }
set { _response = value; RaisePropertyChanged(nameof(Response)); }
}
public StubViewVM(AvailableStub availableStub, StubBase stub)
{
AvailableStub = availableStub;
Stub = stub;
RunCommand = new RelayCommand(Run,(x) => !_running);
CancelCommand = new RelayCommand(Cancel,(x) => _running);
ClearCommand = new RelayCommand(() => Response = String.Empty);
}
private async void Run()
{
_running = true;
InvalidateRelayCommands();
var result = await Stub.Run((response) =>
{
_running = false;
Response += response + Environment.NewLine;
InvalidateRelayCommands();
});
Response += result + Environment.NewLine;
_running = false;
InvalidateRelayCommands();
}
private void Cancel()
{
}
}
}
|