/// <summary> /// Show label for every ingredient in pickedIngredients dictionary /// </summary> /// <summary> /// Remove label and ingredient from dictionary when user click on label with ingredient /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LblIngrClick(object sender, EventArgs e) { Label label = (sender as Label); Controls.Remove(label); labels.Remove(label); pickedIngridients.Remove(FindKey(pickedIngridients, label.Text)); DisplayElements.ChangeLocation(labels, 365, 560, 15, 0, 800, 20); }
/// <summary> /// Delete ingredient and label /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void LblIngrClick(object sender, EventArgs e) { Label label = (sender as Label); Controls.Remove(label); labels.Remove(label); DeleteIngredient(label.Text.ToString()); DisplayElements.ChangeLocation(labels, 12, 415, 15, 0, 475, 20); lblCaloriesValue.Text = Math.Round(CountCalories(), 0).ToString(); }
private void NumPortion_ValueChanged(object sender, EventArgs e) { if (firstLoad) { LoadIngredients(); DisplayElements.DisplayAll(labelsIngRec, panel1, 13, 35, 0, 25); DisplayElements.DisplayAll(labelsIngFrid, panel1, 175, 35, 0, 25); } firstLoad = true; }
private bool NoFood; //if there is no food in fridge to make meal it ll be true public Recipe(int idRecipe, double portion = 0) { this.portionDiet = portion; InitializeComponent(); LoadDBToTB(idRecipe); LoadRecipe(idRecipe); lblRecipe.MaximumSize = new Size(310, 0); LoadIngredients(); DisplayElements.DisplayAll(labelsIngRec, panel1, 13, 35, 0, 25); DisplayElements.DisplayAll(labelsIngFrid, panel1, 175, 35, 0, 25); this.panel1.Size = new System.Drawing.Size(226, (25 * labelsIngRec.Count + 40)); this.ClientSize = new System.Drawing.Size(566, Math.Max(lblRecipe.Bottom, panel1.Bottom) + 4); this.MaximumSize = new System.Drawing.Size(582, Math.Max(lblRecipe.Bottom, panel1.Bottom) + 43); if (portionDiet != 0) { numPortion.Value = (decimal)portionDiet; } }
private void Button2_Click(object sender, EventArgs e) { chLBDiet.SetItemChecked(0, false); txtCalMax.Text = ""; txtCalMin.Text = ""; txtSearch.Text = ""; txtTimeMax.Text = ""; txtTimeMin.Text = ""; UnChackList(chLBFoodType); UnChackList(chLBDiet); UnChackList(chLBStyle); foreach (Label label in labels) { Controls.Remove(label); } pickedIngridients.Clear(); labels.Clear(); DisplayElements.ChangeLocation(labels, 12, 560, 15, 0, 800, 20); }
private void ButAddIngr_Click(object sender, EventArgs e) { double quant; try { quant = double.Parse(txtQuantityIngr.Text.Replace('.', ',')); } catch (Exception) { lblQuntIngr.Visible = true; return; } ingredients.Add(new Ingredient(int.Parse(listVIngr.SelectedItems[0].SubItems[1].Text), listVIngr.SelectedItems[0].SubItems[0].Text, quant, int.Parse(listVIngr.SelectedItems[0].SubItems[2].Text))); Label label = new Label { Text = listVIngr.SelectedItems[0].SubItems[0].Text + " " + txtQuantityIngr.Text + " " + MeasureString(byte.Parse(listVIngr.SelectedItems[0].SubItems[4].Text), quant), AutoSize = true, Size = new Size(70, 20), TabIndex = 17, Visible = true, BackColor = Color.SandyBrown, Cursor = Cursors.No, Tag = "Ing", }; label.Click += new EventHandler(LblIngrClick); labels.Add(label); DisplayElements.ChangeLocation(labels, 12, 415, 15, 0, 475, 20); Controls.Add(label); lblQuntIngr.Visible = false; butAddIngr.Visible = false; txtQuantityIngr.Visible = false; lblIngrName.Visible = false; lblMeasure.Visible = false; txtQuantityIngr.Text = ""; lblCaloriesValue.Text = Math.Round(CountCalories(), 0).ToString(); }
/// <summary> /// Picking ingredients from listViewIngr /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ListVIngr_DoubleClick(object sender, EventArgs e) { if (!pickedIngridients.ContainsKey(int.Parse(listVIngr.SelectedItems[0].SubItems[1].Text))) { pickedIngridients.Add(int.Parse(listVIngr.SelectedItems[0].SubItems[1].Text), listVIngr.SelectedItems[0].SubItems[0].Text); Label label = new Label { Text = listVIngr.SelectedItems[0].SubItems[0].Text, AutoSize = true, Size = new Size(70, 20), TabIndex = 17, Visible = true, BackColor = Color.LemonChiffon, Cursor = Cursors.No, Tag = "Ing", }; label.Click += new EventHandler(this.LblIngrClick); labels.Add(label); DisplayElements.ChangeLocation(labels, 365, 560, 15, 0, 800, 20); Controls.Add(label); } }