Inheritance: Queue.UI.WinForms.DependencyForm
Exemple #1
0
        private void editServiceMenuItem_Click(object sender, EventArgs e)
        {
            var selectedNode = treeView.SelectedNode;
            if (selectedNode != null)
            {
                var service = selectedNode.Tag as Service;
                using (var f = new EditServiceForm(null, service.Id))
                {
                    f.Saved += (s, eventArgs) =>
                    {
                        selectedNode.Text = f.Service.ToString();
                        f.Close();
                    };

                    f.ShowDialog();
                }
            }
        }
Exemple #2
0
        private void addServiceMenuItem_Click(object sender, EventArgs e)
        {
            Guid? groupId = null;

            var selectedNode = treeView.SelectedNode;
            if (selectedNode != null)
            {
                groupId = (selectedNode.Tag as ServiceGroup).Id;
            }

            using (var f = new EditServiceForm(groupId))
            {
                TreeNode treeNode = null;

                f.Saved += (s, eventArgs) =>
                {
                    if (treeNode == null)
                    {
                        treeNode = new TreeNode();
                        treeNode.Tag = f.Service;
                        treeNode.Checked = f.Service.IsActive;

                        if (selectedNode != null)
                        {
                            selectedNode.Nodes.Add(treeNode);
                            selectedNode.Expand();
                        }
                        else
                        {
                            treeView.Nodes.Add(treeNode);
                        }

                        treeView.SelectedNode = treeNode;
                    }

                    treeNode.Text = f.Service.ToString();
                };

                f.ShowDialog();
            }
        }