示例#1
0
        //private new void Bind()
        //{
        //    foreach (var groupBox in this.FindForm().Controls.OfType<GroupBox>())
        //        SetButtonEvent(groupBox);
        //}
        //private void SetButtonEvent(Control control)
        //{
        //    var button = control.Controls.OfType<Button>().OrderBy(x => x.TabIndex).ToList();
        //    //綁定事件
        //    button.ForEach(x => {
        //        x.Click += new EventHandler(Button_Click);
        //        x.Enabled = listType?.Contains<string>(x.Text) ?? false; //判斷是否有這屬性
        //    });
        //}

        //public override void Button_Click(object sender, EventArgs e)
        //{
        //    Button btn = (Button)sender;
        //    proData = btnDatas.Where(x => x.Text == btn.Text).SingleOrDefault();
        //    sDrinkIce = btn.Parent.Name == "gIce" ? btn.Text : sDrinkIce;
        //    sDrinkSugar = btn.Parent.Name == "gSugar" ? btn.Text : sDrinkSugar;
        //    sDrinkSize = btn.Parent.Name == "gSize" ? btn.Text : sDrinkSize ;
        //    if(!string.IsNullOrEmpty(sDrinkSize))
        //    {
        //        switch (sDrinkSize)
        //        {
        //            case "特大": iSizePrice = 10; break;
        //            case "大杯": iSizePrice = 5; break;
        //            case "中杯": iSizePrice = 0; break;
        //        }
        //    }
        //    ChangColor(btn.Text, btn.Parent);
        //}

        public override void Button_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            proData = btnDatas.Where(x => x.Text == btn.Text).SingleOrDefault();
            //反射方法 設定屬性
            var property = drink.GetType().GetProperty(proData.Group);

            property.SetValue(drink, proData.Text);
            drink.sizePrice = proData.Price == 0 ? drink.sizePrice : proData.Price;
            //////end
            ChangColor(btn.Text, btn.Parent);
        }
示例#2
0
        public override void Button_Click(object sender, EventArgs e)
        {
            Button  btn     = (Button)sender;
            BtnData btnData = btnDatas.Where(x => x.Text == btn.Text).SingleOrDefault();

            if (btnData == null)
            {
                return;
            }
            //創建 飲料物件
            drinkdata = new DrinkData(btnData);
            Form2 form2 = new Form2(drinkdata);

            this.Enabled = false;
            if (form2.ShowDialog() == DialogResult.OK)
            {
                //ListViewItem lvi = new ListViewItem(form2.lvItem);
                //listView1.Items.Add(lvi);
                SetList();
                DoCalculate();
            }
            this.Enabled = true;
        }
示例#3
0
        public override void Button_Click(object sender, EventArgs e)
        {
            Button btn = (Button)sender;

            stuffData = btnDatas.Where(x => x.Text == btn.Text).SingleOrDefault();
        }