Пример #1
0
        public PokemonListPanel(PokemonList pl, ContextMenuStrip cms, int num_visible = 6)
        {
            pokemonlist  = pl;
            mnu          = cms ?? new ContextMenuStrip();
            Capacity     = pokemonlist.GetCapacity();
            PartySprites = new PictureBox[Capacity];
            Pokemon      = new Label[Capacity];

            salt = string.Empty;

            mnu.Items[0].Click += HandleView;
            mnu.Items[1].Click += HandleSet;
            mnu.Items[2].Click += HandleDelete;

            AutoScroll  = true;
            Size        = MaximumSize = MinimumSize = new Size(191, 26 * num_visible);
            Location    = new Point(5, 20);
            BackColor   = Color.White;
            BorderStyle = BorderStyle.FixedSingle;

            for (int i = 0; i < Capacity; i++)
            {
                PartySprites[i] = new PictureBox
                {
                    Size             = new Size(16, 16),
                    Location         = new Point(10, 5 + i * 26),
                    Name             = salt + salt + "_" + i,
                    ContextMenuStrip = mnu,
                    Tag       = pokemonlist,
                    AllowDrop = true
                };
                PartySprites[i].DragEnter += HandleDragEnter;
                PartySprites[i].DragDrop  += HandleDragDrop;
                PartySprites[i].MouseDown += HandleMouseDown;

                Pokemon[i] = new Label
                {
                    Font             = Util.Pokered_US,
                    AutoSize         = true,
                    Location         = new Point(31, 5 + i * 26),
                    Name             = salt + salt + "_" + i,
                    ContextMenuStrip = mnu,
                    Tag       = pokemonlist,
                    AllowDrop = true
                };
                Pokemon[i].DragEnter += HandleDragEnter;
                Pokemon[i].DragDrop  += HandleDragDrop;
                Pokemon[i].MouseDown += HandleMouseDown;

                Controls.Add(PartySprites[i]);
                Controls.Add(Pokemon[i]);
            }

            for (int i = 0; i < pokemonlist.Count; i++)
            {
                update(i);
            }
        }
Пример #2
0
        public void SetList(PokemonList pl)
        {
            pokemonlist = pl;
            int old_cap = Capacity;

            Capacity = pokemonlist.GetCapacity();
            if (Capacity != old_cap)
            {
                Size         = MaximumSize = MinimumSize = new Size(191, 26 * Math.Min(6, Capacity));
                PartySprites = new PictureBox[Capacity];
                Pokemon      = new Label[Capacity];
                Controls.Clear();
                for (int i = 0; i < Capacity; i++)
                {
                    PartySprites[i] = new PictureBox
                    {
                        Size             = new Size(16, 16),
                        Location         = new Point(10, 5 + i * 26),
                        Name             = salt + "_" + i,
                        ContextMenuStrip = mnu,
                        Tag       = pokemonlist,
                        AllowDrop = true
                    };
                    PartySprites[i].DragEnter += HandleDragEnter;
                    PartySprites[i].DragDrop  += HandleDragDrop;
                    PartySprites[i].MouseDown += HandleMouseDown;

                    Pokemon[i] = new Label
                    {
                        Font             = Util.Pokered_US,
                        AutoSize         = true,
                        Location         = new Point(31, 5 + i * 26),
                        Name             = salt + "_" + i,
                        ContextMenuStrip = mnu,
                        Tag       = pokemonlist,
                        AllowDrop = true
                    };
                    Pokemon[i].DragEnter += HandleDragEnter;
                    Pokemon[i].DragDrop  += HandleDragDrop;
                    Pokemon[i].MouseDown += HandleMouseDown;

                    Controls.Add(PartySprites[i]);
                    Controls.Add(Pokemon[i]);
                }
            }
            for (int i = 0; i < Capacity; i++)
            {
                update(i);
            }
        }