private void treeViewCommandList_DoubleClick(object sender, EventArgs e) { if (treeViewCommandList.SelectedNode == null || treeViewCommandList.SelectedNode.Level == 0) { return; } string selected = treeViewCommandList.SelectedNode.Text; ListViewItem newCommand = new ListViewItem(); Command command; if (treeViewCommandList.SelectedNode.Parent.Text.Equals(Processor.CategoryIRCommands, StringComparison.OrdinalIgnoreCase)) { command = new CommandBlastIR(new string[] { treeViewCommandList.SelectedNode.Tag as string, _commandProcessor.BlastIrPorts[0] }); if (_commandProcessor.Edit(command, this)) { newCommand.Text = command.GetUserDisplayText(); newCommand.Tag = command.ToString(); listViewMacro.Items.Add(newCommand); } } else if (treeViewCommandList.SelectedNode.Parent.Text.Equals(Processor.CategoryMacros, StringComparison.OrdinalIgnoreCase)) { command = new CommandCallMacro(new string[] { treeViewCommandList.SelectedNode.Tag as string }); newCommand.Text = command.GetUserDisplayText(); newCommand.Tag = command.ToString(); listViewMacro.Items.Add(newCommand); } else { Type commandType = treeViewCommandList.SelectedNode.Tag as Type; command = (Command)Activator.CreateInstance(commandType); if (_commandProcessor.Edit(command, this)) { newCommand.Text = command.GetUserDisplayText(); newCommand.Tag = command.ToString(); listViewMacro.Items.Add(newCommand); } } }
private void treeViewCommandList_DoubleClick(object sender, EventArgs e) { if (treeViewCommandList.SelectedNode == null || treeViewCommandList.SelectedNode.Level == 0) return; string selected = treeViewCommandList.SelectedNode.Text; ListViewItem newCommand = new ListViewItem(); Command command; if (treeViewCommandList.SelectedNode.Parent.Text.Equals(Processor.CategoryIRCommands, StringComparison.OrdinalIgnoreCase)) { command = new CommandBlastIR(new string[] {treeViewCommandList.SelectedNode.Tag as string, _commandProcessor.BlastIrPorts[0]}); if (_commandProcessor.Edit(command, this)) { newCommand.Text = command.GetUserDisplayText(); newCommand.Tag = command.ToString(); listViewMacro.Items.Add(newCommand); } } else if (treeViewCommandList.SelectedNode.Parent.Text.Equals(Processor.CategoryMacros, StringComparison.OrdinalIgnoreCase)) { command = new CommandCallMacro(new string[] {treeViewCommandList.SelectedNode.Tag as string}); newCommand.Text = command.GetUserDisplayText(); newCommand.Tag = command.ToString(); listViewMacro.Items.Add(newCommand); } else { Type commandType = treeViewCommandList.SelectedNode.Tag as Type; command = (Command) Activator.CreateInstance(commandType); if (_commandProcessor.Edit(command, this)) { newCommand.Text = command.GetUserDisplayText(); newCommand.Tag = command.ToString(); listViewMacro.Items.Add(newCommand); } } }