aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/FSE/Tango.FSE.UI/ViewModels/LayoutViewVM.cs
blob: 6623f7aba889ec349c2f443e420a00adcc9624f0 (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
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.Commands;
using Tango.FSE.Common;
using Tango.FSE.UI.Panes;
using Tango.Integration.ExternalBridge;

namespace Tango.FSE.UI.ViewModels
{
    public class LayoutViewVM : FSEViewModel
    {
        private bool _isConnectionPaneOpened;
        public bool IsConnectionPaneOpened
        {
            get { return _isConnectionPaneOpened; }
            set { _isConnectionPaneOpened = value; RaisePropertyChangedAuto(); OnConnectionPaneToggleChanged(); }
        }

        private MachineConnectionPaneVM _connectionPaneVM;
        public MachineConnectionPaneVM ConnectionPaneVM
        {
            get { return _connectionPaneVM; }
            set { _connectionPaneVM = value; RaisePropertyChangedAuto(); }
        }

        private bool _isMenuOpened;
        public bool IsMenuOpened
        {
            get { return _isMenuOpened; }
            set { _isMenuOpened = value; RaisePropertyChangedAuto(); }
        }

        public RelayCommand ToggleConnectionPaneCommand { get; set; }

        public LayoutViewVM()
        {
            ToggleConnectionPaneCommand = new RelayCommand(() => IsConnectionPaneOpened = !IsConnectionPaneOpened);
            ConnectionPaneVM = new MachineConnectionPaneVM();
            ConnectionPaneVM.MachineSelected += ConnectionPaneVM_MachineSelected;
        }

        private void ConnectionPaneVM_MachineSelected(object sender, IExternalBridgeClient machine)
        {
            IsConnectionPaneOpened = false;
            Debug.WriteLine($"Machine selected for connection: {machine.ToString()}");
        }

        private void OnConnectionPaneToggleChanged()
        {
            if (IsConnectionPaneOpened)
            {
                ConnectionPaneVM.Start();
            }
            else
            {
                ConnectionPaneVM.Stop();
            }
        }

        public override void OnApplicationStarted()
        {
            
        }
    }
}