private void AddMapper_transItem(object sender, EventArgs e) { Database.work_group wg = (Database.work_group)sender; if (this.lVMapper.SelectedItems.Count > 0) { if ((int)this.lVMapper.SelectedItems[0].Tag == wg.T1ID) { this.lVMapper.SelectedItems[0].Text = wg.T1NAME; this.lVMapper.SelectedItems[0].SubItems[1].Text = wg.T1INIP; this.lVMapper.SelectedItems[0].SubItems[2].Text = wg.T1INPORT.ToString(); this.lVMapper.SelectedItems[0].SubItems[3].Text = wg.T1OUTIP; this.lVMapper.SelectedItems[0].SubItems[4].Text = wg.T1OUTPORT.ToString(); this.lVMapper.SelectedItems[0].SubItems[5].Text = wg.T1SINGLEMAX.ToString(); this.lVMapper.SelectedItems[0].SubItems[6].Text = wg.T1MAXNUM.ToString(); this.lVMapper.SelectedItems[0].SubItems[7].Text = wg.T1STARTTIME.ToString(); this.lVMapper.SelectedItems[0].SubItems[8].Text = wg.T1STOPTIME.ToString(); ItemToGroup(PmList.Where(x => x.Id == wg.T1ID).First(), lVMapper.SelectedItems[0]); } else { lVMapper.Items.Add(objToItem(wg)); PortMap pm = new PortMap(); ItemToGroup(pm, objToItem(wg)); PmList.Add(pm); } } else { lVMapper.Items.Add(objToItem(wg)); PortMap pm = new PortMap(); ItemToGroup(pm, objToItem(wg)); PmList.Add(pm); } }
public static ListViewItem objToItem(Database.work_group wg) { ListViewItem ivi = new ListViewItem(); ivi.Tag = wg.T1ID; ivi.ImageIndex = 1; ivi.Text = wg.T1NAME; ivi.SubItems.Add(wg.T1INIP); ivi.SubItems.Add(wg.T1INPORT.ToString()); ivi.SubItems.Add(wg.T1OUTIP); ivi.SubItems.Add(wg.T1OUTPORT.ToString()); ivi.SubItems.Add(wg.T1SINGLEMAX.ToString()); ivi.SubItems.Add(wg.T1MAXNUM.ToString()); ivi.SubItems.Add(wg.T1STARTTIME.ToString()); ivi.SubItems.Add(wg.T1STOPTIME.ToString()); return(ivi); }