/************************************************************************
*@file FrameworkLocal\UIClient\CenterViews\DataLogs\Core\SicFastLineDataSeries.cs
* @author Su Liang
* @Date 2022-08-02
*
* @copyright &copy Sicentury Inc.
*
* @brief Reconstructed to support rich functions.
*
* @details Cross-Thread operation allowed.
*
* *****************************************************************************/

using System;
using DocumentFormat.OpenXml.Office2013.Drawing.ChartStyle;
using SciChart.Charting.Model.DataSeries;

namespace MECF.Framework.UI.Client.CenterViews.Core.Charting
{
    public class SicFastLineDataSeries : XyDataSeries<DateTime, double>
    {

        #region Variables

        private double _factor = 1.0;
        private double _offset = 0.0;

        #endregion

        #region Properties

        public double Factor
        {
            get => _factor;
            set
            {
                _factor = value;
                UpdateChartSeriesValue();
            }
        
        }

        public double Offset
        {
            get => _offset;
            set
            {
                _offset = value;
                UpdateChartSeriesValue();
            }
        }

        #endregion

        #region Methods

        /// <summary>
        /// /
        /// </summary>
        public void UpdateChartSeriesValue()
        {
            using (SuspendUpdates())
            {
                for (var i = 0; i < Count; i++)
                {
                    var y = (Metadata[i] as ParameterNodePoint)?.Value;
                    if (y == null)
                        continue;

                    Update(i, (double)y * Factor + Offset);
                }


                //var dataSeries = DataSeries as XyDataSeries<DateTime, double>;
                //for (var index = 0; index < dataSeries.Count; ++index)
                //    dataSeries.Update(index, _queueRawData.ElementAt(index).Item2 * _dataFactor + _dataOffset);
            }
        }

        #endregion
    }
}
