using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using System.Windows.Media.TextFormatting;

namespace Common.Models
{
    /// <summary>
    /// 原液瓶的状态
    /// </summary>
    public enum SourceBottleStateEnum
    {
        /// <summary>
        /// 空闲，没有在使用
        /// </summary>
        Idl = 0,
        /// <summary>
        /// 使用中
        /// </summary>
        Using,
    }

    /// <summary>
    /// 原液瓶盖子的状态
    /// </summary>
    public enum SourceBottleLidStateEnum
    {
        Close,
        Open,
    }

    [Serializable]
    public class SourceLiquidBottleModel : ObservableObject
    {
        private bool _haveBottle = false;
        /// <summary>
        /// 是否有液体瓶子
        /// </summary>
        public bool HaveBottle
        {
            get => _haveBottle;
            set
            {
                SetProperty(ref _haveBottle, value);
            }
        }

        private int _posId = 1;
        /// <summary>
        /// 液体原液瓶在工装中的位置(1-8)
        /// </summary>
        public int PosId_InBox
        {
            get => _posId;
            set
            {
                SetProperty(ref _posId, value);
            }
        }

        private string _boxsn = string.Empty;
        /// <summary>
        /// 液体原液瓶所在载具的二维码信息
        /// </summary>
        public string BoxSNCode
        {
            get => _boxsn;
            set
            {
                SetProperty(ref _boxsn, value);
            }
        }

        private string _sn = string.Empty;
        /// <summary>
        /// 液体原液瓶的二维码信息
        /// </summary>
        public string SNCode
        {
            get => _sn;
            set
            {
                SetProperty(ref _sn, value);
            }
        }

        private string _sourceLiquidName = string.Empty;
        /// <summary>
        /// 液体原液瓶中液体名称
        /// </summary>
        public string SourceLiquidName
        {
            get => _sourceLiquidName;
            set
            {
                if (_sourceLiquidName != value)
                {
                    _sourceLiquidName = value;
                    OnPropertyChanged(nameof(SourceLiquidName));
                    OnPropertyChanged(nameof(LiquidDisplayColor));
                }
            }
        }

        public Brush LiquidDisplayColor
        {
            get
            {
                if (string.IsNullOrEmpty(SourceLiquidName)) //没有有名称
                {
                    return (Brush)new BrushConverter().ConvertFrom("#dcd8d8");
                }
                else
                {
                    return (Brush)new BrushConverter().ConvertFrom("#cab2ec");
                }
            }
        }

        private double _originVolume = 0;
        /// <summary>
        /// 初始体积
        /// </summary>
        public double OriginVolume
        {
            get => _originVolume;
            set
            {
                if (_originVolume != value)
                {
                    _originVolume = value;
                    _remainVolume = value;
                    OnPropertyChanged(nameof(OriginVolume));
                    OnPropertyChanged(nameof(RemainVolume));
                }
            }
        }

        private double _remainVolume = 0;
        /// <summary>
        /// 剩余体积 单位ML
        /// </summary>
        public double RemainVolume
        {
            get => _remainVolume;
            set
            {
                SetProperty(ref _remainVolume, value);
            }
        }

        //private double _density = 1.00;
        ///// <summary>
        ///// 密度,单位g/mL
        ///// </summary>
        //public double Density
        //{
        //    get => _density;
        //    set
        //    {
        //        SetProperty(ref _density, value);
        //    }
        //}

        private SourceBottleStateEnum _sourceBottleState = SourceBottleStateEnum.Idl;
        /// <summary>
        /// 液体原液瓶状态
        /// </summary>
        public SourceBottleStateEnum SourceLiquidBottleState
        {
            get => _sourceBottleState;
            set
            {
                SetProperty(ref _sourceBottleState, value);
            }
        }

        private SourceBottleLidStateEnum _LiquidBottleLidState = SourceBottleLidStateEnum.Close;
        /// <summary>
        /// 液体原液瓶盖子的状态
        /// </summary>
        public SourceBottleLidStateEnum LiquidBottleLidState
        {
            get => _LiquidBottleLidState;
            set
            {
                SetProperty(ref _LiquidBottleLidState, value);
            }
        }

        public SourceLiquidBottleModel()
        {

        }
    }
}
