コード例 #1
0
        public int CompareTo(object obj)
        {
            int result = 1;

            if (obj != null)
            {
                if (obj is MemberItem)
                {
                    MemberItem memberItem = (MemberItem)obj;
                    return(this.DisplayText.CompareTo(memberItem.DisplayText));
                }
                else
                {
                    throw new ArgumentException();
                }
            }


            return(result);
        }
コード例 #2
0
        private bool populateListBox2()
        {
            bool   result = false;
            string word   = this.getLastWord();

            //System.Diagnostics.Debug.WriteLine(" - Path: " +word);

            if (word != "")
            {
                findNodeResult = null;
                findNode(word, this.treeViewItems.Nodes);

                if (this.findNodeResult != null)
                {
                    this.listBoxAutoComplete.Items.Clear();

                    if (this.findNodeResult.Nodes.Count > 0)
                    {
                        result = true;

                        // Sort alphabetically (this could be replaced with
                        // a sortable treeview)
                        MemberItem[] items = new MemberItem[this.findNodeResult.Nodes.Count];
                        for (int n = 0; n < this.findNodeResult.Nodes.Count; n++)
                        {
                            MemberItem memberItem = new MemberItem();
                            memberItem.DisplayText = this.findNodeResult.Nodes[n].Text;
                            memberItem.Tag         = this.findNodeResult.Nodes[n].Tag;

                            if (this.findNodeResult.Nodes[n].Tag != null)
                            {
                                System.Diagnostics.Debug.WriteLine(this.findNodeResult.Nodes[n].Tag.GetType().ToString());
                            }

                            items[n] = memberItem;
                        }
                        Array.Sort(items);

                        for (int n = 0; n < items.Length; n++)
                        {
                            int imageindex = 0;

                            if (items[n].Tag != null)
                            {
                                // Default to method (contains text for parameters)
                                imageindex = 2;
                                if (items[n].Tag is MemberTypes)
                                {
                                    MemberTypes memberType = (MemberTypes)items[n].Tag;

                                    switch (memberType)
                                    {
                                    case MemberTypes.Custom:
                                        imageindex = 1;
                                        break;

                                    case MemberTypes.Property:
                                        imageindex = 3;
                                        break;

                                    case MemberTypes.Event:
                                        imageindex = 4;
                                        break;
                                    }
                                }
                            }

                            this.listBoxAutoComplete.Items.Add(new GListBoxItem(items[n].DisplayText, imageindex));
                        }
                    }
                }
            }

            return(result);
        }