Example #1
0
        private void btnAddOrder_Click(object sender, EventArgs e)
        {
            bool             isFruitChecked     = this.chkFruit.Checked;
            bool             isStatementChecked = this.chkStatement.Checked;
            Product          product            = this.lstProduct.SelectedItem as Product;
            ProductDecorator decoratedProduct;

            decoratedProduct = new StatementTopping(
                new FruitTopping(product, isFruitChecked), isStatementChecked, this.txtStatement.Text);

            // image show
            var imageList = decoratedProduct.ImageList;

            foreach (var img in imageList)
            {
                var pic = new PictureBox();
                this.pnlImage.Controls.Add(pic);
                pic.Image    = img;
                pic.Location = new Point(0, 0);
                pic.Size     = img.Size;
                pic.BringToFront();
            }

            this.txtResult.Text     = decoratedProduct.Name;
            this.txtTotalPrice.Text = decoratedProduct.Price.ToString();
        }
Example #2
0
        private void chkStatement_CheckedChanged(object sender, EventArgs e)
        {
            var statement = new StatementTopping();

            // calculate current topping price and update current price
            this.CurrentToppingPrice = this.chkStatement.Checked
                ? this.CurrentToppingPrice + statement.ToppingPrice  // if checked
                : this.CurrentToppingPrice - statement.ToppingPrice; // if unchecked

            // statement option check
            this.txtStatement.Enabled = this.chkStatement.Checked
                ? true
                : false;
        }