using LiveCharts;
using LiveCharts.Configurations;
using MahApps.Metro.Controls.Dialogs;
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.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;
using WSDDBBrowser.Core;
using WSDDBBrowser.Core.Model;

namespace WSDDBBrowser
{
    /// <summary>
    /// PgMonitorChartConfig.xaml 的交互逻辑
    /// </summary>
    public partial class PgMonitorChartConfig : Page
    {
        PgMonitorChartConfigViewModel viewModel;
        public PgMonitorChartConfig()
        {
            InitializeComponent();

        }
        public void Init()
        {
            viewModel = new PgMonitorChartConfigViewModel();
            viewModel.Init();
            this.DataContext = viewModel;
        }
    }
    /// <summary>
    /// 1.输入OrderNoInput 最少3个字符， 每输入一个字符 更新一次 ProcessList
    /// 2.从ProcessList选择其中一个， 查找出NumberList
    /// 3.选择NumberList， 按【查找】 得到全部数据
    /// </summary>
    public class PgMonitorChartConfigViewModel : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        [PropertyChanged.DoNotCheckEquality]
        public g_sbProcess Process { get; private set; }

        [PropertyChanged.DoNotCheckEquality]
        public List<g_sbNumber> Numbers { get; private set; }

        [PropertyChanged.DoNotCheckEquality]
        public List<g_sbUser> Users { get; private set; }

        public List<RecordCollection> RecordCollections { get; private set; }

        public void Init()
        {
            RecordCollections = DBViewerModel.Instance.RecordCollections;
            Process = DBViewerModel.Instance.SBProcessPack.Process;
            Numbers = DBViewerModel.Instance.SBProcessPack.Numbers;
            Users = DBViewerModel.Instance.SBProcessPack.Users;
        }
    }

    public class PgMonitorChartConfigViewModel_UnitTest : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        public g_sbProcess Process { get; private set; }


        public List<g_sbNumber> Numbers { get; private set; }


        public List<g_sbUser> Users { get; private set; }

        public List<RecordCollection> RecordCollections { get; private set; }

        public PgMonitorChartConfigViewModel_UnitTest()
        {
            Process = new g_sbProcess()
            {
                cOrderNo = "71412312311",
                cProjectNo = "000-00-00-01",
                cTechnologyNo = "000-00-00-00",
                tBeginTime = new DateTime(2019,6,10, 10,30,10),
                tEndTime = new DateTime(2019, 6, 11, 10, 30, 10),
                nTotalLen = 9001
            };
            Numbers = new List<g_sbNumber>()
            {
                new g_sbNumber() { cNumber = "01" },
                new g_sbNumber() { cNumber = "02" },
                new g_sbNumber() { cNumber = "03" }
            };
            Users = new List<g_sbUser>() {
                new g_sbUser(){ cUserName = "root"}
            };

            RecordCollections = new List<RecordCollection>() {
                new RecordCollection(){ DeviceID = "101", DeviceName = "温度1", Target=100, Tolerance=2, Average = 100.1, Min=99, Max = 101, Sigma3 = 1 }
            };
        }
    }
}
