private void ActionTypeComboBox_SelectedIndexChanged(object sender, EventArgs e) { EventGenerator eg = (EventGenerator)SitesTreeView.SelectedNode.Tag; DetectionSystem eventWatcher = (DetectionSystem)SitesTreeView.SelectedNode.Parent.Tag; Action action = null; foreach (Action otherAction in eg.GetActions()) { if (otherAction.Name == ActionsComboBox.Text) { action = otherAction; } } selectedAction = action; switch (ActionTypeComboBox.Text) { case "Analysis": if (!(action is AnalysisAction)) { DialogResult dialogResult = MessageBox.Show("Are you sure you want to switch action to a Analysis?\nThis will overwrite the current action.", "Switch to Analysis", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.No) { ActionTypeComboBox.Text = action.GetActionType(); return; } action.Delete(); AnalysisAction analysisAction = new AnalysisAction(eg, action.Name, 0); analysisAction.AddChannel(((DetectionSystem)eventWatcher).GetInstruments()[0].GetChannels()[0]); analysisAction.GetDataCompilers().Add(new SpectrumCompiler("", new CHNParser(), new CHNWriter())); analysisAction.GetAnalysis().SetResultParser(new FRAMPlutoniumResultParser()); action = analysisAction; } PopulateAnalysisPanels((AnalysisAction)action, eg); AnalysisPanel.Visible = true; CommandPanel.Visible = false; break; case "Command": if (!(action is CommandAction)) { DialogResult dialogResult = MessageBox.Show("Are you sure you want to switch action to a Command?\nThis will overwrite the current action.", "Switch to Command", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.No) { ActionTypeComboBox.Text = action.GetActionType(); return; } action.Delete(); CommandAction analysisAction = new CommandAction(eg, action.Name, 0); action = analysisAction; } PopulateCommandPanels((CommandAction)action, eg); AnalysisPanel.Visible = false; CommandPanel.Visible = true; break; default: MessageBox.Show("Invalid action type!"); return; } }
private void PopulateCommandPanels(CommandAction action, EventGenerator eg) { ActionCommandTextBox.Text = action.GetCommand(); }