using LiveCharts;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace WpfApp1.CharttoImage
{
    /// <summary>
    /// ScanGraph.xaml 的交互逻辑
    /// </summary>
    public partial class ScanGraph : UserControl
    {
        public ScanGraph()
        {
            InitializeComponent();
        }

        /// <summary>
        /// The minimum value property
        /// </summary>
        public static readonly DependencyProperty MinValueProperty = DependencyProperty.Register(
            nameof(MinValue), typeof(double), typeof(ScanGraph),
            new PropertyMetadata(double.NaN));
        /// <summary>
        /// Gets or sets axis min value, set it to double.NaN to make this property Auto, default value is double.NaN
        /// </summary>
        public double MinValue
        {
            get { return (double)GetValue(MinValueProperty); }
            set { SetValue(MinValueProperty, value); }
        }
    }
    public class ScanGraphVm : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        public double XMax { get; set; } = double.NaN;
        public double XMin { get; set; } = double.NaN;

        public double YMax { get; set; } = double.NaN;
        public double YMin { get; set; } = double.NaN;

        public ChartValues<double> Values { get; } = new ChartValues<double>();

        public ScanGraphVm() 
        {
            XMax = 150;
            XMin = 50;
            YMax = 20;
            YMin = -10;
            Random random = new Random();
            double target = 10;

            List<double> values = new List<double>();
            for (int i = 0; i < 200; i++) {
                values.Add((random.NextDouble() - 0.5) * 5 + target);
            }
            Values.AddRange(values);
        }
    }
}
