using SWRIS.Enums;
using System;
using System.Collections.ObjectModel;
using System.ComponentModel;

namespace SWRIS.Dtos
{
    public class RecordDto : INotifyPropertyChanged
    {
        private int? id;
        private int ropeNumber;
        private string ropeName;
        private DateTime startTime;
        private DateTime endTime;
        private double startPoint;
        private double endPoint;
        private double detectionLength;
        private double detectedSpeed;
        private short damageCount;
        private string dataFilePath;
        private int sensorCount;
        private double samplingStep;
        private RiskLevel riskLevel = RiskLevel.Normal;
        private int exportCount;
        private string inUseSensors;
        private bool isSelected = false;
        private ObservableCollection<DamageDto> damages = new ObservableCollection<DamageDto>();


        public int? Id
        {
            get => id;
            set
            {
                if (id != value)
                {
                    id = value;
                    OnPropertyChanged(nameof(Id));
                }
            }
        }

        /// <summary>
        /// 钢丝绳名称
        /// </summary>
        public int RopeNumber
        {
            get => ropeNumber;
            set
            {
                if (ropeNumber != value)
                {
                    ropeNumber = value;
                    OnPropertyChanged(nameof(RopeNumber));
                }
            }
        }
        public string RopeName
        {
            get => ropeName;
            set
            {
                if (ropeName != value)
                {
                    ropeName = value;
                    OnPropertyChanged(nameof(RopeName));
                }
            }
        }

        /// <summary>
        /// 开始时间 时间戳
        /// </summary>
        public DateTime StartTime
        {
            get => startTime;
            set
            {
                if (startTime != value)
                {
                    startTime = value;
                    OnPropertyChanged(nameof(StartTime));
                }
            }
        }

        /// <summary>
        /// 结束时间 时间戳
        /// </summary>
        public DateTime EndTime
        {
            get => endTime;
            set
            {
                if (endTime != value)
                {
                    endTime = value;
                    OnPropertyChanged(nameof(EndTime));
                }
            }
        }

        /// <summary>
        /// 开始位置 m
        /// </summary>
        public double StartPoint
        {
            get => startPoint;
            set
            {
                if (startPoint != value)
                {
                    startPoint = value;
                    OnPropertyChanged(nameof(StartPoint));
                }
            }
        }

        /// <summary>
        /// 结束位置 m
        /// </summary>
        public double EndPoint
        {
            get => endPoint;
            set
            {
                if (endPoint != value)
                {
                    endPoint = value;
                    OnPropertyChanged(nameof(EndPoint));
                }
            }
        }

        /// <summary>
        /// 检测长度 m
        /// </summary>
        public double DetectionLength
        {
            get => detectionLength;
            set
            {
                if (detectionLength != value)
                {
                    detectionLength = value;
                    OnPropertyChanged(nameof(DetectionLength));
                }
            }
        }

        /// <summary>
        /// 检测速度 m/s
        /// </summary>
        public double DetectedSpeed
        {
            get => detectedSpeed;
            set
            {
                if (detectedSpeed != value)
                {
                    detectedSpeed = value;
                    OnPropertyChanged(nameof(DetectedSpeed));
                }
            }
        }

        /// <summary>
        /// 损伤数量
        /// </summary>
        public short DamageCount
        {
            get => damageCount;
            set
            {
                if (damageCount != value)
                {
                    damageCount = value;
                    OnPropertyChanged(nameof(DamageCount));
                }
            }
        }

        /// <summary>
        /// 数据文件路径
        /// </summary>
        public string DataFilePath
        {
            get => dataFilePath;
            set
            {
                if (dataFilePath != value)
                {
                    dataFilePath = value;
                    OnPropertyChanged(nameof(DataFilePath));
                }
            }
        }

        /// <summary>
        /// 传感器数量
        /// </summary>
        public int SensorCount
        {
            get => sensorCount;
            set
            {
                if (sensorCount != value)
                {
                    sensorCount = value;
                    OnPropertyChanged(nameof(SensorCount));
                }
            }
        }

        /// <summary>
        /// 采样步长 mm/点
        /// </summary>
        public double SamplingStep
        {
            get => samplingStep;
            set
            {
                if (samplingStep != value)
                {
                    samplingStep = value;
                    OnPropertyChanged(nameof(SamplingStep));
                }
            }
        }

        /// <summary>
        /// 钢丝绳状态
        /// </summary>
        public RiskLevel RiskLevel
        {
            get => riskLevel;
            set
            {
                if (riskLevel != value)
                {
                    riskLevel = value;
                    OnPropertyChanged(nameof(RiskLevel));
                }
            }
        }
        /// <summary>
        /// 导出次数
        /// </summary>
        public int ExportCount
        {
            get => exportCount;
            set
            {
                if (exportCount != value)
                {
                    exportCount = value;
                    OnPropertyChanged(nameof(ExportCount));
                }
            }
        }
        /// <summary>
        /// 在用传感器 1,2,3,4
        /// </summary>
        public string InUseSensors
        {
            get => inUseSensors;
            set
            {
                if (inUseSensors != value)
                {
                    inUseSensors = value;
                    OnPropertyChanged(nameof(InUseSensors));
                }
            }
        }
        /// <summary>
        /// 是否选中
        /// </summary>
        public bool IsSelected
        {
            get => isSelected;
            set
            {
                if (isSelected != value)
                {
                    isSelected = value;
                    OnPropertyChanged(nameof(IsSelected));
                }
            }
        }
        public ObservableCollection<DamageDto> Damages
        {
            get => damages;
            set
            {
                if (damages != value)
                {
                    damages = value;
                    OnPropertyChanged(nameof(Damages));
                }
            }
        }

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