Beispiel #1
0
        private void generateInitialPagesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MNDocument doc = MNNotificationCenter.CurrentDocument;

            if (doc == null)
            {
                return;
            }

            MNBookData data = doc.Data;

            MNLocalisation lang = doc.DefaultLanguage;

            if (data == null || lang == null)
            {
                return;
            }

            if (data.Pages.Count != 1)
            {
                return;
            }

            data.Pages[0].Title = "Title";
            SetPageHeaderControls(0, data.Pages[0]);
            SetControlsToPage("Title page", data.Pages[0]);

            AddNewPage(doc, "start", "startPage", 0);
            AddNewPage(doc, "tp", "tpPage", 0);
            AddNewPage(doc, "new_letters", "tpNewLetters", 1);
            AddNewPage(doc, "teaching_plan", "tpTeachingPlan", 1);
            List <int> pageNos = new List <int>();

            foreach (MNReferencedSound snd in lang.Sounds)
            {
                if (snd.Name.StartsWith("Page "))
                {
                    int i;
                    if (int.TryParse(snd.Name.Substring(5).Trim(), out i))
                    {
                        pageNos.Add(i);
                    }
                }
            }
            pageNos.Sort();
            foreach (int a in pageNos)
            {
                AddNewPage(doc, "Page " + a, "mainAbove", 3);
            }
            AddNewPage(doc, "ex_before", "", 2);
            AddNewPage(doc, "ex_after", "", 2);
        }
Beispiel #2
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;
 }
Beispiel #3
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;
            }
        }