Example #1
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");
        }
Example #2
0
        private void UpdateDataWithUI()
        {
            if (data != null)
            {
                if (!SelectedBookCode.Equals(data.GetProperty("BookCode")))
                {
                    data.SetProperty("BookCode", SelectedBookCode);
                }

                if (!SelectedLanguageName.Equals(data.GetProperty("LanguageName")))
                {
                    data.SetProperty("LanguageName", SelectedLanguageName);
                }
            }
        }
Example #3
0
        private void UpdateUIWithData()
        {
            if (data == null)
            {
                return;
            }

            toolStripTextBox1.Text = data.GetProperty("BookCode");

            this.Text = string.Format("Language Editor - {0} - {1}", data.GetProperty("BookCode"),
                                      data.GetProperty("LanguageName"));

            listBoxImages.Items.Clear();
            foreach (MNReferencedImage ri in data.Images)
            {
                listBoxImages.Items.Add(ri);
            }
            listBoxTexts.Items.Clear();
            foreach (MNReferencedText rt in data.Texts)
            {
                listBoxTexts.Items.Add(rt);
            }
            listBoxSounds.Items.Clear();
            foreach (MNReferencedSound rs in data.Sounds)
            {
                listBoxSounds.Items.Add(rs);
            }
            Console.Write("Sounds: " + data.Sounds.Count + "\n");
            listBoxAudioTexts.Items.Clear();
            foreach (MNReferencedAudioText rat in data.AudioTexts)
            {
                listBoxAudioTexts.Items.Add(rat);
            }
            listBoxStyles.Items.Clear();
            foreach (MNReferencedStyle st in data.Styles)
            {
                listBoxStyles.Items.Add(st);
            }
        }
Example #4
0
        /// <summary>
        /// Load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripButton2_ClickLoad(object sender, EventArgs e)
        {
            OnSave();

            // load file
            OpenFileDialog d = new OpenFileDialog();

            d.RestoreDirectory = true;
            d.Filter           = "Language Pack Files (*" + fileExtensions + ")|*" + fileExtensions + "||";
            if (Properties.Settings.Default.LastDirectory.Length > 0)
            {
                d.InitialDirectory = Properties.Settings.Default.LastDirectory;
            }
            if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                data     = new MNLocalisation();
                fileName = d.FileName;
                data.Load(d.FileName, true);
                UpdateUIWithData();
                SelectedLanguageName   = data.GetProperty("LanguageName");
                toolStripTextBox1.Text = data.GetProperty("BookCode");
                PresentData(data, "");
            }
        }
Example #5
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);
            }
        }
Example #6
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;
            }
        }