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

namespace HBLConsole.Model
{
    /// <summary>
    /// 属性绑定信息
    /// </summary>
    public class PropBindInfo : VariableInfo
    {
        public PropBindInfo()
        {
            ComboBoxItemInit();
            CancelCommand = new RelayCommand(() => { IsOpen = false; });
            ConfirmCommand = new RelayCommand(() => { IsOpen = false; });
        }

        /// <summary>
        /// 数据类型下拉列表
        /// </summary>
        public ObservableCollection<string> dataType { get; set; } = new ObservableCollection<string>();

        /// <summary>
        /// 报警类型下拉列表
        /// </summary>
        public ObservableCollection<string> alarmType { get; set; } = new ObservableCollection<string>();

        /// <summary>
        /// 报警设置窗离散量报警类型
        /// </summary>
        public ObservableCollection<string> PopupDiscreteAlarmType { get; set; } = new ObservableCollection<string>();

        /// <summary>
        /// 是否显示报警设置框
        /// </summary>
        public bool IsOpen { get { return _mIsOpen; } set { _mIsOpen = value; OnPropertyChanged(); } }
        private bool _mIsOpen;


        /// <summary>
        /// 报警设置框取消操作
        /// </summary>
        public RelayCommand CancelCommand { get; set; }

        /// <summary>
        /// 报警设置框确认按钮
        /// </summary>
        public RelayCommand ConfirmCommand { get; set; }

        /// <summary>
        /// 下拉列表初始化
        /// </summary>
        private void ComboBoxItemInit()
        {
            dataType.Clear();
            alarmType.Clear();
            PopupDiscreteAlarmType.Clear();
            string[] DataTypeNames = Enum.GetNames(typeof(EDataType));
            foreach (var item in DataTypeNames) { dataType.Add(item); }

            string[] AlarmTypeNames = Enum.GetNames(typeof(EAlarmType));
            foreach (var item in AlarmTypeNames) { alarmType.Add(item); }

            string[] PopupAlarmTypes = Enum.GetNames(typeof(EAlongTriggerType));
            foreach (var item in PopupAlarmTypes) { PopupDiscreteAlarmType.Add(item); }
        }
    }
}
