Esempio n. 1
0
        private async static Task LoadMenu(UpdateProgress progress)
        {
            var input = await xmlFile.OpenReadAsync();

            XmlTextReader xmlTextReader = new XmlTextReader(input.AsStreamForRead());
            XmlDocument   xmlDocument   = new XmlDocument();

            xmlDocument.Load(xmlTextReader);
            XmlNode menuNode  = xmlDocument.SelectSingleNode("Menu");
            int     foodMax   = GetAllFoodsCount(menuNode);
            int     foodCount = 0;

            for (int indexCate = 0; indexCate < menuNode.SelectNodes("Cate").Count; indexCate++)
            {
                XmlNode       cateNode = menuNode.SelectNodes("Cate")[indexCate];
                FoodData.Type type     = FoodData.ParseType(cateNode.Attributes["id"].Value);
                for (int indexFood = 0; indexFood < cateNode.SelectNodes("Food").Count; indexFood++)
                {
                    XmlNode foodNode = cateNode.SelectNodes("Food")[indexFood];
                    if (foodNode.SelectSingleNode("EAN") == null)
                    {
                        FoodDatas.Add(await new FoodData(type, foodNode.Attributes["name"].Value, int.Parse(foodNode.SelectSingleNode("Price").InnerText), 0, new Uri(foodNode.SelectSingleNode("Url").InnerText)).PreloadImage(indexCate, foodCount, menuNode.ChildNodes.Count, foodMax, progress));
                    }
                    else
                    {
                        FoodDatas.Add(await new FoodData(type, foodNode.Attributes["name"].Value, foodNode.SelectSingleNode("EAN").InnerText, int.Parse(foodNode.SelectSingleNode("Price").InnerText), 0, new Uri(foodNode.SelectSingleNode("Url").InnerText)).PreloadImage(indexCate, foodCount, menuNode.ChildNodes.Count, foodMax, progress));
                    }

                    foodCount++;
                }
            }

            InitLists();
        }
Esempio n. 2
0
        private void FoodGridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            FoodData foodData = (FoodData)e.ClickedItem;
            FoodData listData;

            if (!Utils.ContainsFoodDataByName(FoodList.Items, foodData.Name))
            {
                listData = (FoodData)foodData.Clone();

                FoodList.Items.Add(listData);
                OrderButton.IsEnabled = true;
            }
            else
            {
                listData = Utils.FindFoodDataByName(FoodList.Items, foodData.Name);
            }
            listData.Count++;
            listData.Price       += listData.DefaultPrice;
            TotalPrice           += listData.DefaultPrice;
            FoodList.SelectedItem = listData;


            SelectedFoodData = (FoodData)FoodList.SelectedItem;
            SetFoodImage(foodData.Image);
        }
Esempio n. 3
0
        private void FoodList_ItemClick(object sender, ItemClickEventArgs e)
        {
            FoodData foodData = (FoodData)e.ClickedItem;

            SelectedFoodData = foodData;
            SetFoodImage(foodData.Image);
        }
Esempio n. 4
0
 private void Clear()
 {
     FoodList.Items.Clear();
     TotalPrice                = 0;
     SelectedFoodData          = null;
     FoodGridView.SelectedItem = null;
     FoodImage.Source          = null;
     OrderButton.IsEnabled     = false;
     PayButton.IsEnabled       = false;
 }
Esempio n. 5
0
 private static void AddIfEmpty(List <FoodData> target, FoodData data)
 {
     if (Utils.ContainsFoodDataByName(target, data.Name))
     {
         FoodData foodinlist = Utils.FindFoodDataByName(target, data.Name);
         foodinlist.Count += data.Count;
         foodinlist.Price += data.Price;
     }
     else
     {
         target.Add(data);
     }
 }
Esempio n. 6
0
 private void RemoveButton_Click(object sender, RoutedEventArgs e)
 {
     if (SelectedFoodData != null)
     {
         FoodList.Items.Remove(SelectedFoodData);
         TotalPrice      -= SelectedFoodData.Price;
         SelectedFoodData = null;
         if (!FoodList.Items.Any())
         {
             FoodImage.Source      = null;
             OrderButton.IsEnabled = false;
             PayButton.IsEnabled   = false;
         }
     }
 }
Esempio n. 7
0
        public void Update()
        {
            cateDatas.Clear();
            foreach (FoodData.Type type in Utils.FoodTypes)
            {
                cateDatas.Add(new CateData(FoodData.ToStringTypeKR(type), StateManager.GetCateCount(type), StateManager.GetCateTotalPrice(type)));
            }

            foodDatas.Clear();
            foreach (FoodData food in StateManager.GetAllFoodDatas())
            {
                foodDatas.Add(food);
            }

            AllTotal.Text     = StateManager.GetAllTotalPrice().ToString();
            CurrentTotal.Text = StateManager.GetCurrentTotalPrice().ToString();
            CardPayCount.Text = StateManager.GetPayTypeCount(StateManager.PayType.Card).ToString();
            CashPayCount.Text = StateManager.GetPayTypeCount(StateManager.PayType.Cash).ToString();
        }
Esempio n. 8
0
        //바코드기 입력 후 끝에 Enter 키 입력 발생 ("\r\n")
        private void CoreWindow_CharacterReceived(CoreWindow sender, CharacterReceivedEventArgs args)
        {
            if (Visibility == Visibility.Collapsed)
            {
                return;
            }
            char inputChar = (char)args.KeyCode;

            if (inputChar == '\r')
            {
                if (IsValidGtin(receivedBarcodeChars))
                {
                    Debug.WriteLine("OK: " + receivedBarcodeChars);
                    FoodData foodData = Utils.FindFoodDataByEANCode(receivedBarcodeChars);
                    FoodData listedFood;
                    if ((listedFood = Utils.FindFoodDataByName(FoodList.Items, foodData.Name)) == null)
                    {
                        FoodData cloneData = (FoodData)foodData.Clone();
                        cloneData.Count = 1;

                        FoodList.Items.Add(cloneData);
                        FoodList.SelectedItem = cloneData;
                        TotalPrice           += cloneData.DefaultPrice;
                        OrderButton.IsEnabled = true;
                    }
                    else
                    {
                        listedFood.Count++;
                        listedFood.Price += listedFood.DefaultPrice;
                        TotalPrice       += listedFood.DefaultPrice;
                    }
                    SelectedFoodData = (FoodData)FoodList.SelectedItem;
                    SetFoodImage(foodData.Image);
                }

                receivedBarcodeChars = string.Empty;
            }

            if (char.IsDigit(inputChar))
            {
                receivedBarcodeChars += inputChar;
            }
        }