示例#1
0
        private void listBox1_DrawItem(object sender, DrawItemEventArgs e)
        {
            if ((e.State & DrawItemState.Selected) != 0)
            {
                e.Graphics.FillRectangle(SMGraphics.GetBrush(Color.LightBlue), e.Bounds);
            }
            else
            {
                e.Graphics.FillRectangle(SMGraphics.GetBrush(listBox1.BackColor), e.Bounds);
            }

            MNBookHeader bh = GetBookAtIndex(e.Index);

            if (bh == null)
            {
                return;
            }

            Rectangle r = new Rectangle(e.Bounds.Left + 4, e.Bounds.Top + 4, e.Bounds.Height - 8, e.Bounds.Height - 8);

            e.Graphics.FillRectangle(SMGraphics.GetBrush(bh.BookColor), r);
            e.Graphics.DrawRectangle(Pens.Black, r);

            r = new Rectangle(e.Bounds.Left + e.Bounds.Height + 16, e.Bounds.Top, e.Bounds.Width - e.Bounds.Height - 16, e.Bounds.Height);
            e.Graphics.DrawString(bh.BookTitle, SMGraphics.GetFontVariation(MNFontName.LucidaSans, 12f),
                                  SMGraphics.GetBrush(listBox1.ForeColor), r, SMGraphics.StrFormatLeftCenter);
        }
示例#2
0
        private void buttonPlay_Click(object sender, EventArgs e)
        {
            if (listBox1.SelectedIndex >= 0)
            {
                MNBookHeader bh = (MNBookHeader)(listBox1.Items[listBox1.SelectedIndex]);
                if (bh != null)
                {
                    CurrentBook           = bh;
                    pageView1.CurrentBook = bh;
                    pageView1.SetDocument(bh.LoadFull());

                    MNNotificationCenter.BroadcastMessage(this, "StartDocumentReview", pageView1.CurrentDocument, bh.FilePath);
                    // this is default loading of language file
                    if (bh.Languages != null && bh.Languages.Count > 0)
                    {
                        MNLocalisation file = new MNLocalisation();
                        file.Load(bh.Languages[0].FilePath, true);
                        pageView1.CurrentDocument.CurrentLanguage = file;
                    }
                    // this is presenting book to the user
                    SetShowPanel("book");
                    pageView1.Start();
                }
            }
        }
示例#3
0
 public void showSelectLanguageDialog(MNBookHeader book)
 {
     if (book != null && book.Languages != null && book.Languages.Count > 0)
     {
         CurrentBook = book;
         SetShowPanel("lang");
         panelSelectLanguage.SetBook(Library.FindBook(book.BookTitle));
         panelSelectLanguage.ParentFrame = this;
     }
 }
示例#4
0
        private void listBox1_MeasureItem(object sender, MeasureItemEventArgs e)
        {
            MNBookHeader bh = GetBookAtIndex(e.Index);

            if (bh == null)
            {
                return;
            }

            e.ItemHeight = 32;
        }
示例#5
0
        public void GetCurrentBookDatabase(string directory)
        {
            if (directory != null)
            {
                LastDirectory = directory;
            }

            List <string> bookFileNames = new List <string>();
            List <string> langFileNames = new List <string>();

            foreach (string s in Directory.EnumerateFiles(LastDirectory))
            {
                if (s.EndsWith(".smb"))
                {
                    bookFileNames.Add(s);
                }
                else if (s.EndsWith(".sme"))
                {
                    langFileNames.Add(s);
                }
            }

            Books.Clear();
            foreach (string file in bookFileNames)
            {
                if (!File.Exists(file.Replace(".smb", ".smd")))
                {
                    continue;
                }
                if (!File.Exists(file.Replace(".smb", ".sme")))
                {
                    continue;
                }
                MNBookHeader bh = new MNBookHeader();
                if (bh.LoadHeader(file))
                {
                    InsertOrderedBook(Books, bh);
                }
            }

            foreach (string file in langFileNames)
            {
                MNBookLanguage bl = new MNBookLanguage();
                PreviewLanguage(bl, file);
                MNBookHeader bh = GetBookByCode(bl.BookCode);
                if (bh != null)
                {
                    bh.Languages.Add(bl);
                }
            }
        }
示例#6
0
        public void InsertOrderedBook(List <MNBookHeader> bookList, MNBookHeader bh)
        {
            bool added = false;

            for (int i = 0; i < bookList.Count; i++)
            {
                if (bookList[i].BookPriority > bh.BookPriority)
                {
                    bookList.Insert(i, bh);
                    added = true;
                    break;
                }
            }

            if (!added)
            {
                bookList.Add(bh);
            }
        }
示例#7
0
        public void dialogDidSelectLanguage(RemoteFileRef book, RemoteFileRef lang)
        {
            if (book == null)
            {
                SetShowPanel("book");
                return;
            }

            MNBookHeader bh = Library.FindBookHeader(book.Text);

            if (bh != null && lang != null)
            {
                if (lang.Local)
                {
                    if (lang.Text.Equals("Default"))
                    {
                        pageView1.CurrentDocument.CurrentLanguage = null;
                        pageView1.ReloadPage(false);
                    }
                    else
                    {
                        MNLocalisation file = new MNLocalisation();
                        file.Load(Library.GetLocalFile(lang.FileName), true);
                        pageView1.CurrentDocument.CurrentLanguage = file;
                        pageView1.ReloadPage(false);
                    }
                    SetShowPanel("book");
                }
                else
                {
                    p_fileDown = lang.FileName;
                    panelDownload.FilesToDownload.Clear();
                    panelDownload.FilesToDownload.Add(lang.FileName);
                    panelDownload.Start(Library);
                    SetShowPanel("downloader");
                }
            }
            else
            {
                SetShowPanel("book");
            }
        }
示例#8
0
 public static void ProcessFileComplete(string cmdFile)
 {
     OutputDir = Path.GetDirectoryName(cmdFile);
     ProcessFile(cmdFile);
     if (Book != null)
     {
         string fn = Path.Combine(OutputDir, Book.BookCode + ".smb");
         if (File.Exists(fn))
         {
             File.Delete(fn);
         }
         using (Stream s = File.Create(fn))
         {
             using (BinaryWriter bw = new BinaryWriter(s))
             {
                 RSFileWriter fw = new RSFileWriter(bw);
                 Book.Save(fw);
             }
         }
     }
     if (Data != null)
     {
         string fn = Path.Combine(OutputDir, Book.BookCode + ".smd");
         if (File.Exists(fn))
         {
             File.Delete(fn);
         }
         using (Stream s = File.Create(fn))
         {
             using (BinaryWriter bw = new BinaryWriter(s))
             {
                 RSFileWriter fw = new RSFileWriter(bw);
                 Data.Save(fw);
             }
         }
     }
     Book         = null;
     Data         = null;
     Localisation = null;
 }
示例#9
0
        private static void ProcessCommand(string cmd, string arg)
        {
            string[] p;
            string   fn;

            switch (cmd)
            {
            case "BookCode":
                Doc           = new MNDocument();
                Book          = new MNBookHeader();
                Book.BookCode = arg;
                BookCode      = arg;
                Data          = new MNBookData(Doc);
                break;

            case "BookName":
                Book.BookTitle = arg;
                break;

            case "BookColor":
                string[] rgb = arg.Split(',');
                Book.BookColor = Color.FromArgb(int.Parse(rgb[0]), int.Parse(rgb[1]),
                                                int.Parse(rgb[2]));
                break;

            case "BookIcon":
                Book.BookImage = GetSmallImage(arg);
                break;

            case "Author":
                Book.BookAuthor = arg;
                break;

            case "Copyright":
                Book.BookCopyright = arg;
                break;

            case "Publisher":
                Book.BookPublisher = arg;
                break;

            case "Collection":
                Book.BookCollection = arg;
                break;

            case "ExecuteFile":
                ProcessFile(arg);
                break;

            case "Language":
                Localisation = new MNLocalisation();
                Localisation.SetProperty("BookCode", Book.BookCode);
                Localisation.SetProperty("LanguageName", arg);
                break;

            case "EndLanguage":
                string ln = Localisation.GetProperty("LanguageName");
                if (ln == "Default")
                {
                    fn = BookCode + ".sme";
                }
                else
                {
                    fn = string.Format("{0}_{1}.sme", BookCode, Localisation.GetProperty("LanguageName"));
                }
                string filePath = Path.Combine(OutputDir, fn);
                try
                {
                    File.Delete(filePath);
                }
                catch
                {
                }
                Localisation.Save(filePath);
                Localisation = null;
                break;

            case "AddImage":
                MNReferencedImage img = new MNReferencedImage();
                p             = arg.Split(',');
                img.Name      = p[0];
                img.ImageData = Image.FromFile(p[1]);
                Localisation.Images.Add(img);
                break;

            case "AddSound":
                MNReferencedSound snd = new MNReferencedSound();
                p        = arg.Split(',');
                snd.Name = p[0];
                snd.InitializeWithFile(p[1]);
                Localisation.Sounds.Add(snd);
                break;
            }
        }