Пример #1
0
        public void SetupActionGroupBox()
        {
            EventGenerator eg     = (EventGenerator)SitesTreeView.SelectedNode.Tag;
            Action         action = null;

            foreach (Action otherAction in eg.GetActions())
            {
                if (otherAction.Name == ActionsComboBox.Text)
                {
                    action = otherAction;
                }
            }
            selectedAction         = action;
            ActionNameTextBox.Text = action.Name;
            if (action is AnalysisAction)
            {
                ActionTypeComboBox.Text = "Analysis";
                PopulateAnalysisPanels((AnalysisAction)action, eg);
            }
            else if (action is CommandAction)
            {
                ActionTypeComboBox.Text = "Command";
                PopulateCommandPanels((CommandAction)action, eg);
            }
        }
Пример #2
0
        private void SaveButton_Click(object sender, EventArgs e)
        {
            TreeNode node = SitesTreeView.SelectedNode;
            Action   act  = null;

            if (node.Tag is EventGenerator)
            {
                DetectionSystem eventWatcher = (DetectionSystem)node.Parent.Tag;
                EventGenerator  eg           = (EventGenerator)node.Tag;
                if (eg.Name != NameTextBox.Text && siteMan.ContainsName(NameTextBox.Text))
                {
                    MessageBox.Show("All items in the Site Manager and Event Manager require a unique name!");
                    return;
                }
                if (!ParamListPanel.ValidateInput())
                {
                    return;
                }
                EventGeneratorHookup hookup = EventGenerator.GetHookup(eg.GetEventGeneratorType());

                int index = 0;
                List <EventGenerator> egs = (eg.Parent as DetectionSystem).GetEventGenerators();
                for (int i = 0; i < egs.Count; i++)
                {
                    if (eg.ID == egs[i].ID)
                    {
                        index = i;
                        break;
                    }
                }
                eg.Delete();
                eg = hookup.FromParameters(eventWatcher, NameTextBox.Text, ParamListPanel.Parameters, eg.ID);
                eg.SetIndex(index);

                foreach (Action action in eg.GetActions())
                {
                    if (action.Name == ActionsComboBox.Text)
                    {
                        SaveAction(eg, action);
                        act = action;
                        break;
                    }
                }

                siteMan.Save();
                UpdateSitesTree();
                siteManChanged             = true;
                SitesTreeView.SelectedNode = SitesTreeView.Nodes.Find(eg.Name, true)[0];
                if (act != null)
                {
                    ActionsComboBox.Text = act.Name;
                }
            }
        }
Пример #3
0
        private void RemoveActionButton_Click(object sender, EventArgs e)
        {
            EventGenerator eg     = (EventGenerator)SitesTreeView.SelectedNode.Tag;
            Action         action = null;

            foreach (Action otherAction in eg.GetActions())
            {
                if (otherAction.Name == ActionsComboBox.Text)
                {
                    action = otherAction;
                }
            }
            action.Delete();
            siteMan.Save();
            UpdateSitesTree();
            siteManChanged             = true;
            SitesTreeView.SelectedNode = SitesTreeView.Nodes.Find(eg.Name, true)[0];
            ResetFields();
        }
Пример #4
0
 public Action(EventGenerator parent, string name, uint id) : base(parent, name, id)
 {
     eventGenerator = parent;
     eventGenerator.GetActions().Add(this);
 }
Пример #5
0
 public override bool SetIndex(int index)
 {
     eventGenerator.GetActions().Remove(this);
     eventGenerator.GetActions().Insert(index, this);
     return(base.SetIndex(index));
 }
Пример #6
0
        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;
            }
        }
Пример #7
0
        public void ResetFields()
        {
            selectedAction        = null;
            selectedActionChannel = null;
            TreeNode node = SitesTreeView.SelectedNode;

            if (node.Tag is EventGenerator)
            {
                DetectionSystem eventWatcher = (DetectionSystem)node.Parent.Tag;

                NameTextBox.Enabled = true;

                EventGenerator   eg         = (EventGenerator)node.Tag;
                List <Parameter> parameters = eg.GetParameters();
                ParamListPanel.LoadParameters(parameters);
                ParamListPanel.Visible = true;
                NameTextBox.Text       = eg.Name;

                ActionPanel.Visible = true;
                ActionsComboBox.Items.Clear();
                ActionsComboBox.Text = "";
                if (eg.GetActions().Count > 0)
                {
                    foreach (Action action in eg.GetActions())
                    {
                        ActionsComboBox.Items.Add(action.Name);
                    }
                    ActionsComboBox.Text = eg.GetActions()[0].Name;
                    selectedAction       = eg.GetActions()[0];
                    SetupActionGroupBox();
                    ActionGroupBox.Visible = true;
                }
                else
                {
                    ActionGroupBox.Visible = false;
                }

                UpButton.Enabled     = true;
                DownButton.Enabled   = true;
                AddButton.Enabled    = true;
                DeleteButton.Enabled = true;
                SaveButton.Enabled   = true;
            }
            else if (node.Tag is DetectionSystem)
            {
                NameTextBox.Text    = "";
                NameTextBox.Enabled = false;

                ParamListPanel.Visible = false;
                ActionPanel.Visible    = false;

                UpButton.Enabled     = false;
                DownButton.Enabled   = false;
                AddButton.Enabled    = true;
                DeleteButton.Enabled = false;
                SaveButton.Enabled   = false;
            }
            else
            {
                NameTextBox.Text    = "";
                NameTextBox.Enabled = false;

                ParamListPanel.Visible = false;
                ActionPanel.Visible    = false;

                UpButton.Enabled     = false;
                DownButton.Enabled   = false;
                AddButton.Enabled    = false;
                DeleteButton.Enabled = false;
                SaveButton.Enabled   = false;
            }
        }