using MeterVision.db;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace MeterVision.model
{
    //标准模板目录
    public class StandItem : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }

        private int _index;
        public int Index
        {
            get => _index;
            set
            {
                if (_index != value)
                {
                    _index = value;
                    OnPropertyChanged(nameof(Index));
                }
            }
        }

        public string StandId { get; set; }
        public string CreateTime { get; set; }

        public string StandTime => GetStandTime();

        private string _standName;
        public string StandName
        {
            get => _standName;
            set
            {
                if(_standName != value)
                {
                    _standName = value;
                    OnPropertyChanged(nameof(StandName));
                }
            }
        }

        public int StandType { get; set; }

        public string StandTypeName
        {
            get
            {
                //return StandType == 1 ? "自定义" :
                //    (StandType == 2 ? "导入" : string.Empty);
                return StandType == 1 ? "⚙️[自建模板]" : " 📊[导入Excel]";
                    //(StandType == 2 ? "导入" : string.Empty);
            }
        }

        public string StandTypeNameColor
        {
            get
            {
                return StandType == 1 ? "#007BFF" : "#28A745";
            }
        }

        private int _standCount;
        public int StandCount
        {
            get => _standCount;
            set
            {
                if(_standCount != value)
                {
                    _standCount = value;
                    OnPropertyChanged(nameof(StandCount));
                }
            }
        }
        //标准模板的文件全路径+文件名称
        public string StandFile { get; set; }

        public string StandFileName
        {
            get
            {
                if (StandFile != String.Empty)
                {
                    return ThisApp.GetFileNameWithoutExtension(StandFile);
                }
                return string.Empty;
            }
        }


        private string GetStandTime()
        {
            if(CreateTime != string.Empty)
            {
                return ThisApp.ConvertDateFormat(CreateTime);
            }
            return string.Empty;
        }


        public StandItem()
        {

        }

        public StandItem(VStand vStand)
        {
            this.StandId = vStand.StandId;
            this.CreateTime = vStand.CreateTime;
            this.StandName = vStand.StandName;
            this.StandType = vStand.StandType;
            this.StandFile = vStand.StandFile;
            this.StandCount = vStand.StandCount;
        }
        ///////////////////////////////////////////
    }
}
