using CNAS_DBSync;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml.Serialization;

namespace CNAS_RunSync
{
    public partial class frmSyncShow : Form
    {
        private log4net.ILog log = log4net.LogManager.GetLogger("frmSyncShow");
        public List<SyncInstrumentItemInfo> lstSyncInstrument = new List<SyncInstrumentItemInfo>();

        public frmSyncShow()
        {
            InitializeComponent();
        }

        private void frmSyncShow_Load(object sender, EventArgs e)
        {
            //1.读取本地存储的仪器信息
            //2.每一个仪器创建一个TabPage
            //3.每个TabPage页内加载一个ucSyncShow,展示这个仪器的详细信息和操作

            //读取本地文件中存储的配置信息
            XmlSerializer serializer = new XmlSerializer(lstSyncInstrument.GetType());
            FileStream stream = new FileStream(FileHelper.getBasePath() + "/Data/SyncInStrumentData.xml", FileMode.Open);
            lstSyncInstrument = (List<SyncInstrumentItemInfo>)serializer.Deserialize(stream);
            stream.Close();

            if (lstSyncInstrument.Count > 0)
            {
                int index = 0;
                foreach (var item in lstSyncInstrument)
                {
                    tabcSyncData.TabPages.Add(index.ToString(), item.Code);

                    ucSyncShow show = new ucSyncShow(item);
                    tabcSyncData.TabPages[index].Controls.Add(show);
                    show.Dock = DockStyle.Fill;

                    index++;
                }
            }
        }
    }
}
