private void buttonDecreaseInventory_Click(object sender, RoutedEventArgs e)
 {
     if (!IngredientSet.HasEntries(ActiveIngredient.Id))
     {
         AdjustInventory(Types.Strings.IngredientEditorDecreaseByAmount, -1);
     }
     else
     {
         AdjustInventoryByRecipe(Types.Strings.IngredientEditorDecreaseByRecipe, -1);
     }
 }
 private void buttonDecreaseBy_Click(object sender, RoutedEventArgs e)
 {
     if (!IngredientSet.HasEntries(ActiveIngredient.Id))
     {
         AdjustInventory(Strings.InventoryDecreaseByAmount, -1);
     }
     else
     {
         AdjustInventoryByRecipe(Strings.InventoryDecreaseByRecipe, -1);
     }
     UpdateListBoxItem();
 }
        private void comboBoxMeasuringUnits_SelectedIndexChanged(object sender, EventArgs e)
        {
            MeasurementUnit oldUnit = MeasurementUnit;
            string          text    = comboBoxMeasuringUnits.SelectedItem;

            if (text == null)
            {
                MeasurementUnit = MeasurementUnit.None;
            }
            else
            {
                switch (comboBoxMeasuringUnits.SelectedIndex)
                {
                case 0:
                    MeasurementUnit = MeasurementUnit.Unit;
                    break;

                case 1:
                    MeasurementUnit = MeasurementUnit.Pound;
                    break;

                case 2:
                    MeasurementUnit = MeasurementUnit.Ounce;
                    break;

                case 3:
                    MeasurementUnit = MeasurementUnit.Gram;
                    break;

                case 4:
                    MeasurementUnit = MeasurementUnit.Kilogram;
                    break;

                case 5:
                    MeasurementUnit = MeasurementUnit.Milligram;
                    break;

                case 6:
                    MeasurementUnit = MeasurementUnit.Gallon;
                    break;

                case 7:
                    MeasurementUnit = MeasurementUnit.Quart;
                    break;

                case 8:
                    MeasurementUnit = MeasurementUnit.Pint;
                    break;

                case 9:
                    MeasurementUnit = MeasurementUnit.Cup;
                    break;

                case 10:
                    MeasurementUnit = MeasurementUnit.Tablespoon;
                    break;

                case 11:
                    MeasurementUnit = MeasurementUnit.Teaspoon;
                    break;

                case 12:
                    MeasurementUnit = MeasurementUnit.Liter;
                    break;

                case 13:
                    MeasurementUnit = MeasurementUnit.FluidOunce;
                    break;

                case 14:
                    MeasurementUnit = MeasurementUnit.Milliliter;
                    break;

                case 15:
                    MeasurementUnit = MeasurementUnit.Kiloliter;
                    break;
                }
            }
            if ((oldUnit != MeasurementUnit) &&
                (MeasurementUnit != MeasurementUnit.Unit) && (MeasurementUnit != MeasurementUnit.None) &&
                ((oldUnit.IsVolume() && MeasurementUnit.IsVolume()) || (oldUnit.IsWeight() && MeasurementUnit.IsWeight())) &&
                PosDialogWindow.ShowDialog(
                    Types.Strings.IngredientEditorConvert1 +
                    (IngredientSet.HasEntries(ActiveIngredient.Id) ? Types.Strings.IngredientEditorConvert2 : "") +
                    Types.Strings.IngredientEditorConvert3,
                    Types.Strings.IngredientEditorUpdateInventory, DialogButtons.YesNo) == DialogButton.Yes)
            {
                InventoryAmount =
                    UnitConversion.Convert(InventoryAmount, oldUnit, MeasurementUnit);
                textBoxInventoryAmount.Text = FormatDoubleToString(InventoryAmount);
                if (UnitsChanged != null)
                {
                    UnitsChanged.Invoke(MeasurementUnit, new EventArgs());
                }
            }
            else
            {
                if (UnitsChanged != null)
                {
                    UnitsChanged.Invoke(MeasurementUnit, null);
                }
            }

            // Events
            DoValueChangedEvent();
        }