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

namespace Common.Models
{
    /// <summary>
    /// 粉末瓶类型
    /// </summary>
    public enum PowderBottleTypeEnum
    {
        /// <summary>
        /// 如果是16ml  一个工装放4个
        /// </summary>
        _16mL,
        /// <summary>
        /// 如果是125ml, 一个工装放2个
        /// </summary>
        _125mL,
    }

    [Serializable]
    public class SourcePowderBottleModel : ObservableObject
    {
        private PowderBottleTypeEnum powderbottletype = PowderBottleTypeEnum._125mL;
        public PowderBottleTypeEnum PowderBottleType
        {
            get { return powderbottletype; }
            set { SetProperty(ref powderbottletype, value); }
        }

        private bool _haveBottle = false;
        /// <summary>
        /// 是否有粉末瓶子
        /// </summary>
        public bool HaveBottle
        {
            get => _haveBottle;
            set
            {
                SetProperty(ref _haveBottle, value);
            }
        }

        private int _sourceInde = 0;
        /// <summary>
        /// 粉末原液瓶在工装中的原本位置
        /// </summary>
        public int SourceIndex
        {
            get => _sourceInde;
            set
            {
                SetProperty(ref _sourceInde, value);
            }
        }

        private int _pos = 1;
        /// <summary>
        /// 粉末原液瓶在工装中的位置(1-4   对于125ml的粉末，位置对应1-2)
        /// </summary>
        public int PosId_InBox
        {
            get => _pos;
            set
            {
                SetProperty(ref _pos, value);
            }
        }

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

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

        private string _sourcePowderName = string.Empty;
        /// <summary>
        /// 粉末原液瓶中粉末名称
        /// </summary>
        public string SourcePowderName
        {
            get => _sourcePowderName;
            set
            {
                if (_sourcePowderName != value)
                {
                    _sourcePowderName = value;
                    OnPropertyChanged(nameof(SourcePowderName));
                    OnPropertyChanged(nameof(PowderDisplayColor));
                }
            }
        }

        public Brush PowderDisplayColor
        {
            get
            {
                if (string.IsNullOrEmpty(SourcePowderName)) //没有有名称
                {
                    return (Brush)new BrushConverter().ConvertFrom("#dcd8d8");
                }
                else
                {
                    return (Brush)new BrushConverter().ConvertFrom("#b9cbf5");  //#FFFAFAF7
                }
            }
        }

        private double _originWeight = 0.00;
        /// <summary>
        /// 粉末原液瓶初始重量
        /// </summary>
        public double OriginWeight
        {
            get => _originWeight;
            set
            {
                if (_originWeight != value)
                {
                    _originWeight = value;
                    _remainWeight = value;
                    OnPropertyChanged(nameof(OriginWeight));
                    OnPropertyChanged(nameof(RemainWeight));
                }
            }
        }

        private double _remainWeight = 0;
        /// <summary>
        /// 剩余重量 单位g
        /// </summary>
        public double RemainWeight
        {
            get => _remainWeight;
            set
            {
                SetProperty(ref _remainWeight, value);
            }
        }

        private SourceBottleStateEnum _state = SourceBottleStateEnum.Idl;
        /// <summary>
        /// 粉末原液瓶状态
        /// </summary>
        public SourceBottleStateEnum SourcePowderBottleState
        {
            get => _state;
            set
            {
                SetProperty(ref _state, value);
            }
        }

        private int _pos_inDosePowderHC = 1;
        /// <summary>
        /// 粉末原液瓶在投料工站中的10个粉末瓶缓存的位置(1-10)
        /// </summary>
        public int Pos_InDosePowderHC
        {
            get => _pos_inDosePowderHC;
            set
            {
                SetProperty(ref _pos_inDosePowderHC, value);
            }
        }

    }
}
