using SWRIS.Dtos;
using SWRIS.Enums;
using SWRIS.Extensions;
using System;
using System.Collections.Generic;
using System.ComponentModel;

namespace SWRIS.Models.ViewModel
{
    public class SettingViewModel : INotifyPropertyChanged
    {
        private string _appName = "在线式钢丝绳电磁检测系统";
        private string _version = "250902";
        private string _copyright = "河南恒达机电设备有限公司";
        private string _ipAddress = "192.168.1.233";
        private int _port = 9005;
        private int _dataSaveDays = 120;
        private TimeSpan _cleanScheduledTime = TimeSpan.FromHours(2);
        private int _damageNearPointCount = 20;
        private bool _showDebugMessage = true;
        private int _sountRiskLevel = (int)RiskLevel.Moderate;
        private double _speedVariationThreshold = 0.25;
        private double _damageExtent = 0.5;
        private int _alarmValidCount = 3;
        private string _crane = "炼钢一跨1#";
        private CalibrationDataModel _calibration;
        private bool _isAutoStart = true;
        /// <summary>
        /// 应用名称
        /// </summary>
        public string AppName
        {
            get => _appName;
            set
            {
                _appName = value;
                OnPropertyChanged(nameof(AppName));
            }
        }
        /// <summary>
        /// 应用版本
        /// </summary>
        public string Version
        {
            get => _version;
            set
            {
                _version = value;
                OnPropertyChanged(nameof(Version));
            }
        }
        /// <summary>
        /// 技术支持
        /// </summary>
        public string Copyright
        {
            get => _copyright;
            set
            {
                _copyright = value;
                OnPropertyChanged(nameof(Copyright));
            }
        }
        /// <summary>
        /// 服务端IP地址
        /// </summary>
        public string IpAddress
        {
            get => _ipAddress;
            set
            {
                _ipAddress = value;
                OnPropertyChanged(nameof(IpAddress));
            }
        }
        /// <summary>
        /// 服务端端口号
        /// </summary>
        public int Port
        {
            get => _port;
            set
            {
                _port = value;
                OnPropertyChanged(nameof(Port));
            }
        }
        /// <summary>
        /// 是否显示调试信息
        /// </summary>
        public bool ShowDebugMessage
        {
            get => _showDebugMessage;
            set
            {
                _showDebugMessage = value;
                OnPropertyChanged(nameof(ShowDebugMessage));
            }
        }
        /// <summary>
        /// 数据存储天数
        /// </summary>
        public int DataSaveDays
        {
            get => _dataSaveDays;
            set
            {
                _dataSaveDays = value;
                OnPropertyChanged(nameof(DataSaveDays));
            }
        }
        /// <summary>
        /// 清理数据计划时间
        /// </summary>
        public TimeSpan CleanScheduledTime
        {
            get => _cleanScheduledTime;
            set
            {
                _cleanScheduledTime = value;
                OnPropertyChanged(nameof(CleanScheduledTime));
            }
        }
        /// <summary>
        /// 损伤邻近点数
        /// </summary>
        public int DamageNearPointCount
        {
            get => _damageNearPointCount;
            set
            {
                _damageNearPointCount = value;
                OnPropertyChanged(nameof(DamageNearPointCount));
            }
        }
        /// <summary>
        /// 语音报警风险等级
        /// </summary>
        public int SoundRiskLevel
        {
            get => _sountRiskLevel;
            set
            {
                _sountRiskLevel = value;
                OnPropertyChanged(nameof(SoundRiskLevel));
            }
        }
        /// <summary>
        /// 速度变化阈值
        /// </summary>
        public double SpeedVariationThreshold
        {
            get => _speedVariationThreshold;
            set
            {
                _speedVariationThreshold = value;
                OnPropertyChanged(nameof(SpeedVariationThreshold));
            }
        }
        /// <summary>
        /// 损伤验证范围
        /// </summary>
        public double DamageExtent
        {
            get => _damageExtent;
            set
            {
                _damageExtent = value;
                OnPropertyChanged(nameof(DamageExtent));
            }
        }
        /// <summary>
        /// 损伤验证次数
        /// </summary>
        public int AlarmValidCount
        {
            get => _alarmValidCount;
            set
            {
                _alarmValidCount = value;
                OnPropertyChanged(nameof(AlarmValidCount));
            }
        }
        /// <summary>
        /// 起重机名称
        /// </summary>
        public string Crane
        {
            get => _crane;
            set
            {
                _crane = value;
                OnPropertyChanged(nameof(Crane));
            }
        }
        /// <summary>
        /// 标定设置
        /// </summary>
        public CalibrationDataModel Calibration
        {
            get => _calibration;
            set
            {
                _calibration = value;
                OnPropertyChanged(nameof(Calibration));
            }
        }
        public bool IsAutoStart
        {
            get => _isAutoStart;
            set
            {
                _isAutoStart = value;
                OnPropertyChanged(nameof(IsAutoStart));
            }
        }
        public List<KeyAndValueDto> RiskLevels => TypeExtension.ToKeyAndDescriptionList(typeof(RiskLevel));



        public event PropertyChangedEventHandler PropertyChanged;
        protected internal virtual void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
    }

}
