EquipControl.cs 5.3 KB
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OnlineStore.DeviceLibrary;

namespace OnlineStore.AssemblyLine
{
    public partial class EquipControl : UserControl
    {
        public string TrayNum
        {
            get { return lblTrayNum.Text; }
            set { lblTrayNum.Text = value; }
        }
        public string EquipName
        {
            get { return lblName.Text; }
            set { lblName.Text = value; }
        }
        public string WorkStatus
        {
            get { return lblStatus.Text; }
            set { lblStatus.Text = value; }
        }
        public string MoveInfo
        {
            get { return lblMoveInfo.Text; }
            set { lblMoveInfo.Text = value; }
        }

        public Color ColorStatus
        {
            get { return this.BackColor; }
            set
            {
                this.BackColor = value;
            }
        }
        public void SelectStyle()
        {
            panName.BackColor = Color.DeepSkyBlue;
        }
        public void UnSelectStyle()
        {
            panName.BackColor = Color.Transparent;
        }
        public void InitData(EquipBase equip)
        {
            //lblInfo.Visible = false;
            lblInfo.Text = "";
            DeviceId = equip.DeviceID;
            lblName.Text = equip.Name;
        }

        public int DeviceId = 0;
        public void ShowData(EquipBase equip)
        {
            if (equip.IsIdle())
            {
                lblInfo.BackColor = Color.LightGreen;
            }
            else
            {
                lblInfo.BackColor = Color.LightGray;
            }
            lblInfo.Text = equip.EquipInfo;
            lblTrayNum.Text = "容器:" + equip.CurContainerId;
            lblStatus.Text = equip.GetRunStr();
            if (equip.MoveStop)
            {
                lblStatus.Text += "/暂停运动";
            }
            toolTip1.ToolTipTitle = "" + equip.Name + ":双击进入";
            lblDebug.Text = "启用" + (equip.IsDebug ? "✘" : "✔");
            lblWarn.Text = equip.WarnMsg;
            lblUseServo.Visible = false;
            if (equip.RFIDIP == null || equip.RFIDIP.Count == 0)
            {
                lblTrayNum.Visible = false;
            }
            else
            {
                lblTrayNum.Visible = true;
            }

            if (equip.MoveInfo.MoveType.Equals(LineMoveType.OutStore))
            {
                lblMoveInfo.Text = "容器流出[" + equip.CurContainerId + "]";
            }
            else if (equip.MoveInfo.MoveType.Equals(LineMoveType.InStore))
            {
                lblMoveInfo.Text = "容器流入[" + equip.CurContainerId + "]";
            }
            else if (equip.MoveInfo.MoveType.Equals(LineMoveType.Box))
            {
                lblMoveInfo.Text = "容器[" + equip.CurContainerId + "]处理中";
            }
            else
            {
                lblMoveInfo.Text = "暂无容器处理";
            }

            this.BackColor = equip.GetShowColor();
        }
        public EquipControl()
        {
            InitializeComponent();
        }
        private void EquipControl_Load(object sender, EventArgs e)
        {
        }

        public static EquipControl NewControl(EquipBase equip)
        {
            EquipControl control = new EquipControl();
            //control.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
            // | System.Windows.Forms.AnchorStyles.Left)
            // | System.Windows.Forms.AnchorStyles.Right)));
            control.BackColor = System.Drawing.SystemColors.Control;
            control.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
            control.ColorStatus = System.Drawing.SystemColors.Control;
            control.EquipName = "";
            control.Location = new System.Drawing.Point(3, 3);
            control.MoveInfo = "";
            control.Name = "EquipControl" + equip.DeviceID;
            control.Size = new System.Drawing.Size(300, 150);
            control.TabIndex = 0;
            control.TrayNum = "";
            control.WorkStatus = "";
            control.EquipName = equip.Name;
            control.DeviceId = equip.DeviceID;
            control.InitData(equip);
            control.ShowData(equip);
            return control;
        }

        private void lblName_DoubleClick(object sender, EventArgs e)
        {
            this.OnDoubleClick(e);
        }

        private void lblName_MouseEnter(object sender, EventArgs e)
        {
            this.OnMouseEnter(e);
        }

        private void panName_MouseEnter(object sender, EventArgs e)
        {
            this.OnMouseEnter(e);
        }

        private void panName_DoubleClick(object sender, EventArgs e)
        {
            this.OnDoubleClick(e);
        }

        private void lblStatus_DoubleClick(object sender, EventArgs e)
        {
            this.OnDoubleClick(e);
        }

        private void lblStatus_MouseEnter(object sender, EventArgs e)
        {
            this.OnMouseEnter(e);
        }

        private void lblBox_MouseEnter(object sender, EventArgs e)
        {
            this.OnMouseEnter(e);
        }
    }
}