Exemplo n.º 1
0
 private void Republish(Mobile contributor, PublishedBook book)
 {
     if (!book.IsPublishable())
     {
         this.SayTo(contributor, "You might want to try writing something of interest first.");
     }
     else if (book.IsModified())
     {
         book.AddContributor(contributor.Name);
         if (XmlBook.Save(book))
         {
             book.RePublish();
             //contributor.AddToBackpack(new Gold (100));
             this.SayTo(contributor, "Your book appears to have changed. Let me publish that for you!");
             //contributor.SendMessage("You receive some gold.");
             //if (m_Sound)
             //    Effects.PlaySound(contributor.Location, contributor.Map, 0x2E5);
         }
         else
         {
             this.SayTo(contributor, "Our machines are not working right. Check back later.");
         }
     }
     else
     {
         this.SayTo(contributor, "It looks the same as the last story we printed.");
     }
 }
Exemplo n.º 2
0
        public PublishedBook(string id, int pageCount) : base(0x0000, "", "", pageCount, false)
        {
            XmlBook book = XmlBook.Load(id);

            this.ItemID           = book.ItemID;
            this.Title            = book.Title;
            this.Author           = book.Author;
            this.Hue              = book.Hue;
            this.PublishID        = book.ID.ToString();
            this.m_FirstPublished = DateTime.Parse(book.FirstPublished);
            this.m_LastPublished  = DateTime.Parse(book.LastPublished);
            for (int i = 0; i < book.Contributors.Length; i++)
            {
                AddContributor(book.Contributors[i].Name);
            }
            for (int i = 0; i < book.Contents.Length; i++)
            {
                if (this.Pages[book.Contents[i].Page - 1].Lines.Length == 0)
                {
                    this.Pages[book.Contents[i].Page - 1].Lines = new string[8];
                    for (int j = 0; j < this.Pages[book.Contents[i].Page - 1].Lines.Length; j++)
                    {
                        this.Pages[book.Contents[i].Page - 1].Lines[j] = string.Empty;
                    }
                }
                this.Pages[book.Contents[i].Page - 1].Lines[book.Contents[i].Line - 1] = book.Contents[i].Text;
            }
        }
Exemplo n.º 3
0
 public InternalBuyInfo()
 {
     //Add(new GenericBuyInfo(typeof(BlueBook), 10, 20, 0xFF2, 0x00));
     //Add(new GenericBuyInfo(typeof(TanBook), 10, 20, 0xFF0, 0x00));
     //Add(new GenericBuyInfo(typeof(RedBook), 10, 20, 0xFF1, 0x00));
     //Add(new GenericBuyInfo(typeof(BrownBook), 10, 20, 0xFEF, 0x00));
     string[] books = XmlBook.RandomBookIds(10);
     for (int i = 0; i < books.Length; i++)
     {
         Add(new BookBuyInfo(books[i]));
     }
 }
Exemplo n.º 4
0
        public BookBuyInfo(string id) : base(typeof(PublishedBook), 30, 10, 0x0000, 0x000)
        {
            XmlBook book = XmlBook.Load(id);

            m_ID        = id;
            m_PageCount = 1;
            for (int i = 0; i < book.Contents.Length; i++)
            {
                if (m_PageCount < book.Contents[i].Page)
                {
                    m_PageCount = book.Contents[i].Page;
                }
            }
            this.Name   = book.Title;
            this.ItemID = book.ItemID;
            this.Hue    = book.Hue;
            // base the price upon the number of lines written
            this.Price = book.Contents.Length;
            // stock between 5 and 20 items
            this.Amount    = 5;
            this.MaxAmount = 20;
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            try
            {
                Book book = new XmlBook();

                Font boldFont = book.addFont();
                boldFont.bold = true;

                Font titleFont = book.addFont();
                titleFont.name = "Arial Black";
                titleFont.size = 16;

                Format titleFormat = book.addFormat();
                titleFormat.font = titleFont;

                Format headerFormat = book.addFormat();
                headerFormat.alignH = AlignH.ALIGNH_CENTER;
                headerFormat.setBorder(BorderStyle.BORDERSTYLE_THIN);
                headerFormat.font                   = boldFont;
                headerFormat.fillPattern            = FillPattern.FILLPATTERN_SOLID;
                headerFormat.patternForegroundColor = Color.COLOR_TAN;

                Format descriptionFormat = book.addFormat();
                descriptionFormat.borderLeft = BorderStyle.BORDERSTYLE_THIN;

                Format amountFormat = book.addFormat();
                amountFormat.setNumFormat(NumFormat.NUMFORMAT_CURRENCY_NEGBRA);
                amountFormat.borderLeft  = BorderStyle.BORDERSTYLE_THIN;
                amountFormat.borderRight = BorderStyle.BORDERSTYLE_THIN;

                Format totalLabelFormat = book.addFormat();
                totalLabelFormat.borderTop = BorderStyle.BORDERSTYLE_THIN;
                totalLabelFormat.alignH    = AlignH.ALIGNH_RIGHT;
                totalLabelFormat.font      = boldFont;

                Format totalFormat = book.addFormat();
                totalFormat.setNumFormat(NumFormat.NUMFORMAT_CURRENCY_NEGBRA);
                totalFormat.setBorder(BorderStyle.BORDERSTYLE_THIN);
                totalFormat.font                   = boldFont;
                totalFormat.fillPattern            = FillPattern.FILLPATTERN_SOLID;
                totalFormat.patternForegroundColor = Color.COLOR_YELLOW;

                Format signatureFormat = book.addFormat();
                signatureFormat.alignH    = AlignH.ALIGNH_CENTER;
                signatureFormat.borderTop = BorderStyle.BORDERSTYLE_THIN;

                Sheet sheet = book.addSheet("Invoice");

                sheet.writeStr(2, 1, "Invoice No. 3568", titleFormat);

                sheet.writeStr(4, 1, "Name: John Smith");
                sheet.writeStr(5, 1, "Address: San Ramon, CA 94583 USA");

                sheet.writeStr(7, 1, "Description", headerFormat);
                sheet.writeStr(7, 2, "Amount", headerFormat);

                sheet.writeStr(8, 1, "Ball-Point Pens", descriptionFormat);
                sheet.writeNum(8, 2, 85, amountFormat);
                sheet.writeStr(9, 1, "T-Shirts", descriptionFormat);
                sheet.writeNum(9, 2, 150, amountFormat);
                sheet.writeStr(10, 1, "Tea cups", descriptionFormat);
                sheet.writeNum(10, 2, 45, amountFormat);

                sheet.writeStr(11, 1, "Total:", totalLabelFormat);
                sheet.writeFormula(11, 2, "=SUM(C9:C11)", totalFormat);

                sheet.writeStr(14, 2, "Signature", signatureFormat);

                sheet.setCol(1, 1, 40);
                sheet.setCol(2, 2, 15);

                book.save("invoice.xlsx");

                System.Diagnostics.Process.Start("invoice.xlsx");
            }
            catch (System.Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemplo n.º 6
0
        private void Publish(Mobile contributor, BaseBook book)
        {
            PublishedBook publishedBook = book as PublishedBook;

            if (publishedBook != null)
            {
                publishedBook.AddContributor(contributor.Name);
                Republish(contributor, publishedBook);
                return;
            }

            // change into published book
            publishedBook = new PublishedBook(book);
            publishedBook.AddContributor(contributor.Name);
            if (!publishedBook.IsPublishable())
            {
                publishedBook.Delete();
                this.SayTo(contributor, "You might want to try writing something of interest first.");
            }
            else if (XmlBook.Save(publishedBook))
            {
                switch (Utility.Random(3))
                {
                case 0:
                {
                    contributor.AddToBackpack(new Gold(1500, 3000));
                    this.SayTo(contributor, "This seems to be a excellent material. Let me see... hm... here - your royalty. You should see the story soon. I am sure it will sell well.");
                    contributor.SendMessage("You receive a good amount of gold.");
                    if (m_Sound)
                    {
                        Effects.PlaySound(contributor.Location, contributor.Map, 0x2E5);
                    }
                    contributor.AddToBackpack(publishedBook);
                    book.Delete();
                    break;
                }

                case 1:
                {
                    contributor.AddToBackpack(new Gold(1000, 1250));
                    this.SayTo(contributor, "This seems to be decent material. Let me see... hm... here - your royalty. You should see the story soon. I hope it will sell well.");
                    contributor.SendMessage("You receive a decent amount of gold.");
                    if (m_Sound)
                    {
                        Effects.PlaySound(contributor.Location, contributor.Map, 0x2E5);
                    }
                    contributor.AddToBackpack(publishedBook);
                    book.Delete();
                    break;
                }

                case 2:
                {
                    contributor.AddToBackpack(new Gold(100, 500));
                    this.SayTo(contributor, "I don't know if this is good enough to be sold, but let me see... hm... here - I can't give you more for this. I am not sure it will sell at all.");
                    contributor.SendMessage("You receive some gold.");
                    if (m_Sound)
                    {
                        Effects.PlaySound(contributor.Location, contributor.Map, 0x2E5);
                    }
                    contributor.AddToBackpack(publishedBook);
                    book.Delete();
                    break;
                }
                }
            }
            else
            {
                publishedBook.Delete();
                this.SayTo(contributor, "Our machines are not working right. Check back later.");
            }
        }