AddRange() public method

public AddRange ( ObjectCollection value ) : void
value ObjectCollection
return void
Esempio n. 1
0
        private void main_Load(object sender, EventArgs e)
        {
            //Generate objects
            ItemFetcher.GenerateObjects();

            //Custom items (soul ring recipe etc)
            if (File.Exists("cache/items.custom.json"))
            {
                ItemFetcher.GenerateObjects("cache/items.custom.json", true);
            }

            //Hide while the startup happens
            this.Visible = false;
            backup = new ListBox.ObjectCollection(new ListBox());

            GListBox1.ImageList = new ImageList();
            GListBox1.ImageList.ImageSize = new System.Drawing.Size(32, 24);

            //Imageindex
            int n = 0;
             try
                {
            foreach (Item it in ItemFetcher.AllItems)
            {
                try { GListBox1.ImageList.Images.Add(it.Name, Image.FromFile("cache\\items\\" + it.DotaName + ".png")); }
                catch
                {
                    GListBox1.ImageList.Images.Add(it.Name, Image.FromFile("cache\\items\\" + it.img ));
                }
                    GListBox1.Items.Add(new GListBoxItem(it.Name, n));
                    it.ImageListIndex = n;
                    n++;

            }
            }
                catch (Exception ex)
             {
                 MessageBox.Show("Error while loading files. Please verify cache and try again.","",MessageBoxButtons.OK,MessageBoxIcon.Error);
                }

            //Backup for searching
            backup.AddRange(GListBox1.Items);

            if (tabControl1.TabCount == 0)
            {
                //Creating Default tabs
                AddNewBuildtab("Starting Items");
                AddNewBuildtab("Early Game");
                AddNewBuildtab("Core Items");
                AddNewBuildtab("Situational");
                AddNewBuildtab("Luxury");
            }
            else
            {
                foreach (BuildTab b in tabControl1.TabPages)
                {
                    b.ItemList.LargeImageList = GListBox1.ImageList;
                    b.ItemList.SmallImageList = GListBox1.ImageList;
                }
            }
            //Change the Picture and text to match hero and build
            Image pic = Image.FromFile(hero.ImagePath);
            this.HeroNameLabel.Text = hero.Name + " - " + title;
            pictureBox1.Image = pic;
            pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            //Enable Tad dragger
            tabDragger = new TabDragger(tabControl1, TabDragBehavior.TabDragArrange);

            this.Visible = true;

            this.Text = "DIRE - Build";
        }
Esempio n. 2
0
            private ListBox.ObjectCollection quicksort(ListBox.ObjectCollection list)
            {
                ListBox.ObjectCollection sorted = new ListBox.ObjectCollection(new ListBox());
                sorted.AddRange(list);

                if(sorted.Count <= 1)
                    return sorted;

                int random = randomNumberGenerator.Next(0, sorted.Count - 1);

                string pivot = (string)list[random];
                sorted.RemoveAt(random);

                ListBox.ObjectCollection lessThan = new ListBox.ObjectCollection(new ListBox());
                ListBox.ObjectCollection greaterThan = new ListBox.ObjectCollection(new ListBox());

                for(int i = 0; i < sorted.Count; ++i)
                    sortItem(sorted[i], pivot, lessThan, greaterThan);

                sorted = quicksort(lessThan);
                sorted.Add(pivot);
                sorted.AddRange(quicksort(greaterThan));

                return sorted;
            }