Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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();
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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();
        }
Ejemplo n.º 5
0
 /// <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);
     }
 }