예제 #1
0
        public void addGoodButton(int id, string imageURL, string name)
        {
            ButtonWithId btn = new ButtonWithId();
            if (imageURL == "" || !File.Exists(imageURL)) imageURL = @"C:\Users\Toxuin\Documents\IMAGES\noItemImage.png";
            btn.Image = Image.FromFile(imageURL);

            btn.ImageAlign = System.Drawing.ContentAlignment.BottomCenter;
            btn.Width = 120;
            btn.Height = 120;
            btn.ItemId = id;
            btn.Text = name;
            btn.TextAlign = System.Drawing.ContentAlignment.TopCenter;
            btn.Click += (sender, evnt) => { itemClickCallback(((ButtonWithId)sender).ItemId); };

            // Doesn't go off screen now
            Point lctn = goodsBox.DisplayRectangle.Location;
            int initY = lctn.Y;
            int initX = 30;
            int row = (int)(goodsBox.Controls.Count / 5);
            int col = goodsBox.Controls.Count - (row * 5);
            lctn.Y = initY + row * 130;
            lctn.X = initX + col * 130;
            btn.Location = lctn;

            goodsBox.Controls.Add(btn);
        }
예제 #2
0
        public void addSaleButton(int id, string name)
        {
            ButtonWithId btn = new ButtonWithId();
            btn.Width = 120;
            btn.Height = 50;
            btn.ItemId = id;
            btn.Text = name;
            btn.Click += (sender, evnt) => { saleClickCallback(((ButtonWithId)sender).ItemId); };

            // COULD GO OFF THE SCREEN
            Point lctn = saleBox.DisplayRectangle.Location;
            int initY = lctn.Y;
            int initX = 20;
            int row = (int)(saleBox.Controls.Count / 3);
            int col = saleBox.Controls.Count - (row * 3);
            lctn.Y = initY + row * 60;
            lctn.X = initX + col * 130;
            btn.Location = lctn;
            saleBox.Controls.Add(btn);
        }