Example #1
0
        /// <summary>
        /// Generates the associate projects menu item.
        /// </summary>
        /// <returns></returns>
        private ToolStripMenuItem GenerateAssociateProjectsMenu()
        {
            ToolStripMenuItem menuItem = new ToolStripMenuItem("Associate projects...");

            menuItem.Image  = CCNetConfig.Properties.Resources.queueprojectlink_16x16;
            menuItem.Click += delegate(object sender, EventArgs e)
            {
                ProjectQueuesTreeNode ParentNode = (Parent as ProjectQueuesTreeNode);
                QueueProjectLinkForm  form       = new QueueProjectLinkForm();
                form.LoadProjects(queue, ParentNode.Configuration);
                form.Saved += delegate(object source, EventArgs args)
                {
                    foreach (Project proj in queue.Projects)
                    {
                        if (proj.Queue == queue.Name)
                        {
                            proj.Queue = null;
                        }
                    }
                    queue.Projects.Clear();
                    queue.Projects.AddRange(form.SelectedProjects);
                    foreach (Project proj in queue.Projects)
                    {
                        if (!string.IsNullOrEmpty(proj.Queue) && (proj.Queue != queue.Name))
                        {
                            ParentNode.Configuration.Queues[proj.Queue].RemoveProject(proj);
                        }
                        if (proj.Queue != queue.Name)
                        {
                            proj.Queue = queue.Name;
                        }
                    }
                    UpdateProjects();
                };
                form.ShowDialog();
            };
            return(menuItem);
        }
Example #2
0
        /// <summary>
        /// Generates the remove queue menu.
        /// </summary>
        /// <returns></returns>
        private ToolStripMenuItem GenerateRemoveQueueMenu()
        {
            ToolStripMenuItem menuItem = new ToolStripMenuItem("Remove queue");

            menuItem.Image  = CCNetConfig.Properties.Resources.queuedelete_16x16;
            menuItem.Click += delegate(object sender, EventArgs e)
            {
                if (MessageBox.Show(MainForm,
                                    string.Format("Are you sure you want to delete the queue '{0}'?", queue.Name),
                                    "Confirm delete",
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Exclamation) == DialogResult.Yes)
                {
                    foreach (Project project in queue.Projects)
                    {
                        project.Queue = null;
                    }
                    ProjectQueuesTreeNode parent = Parent as ProjectQueuesTreeNode;
                    parent.Configuration.Queues.Remove(queue);
                    Parent.Nodes.Remove(this);
                }
            };
            return(menuItem);
        }