示例#1
0
    private void AddButtons()
    {
        if (buttonList == null)
        {
            buttonList = new List <CustomerButton>();
        }
        for (int i = 0; i < customerList.Count; i++)
        {
            Cult cult = customerList[i];

            CustomerButton button = Instantiate(buttonToSpawn);
            button.transform.SetParent(content.transform, false);
            button.transform.localPosition = Vector3.zero;
            button.Setup(cult, this);
            buttonList.Add(button);
            Debug.Log("Button added. I now have " + buttonList.Count + " customer buttons");

            //   var copy = Instantiate(itemTemplate);
            //   copy.transform.SetParent(content.transform, false);
            //   copy.transform.localPosition = Vector3.zero;

            //    GameObject newButton = buttonObjectPool.GetObject();
            //   newButton.transform.SetParent(contentPanel);

            //    CultButton button = newButton.GetComponent<CultButton>();
            //   button.Setup( cult, this );
        }
    }
示例#2
0
        public void InitContainer()
        {
            foreach (FunctionInfo functionInfo in FunctionList)
            {
                CustomerButton customerBtn = new CustomerButton();
                customerBtn.Width = 90;
                customerBtn.Tag   = functionInfo.Remark;
                customerBtn.Text  = functionInfo.Remark;

                customerBtn.functionInfo = functionInfo;
                customerBtn.Click       += new EventHandler(customerBtn_Click);
                this.Controls.Add(customerBtn);
                if (x + customerBtn.Width + 10 > this.Parent.Width)
                {
                    y += customerBtn.Height + 10;
                    x  = 10;
                    customerBtn.Location = new Point(x, y);
                }
                else
                {
                    if (y == 10)
                    {
                        customerBtn.Location = new Point(x, y);
                        x += customerBtn.Width + 10;
                    }
                    else
                    {
                        x += customerBtn.Width + 10;
                        customerBtn.Location = new Point(x, y);
                    }
                }
            }
        }
示例#3
0
        private void customerBtn_Click(object sender, EventArgs e)
        {
            CustomerButton customerBtn = sender as CustomerButton;

            if (customerBtn != null)
            {
                ClickButton(customerBtn.functionInfo);
            }
        }