コード例 #1
0
 private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
 {
     if (e.CurrentValue == CheckState.Indeterminate)
     {
         e.NewValue = CheckState.Indeterminate;
     }
     else
     {
         if (_current != null)
         {
             if (e.Index >= 0 && e.Index < checkedListBox1.Items.Count)
             {
                 ProjectDependencies pd = checkedListBox1.Items[e.Index] as ProjectDependencies;
                 if (pd != null)
                 {
                     if (e.NewValue == CheckState.Checked)
                     {
                         _current.AddDependency(pd.Project);
                     }
                     else if (e.NewValue == CheckState.Unchecked)
                     {
                         _current.RemoveDependency(pd.Project);
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="p">currently selected project</param>
 /// <param name="lst"></param>
 /// <returns></returns>
 public bool IsInDependenciesIndirect(ProjectDependencies p, SortedList <string, ProjectDependencies> lst, List <Guid> usedProjects)
 {
     if (IsInDependencies(p.Project))
     {
         return(true);
     }
     if (usedProjects.Contains(_prj.ProjectGuid))
     {
         return(false);
     }
     usedProjects.Add(_prj.ProjectGuid);
     foreach (LimnorProject p0 in _dependencies)
     {
         ProjectDependencies pdx = null;
         foreach (ProjectDependencies pd in lst.Values)
         {
             if (pd.Project.ProjectGuid == p0.ProjectGuid)
             {
                 pdx = pd;
                 break;
             }
         }
         if (pdx != null)
         {
             if (pdx.IsInDependenciesIndirect(p, lst, usedProjects))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
コード例 #3
0
        public List <ProjectDependencies> GetDependencies()
        {
            List <ProjectDependencies> lst = new List <ProjectDependencies>();

            for (int i = 0; i < Nodes.Count; i++)
            {
                ProjectNode pn = Nodes[i] as ProjectNode;
                if (pn != null)
                {
                    ProjectNodeData      pnd  = pn.PropertyObject as ProjectNodeData;
                    LimnorProject        lp   = pnd.Project;
                    IList <Guid>         pids = pn.DependedProjects;
                    List <LimnorProject> ps   = new List <LimnorProject>();
                    if (pids != null && pids.Count > 0)
                    {
                        foreach (Guid g in pids)
                        {
                            LimnorProject dp = LimnorSolution.Solution.GetProjectByGuid(g);
                            if (dp != null)
                            {
                                ps.Add(dp);
                            }
                        }
                    }
                    ProjectDependencies pds = new ProjectDependencies(lp, ps);
                    lst.Add(pds);
                }
            }
            return(lst);
        }
コード例 #4
0
        public static List <ProjectDependencies> GetBuildOrder(List <ProjectDependencies> projects)
        {
            List <ProjectDependencies> orders = new List <ProjectDependencies>();

            orders.AddRange(projects);
            //go through each project
            foreach (ProjectDependencies pd in projects)
            {
                //pd is one project to be tested
                List <LimnorProject> pds = pd.Dependencies;
                if (pds.Count > 0)
                {
                    int n = -1;
                    for (int i = 0; i < orders.Count; i++)
                    {
                        if (pd.Project.ProjectGuid == orders[i].Project.ProjectGuid)
                        {
                            n = i;
                            break;
                        }
                    }
                    //n is the index of pd in orders
                    if (n >= 0)
                    {
                        //go through dependencies of pd
                        foreach (LimnorProject p in pds)
                        {
                            ProjectDependencies pdx = null;
                            int k = -1;
                            for (int i = 0; i < orders.Count; i++)
                            {
                                if (p.ProjectGuid == orders[i].Project.ProjectGuid)
                                {
                                    pdx = orders[i];
                                    k   = i;
                                    break;
                                }
                            }
                            //k is the dependent index in orders
                            if (k >= 0)
                            {
                                if (k > n)
                                {
                                    orders.RemoveAt(k);

                                    orders.Insert(n, pdx);
                                    n++;
                                }
                            }
                        }
                    }
                }
            }
            return(orders);
        }
コード例 #5
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (_loading)
            {
                return;
            }
            _loading = true;
            _current = null;
            checkedListBox1.Items.Clear();
            ProjectDependencies pd0 = comboBox1.SelectedItem as ProjectDependencies;

            if (pd0 != null)
            {
                SortedList <string, ProjectDependencies> lst = new SortedList <string, ProjectDependencies>();
                foreach (ProjectDependencies pd in ProjectDependencies)
                {
                    if (pd.Project.ProjectGuid != pd0.Project.ProjectGuid)
                    {
                        if (!lst.ContainsKey(pd.Project.ProjectName))
                        {
                            lst.Add(pd.Project.ProjectName, pd);
                        }
                    }
                }
                //add all projects
                IEnumerator <KeyValuePair <string, ProjectDependencies> > ie = lst.GetEnumerator();
                while (ie.MoveNext())
                {
                    //add a project to listbox
                    int n = checkedListBox1.Items.Add(ie.Current.Value);
                    //the current project depends on this project?
                    if (pd0.IsInDependencies(ie.Current.Value.Project))
                    {
                        checkedListBox1.SetItemChecked(n, true);
                    }
                    //this project depends on current project, directly/indirectly?
                    List <Guid> usedProjects = new List <Guid>();
                    if (ie.Current.Value.IsInDependenciesIndirect(pd0, lst, usedProjects))
                    {
                        checkedListBox1.SetItemChecked(n, false);
                        checkedListBox1.SetItemCheckState(n, CheckState.Indeterminate);
                    }
                }
                _current = pd0;
            }
            _loading = false;
        }