コード例 #1
0
 private void UpdatePcUi(PCUserControl pc, int status, string name)
 {
     if (pc.InvokeRequired)
     {
         pc.Invoke((MethodInvoker) delegate
         {
             pc.SetPcName(name);
             // pc.SetOnLineStatus(status);
             if (status == 1)
             {
                 pc.SetOnLineStatus("在线");
             }
             else
             {
                 pc.SetOnLineStatus("离线");
             }
         });
     }
     else
     {
         pc.SetPcName(name);
         // pc.SetOnLineStatus(status);
         if (status == 1)
         {
             pc.SetOnLineStatus("在线");
         }
         else
         {
             pc.SetOnLineStatus("离线");
         }
     }
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: 524300045/jixieshour
        private void Form1_Load(object sender, EventArgs e)
        {
            RobotInfo.DeviceCode = ConfigurationManager.AppSettings["devicecode"];

            List <ClientIpInfoModel> list = new List <ClientIpInfoModel>();
            DataTable dt = new ClientInfoDal().GetDS();

            if (dt != null && dt.Rows.Count > 0)
            {
                int width = 0;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    ClientIpInfoModel model = new ClientIpInfoModel();
                    model.Id       = Convert.ToInt32(dt.Rows[i]["id"].ToString());
                    model.Code     = dt.Rows[i]["code"].ToString();
                    model.Name     = dt.Rows[i]["name"].ToString();
                    model.IP       = dt.Rows[i]["ip"].ToString();
                    model.Port     = dt.Rows[i]["port"].ToString();
                    model.Timeouts = Convert.ToInt32(dt.Rows[i]["timeouts"].ToString());
                    model.Status   = Convert.ToInt32(dt.Rows[i]["status"].ToString());
                    list.Add(model);

                    PCUserControl pc = new PCUserControl();
                    pc.LabelText(model.Name);
                    pc.Location = new Point(width, 0);
                    width       = width + pc.Width;
                    panelPC.Controls.Add(pc);
                }
            }
            AppInfo.ClientInfoList = list;

            //串口打开
            try
            {
                if (!serialPort1.IsOpen)
                {
                    serialPort1.Open();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }