blob: 2a76ba80f28db476a83eef48357b035518e7a88b (
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
|
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Tango.BL;
using Tango.Core;
using Tango.Core.DI;
using Tango.Core.Helpers;
using Tango.PPC.Common;
using Tango.PPC.Common.Application;
using Tango.PPC.Common.Authentication;
using Tango.PPC.Common.MachineSetup;
using Tango.PPC.Common.Modules;
using Tango.PPC.Common.Navigation;
using Tango.PPC.Common.Notifications;
using Tango.PPC.Common.Notifications.NotificationItems;
using Tango.PPC.Jobs;
using Tango.SharedUI;
namespace Tango.PPC.UI.ViewModels
{
/// <summary>
/// Represents the PPC loading splash screen view model.
/// </summary>
/// <seealso cref="Tango.PPC.Common.PPCViewModel" />
public class LoadingViewVM : PPCViewModel, INavigationObjectReceiver<MachineSetupResult>
{
private bool _setup;
private SetupRequiredEventArgs _setupArgs;
private bool _post_setup;
/// <summary>
/// Gets or sets the module loader.
/// </summary>
[TangoInject]
public IPPCModuleLoader ModuleLoader { get; set; }
private bool _isLoading;
/// <summary>
/// Gets or sets a value indicating whether this instance is loading.
/// </summary>
public bool IsLoading
{
get { return _isLoading; }
set { _isLoading = value; RaisePropertyChangedAuto(); }
}
/// <summary>
/// Initializes a new instance of the <see cref="LoadingViewVM"/> class.
/// </summary>
public LoadingViewVM(IPPCApplicationManager applicationManager)
{
if (!DesignMode)
{
applicationManager.SetupRequired += ApplicationManager_SetupRequired;
Task.Delay(1000).ContinueWith((x) => { IsLoading = true; });
}
}
private void ApplicationManager_SetupRequired(object sender, SetupRequiredEventArgs e)
{
_setupArgs = e;
_setup = true;
NavigationManager.NavigateTo(NavigationView.MachineSetupView);
}
/// <summary>
/// Called when the application has been started.
/// </summary>
public override void OnApplicationStarted()
{
IsLoading = false;
if (!_setup || _post_setup)
{
NavigationManager.NavigateTo(NavigationView.LoginView);
}
}
public async void OnNavigatedToWithObject(MachineSetupResult machineSetupResult)
{
if (machineSetupResult.Completed)
{
_post_setup = true;
_setup = false;
IsLoading = true;
await Task.Delay(500);
_setupArgs.Continue();
}
}
}
}
|