示例#1
0
 private void dataGridView1_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
 {
     try {
         if (this.dataGridView1.Columns[e.ColumnIndex].Name.Equals("isConnectDataGridViewCheckBoxColumn"))
         {
             if (e.RowIndex < LightCrlParaManager.Instance.LightCtrParaItems.Count())
             {
                 LightCrlParaItem item = LightCrlParaManager.Instance.LightCtrParaItems[e.RowIndex];
                 // item.IsOpen = true;
                 if (item == null)
                 {
                     e.Value = this.imageList1.Images[3];
                 }
                 else if (item.IsConnect)
                 {
                     e.Value = (item.IsActive == true) ? this.imageList1.Images[2] : this.imageList1.Images[2];
                 }
                 else
                 {
                     e.Value = this.imageList1.Images[1];
                 }
             }
         }
     }
     catch
     { }
 }
示例#2
0
 /// <summary>
 /// 打开,并连接串口
 /// </summary>
 public virtual void DoStart()
 {
     try {
         if (lightCtrlParaItem.IsActive)
         {
             port.Open(); //
                          //正常打开,设置IsConnect =true ;
             if (port.IsOpen)
             {
                 lightCtrlParaItem.IsConnect = true;
                 LightCrlParaItem item = LightCrlParaManager.Instance.GetParaItem(lightCtrlParaItem);
                 item.IsConnect = true;
             }
             else
             {
                 lightCtrlParaItem.IsConnect = false;
                 LightCrlParaItem item = LightCrlParaManager.Instance.GetParaItem(lightCtrlParaItem);
                 item.IsConnect = false;
             }
         }
     }
     catch  {
         lightCtrlParaItem.IsConnect = false;
         LightCrlParaItem item = LightCrlParaManager.Instance.GetParaItem(lightCtrlParaItem);
         item.IsConnect = false;
     }
 }
示例#3
0
 /// <summary>
 /// 关闭串口
 /// </summary>
 public virtual void DoStop()
 {
     try{
         port.Close();
         LightCrlParaItem item = LightCrlParaManager.Instance.GetParaItem(lightCtrlParaItem);
         item.IsConnect = false;
     }
     catch
     { }
 }
示例#4
0
        public LightCrlParaItem GetParaItem(LightCrlParaItem lightCtrlParaIn)
        {
            IEnumerable ie = from lst in this.LightCtrParaItems
                             where lst.PortName == lightCtrlParaIn.PortName
                             select lst;
            List <LightCrlParaItem> ioLst = ie.Cast <LightCrlParaItem>().ToList();

            if (ioLst.Count > 0)
            {
                return(ioLst[0]);
            }
            else
            {
                return(null);
            }
        }
示例#5
0
        public bool Read()
        {
            bool IsOk = true;
            LightCrlParaManager Obj = XML <LightCrlParaManager> .Read(Path + @"\" + "LightCrlParaManager.xml");

            if (Obj == null)
            {
                Obj = LightCrlParaManager.Instance;
            }
            if (Obj.LightCtrParaItems.Count() == 0)
            {
                LightCrlParaItem item = new LightCrlParaItem();
                Obj.LightCtrParaItems = new BindingList <LightCrlParaItem>();
                Obj.LightCtrParaItems.Add(item);
            }
            _instance = Obj;
            return(IsOk);
        }
示例#6
0
 public virtual void SetPara(LightCrlParaItem lightCtrlParaIn)
 {
     this.lightCtrlParaItem = lightCtrlParaIn;
 }