Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Drawing.Drawing2D;
- using System.Drawing.Imaging;
- namespace ZaDude
- {
- public partial class Form1 : Form
- {
- public struct pizza
- {
- public void pizzainit(int items)
- {
- toppings = new Image[items];
- active = new bool[items];
- price = 0;
- final = null;
- }
- public Image[] toppings;
- public bool[] active;
- public int price;
- public Image final;
- }
- public struct topping{
- public topping(int items){
- toppings = new Image[13];
- }
- public Image[] toppings;
- }
- pizza[] pizzaaa = new pizza[10];
- //pizza pizzaa = new pizza();
- topping top = new topping(13);
- public Form1()
- {
- InitializeComponent();
- }
- Button confirm = new Button();
- int activeZa = 0;
- private void Form1_Load(object sender, EventArgs e)
- {
- confirm.Location = new Point(btnClr.Location.X + 100,btnClr.Location.Y);
- confirm.Text = "Confirm";
- this.Controls.Add (confirm);
- top.toppings[0] = Properties.Resources._base;
- top.toppings[1] = Properties.Resources.PO;
- top.toppings[2] = Properties.Resources.H;
- top.toppings[3] = Properties.Resources.CH;
- top.toppings[4] = Properties.Resources.GP;
- top.toppings[5] = Properties.Resources.O;
- top.toppings[6] = Properties.Resources.FM;
- top.toppings[7] = Properties.Resources.IS;
- top.toppings[8] = Properties.Resources.GB;
- top.toppings[9] = Properties.Resources.GO;
- top.toppings[10] = Properties.Resources.HP;
- top.toppings[11] = Properties.Resources.PI;
- top.toppings[12] = Properties.Resources.B;
- for (int i = 0; i < pizzaaa.Length; i++)
- {
- pizzaaa[i].pizzainit(12);
- pizzaaa[i].active[0] = true;
- for (int j = 0; j < 12; j++)
- {
- pizzaaa[i].active[j] = false;
- }
- }
- }
- void ConfirmClick(object sender, EventArgs e){
- confirm.Text = "clicked";
- pizzaaa[activeZa].final = a.Image;
- }
- private void a_Click(object sender, EventArgs e)
- {
- }
- private void button2_Click(object sender, EventArgs e)
- {
- ClearChk();
- }
- public void ClearChk()
- {
- foreach (CheckBox chk in groupBox1.Controls)
- {
- chk.Checked = false;
- }
- }
- public void MergeImages(PictureBox todraw, bool[] active)
- {
- var finalImage = new Bitmap(340, 340, PixelFormat.Format32bppArgb);
- var graphics = Graphics.FromImage(finalImage);
- graphics.CompositingMode = CompositingMode.SourceOver;
- graphics.DrawImage(top.toppings[0], 0, 0);
- pizzaaa[activeZa].price = 500;
- lblPrice.Text = "Price: $" + (pizzaaa[activeZa].price/100) + "." + (pizzaaa[activeZa].price % 100);
- for (int i = 1; i< top.toppings.Length; i++)
- {
- //Clear price when 0 toppings, when 0 toppings, clear added price
- if (active[i])
- {
- graphics.DrawImage(top.toppings[i], 0, 0);
- pizzaaa[activeZa].price += 150;
- lblPrice.Text = "Price: $" + (pizzaaa[activeZa].price/100) + "." + (pizzaaa[activeZa].price %100);
- }
- }
- todraw.Image = finalImage;
- }
- private void chkPep_CheckedChanged(object sender, EventArgs e)
- {
- pizzaaa[activeZa].active[1] = chkPep.Checked;
- MergeImages(a,pizzaaa[activeZa].active);
- }
- private void chkB_CheckedChanged(object sender, EventArgs e)
- {
- pizzaaa[activeZa].active[12] = chkB.Checked;
- MergeImages(a,pizzaaa[activeZa].active);
- }
- private void chkGP_CheckedChanged(object sender, EventArgs e)
- {
- pizzaaa[activeZa].active[4] = chkGP.Checked;
- MergeImages(a,pizzaaa[activeZa].active);
- }
- private void chkFM_CheckedChanged(object sender, EventArgs e)
- {
- pizzaaa[activeZa].active[6] = chkFM.Checked;
- MergeImages(a,pizzaaa[activeZa].active);
- }
- private void chkH_CheckedChanged(object sender, EventArgs e)
- {
- pizzaaa[activeZa].active[2] = chkH.Checked;
- MergeImages(a,pizzaaa[activeZa].active);
- }
- private void chkCH_CheckedChanged(object sender, EventArgs e)
- {
- pizzaaa[activeZa].active[3] = chkCH.Checked;
- MergeImages(a,pizzaaa[activeZa].active);
- }
- private void chkRO_CheckedChanged(object sender, EventArgs e)
- {
- pizzaaa[activeZa].active[5] = chkRO.Checked;
- MergeImages(a,pizzaaa[activeZa].active);
- }
- private void ckhIS_CheckedChanged(object sender, EventArgs e)
- {
- pizzaaa[activeZa].active[7] = chkIS.Checked;
- MergeImages(a,pizzaaa[activeZa].active);
- }
- private void chkGB_CheckedChanged(object sender, EventArgs e)
- {
- pizzaaa[activeZa].active[8] = chkGB.Checked;
- MergeImages(a,pizzaaa[activeZa].active);
- }
- private void chkHP_CheckedChanged(object sender, EventArgs e)
- {
- pizzaaa[activeZa].active[10] = chkHP.Checked;
- MergeImages(a,pizzaaa[activeZa].active);
- }
- private void chkPI_CheckedChanged(object sender, EventArgs e)
- {
- pizzaaa[activeZa].active[11] = chkPI.Checked;
- MergeImages(a,pizzaaa[activeZa].active);
- }
- private void chkGO_CheckedChanged(object sender, EventArgs e)
- {
- pizzaaa[activeZa].active[9] = chkGO.Checked;
- MergeImages(a,pizzaaa[activeZa].active);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement