Exemple #1
0
        // удаление ингредиента
        private void ingrDel(object sender, Point point)
        {
            // получить контролы из нажатого элемента
            //    listbox ингредиентов
            ListBoxItem lbiIngr = (ListBoxItem)AppLib.FindVisualParentByType((FrameworkElement)sender, typeof(ListBoxItem));
            ListBox     lbIngr  = (ListBox)AppLib.FindVisualParentByType((FrameworkElement)lbiIngr, typeof(ListBox));
            DishAdding  tmpIngr = (DishAdding)lbIngr.ItemContainerGenerator.ItemFromContainer(lbiIngr);

            int iCnt = lbIngr.ItemContainerGenerator.IndexFromContainer(lbiIngr);

            if (lbIngr.SelectedIndex != iCnt)
            {
                lbIngr.SelectedIndex = iCnt;
            }

            //    listbox блюд
            AppLib.SelectListBoxItemByHisInnerControl((FrameworkElement)lbIngr, lstDishes); // делаем это принудетельно

            DishItem   dishItem = (DishItem)lstDishes.SelectedItem;
            DishAdding ingrItem = (DishAdding)lbIngr.SelectedItem;

            AppLib.WriteAppAction($"CartWin|Нажата кнопка удаления ингредиента '{ingrItem.langNames["ru"]}' для блюда '{dishItem.langNames["ru"]}'");

            string           title  = AppLib.GetLangTextFromAppProp("cartDelIngrTitle");
            string           msg    = string.Format("{0} \"{1}\" ?", AppLib.GetLangTextFromAppProp("cartDelIngrQuestion"), AppLib.GetLangText(ingrItem.langNames));
            MessageBoxResult result = AppLib.ShowChoiceBox(title, msg);

            AppLib.WriteAppAction($"CartWin|Удаление ингредиента {ingrItem.langNames["ru"]}: {result.ToString()}");
            if (result == MessageBoxResult.Yes)
            {
                dishItem.SelectedIngredients.Remove(ingrItem);
                lbIngr.Items.Refresh();

                updatePriceControls();
            }
            this.Activate();
        }