Ejemplo n.º 1
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;
                }
            }
        }
Ejemplo n.º 2
0
        private void DeleteButton_Click(object sender, EventArgs e)
        {
            TreeNode node = SitesTreeView.SelectedNode;

            if (node.Tag is EventGenerator)
            {
                DialogResult dialogResult = MessageBox.Show("Are you sure you want to delete " + node.Text + "?", "Delete Item", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.No)
                {
                    return;
                }

                EventGenerator  eg  = (EventGenerator)node.Tag;
                DetectionSystem sys = (DetectionSystem)node.Parent.Tag;
                eg.Delete();

                siteMan.Save();
                UpdateSitesTree();
                siteManChanged = true;
            }
        }