コード例 #1
0
        private void PrintKitchenVersion(OrderDetails orderDetails)
        {
            ObservableCollection <Tuple <IItem, int> > concattedItems = orderDetails.ItemBasket.ConcatItems;

            try
            {
                TextComponent forKitchen = new TextBold(new TextCentreAlign(new TextBase("FOR KITCHEN")));
                PrintEnglish(forKitchen.GetDec());
                foreach (Tuple <IItem, int> item in concattedItems)
                {
                    string englishSizeModifier = "";
                    string chineseSizeModifier = "";
                    if (item.Item1.GetType() == typeof(SizeItem))
                    {
                        SizeItem si = (SizeItem)item.Item1;
                        englishSizeModifier = "(" + si.EnglishSizeString + ")";
                        chineseSizeModifier = "(" + si.ChineseSizeString + ")";
                    }

                    if (item.Item1.GetType() == typeof(PieItem))
                    {
                        PieItem p = (PieItem)item.Item1;
                        englishSizeModifier = "(" + p.EnglishSizeString + ")";
                        chineseSizeModifier = "(" + p.ChineseSizeString + ")";
                    }

                    TextComponent englishText  = new TextBase(EllipsisTruncate(item.Item1.EnglishName, 36));
                    TextComponent chineseText  = new TextBase(item.Item1.ChineseName);
                    TextComponent specialText  = new TextBold(new TextBase(item.Item1.ConcatProperties));
                    TextComponent quantityText = new TextDoubleWidthHeight(new TextBold(new TextBase(" X" + item.Item2.ToString())));

                    PrintEnglish(englishText.GetDec() + englishSizeModifier + quantityText.GetDec());
                    PrintChinese(item.Item1.ChineseName + chineseSizeModifier);
                    PrintEnglish(specialText.GetDec());

                    /*if (string.IsNullOrEmpty(specialText.GetDec()))
                     * {
                     *  PrintEnglish(" ");
                     * }*/
                    PrintEnglish(" ");
                }

                if (orderDetails.CurrentAddress != null)
                {
                    PrintEnglish("Deliver to: " + orderDetails.CurrentAddress.Concat);
                }
                else
                {
                    PrintEnglish("Pick Up Order");
                }

                PrintEnglish(" ");
                PrintEnglish(" ");
                PrintEnglish(" ");
                PrintEnglish(" ");
                PrintEnglish(" ");
            }
            catch (PosControlException)
            {
                Console.WriteLine("Cover open?");
            }
        }
コード例 #2
0
        private void PrintCustomerVersion(OrderDetails orderDetails)
        {
            ObservableCollection <Tuple <IItem, int> > concattedItems = orderDetails.ItemBasket.ConcatItems;

            try
            {
                TextComponent forCustomer = new TextBold(new TextCentreAlign(new TextBase("FOR RECORDS - " + DateTime.UtcNow.Date.ToString("dd/MM/yyyy"))));
                PrintEnglish(" ");
                PrintEnglish(forCustomer.GetDec());
                foreach (Tuple <IItem, int> item in concattedItems)
                {
                    string englishSizeModifier = "";
                    string chineseSizeModifier = "";
                    if (item.Item1.GetType() == typeof(SizeItem))
                    {
                        SizeItem si = (SizeItem)item.Item1;
                        englishSizeModifier = "(" + si.EnglishSizeString + ")";
                        chineseSizeModifier = "(" + si.ChineseSizeString + ")";
                    }

                    if (item.Item1.GetType() == typeof(PieItem))
                    {
                        PieItem p = (PieItem)item.Item1;
                        englishSizeModifier = "(" + p.EnglishSizeString + ")";
                        chineseSizeModifier = "(" + p.ChineseSizeString + ")";
                    }

                    TextComponent englishText  = new TextBase(item.Item1.EnglishName);
                    TextComponent priceText    = new TextRightAlign(new TextBase("£" + (item.Item1.Price * item.Item2).ToString("0.00")));
                    TextComponent quantityText = new TextRightAlign(new TextBase("X" + item.Item2.ToString() + "    "));
                    TextComponent chineseText  = new TextBase(item.Item1.ChineseName);

                    PrintEnglish(englishText.GetDec() + englishSizeModifier);
                    PrintChinese(item.Item1.ChineseName + chineseSizeModifier);
                    PrintEnglish(quantityText.GetDec() + priceText.GetDec());
                }

                TextComponent total = new TextRightAlign(new TextBold(new TextUnderline(new TextBase("  Total: " + orderDetails.PriceText))));
                PrintEnglish(total.GetDec());
                if (orderDetails.CurrentAddress != null)
                {
                    TextComponent phoneNumberText = new TextBold(new TextBase(orderDetails.CurrentAddress.PhoneNumber));
                    TextComponent roadText        = new TextRightAlign(new TextBold(new TextBase(orderDetails.CurrentAddress.Number + " " + orderDetails.CurrentAddress.Road)));
                    TextComponent townText        = new TextRightAlign(new TextBold(new TextBase(orderDetails.CurrentAddress.Town)));
                    TextComponent postCodeText    = new TextRightAlign(new TextBold(new TextBase(orderDetails.CurrentAddress.PostCode)));

                    PrintEnglish("Deliver to: " + roadText.GetDec());
                    PrintEnglish(townText.GetDec());
                    if (orderDetails.CurrentAddress.PhoneNumber != "")
                    {
                        PrintEnglish("Phone Number: " + phoneNumberText.GetDec() + postCodeText.GetDec());
                    }
                }
                else
                {
                    PrintEnglish("Pick Up Order");
                }
                PrintEnglish(" ");
                PrintEnglish(" ");
                PrintEnglish(" ");
                PrintEnglish(" ");
                PrintEnglish(" ");
                PrintEnglish(" ");
            }
            catch (PosControlException)
            {
                Console.WriteLine("Cover open?");
                //throw e;
            }
        }