示例#1
0
        public Page()
        {
            UseVisualStyleBackColor = true;

            if (resources == null) {
                resources = new ResourceManager("INVedit.Resources", GetType().Assembly);
                head = (Image)resources.GetObject("head");
                chest = (Image)resources.GetObject("chest");
                pants = (Image)resources.GetObject("pants");
                boots = (Image)resources.GetObject("boots");
            }

            boxInventory = new GroupBox(){ Text = "Inventory", Location = new Point(6, 6), Size = new Size(461, 285) };
            Controls.Add(boxInventory);
            boxInventory.Controls.Add(new Label(){ Location = new Point(287, 19), Size = new Size(54, 20),
                                      	Text = "Damage:", TextAlign = ContentAlignment.MiddleRight });
            boxInventory.Controls.Add(new Label(){ Location = new Point(287, 44), Size = new Size(54, 20),
                                      	Text = "Count:", TextAlign = ContentAlignment.MiddleRight });
            boxDamage = new NumericUpDown();
            boxDamage.Location = new Point(344, 21);
            boxDamage.Size = new Size(57, 20);
            boxDamage.Minimum = -32768;
            boxDamage.Maximum = 32767;
            boxDamage.TextAlign = HorizontalAlignment.Right;
            boxDamage.Enabled = false;
            boxInventory.Controls.Add(boxDamage);
            boxCount = new NumericUpDown();
            boxCount.Location = new Point(344, 46);
            boxCount.Size = new Size(57, 20);
            boxCount.Minimum = 0;
            boxCount.Maximum = 255;
            boxCount.TextAlign = HorizontalAlignment.Right;
            boxCount.Enabled = false;
            boxInventory.Controls.Add(boxCount);

            CreateSlot(103, 7, 19, head);
            CreateSlot(102, 7 + 50, 19, chest);
            CreateSlot(101, 7 + 100, 19, pants);
            CreateSlot(100, 7 + 150, 19, boots);
            for (int i = 0; i < 9; ++i) CreateSlot((byte)(9+i), 7 + i*50, 75);
            for (int i = 0; i < 9; ++i) CreateSlot((byte)(18+i), 7 + i*50, 125);
            for (int i = 0; i < 9; ++i) CreateSlot((byte)(27+i), 7 + i*50, 175);
            for (int i = 0; i < 9; ++i) CreateSlot((byte)i, 7 + i*50, 231);

            DeleteItemSlot delete = new DeleteItemSlot(
                (Image)resources.GetObject("delete1"),
                (Image)resources.GetObject("delete2")
            ){ Location = new Point(407, 19), UseVisualStyleBackColor = true };
            boxInventory.Controls.Add(delete);
            delete.DeleteDone += delegate {
                boxDamage.Enabled = false;
                boxCount.Enabled = false;
                boxDamage.Value = 0;
                boxCount.Minimum = 0;
                boxCount.Value = 0;
            };

            boxDamage.LostFocus += BoxLostFocus;
            boxCount.LostFocus += BoxLostFocus;
            boxDamage.ValueChanged += ValueChanged;
            boxCount.ValueChanged += ValueChanged;
        }