public void checkAndAddFoodIdToComboBox(int foodId)
        {
            foreach (ComboBoxItem comboData in ComboBoxSelectFood.ComboBoxData.Items)
            {
                if ((int)comboData.Tag == foodId)
                {
                    return;
                }
            }
            var    foodData = FoodManager.getInstance().FoodList[foodId];
            string txt      = foodData.FoodId + " - " + foodData.Name;
            var    imgSrc   = (ImageSource)Application.Current.FindResource("ImageDefaultFood");

            if (foodData.ImageId != null)
            {
                byte[] imgData = null;
                ImageManager.getInstance().loadImageFromLocal(foodData.ImageId ?? default(int), out imgData);
                if (imgData != null)
                {
                    var img = UtilFuction.ByteToImage(imgData);
                    imgSrc = UtilFuction.imageToBitmapSource(img);
                }
            }
            var item = ComboBoxSelectFood.addItem(txt, imgSrc);

            item.Tag = foodData.FoodId;
        }
Пример #2
0
        public void reloadAllUI()
        {
            reloadLVOrderWithFood();
            var order = OrderManager.getInstance().OrderList[OrderId];

            TextBlockHeader.Text = "Order " + OrderId;
            billMoney            = order.BillMoney;

            BtnAccept.Visibility = Visibility.Hidden;
            BtnCancel.Visibility = Visibility.Hidden;

            ComboBoxSelectFood.clear();

            foreach (KeyValuePair <int, Food> entry in FoodManager.getInstance().FoodList)
            {
                if (entry.Value != null)
                {
                    bool isContinue = false;
                    foreach (FoodWithOrder foodWithOrder in order.FoodWithOrders)
                    {
                        if (foodWithOrder.FoodId == entry.Value.FoodId)
                        {
                            isContinue = true;
                        }
                    }
                    if (isContinue)
                    {
                        continue;
                    }


                    string txt    = entry.Value.FoodId + " - " + entry.Value.Name;
                    var    imgSrc = (ImageSource)Application.Current.FindResource("ImageDefaultFood");
                    if (entry.Value.ImageId != null)
                    {
                        byte[] imgData = null;
                        ImageManager.getInstance().loadImageFromLocal(entry.Value.ImageId ?? default(int), out imgData);
                        if (imgData != null)
                        {
                            var img = UtilFuction.ByteToImage(imgData);
                            imgSrc = UtilFuction.imageToBitmapSource(img);
                        }
                    }
                    var item = ComboBoxSelectFood.addItem(txt, imgSrc);
                    item.Tag = entry.Value.FoodId;
                }
            }
            onChangeMoney();


            if (orderHistoryTab != null)
            {
                BtnAddFood.Visibility = Visibility.Hidden;
                TextBlockHeader.Text += ("  -  " + order.CreatedDate.ToShortDateString()) + "  -  " + UtilFuction.formatMoney(billMoney) + " VND";
            }
        }