using SlMesDbIterface;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using System.ComponentModel;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace MesWork
{
    /// <summary>
    /// 
    /// </summary>
    public partial class Temp { }
   /// <summary>
   /// 布局
   /// </summary>
    public partial class MesWorkForm
    {
      
        /// <summary>
        /// 添加布局
        /// </summary>
        public void ReLoadStationIcon()
        {
            ht_Station_Content = new Hashtable();
            ht_Station_Label = new Hashtable();
            G_DC_IP_OP = new Dictionary<String, List<String>>();

            ExecuteDB.Select_Station(out DataTable dt);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                var 工位号 = dt.Rows[i]["工位号"].ToString();
                var 工位名称 = dt.Rows[i]["工位名称"].ToString();
                var PLC = dt.Rows[i]["PLC"].ToString();
                var PLC代码 = dt.Rows[i]["PLC代码"].ToString();
                var PX = Convert.ToInt32(dt.Rows[i]["PX"]);
                var PY = Convert.ToInt32(dt.Rows[i]["PY"]);
                var PX_T = Convert.ToInt32(dt.Rows[i]["PX_T"]);
                var PY_T = Convert.ToInt32(dt.Rows[i]["PY_T"]);
                var 控件启用 = dt.Rows[i]["控件启用"].ToString().ToLower();

                if (控件启用 == "1" | 控件启用 == "true")
                {
                    SetMember(工位号, Release(new Panel()
                    {
                        Location = new System.Drawing.Point(PX, PY),
                        Size = new Size(30, 30),
                        BackColor = color_Bad,
                        Tag = 工位号,
                        BorderStyle = BorderStyle.Fixed3D
                    }));
                    SetMember(工位号, Release(new Label()
                    {
                        Location = new System.Drawing.Point(PX_T, PY_T),
                        Size = new Size(35, 25),
                        Text = 工位号.Replace("OP", "")
                    }));
                
                }

                try
                {
                    if (G_DC_IP_OP.ContainsKey(PLC))
                    {
                        G_DC_IP_OP[PLC].Add(工位号);
                    }
                    else
                    {
                        var list = new List<String>();
                        list.Add(工位号);
                        G_DC_IP_OP.Add(PLC, list);
                    }
                }
                catch (Exception err)
                {
                }

            }

        }

    

    }
}
