using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;

namespace Common.Models
{
    public enum FunctionTypeEnum
    {
        [Description("添加液体原料")]
        加液体原料,
        [Description("添加固体原料")]
        加固体原料,
        [Description("震荡摇匀")]
        震荡摇匀,
    }

    [Serializable]
    public class MaterialDoseFunctionFlow : ObservableObject
    {
        private bool bisdosefinish = false;
        /// <summary>
        /// 是否配置完成
        /// </summary>
        public bool IsDoseFinish
        {
            get { return bisdosefinish; }
            set { SetProperty(ref bisdosefinish, value); }
        }

        private FunctionTypeEnum functionType = FunctionTypeEnum.加液体原料;
        public FunctionTypeEnum FunctionFlowType
        {
            get => functionType;
            set
            {
                SetProperty(ref functionType, value);
            }
        }

        private string useMaterialName = string.Empty;
        /// <summary>
        /// 使用的试剂名称
        /// </summary>
        public string UseMaterialName
        {
            get { return useMaterialName; }
            set
            {
                SetProperty(ref useMaterialName, value);
            }
        }

        private double targetVolume = 0;
        /// <summary>
        /// 目标体积（μl）/目标重量(mg)
        /// </summary>
        public double TargetVolume
        {
            get { return targetVolume; }
            set
            {
                SetProperty(ref targetVolume, value);
            }
        }

        private double actualVolume;
        /// <summary>
        /// 实际加入体积/重量
        /// </summary>
        public double ActualVolume
        {
            get { return actualVolume; }
            set
            {
                SetProperty(ref actualVolume, value);
            }
        }

        //private double liquidprecision = 1;
        ///// <summary>
        ///// 液体加液最大精度,单位g
        ///// </summary>
        //public double LiquidPrecision
        //{
        //    get { return liquidprecision; }
        //    set
        //    {
        //        SetProperty(ref liquidprecision, value);
        //    }
        //}
    }

    //[Serializable]
    //public class SampleBottlePowderFunctionFlow : ObservableObject
    //{
    //    private FunctionTypeEnum functionType = FunctionTypeEnum.加固体原料;
    //    public FunctionTypeEnum FunctionFlowType
    //    {
    //        get => functionType;
    //        set
    //        {
    //            SetProperty(ref functionType, value);
    //        }
    //    }

    //    private string useSourcePowderName = string.Empty;
    //    /// <summary>
    //    /// 使用的粉末试剂名称
    //    /// </summary>
    //    public string UsePowderName
    //    {
    //        get { return useSourcePowderName; }
    //        set
    //        {
    //            SetProperty(ref useSourcePowderName, value);
    //        }
    //    }

    //    private double targetPowderAmount;
    //    /// <summary>
    //    /// 粉末目标加入量，单位g
    //    /// </summary>
    //    public double TargetPowderAmount
    //    {
    //        get { return targetPowderAmount; }
    //        set
    //        {
    //            if (targetPowderAmount != value)
    //            {
    //                targetPowderAmount = value;
    //                PowderPrecision = PrecisionRuleHelper.GetPowderPrecision(value); // 根据目标量获取精度g
    //                OnPropertyChanged(nameof(TargetPowderAmount));
    //                OnPropertyChanged(nameof(PowderPrecision));
    //            }
    //        }
    //    }

    //    private double actualPowderAmount;
    //    /// <summary>
    //    /// 粉末实际加入量,单位g
    //    /// </summary>
    //    public double ActualPowderAmount
    //    {
    //        get { return actualPowderAmount; }
    //        set
    //        {
    //            SetProperty(ref actualPowderAmount, value);
    //        }
    //    }

    //    private double powderprecision = 1;
    //    /// <summary>
    //    /// 粉末加量最大精度,单位g
    //    /// </summary>
    //    public double PowderPrecision
    //    {
    //        get { return powderprecision; }
    //        set
    //        {
    //            SetProperty(ref powderprecision, value);
    //        }
    //    }
    //}

    public enum ReactFunctionTypeEnum
    {
        [Description("取样")]
        取样,
        [Description("补液")]
        补液,
    }

    /// <summary>
    /// 取样操作类
    /// </summary>
    [Serializable]
    public class ReactSampleFunctionFlow : ObservableObject
    {
        private double time;
        /// <summary>
        /// 操作时间
        /// </summary>
        public double OperateTime
        {
            get { return time; }
            set { time = value; }
        }

        private double targetVolume = 0;
        /// <summary>
        /// 取样体积
        /// </summary>
        public double TargetAddVolume
        {
            get { return targetVolume; }
            set
            {
                SetProperty(ref targetVolume, value);
            }
        }

        private bool bAddLiquid = false;
        /// <summary>
        /// 取样后是否紧接着加样
        /// </summary>
        public bool bAfterAddLiquid
        {
            get { return bAddLiquid; }
            set { SetProperty(ref bAddLiquid, value); }
        }

        private ObservableCollection<AddLiquidFunctionFlow> addLiquidList = new ObservableCollection<AddLiquidFunctionFlow>();
        /// <summary>
        /// 加液集合
        /// </summary>
        public ObservableCollection<AddLiquidFunctionFlow> AddLiquidList
        {
            get { return addLiquidList; }
            set { SetProperty(ref addLiquidList, value); }
        }

        private bool _isDuilte = false;
        /// <summary>
        /// 是否稀释,默认都会稀释
        /// </summary>
        public bool IsDulite
        {
            get => _isDuilte;
            set => SetProperty(ref _isDuilte, value);
        }

        private ObservableCollection<AddDiluentFunction> diluentList = new ObservableCollection<AddDiluentFunction>();
        /// <summary>
        /// 稀释剂集合
        /// </summary>
        public ObservableCollection<AddDiluentFunction> DiluentFunctionFlowList
        {
            get { return diluentList; }
            set { SetProperty(ref diluentList, value); }
        }
    }


    [Serializable]
    public class AddLiquidFunctionFlow : ObservableObject
    {
        private double time;
        /// <summary>
        /// 操作时间
        /// </summary>
        public double OperateTime
        {
            get { return time; }
            set { time = value; }
        }

        private string liquidName = string.Empty;
        /// <summary>
        /// 液体名称
        /// </summary>
        public string LiquidName
        {
            get { return liquidName; }
            set { SetProperty(ref liquidName, value); }
        }

        private double targetVolume;
        /// <summary>
        ///目标加入体积
        /// </summary>
        public double TargetAddVolume
        {
            get { return targetVolume; }
            set
            {
                SetProperty(ref targetVolume, value);
            }
        }

        private double actualVolume;
        /// <summary>
        /// 实际加入体积
        /// </summary>
        public double ActualVolume
        {
            get { return actualVolume; }
            set
            {
                SetProperty(ref actualVolume, value);
            }
        }
    }


    /// <summary>
    /// 添加稀释剂
    /// </summary>
    [Serializable]
    public class AddDiluentFunction : ObservableObject
    {
        private string diluentName = string.Empty;
        /// <summary>
        /// 稀释剂名称
        /// </summary>
        public string DiluentName
        {
            get { return diluentName; }
            set { SetProperty(ref diluentName, value); }
        }

        private double targetDiluentVolume = 0.00;
        /// <summary>
        ///稀释剂目标加入体积
        /// </summary>
        public double TargetDiluentVolume
        {
            get { return targetDiluentVolume; }
            set
            {
                SetProperty(ref targetDiluentVolume, value);
            }
        }

        private double actualDiluentVolume = 0.00;
        /// <summary>
        /// 稀释剂实际加入体积
        /// </summary>
        public double ActualDiluentVolume
        {
            get { return actualDiluentVolume; }
            set
            {
                SetProperty(ref actualDiluentVolume, value);
            }
        }

        private double diluentfactor = 1.00;
        /// <summary>
        /// 稀释倍数，自动计算
        /// </summary>
        public double DiluentFactor
        {
            get { return diluentfactor; }
            set { SetProperty(ref diluentfactor, value); }
        }

    }
}
