void grid_MouseDoubleClick(object sender, MouseEventArgs e) { int[] rows = grid.Selection.GetSelectionRegion().GetRowsIndex(); SNMPChannelImp chan = (SNMPChannelImp)grid[rows[0], gridColName].Tag; string oldname = chan.Name; List <string> forbiddenNames = new List <string>(); for (int i = 1; i < grid.RowsCount; i++) { if (i != rows[0]) { forbiddenNames.Add(grid[i, gridColName].DisplayText); } } List <string> stations = new List <string>(); for (int i = 1; i < agentGrid.RowsCount; i++) { stations.Add(((SNMPAgent)agentGrid[i, agentGridColName].Tag).Name); } ModifyChannelForm mcc = new ModifyChannelForm(chan, forbiddenNames, stations, null); if ((chan = mcc.DoShow()) != null) { showChannel(rows[0], chan); grid.Invalidate(); } else { return; } }
public static void SaveChannel(XmlElement node, IChannel channel) { SNMPChannelImp channelBase = (SNMPChannelImp)channel; node.SetAttribute("name", channelBase.Name); node.SetAttribute("type", channelBase.GetType().ToString()); node.SetAttribute("agent", channelBase.AgentName); node.SetAttribute("oid", channelBase.Oid); }
private void OnAddVariable(object sender, EventArgs e) { if (agentGrid.RowsCount > 1) { string var = GetUniqueVariableName(); string statname; int [] sel = agentGrid.Selection.GetSelectionRegion().GetRowsIndex(); if (sel.GetLength(0) > 0) { if (sel[0] > 1) { statname = agentGrid[sel[0], agentGridColName].DisplayText; } else { statname = agentGrid[1, agentGridColName].DisplayText; } } else { statname = agentGrid[1, agentGridColName].DisplayText; } int[] rows = grid.Selection.GetSelectionRegion().GetRowsIndex(); List <string> forbiddenNames = new List <string>(); for (int i = 1; i < grid.RowsCount; i++) { if (rows.Length > 0) { if (i != rows[0]) { forbiddenNames.Add(grid[i, gridColName].DisplayText); } } else { forbiddenNames.Add(grid[i, gridColName].DisplayText); } } List <string> stations = new List <string>(); for (int i = 1; i < agentGrid.RowsCount; i++) { stations.Add(((SNMPAgent )agentGrid[i, agentGridColName].Tag).Name); } SNMPChannelImp ch = (SNMPChannelImp)ChannelFactory.CreateChannel(var, plugin, typeof(int), statname, ""); ModifyChannelForm mcc = new ModifyChannelForm(ch, forbiddenNames, stations, statname); if ((ch = mcc.DoShow()) != null) { AddVariable(ch); } } else { MessageBox.Show(StringConstants.CannotCreateVariable, StringConstants.Error); } }
private void AddVariable(SNMPChannelImp channel) { int row = grid.RowsCount; grid.RowsCount++; showChannel(row, channel); grid.Selection.ResetSelection(true); grid.Selection.SelectRow(row, true); }
public static IChannel CreateChannel(XmlElement node, Plugin plugin) { string name = node.Attributes["name"].Value; string type = node.Attributes["type"].Value; string agent = node.Attributes["agent"].Value; string oid = node.Attributes["oid"].Value; Type t = Type.GetType("System." + type); SNMPChannelImp ch = (SNMPChannelImp)CreateChannel(name, plugin, t, agent, oid); return(ch); }
void ModifyChannelForm_FormClosing(object sender, FormClosingEventArgs e) { if ((sender as ModifyChannelForm).test) { SNMPChannelImp ch = (SNMPChannelImp)this.Tag; if (forbiddenNames != null && forbiddenNames.Contains(ch.Name)) { e.Cancel = true; MessageBox.Show(StringConstants.NameAssigned); } (sender as ModifyChannelForm).test = false; } }
private void showChannel(int row, SNMPChannelImp channel) { grid[row, gridColName] = new SourceGrid.Cells.Cell(channel.Name); grid[row, gridColName].Tag = channel; grid[row, gridColName].Editor = null; grid[row, gridColFSType] = new SourceGrid.Cells.Cell(channel.GetType().ToString(), typeof(string)); grid[row, gridColFSType].Editor = null; grid[row, gridColAgent] = new SourceGrid.Cells.Cell(channel.AgentName, typeof(string)); grid[row, gridColAgent].Editor = null; grid[row, gridColOid] = new SourceGrid.Cells.Cell(channel.Oid, typeof(string)); grid[row, gridColOid].Editor = null; }
public ModifyChannelForm(SNMPChannelImp ch, List <string> forbiddenNames, List <string> stations, string selectedStation) { InitializeComponent(); InitializeTooltips(); this.Tag = ch; this.forbiddenNames = forbiddenNames; this.stations = stations; this.selectedStation = selectedStation; this.FormClosing += new FormClosingEventHandler(ModifyChannelForm_FormClosing); nameTextBox.Text = ch.Name; foreach (string s in stations) { agentComboBox.Items.Add(s); } agentComboBox.SelectedItem = ch.AgentName; MakeControlsValidation(ch); }
public void AddChannel(SNMPChannelImp channel) { channels.Add(channel); }
public SNMPChannelImp(string name, SNMPChannelImp ch) : base(name, false, ch.plugin, ch.Type) { this.agentName = ch.agentName; this.oid = ch.oid; }
void MakeControlsValidation(SNMPChannelImp ch) { }