aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModels/MainViewVM.cs
blob: cf85246f8da6c14b5c1a90d20867c8e05bb6b03c (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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.DI;
using Tango.PPC.Common;
using Tango.PPC.Common.Application;
using Tango.PPC.Common.Authentication;
using Tango.PPC.Common.ExternalBridge;
using Tango.PPC.Common.Modules;
using Tango.PPC.Common.Navigation;
using Tango.PPC.Common.Notifications;
using Tango.SharedUI;

namespace Tango.PPC.UI.ViewModels
{
    /// <summary>
    /// Represents the PPC main view model.
    /// </summary>
    /// <seealso cref="Tango.PPC.Common.PPCViewModel" />
    public class MainViewVM : PPCViewModel
    {
        [TangoInject]
        public IPPCExternalBridgeService ExternalBridgeService { get; set; }

        public override void OnApplicationStarted()
        {
            ExternalBridgeService.ClientConnected += ExternalBridgeService_ClientConnected;
            ExternalBridgeService.ClientDisconnected += ExternalBridgeService_ClientDisconnected;
        }

        private void ExternalBridgeService_ClientDisconnected(object sender, EventArgs e)
        {
            InvokeUI(() =>
            {
                NavigationManager.NavigateTo(Common.Navigation.NavigationView.HomeModule);
            });
        }

        private void ExternalBridgeService_ClientConnected(object sender, EventArgs e)
        {
            InvokeUI(() =>
            {
                NavigationManager.NavigateTo(Common.Navigation.NavigationView.ExternalBridgeView, false);
            });
        }
    }
}