Пример #1
0
        public MNLocalisation LoadLanguage(MNBookLanguage bl)
        {
            MNLocalisation file = new MNLocalisation();

            file.Load(bl.FilePath, true);
            return(file);
        }
Пример #2
0
        public void PreviewLanguage(MNBookLanguage bl, string fileName)
        {
            MNLocalisation file = new MNLocalisation();

            bl.FilePath = fileName;
            file.Load(bl.FilePath, false);
            bl.BookCode     = file.GetProperty("BookCode");
            bl.LastTimeSave = file.GetProperty("LastTime");
            bl.LanguageName = file.GetProperty("LanguageName");
        }
Пример #3
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);
                }
            }
        }
Пример #4
0
        private void buttonCreate_Click(object sender, EventArgs e)
        {
            if (textBox2.Text.Trim().Length > 0)
            {
                MNDocument     doc  = MNNotificationCenter.CurrentDocument;
                MNLocalisation data = new MNLocalisation();
                data.SetProperty("BookCode", doc.Book.BookCode);
                data.SetProperty("LanguageName", textBox2.Text.Trim());


                string path     = Path.GetDirectoryName(MNNotificationCenter.CurrentFileName);
                string fileName = Path.Combine(path, string.Format("{0}_{1}.sme", data.GetProperty("BookCode"), data.GetProperty("LanguageCode")));
                data.Save(fileName);

                MNBookLanguage bookLang = new MNBookLanguage();
                bookLang.FilePath     = fileName;
                bookLang.BookCode     = data.GetProperty("BookCode");
                bookLang.LanguageName = data.GetProperty("LanguageName");
                doc.Book.Languages.Add(bookLang);

                mainForm.SetLocalisationData(data);
                mainForm.SetFileName(fileName);
            }
        }