using MultiLayout.UiModule;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FLY.Thick.Base.UI.UiModule
{
    /// <summary>
    /// 
    /// </summary>
    public class FixGraphItemParam : UIModuleParam
    {
        int len = 500;
        public int Len
        {
            get { return len; }
            set
            {
                if (value < 100)
                    value = 100;
                else if (value > 50000)
                    value = 50000;

                if (len != value)
                {
                    len = value;
                }
            }

        }

        private int interval = 1000;
        /// <summary>
        /// 间隔，只能选 1, 10, 100, 1000, 这些单位；
        /// 1 = 1ms，10=10ms，100=100ms
        /// </summary>
        public int Interval
        {
            get { return interval; }
            set
            {
                if (value < 1)//最短1.28ms
                    value = 1;
                else if (value > 3000)//最长3s
                    value = 3000;
                if (interval != value)
                {
                    interval = value;

                }
            }
        }

        private int mix = 1;

        public int Mix
        {
            get
            {
                return mix;
            }
            set
            {
                if (value < 1)
                    value = 1;
                else if (value > 100)
                    value = 100;

                if (mix != value)
                {
                    mix = value;
                }
            }
        }

        /// <summary>
        /// 自动目标值
        /// </summary>
        public bool IsAutoTarget { get; set; } = true;

        /// <summary>
        /// 显示AD值
        /// </summary>
        public bool IsADMode { get; set; }

        /// <summary>
        /// 自动Y轴
        /// </summary>
        public bool IsAutoY { get; set; } = false;
        public double YTarget { get; set; }

        double yrange = 10;

        public double YRange
        {
            get { return yrange; }
            set
            {
                if (value <= 0)
                    value = 1;

                if (yrange != value)
                {
                    yrange = value;
                }
            }
        }


        public void CopyTo(FixGraphItemParam dest)
        {
            dest.ID = ID;
            dest.Len = Len;
            dest.Interval = Interval;
            dest.Mix = Mix;
            dest.IsAutoTarget = IsAutoTarget;
            dest.IsAutoY = IsAutoY;
            dest.IsADMode = IsADMode;
            dest.YRange = YRange;
            dest.YTarget = YTarget;
        }




    }
}
