Ejemplo n.º 1
0
 public void DelFromTrash(Book toDel)
 {
     if (currUser != null)
     {
         currUser.sTrash.Delete(toDel);
     }
     else
     {
         publicTrash.Delete(toDel);
     }
 }
Ejemplo n.º 2
0
            bool TrashScreen(Trash trash)
            {
                Element[] trashToPrint = new Element[trash.Length * 3 + 2];
                Book      currBook;
                string    str;

                for (int i = 0; i < trash.Length; ++i)
                {
                    if (trash[i].stored is Book)
                    {
                        currBook                = trash[i].stored as Book;
                        str                     = Validator.ValidStr(currBook.shortTitle, 16) + " | ";
                        str                    += Validator.ValidStr(currBook.autherName, 16) + " | ";
                        str                    += Validator.ValidStr(currBook.price.ToString(), 7);
                        trashToPrint[i * 3]     = new ActiveStaticElement(str, new Coord(5, (short)(i + 5)));
                        trashToPrint[i * 3 + 1] = new ActiveCounter("-----", new Coord(53, (short)(i + 5)), new Coord(1, 0), ref trash[i].cnt, 1, 255, "   ");
                        trashToPrint[i * 3 + 2] = new ActiveStaticElement("X", new Coord(62, (short)(i + 5)));
                    }
                }
                str  = Validator.ValidStr("Title", 16) + " | ";
                str += Validator.ValidStr("Auther name", 16) + " | ";
                str += Validator.ValidStr("Price", 7) + " | ";
                str += Validator.ValidStr("Cnt", 5) + " | ";
                str += Validator.ValidStr("Del", 5);
                trashToPrint[trash.Length * 3] = new StaticElement(str, new Coord(5, 4));
                if (trash.Length != 0)
                {
                    string buyBtn = "_____\n|Buy|\n-----";
                    trashToPrint[trash.Length * 3 + 1] = new ActiveStaticElement(buyBtn, new Coord((short)(str.Length / 2 - buyBtn.Length / 2), (short)(trash.Length + 6)));
                }
                else
                {
                    trashToPrint[trash.Length * 3 + 1] = null;
                }
                byte choose;
                ActiveElementDraw trashWindow = new ActiveElementDraw(head, trashToPrint);
                NextWindow        nextWindow  = null;

                trashWindow.InitStatic();
                while (true)
                {
                    trashWindow.Print();
                    choose = trashWindow.Input(InbisibleInput());
                    if (choose == 255)
                    {
                        continue;
                    }

                    switch (choose)
                    {
                    //Main
                    case 0:
                        goto TRASH_SCREEN_RETURN;

                    //Find
                    case 1:
                        nextWindow = new NextWindow(BooksListByName);
                        goto TRASH_SCREEN_RETURN;

                    //Register/Login    Logout
                    case 2:
                        nextWindow = new NextWindow(ClickOnLoginBtn);
                        goto TRASH_SCREEN_RETURN;

                    default:

                        choose -= 13;
                        if (choose == trash.Length * 3 + 1)
                        {
                            TrashObj[] deliver = shop.Buy();
                            trashWindow.ClearScreen();
                            bool accept = AcceptBeforeDeliver(deliver);
                            trashWindow.InitStatic();
                            if (accept)
                            {
                                if (shop.IsLogOn())
                                {
                                    ;                            //Послать юзеру
                                }
                                else
                                {
                                    ;                            //Открить окно ввода адреса
                                }
                            }
                            else
                            {
                                foreach (var i in deliver)
                                {
                                    if (i.cnt != 0 && i.stored != null)
                                    {
                                        shop.GetClientTrash().Add(i);
                                        for (int j = 0; j < i.cnt; ++j)
                                        {
                                            shop.GetCargo().Add(i.stored);
                                        }
                                    }
                                }
                            }
                            goto TRASH_SCREEN_RETURN;
                        }
                        else if (choose % 3 == 0)
                        {
                            trashWindow.ClearScreen();
                            BookInfoScreen(((Book)trash[choose / 3].stored), false);
                            trashWindow.InitStatic();
                        }
                        else if (choose % 3 == 2)
                        {
                            trash.Delete(((Book)trash[choose / 3].stored));
                            trashWindow.ClearScreen();
                            TrashScreen(trash);
                            goto TRASH_SCREEN_RETURN;
                        }
                        break;
                    }
                }

TRASH_SCREEN_RETURN:
                trashWindow.ClearScreen();
                if (nextWindow != null)
                {
                    nextWindow.Invoke();
                }
                return(true);
            }