public rtrnNodeInfo checkNodeLife(int nodeid) { rtrnNodeInfo rtrn = new rtrnNodeInfo(); for (int i = 0; i < 256; i++) { if (checkBox1420.NodeID[i] == nodeid) { checkBox1420.flag[i] = 1; checkBox1420.life[i] = 1; rtrn.index = checkBox1420.index[i]; rtrn.flag = 1; return(rtrn); } } // 새로운 노드일 경우 checkBox1420.NodeID[checkBox1420.dept] = nodeid; checkBox1420.index[checkBox1420.dept] = checkBox1420.dept; checkBox1420.life[checkBox1420.dept] = 1; rtrn.index = checkBox1420.dept; rtrn.flag = 0; checkBox1420.dept++; return(rtrn); }
public void OnUpdatePacketView(byte[] data) { try { //if (this.PacketlistView.InvokeRequired) //{ // this.PacketlistView.BeginInvoke(new UpdatePacketView(OnUpdatePacketView), data); //} //else //{ this.PacketlistView.Invoke(new EventHandler(delegate { String Group = String.Format("{0}", data[1]); String NodeID = String.Format("{0}", data[2]); String SeqNo = String.Format("{0}", data[3]); String DI1 = String.Format("{0}", data[4]); String DI2 = String.Format("{0}", data[5]); String DI3 = String.Format("{0}", data[6]); String DI4 = String.Format("{0}", data[7]); rtrnNodeInfo rtrn = new rtrnNodeInfo(); rtrn = checkNodeLife(Int32.Parse(NodeID)); if (rtrn.flag == 1) { //if (Int32.Parse(NodeID) == 31) // this.PacketlistView.Items[rtrn.index].BackColor = Color.Red; // //this.PacketlistView.Items[rtrn.index].ForeColor = Color.Red; //if (Int32.Parse(NodeID) == 32) // this.PacketlistView.Items[rtrn.index].BackColor = Color.Yellow; //if (Int32.Parse(NodeID) == 33) // this.PacketlistView.Items[rtrn.index].BackColor = Color.Green; this.PacketlistView.Items[rtrn.index].SubItems[2].Text = SeqNo; this.PacketlistView.Items[rtrn.index].SubItems[3].Text = DI1; this.PacketlistView.Items[rtrn.index].SubItems[4].Text = DI2; this.PacketlistView.Items[rtrn.index].SubItems[5].Text = DI3; this.PacketlistView.Items[rtrn.index].SubItems[6].Text = DI4; //this.PacketlistView.Invalidate(); } else { this.PacketlistView.Items.Add(new ListViewItem(new string[] { Group, NodeID, SeqNo, DI1, DI2, DI3, DI4 })); } } )); //this.PacketlistView.Items[this.PacketlistView.Items.Count - 1].EnsureVisible(); //this.PacketlistView.EndUpdate(); //} } catch (Exception er) { MessageBox.Show(er.Message); } }