コード例 #1
0
        private void dishDel()
        {
            DishItem dishItem = (DishItem)lstDishes.SelectedItem;

            if (dishItem == null)
            {
                return;
            }
            OrderItem order = AppLib.GetCurrentOrder();

            AppLib.WriteAppAction($"CartWin|Удаление блюда '{dishItem.langNames["ru"]}'...");

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

            AppLib.WriteAppAction($"CartWin|Удаление блюда '{dishItem.langNames["ru"]}': {result.ToString()}");

            if (result == MessageBoxResult.Yes)
            {
                order.Dishes.Remove(dishItem);
                lstDishes.Items.Refresh();
                scrollDishes.ScrollToTop();

                updatePriceOrder();
            }
        }
コード例 #2
0
        }  // method

        #region добавить блюдо к заказу

        private void BtnAddDish_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            if (AppLib.IsDrag)
            {
                return;
            }
            if (AppLib.IsEventsEnable == false)
            {
                AppLib.IsEventsEnable = true; return;
            }

            Border brdAddButton = (Border)sender;

            if (brdAddButton.Opacity == 0)
            {
                return;
            }

            OrderItem _currentOrder = AppLib.GetCurrentOrder();

            // изображение взять из элемента
            ImageBrush  imgBrush = (ImageBrush)_pathImage.Fill;
            BitmapImage bmpImage = (imgBrush.ImageSource as BitmapImage);

            // если нет ИНГРЕДИЕНТОВ, то сразу в корзину
            // т.к. блюда без гарниров тоже могут быть с ингредиентами (и рекомендациями)
            if ((_dishItem.Ingredients == null) || (_dishItem.Ingredients.Count == 0))
            {
                AppLib.WriteAppAction($"MainWin|Нажата кнопка выбора блюда '{_dishItem.langNames["ru"]}' (price {_dishItem.GetPrice().ToStringMoneyFormat()}) БЕЗ гарнира");

                DishItem orderDish = _dishItem.GetCopyForOrder();
                orderDish.Image = bmpImage;

                _currentOrder.Dishes.Add(orderDish);
                // анимировать перемещение блюда в корзину
                animateDishToCart();
            }

            // иначе через "всплывашку"
            else
            {
                AppLib.WriteAppAction($"MainWin|Нажата кнопка выбора блюда '{_dishItem.langNames["ru"]}' (price {_dishItem.GetPrice().ToStringMoneyFormat()}) С гарниром '{_dishItem.Ingredients[0].langNames["ru"]}' (price {_dishItem.Ingredients[0].Price.ToStringMoneyFormat()})");

                // текущее блюдо и его изображение передать в конструкторе
                DishPopup popupWin = new DishPopup(_dishItem, bmpImage);
                popupWin.ShowDialog();

                // очистить выбранный гарнир
                ClearSelectedGarnish();
            } // if else
        }
コード例 #3
0
        public Cart()
        {
            InitializeComponent();

            this.Loaded += Cart_Loaded;

            _currentOrder = AppLib.GetCurrentOrder();
            this.lstDishes.ItemsSource = _currentOrder.Dishes;

            initUI();

            //if (AppLib.GetAppSetting("IsWriteWindowEvents").ToBool())
            //{
            //    _eventsLog = new UserActionsLog(this, EventsMouseEnum.Bubble, EventsKeyboardEnum.None, EventsTouchEnum.Bubble, UserActionLog.LogFilesPathLocationEnum.App_Logs, true, false);
            //}

            updatePriceOrder();
        }
コード例 #4
0
        // выбор блюда
        // ****** ??? процедура вызывается 2 раза!!!
        // если это MouseUp, если PreviewMouseUp - то один раз!!
        private void btnAddDish_MouseUp(object sender, MouseButtonEventArgs e)
        {
            _closeCause = "ButtonAddDish";
            AppLib.WriteAppAction("DishPopup|Нажата кнопка AddDish");
            e.Handled = true;

            // добавить блюдо в заказ
            OrderItem curOrder  = AppLib.GetCurrentOrder();
            DishItem  orderDish = _currentDish.GetCopyForOrder();  // сделать копию блюда со всеми добавками

            // изображение взять из элемента
            ImageBrush  imgBrush = (ImageBrush)dishImage.Fill;
            BitmapImage bmpImage = (imgBrush.ImageSource as BitmapImage);

            orderDish.Image = bmpImage;

            curOrder.Dishes.Add(orderDish);

            //Debug.Print("order.Dishes.Count = " + curOrder.Dishes.Count.ToString());

            // добавить в заказ рекомендации
            if ((_currentDish.SelectedRecommends != null) && (_currentDish.SelectedRecommends.Count > 0))
            {
                foreach (DishItem item in _currentDish.SelectedRecommends)
                {
                    curOrder.Dishes.Add(item);
                }
            }

            if ((bool)AppLib.GetAppGlobalValue("isAnimatedSelectVoki"))
            {
                // закрыть окно после завершения анимации
                animateDishSelection();
            }
            else
            {
                updatePriceAndClose(false);
            }
        }