void agentGrid_MouseDoubleClick(object sender, MouseEventArgs e) { SourceGrid.Grid agentGrid = (SourceGrid.Grid)sender; int [] rows = agentGrid.Selection.GetSelectionRegion().GetRowsIndex(); SNMPAgent agent = (SNMPAgent)agentGrid[rows[0], agentGridColName].Tag; string oldname = agent.Name; List <string> forbiddenNames = new List <string>(); for (int i = 1; i < agentGrid.RowsCount; i++) { if (i != rows[0]) { forbiddenNames.Add(agentGrid[i, agentGridColName].DisplayText); } } FormProfile fpr = new FormProfile(agent, forbiddenNames); if (fpr.ShowDialog() == DialogResult.OK) { agentGrid[rows[0], agentGridColName].Value = agent.Name; agentGrid[rows[0], agentGridColActive].Value = agent.AgentActive; agentGrid[rows[0], agentGridColAddr].Value = "IP: " + agent.AgentIP.ToString(); agentGrid[rows[0], agentGridColPara].Value = "Version = " + agent.VersionCode.ToString() + ", GetCommunity = " + agent.GetCommunity + ", SetCommunity = " + agent.SetCommunity; agentGrid.Invalidate(); } else { return; } if (oldname != agent.Name) { for (int i = 1; i < grid.RowsCount; i++) { if (grid[i, gridColAgent].DisplayText == oldname) { (grid[i, gridColName].Tag as SNMPAgent).Name = agent.Name; grid[i, gridColAgent].Value = agent.Name; grid.Invalidate(); } } } }
void stationGrid_MouseDoubleClick(object sender, MouseEventArgs e) { SourceGrid.Grid stationGrid = (SourceGrid.Grid)sender; int [] rows = stationGrid.Selection.GetSelectionRegion().GetRowsIndex(); IModbusStation stat = (IModbusStation)stationGrid[rows[0], stationGridColName].Tag; string oldname = stat.Name; List <string> forbiddenNames = new List <string>(); for (int i = 1; i < stationGrid.RowsCount; i++) { if (i != rows[0]) { forbiddenNames.Add(stationGrid[i, stationGridColName].DisplayText); } } if (stat is ModbusTCPClientStation) { ModifyTCPClientStationForm mtc = new ModifyTCPClientStationForm((ModbusTCPClientStation)stat, forbiddenNames); if (mtc.ShowDialog() == DialogResult.OK) { stationGrid[rows[0], stationGridColName].Value = (stat as ModbusTCPClientStation).Name; stationGrid[rows[0], stationGridColActive].Value = stat.StationActive; stationGrid[rows[0], stationGridColAddr].Value = "MODBUS/TCP, " + (stat as ModbusTCPClientStation).IPAddress; stationGrid[rows[0], stationGridColPara].Value = "TCPport = " + (stat as ModbusTCPClientStation).TCPPort; stationGrid.Invalidate(); } else { return; } } if (stat is ModbusSerialClientStation) { ModifySerialClientStationForm msc = new ModifySerialClientStationForm((ModbusSerialClientStation)stat, forbiddenNames); if (msc.ShowDialog() == DialogResult.OK) { stationGrid[rows[0], stationGridColName].Value = (stat as ModbusSerialClientStation).Name; stationGrid[rows[0], stationGridColActive].Value = stat.StationActive; stationGrid[rows[0], stationGridColAddr].Value = "MODBUS/" + (stat as ModbusSerialClientStation).SerialType.ToString() + ", " + (stat as ModbusSerialClientStation).ComPort; stationGrid[rows[0], stationGridColPara].Value = (stat as ModbusSerialClientStation).BaudRate.ToString() + "," + (stat as ModbusSerialClientStation).DataBits.ToString() + "," + (stat as ModbusSerialClientStation).Parity.ToString() + "," + (stat as ModbusSerialClientStation).StopBits.ToString(); stationGrid.Invalidate(); } else { return; } } if (oldname != stat.Name) { for (int i = 1; i < grid.RowsCount; i++) { if (grid[i, gridColStation].DisplayText == oldname) { (grid[i, gridColName].Tag as ModbusChannelImp).ModbusStation = stat.Name; grid[i, gridColStation].Value = stat.Name; grid.Invalidate(); } } } }