aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs
blob: 213d1a83d384bba5ec08c52c1dbfffdda89dce70 (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
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Tango.Core.Commands;
using Tango.MachineStudio.Common;
using Tango.MachineStudio.Common.Authentication;
using Tango.MachineStudio.Common.Modules;
using Tango.MachineStudio.UI.SupervisingController;
using Tango.SharedUI;

namespace Tango.MachineStudio.UI.ViewModels
{
    public class MainViewVM : ViewModel<IMainView>
    {
        private IStudioModule _currentModule;

        public IStudioModule CurrentModule
        {
            get { return _currentModule; }
            set { _currentModule = value; RaisePropertyChangedAuto(); }
        }

        private bool _isMenuOpened;

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

        public RelayCommand<IStudioModule> StartModuleCommand { get; set; }

        public RelayCommand HomeCommand { get; set; }

        private IAuthenticationProvider _authenticationProvider;
        public IAuthenticationProvider AuthenticationProvider
        {
            get { return _authenticationProvider; }
            set { _authenticationProvider = value; RaisePropertyChangedAuto(); }
        }

        private IStudioModuleLoader _studioModuleLoader;

        public IStudioModuleLoader StudioModuleLoader
        {
            get { return _studioModuleLoader; }
            set { _studioModuleLoader = value; RaisePropertyChangedAuto(); }
        }

        public MainViewVM(IMainView view, IAuthenticationProvider authenticationProvider, IStudioModuleLoader studioModuleLoader) : base(view)
        {
            AuthenticationProvider = authenticationProvider;
            StudioModuleLoader = studioModuleLoader;

            StartModuleCommand = new RelayCommand<IStudioModule>(StartModule);

            HomeCommand = new RelayCommand(Home);
        }

        private void Home()
        {
            StartModule(null);
        }

        private void StartModule(IStudioModule module)
        {
            IsMenuOpened = false;
            CurrentModule = module;
        }

        protected override void OnViewAttached()
        {
            base.OnViewAttached();
        }
    }
}