コード例 #1
0
        private void AddItems(ICollection items, TreeNodeCollection parent, bool topLevel)
        {
            foreach (object o in items)
            {
                if (o is QuickFix)
                {
                    QuickFix qf   = (QuickFix)o;
                    string   text = qf.SubText;
                    if (topLevel)
                    {
                        text = string.Format("{0} '{1}'", qf.MainText, qf.SubText);
                    }

                    TreeNode tnSub = new TreeNode(text);
                    parent.Add(tnSub);
                    tnSub.Tag                = qf;
                    tnSub.ImageIndex         = 2;
                    tnSub.SelectedImageIndex = 2;
                }
                else
                {
                    // must be group
                    QuickFixGroup qfg    = (QuickFixGroup)o;
                    TreeNode      tnMain = new TreeNode(qfg.Name);
                    parent.Add(tnMain);
                    tnMain.ImageIndex         = 1;
                    tnMain.SelectedImageIndex = 1;
                    AddItems(qfg.Items, tnMain.Nodes, false);
                    if (topLevel)
                    {
                        tnMain.Expand();
                    }
                }
            }
        }
コード例 #2
0
        private void Sort(ICollection fixes, int maxItems)
        {
            topGroups.Clear();

            foreach ( QuickFix qf in fixes )
            {
                QuickFixGroup qfg=(QuickFixGroup) topGroups[qf.MainText];
                if ( qfg == null )
                {
                    qfg=new QuickFixGroup();
                    qfg.Name=qf.MainText;
                    topGroups[qfg.Name]=qfg;
                }
                qfg.Items.Add(qf);
            }

            TopItems.Clear();

            foreach ( QuickFixGroup qfg in topGroups.Values )
            {
                if ( qfg.Items.Count == 1 )
                {
                    TopItems.Add(qfg.Items[0]);
                    continue;
                }

                if ( qfg.Items.Count > maxItems )
                {
                    qfg.Items.Sort(new Sorter());
                    QuickFixGroup newGroup=null;
                    ArrayList origItems=qfg.Items;
                    qfg.Items=new ArrayList();

                    int count=0;
                    foreach ( QuickFix qf in origItems )
                    {
                        if ( newGroup == null )
                        {
                            newGroup=new QuickFixGroup();
                            newGroup.Name=qf.SubText;
                            count=0;
                        }
                        newGroup.Items.Add(qf);
                        count++;
                        if ( count > maxItems )
                        {
                            newGroup.Name+=" - "+qf.SubText;
                            qfg.Items.Add(newGroup);
                            newGroup=null;
                        }
                    }
                    if ( newGroup != null )
                    {
                        QuickFix qf=(QuickFix) origItems[origItems.Count-1];
                        newGroup.Name+=" - "+qf.SubText;
                        qfg.Items.Add(newGroup);
                    }
                }
                TopItems.Add(qfg);
            }
        }
コード例 #3
0
        private void Sort(ICollection fixes, int maxItems)
        {
            topGroups.Clear();

            foreach (QuickFix qf in fixes)
            {
                QuickFixGroup qfg = (QuickFixGroup)topGroups[qf.MainText];
                if (qfg == null)
                {
                    qfg                 = new QuickFixGroup();
                    qfg.Name            = qf.MainText;
                    topGroups[qfg.Name] = qfg;
                }
                qfg.Items.Add(qf);
            }

            TopItems.Clear();

            foreach (QuickFixGroup qfg in topGroups.Values)
            {
                if (qfg.Items.Count == 1)
                {
                    TopItems.Add(qfg.Items[0]);
                    continue;
                }

                if (qfg.Items.Count > maxItems)
                {
                    qfg.Items.Sort(new Sorter());
                    QuickFixGroup newGroup  = null;
                    ArrayList     origItems = qfg.Items;
                    qfg.Items = new ArrayList();

                    int count = 0;
                    foreach (QuickFix qf in origItems)
                    {
                        if (newGroup == null)
                        {
                            newGroup      = new QuickFixGroup();
                            newGroup.Name = qf.SubText;
                            count         = 0;
                        }
                        newGroup.Items.Add(qf);
                        count++;
                        if (count > maxItems)
                        {
                            newGroup.Name += " - " + qf.SubText;
                            qfg.Items.Add(newGroup);
                            newGroup = null;
                        }
                    }
                    if (newGroup != null)
                    {
                        QuickFix qf = (QuickFix)origItems[origItems.Count - 1];
                        newGroup.Name += " - " + qf.SubText;
                        qfg.Items.Add(newGroup);
                    }
                }
                TopItems.Add(qfg);
            }
        }