FrmTrayInfo.cs 2.2 KB

using OnlineStore.Common;
using OnlineStore.DeviceLibrary;
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace OnlineStore.AssemblyLine
{
    internal partial class FrmTrayInfo : FrmBase
    {
        public FrmTrayInfo()
        {
            InitializeComponent();
        } 
        private string _contentText = "暂无信息!";

        public string ContentText
        {
            get { return _contentText; }
            set { _contentText = value; }
        }

        private string gouStr = "✔";
        private void FrmTrayInfo_Load(object sender, EventArgs e)
        {
            loadMsg();
        }
        private string getMsg()
        {
            string msg = "";

            List<TrayInfo> tray = TrayManager.getTrayList();
            LogUtil.info("-------------------开始打印托盘信息:");
            msg += "-------------------开始打印托盘信息:\r\n";
            foreach (TrayInfo t in tray)
            {
                string disstr = gouStr;
                if (TrayDisableManager.DisableTray(t.TrayCode))
                {
                    disstr = "✘";
                }
                LogUtil.info(disstr + t.ToStr());
                msg += disstr + t.ToStr() + "\r\n";
            }
             
            LogUtil.info("-------------------结束打印托盘信息");
            msg += "-------------------结束打印托盘信息";
            return msg;
        }
        private void loadMsg()
        {
            this._contentText = getMsg();
            if (this._contentText.Trim() != "")
            { 
                this.label1.Text = this._contentText;
            }
        }
       

        private void btnUpdate_Click(object sender, EventArgs e)
        { 
            loadMsg();
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void FrmTrayInfo_SizeChanged(object sender, EventArgs e)
        {
            this.Left = Screen.PrimaryScreen.Bounds.Width / 2 - this.Width / 2;//桌面的宽度的一半减去自身宽的的一半
            this.Top = Screen.PrimaryScreen.Bounds.Height / 2 - this.Height / 2;//桌面的高度的一半减去自身高度的一半
 
        }
    }
}