Advertisement
Guest User

Untitled

a guest
Dec 3rd, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.91 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.Drawing.Drawing2D;
  11. using System.Drawing.Imaging;
  12.  
  13. namespace ZaDude
  14. {
  15.  
  16. public partial class Form1 : Form
  17. {
  18. public struct pizza
  19. {
  20. public void pizzainit(int items)
  21. {
  22. toppings = new Image[items];
  23. active = new bool[items];
  24. price = 0;
  25. final = null;
  26. }
  27.  
  28. public Image[] toppings;
  29. public bool[] active;
  30. public int price;
  31. public Image final;
  32. }
  33. public struct topping{
  34. public topping(int items){
  35. toppings = new Image[13];
  36.  
  37. }
  38.  
  39. public Image[] toppings;
  40. }
  41.  
  42. pizza[] pizzaaa = new pizza[10];
  43.  
  44. //pizza pizzaa = new pizza();
  45. topping top = new topping(13);
  46. public Form1()
  47. {
  48. InitializeComponent();
  49. }
  50. Button confirm = new Button();
  51. int activeZa = 0;
  52. private void Form1_Load(object sender, EventArgs e)
  53. {
  54.  
  55. confirm.Location = new Point(btnClr.Location.X + 100,btnClr.Location.Y);
  56. confirm.Text = "Confirm";
  57. this.Controls.Add (confirm);
  58.  
  59. top.toppings[0] = Properties.Resources._base;
  60. top.toppings[1] = Properties.Resources.PO;
  61. top.toppings[2] = Properties.Resources.H;
  62. top.toppings[3] = Properties.Resources.CH;
  63. top.toppings[4] = Properties.Resources.GP;
  64. top.toppings[5] = Properties.Resources.O;
  65. top.toppings[6] = Properties.Resources.FM;
  66. top.toppings[7] = Properties.Resources.IS;
  67. top.toppings[8] = Properties.Resources.GB;
  68. top.toppings[9] = Properties.Resources.GO;
  69. top.toppings[10] = Properties.Resources.HP;
  70. top.toppings[11] = Properties.Resources.PI;
  71. top.toppings[12] = Properties.Resources.B;
  72.  
  73. for (int i = 0; i < pizzaaa.Length; i++)
  74. {
  75. pizzaaa[i].pizzainit(12);
  76.  
  77. pizzaaa[i].active[0] = true;
  78.  
  79. for (int j = 0; j < 12; j++)
  80. {
  81. pizzaaa[i].active[j] = false;
  82. }
  83.  
  84. }
  85. }
  86. void ConfirmClick(object sender, EventArgs e){
  87. confirm.Text = "clicked";
  88. pizzaaa[activeZa].final = a.Image;
  89. }
  90.  
  91. private void a_Click(object sender, EventArgs e)
  92. {
  93.  
  94. }
  95.  
  96.  
  97. private void button2_Click(object sender, EventArgs e)
  98. {
  99. ClearChk();
  100. }
  101.  
  102. public void ClearChk()
  103. {
  104. foreach (CheckBox chk in groupBox1.Controls)
  105. {
  106. chk.Checked = false;
  107. }
  108. }
  109.  
  110. public void MergeImages(PictureBox todraw, bool[] active)
  111. {
  112.  
  113.  
  114. var finalImage = new Bitmap(340, 340, PixelFormat.Format32bppArgb);
  115. var graphics = Graphics.FromImage(finalImage);
  116. graphics.CompositingMode = CompositingMode.SourceOver;
  117. graphics.DrawImage(top.toppings[0], 0, 0);
  118. pizzaaa[activeZa].price = 500;
  119. lblPrice.Text = "Price: $" + (pizzaaa[activeZa].price/100) + "." + (pizzaaa[activeZa].price % 100);
  120. for (int i = 1; i< top.toppings.Length; i++)
  121. {
  122.  
  123. //Clear price when 0 toppings, when 0 toppings, clear added price
  124. if (active[i])
  125. {
  126. graphics.DrawImage(top.toppings[i], 0, 0);
  127. pizzaaa[activeZa].price += 150;
  128.  
  129. lblPrice.Text = "Price: $" + (pizzaaa[activeZa].price/100) + "." + (pizzaaa[activeZa].price %100);
  130. }
  131.  
  132. }
  133.  
  134. todraw.Image = finalImage;
  135. }
  136.  
  137. private void chkPep_CheckedChanged(object sender, EventArgs e)
  138. {
  139. pizzaaa[activeZa].active[1] = chkPep.Checked;
  140. MergeImages(a,pizzaaa[activeZa].active);
  141. }
  142.  
  143. private void chkB_CheckedChanged(object sender, EventArgs e)
  144. {
  145. pizzaaa[activeZa].active[12] = chkB.Checked;
  146. MergeImages(a,pizzaaa[activeZa].active);
  147. }
  148.  
  149.  
  150. private void chkGP_CheckedChanged(object sender, EventArgs e)
  151. {
  152. pizzaaa[activeZa].active[4] = chkGP.Checked;
  153. MergeImages(a,pizzaaa[activeZa].active);
  154. }
  155. private void chkFM_CheckedChanged(object sender, EventArgs e)
  156. {
  157. pizzaaa[activeZa].active[6] = chkFM.Checked;
  158. MergeImages(a,pizzaaa[activeZa].active);
  159. }
  160.  
  161.  
  162. private void chkH_CheckedChanged(object sender, EventArgs e)
  163. {
  164. pizzaaa[activeZa].active[2] = chkH.Checked;
  165. MergeImages(a,pizzaaa[activeZa].active);
  166. }
  167. private void chkCH_CheckedChanged(object sender, EventArgs e)
  168. {
  169. pizzaaa[activeZa].active[3] = chkCH.Checked;
  170. MergeImages(a,pizzaaa[activeZa].active);
  171. }
  172.  
  173. private void chkRO_CheckedChanged(object sender, EventArgs e)
  174. {
  175. pizzaaa[activeZa].active[5] = chkRO.Checked;
  176. MergeImages(a,pizzaaa[activeZa].active);
  177. }
  178.  
  179. private void ckhIS_CheckedChanged(object sender, EventArgs e)
  180. {
  181. pizzaaa[activeZa].active[7] = chkIS.Checked;
  182. MergeImages(a,pizzaaa[activeZa].active);
  183. }
  184.  
  185. private void chkGB_CheckedChanged(object sender, EventArgs e)
  186. {
  187. pizzaaa[activeZa].active[8] = chkGB.Checked;
  188. MergeImages(a,pizzaaa[activeZa].active);
  189. }
  190.  
  191. private void chkHP_CheckedChanged(object sender, EventArgs e)
  192. {
  193. pizzaaa[activeZa].active[10] = chkHP.Checked;
  194. MergeImages(a,pizzaaa[activeZa].active);
  195. }
  196.  
  197. private void chkPI_CheckedChanged(object sender, EventArgs e)
  198. {
  199. pizzaaa[activeZa].active[11] = chkPI.Checked;
  200. MergeImages(a,pizzaaa[activeZa].active);
  201. }
  202.  
  203. private void chkGO_CheckedChanged(object sender, EventArgs e)
  204. {
  205. pizzaaa[activeZa].active[9] = chkGO.Checked;
  206. MergeImages(a,pizzaaa[activeZa].active);
  207. }
  208.  
  209.  
  210. }
  211. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement