using Microsoft.Toolkit.Mvvm.ComponentModel;
using Microsoft.Toolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HBLConsole.Interface;
using Newtonsoft.Json;

namespace HBLConsole.Model
{
    public class CommunicationSet : ObservableObject
    {
        public CommunicationSet()
        {
            RemoveCommand = new RelayCommand<object>((o) => { if (RemoveAction != null) RemoveAction(o); });
        }

        public Action<object> RemoveAction { get; set; }

        /// <summary>
        /// 使用特性对接口反序列化
        /// </summary>
        [JsonProperty(TypeNameHandling = TypeNameHandling.Auto)]
        public IDeviceType Device { get { return _mDevice; } set { _mDevice = value; OnPropertyChanged(); } }
        private IDeviceType _mDevice;

        /// <summary>
        /// 是否激活
        /// </summary>
        public bool IsActive { get { return _mIsActive; } set { _mIsActive = value; OnPropertyChanged(); } }
        private bool _mIsActive = true;

        /// <summary>
        /// 新增设备名称
        /// </summary>
        public string DeviceName { get { return _mDeviceName; } set { _mDeviceName = value; OnPropertyChanged(); } }
        private string _mDeviceName;

        /// <summary>
        /// 设备类型
        /// </summary>
        public EDeviceType deviceType { get { return _mdeviceType; } set { _mdeviceType = value; OnPropertyChanged(); } }
        private EDeviceType _mdeviceType;

        /// <summary>
        /// 客户端启动设备类型
        /// </summary>
        public string ClientDeviceType { get; set; }

        public RelayCommand<object> RemoveCommand { get; set; }
    }
}
