blob: f69257e4559f4fb27cf0f8ea6d9a33288386fe6a (
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
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL.Entities;
using Tango.Core.Commands;
using Tango.FSE.Common;
using Tango.FSE.Common.AutoComplete;
using Tango.FSE.Upgrade.Views;
namespace Tango.FSE.Upgrade.ViewModels
{
public class WelcomeViewVM : RemoteUpgradeViewModel
{
private Machine _selectedMachine;
/// <summary>
/// Gets or sets the selected machine.
/// </summary>
public Machine SelectedMachine
{
get { return _selectedMachine; }
set { _selectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
}
private bool _isApplicationUpdate;
/// <summary>
/// Gets or sets a value indicating whether to update application and firmware, otherwise only firmware.
/// </summary>
public bool IsApplicationUpdate
{
get { return _isApplicationUpdate; }
set { _isApplicationUpdate = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
}
private bool _isUpdateConnectedMachine;
/// <summary>
/// Gets or sets a value indicating whether to update the currently connected machine (relevant only on application update).
/// </summary>
public bool IsUpdateConnectedMachine
{
get { return _isUpdateConnectedMachine; }
set { _isUpdateConnectedMachine = value; RaisePropertyChangedAuto(); InvalidateRelayCommands(); }
}
/// <summary>
/// Gets or sets the start upgrade command.
/// </summary>
public RelayCommand StartUpgradeCommand { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="WelcomeViewVM"/> class.
/// </summary>
public WelcomeViewVM()
{
IsApplicationUpdate = true;
IsUpdateConnectedMachine = true;
StartUpgradeCommand = new RelayCommand(StartUpgrade, () => !IsApplicationUpdate || IsUpdateConnectedMachine || SelectedMachine != null);
}
public override void OnApplicationStarted()
{
base.OnApplicationStarted();
MachineProvider.MachineConnected += (_, __) => { if (IsVisible) InvalidateIsUpdateConnectedMachine(); };
MachineProvider.MachineDisconnected += (_, __) => { if (IsVisible) InvalidateIsUpdateConnectedMachine(); };
}
private void InvalidateIsUpdateConnectedMachine()
{
if (IsUpdateConnectedMachine)
{
IsUpdateConnectedMachine = MachineProvider.IsConnected && MachineProvider.ConnectionType.IsRemote();
}
}
/// <summary>
/// Called before the navigation system has navigated to this VM view.
/// </summary>
public override void OnBeforeNavigatedTo()
{
base.OnBeforeNavigatedTo();
InvalidateIsUpdateConnectedMachine();
}
private async void StartUpgrade()
{
if (IsApplicationUpdate)
{
await ModularNavigationManager.NavigateTo<ApplicationUpgradeViewVM.NavigationObject>(Navigation.RemoteUpgradeView.ApplicationUpgradeView, new ApplicationUpgradeViewVM.NavigationObject()
{
ApplicationUpgradeMode = IsUpdateConnectedMachine ? ApplicationUpgradeViewVM.ApplicationUpgradeMode.ConnectedMachine : ApplicationUpgradeViewVM.ApplicationUpgradeMode.OtherMachine,
SelectedMachine = IsUpdateConnectedMachine ? MachineProvider.Machine : SelectedMachine
});
}
else
{
await ModularNavigationManager.NavigateTo(Navigation.RemoteUpgradeView.FirmwareUpgradeView);
}
}
}
}
|