﻿using IoTHubInDepth.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
using Windows.UI.Core;

namespace IoTHubInDepth
{
    class MainPageVM : ObservableObject
    {
        private readonly CoreDispatcher dispatcher;

        public MainPageVM()
        {
            if (!Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
            }
        }

        #region Public Properties
        private string msgPayLoad;

        public string MsgPayLoad
        {
            get
            {
                return msgPayLoad;
            }
            set
            {
                msgPayLoad = value;
                OnPropertyChanged();
                Msg2IoTHubEnabled = msgPayLoad.Length > 0;
            }
        }

        private bool msg2IoTHubEnabled;

        public bool Msg2IoTHubEnabled
        {
            get
            {
                return msg2IoTHubEnabled;
            }
            set
            {
                msg2IoTHubEnabled = value;
                OnPropertyChanged();
            }
        }

        private string methodName;

        public string MethodName
        {
            get
            {
                return methodName;
            }
            set
            {
                methodName = value;
                OnPropertyChanged();
                DirectCmdFromIoTHubEnabled = msgPayLoad.Length > 0;
            }
        }

        private bool directCmdFromIoTHubEnabled;

        public bool DirectCmdFromIoTHubEnabled
        {
            get
            {
                return directCmdFromIoTHubEnabled;
            }
            set
            {
                directCmdFromIoTHubEnabled = value;
                OnPropertyChanged();
            }
        }

        private RelayCommand msg2IoTHub;

        public ICommand Msg2IoTHub
        {
            get
            {
                if (msg2IoTHub == null)
                {
                    msg2IoTHub = new RelayCommand(Msg2IoTHubCommand);
                }
                return msg2IoTHub;
            }
        }

        private RelayCommand directCmdFromIoTHub;

        public ICommand DirectCmdFromIoTHub
        {
            get
            {
                if (directCmdFromIoTHub == null)
                {
                    directCmdFromIoTHub = new RelayCommand(DirectCmdFromIoTHubCommand);
                }
                return directCmdFromIoTHub;
            }
        }

        private RelayCommand newReportedProperty;

        public ICommand NewReportedProperty
        {
            get
            {
                if (newReportedProperty == null)
                {
                    newReportedProperty = new RelayCommand(NewReportedPropertyCommand);
                }
                return newReportedProperty;
            }
        }
        #endregion

        private void Msg2IoTHubCommand(object obj)
        {
            throw new NotImplementedException();
        }

        private void DirectCmdFromIoTHubCommand(object obj)
        {
            throw new NotImplementedException();
        }

        private void NewReportedPropertyCommand(object obj)
        {
            throw new NotImplementedException();
        }
    }
}