using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using QMAPP.FJC.Entity.Injection;

namespace QMAPP.WinForm.Forms.Injection
{
    public partial class InjectPlat : Form
    {
        
        public InjectPlat()
        {
            InitializeComponent();
        }


        /// <summary>
        /// 加载当前页面
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void InjectPlat_Load(object sender, EventArgs e)
        {
            int columns = this.TLP.ColumnCount;//定义列数
            int line = this.TLP.RowCount;//定义行数
            this.TLP.Controls.Clear();
            Size a = new Size();//new一个size
            a.Width = 124;
            a.Height = 103;
            //查询孔与料罐关系表
            QMAPP.ServicesAgent.ServiceAgent agent = ClientContext.GetServiceAgent();
            List<InjectHole> recorder = agent.InvokeServiceFunction<List<InjectHole>>("InjectionRecorderBLL_GetInjectHoleList");
            //
            if (recorder != null)
            {
                foreach (var item in recorder)
                {
                    //for (int i = 0; i < line * columns; i++)
                    //{
                        //if (i <= recorder.Count() - 1)
                        //{
                            UcControl.DetailHole panel = new UcControl.DetailHole(item.CHARINGBARREL_CODE);
                            this.TLP.Controls.Add(panel);
                            //行
                            string[] sArray = item.COORDINATE.Split(',');
                            int r = Convert.ToInt32(sArray[0]);
                            TLP.SetRow(panel, r);
                            //列
                            int c = Convert.ToInt32(sArray[1]);
                            TLP.SetColumn(panel, c);
                        //}
                        //else
                        //{
                            //UcControl.BaseHole BASE = new UcControl.BaseHole();
                            //this.TLP.Controls.Add(BASE);
                        //}


                    //}
                }
            }
        }

        /// <summary>
        /// 定时刷新
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timer1_Tick(object sender, EventArgs e)
        {
            InjectPlat_Load(sender, e);
        }

    }
}