public void SetLocalisationData(MNLocalisation ld) { data = ld; fileName = null; UpdateUIWithData(); PresentData(data, null); }
public MNLocalisation LoadLanguage(MNBookLanguage bl) { MNLocalisation file = new MNLocalisation(); file.Load(bl.FilePath, true); return(file); }
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(); } } }
void panelDownload_OnDownloadComplete(object sender, EventArgs e) { MNLocalisation file = new MNLocalisation(); file.Load(Library.GetLocalFile(p_fileDown), true); pageView1.CurrentDocument.CurrentLanguage = file; pageView1.ReloadPage(false); SetShowPanel("book"); }
private void SaveDocument(string filePath) { if (filePath != null) { MNNotificationCenter.CurrentFileName = filePath; } else { filePath = MNNotificationCenter.CurrentFileName; } RSFileWriter fw; string fileName = filePath; MNDocument doc = MNNotificationCenter.CurrentDocument; using (StreamWriter sw = new StreamWriter(@"d:\LearnToRead\save_book.txt")) { using (BinaryWriter bw = new BinaryWriter(File.Create(fileName))) { fw = new RSFileWriter(bw); fw.logStream = sw; doc.Book.Save(fw); } } fileName = fileName.Replace(".smb", ".smd"); using (StreamWriter sw = new StreamWriter(@"d:\LearnToRead\save_data.txt")) { using (BinaryWriter bw = new BinaryWriter(File.Create(fileName))) { fw = new RSFileWriter(bw); fw.logStream = sw; doc.Data.Save(fw); } } if (doc.DefaultLanguage.IsModified()) { fileName = fileName.Replace(".smd", ".sme"); using (StreamWriter sw = new StreamWriter(@"d:\LearnToRead\save_lang.txt")) { using (BinaryWriter bw = new BinaryWriter(File.Create(fileName))) { fw = new RSFileWriter(bw); fw.logStream = sw; MNLocalisation loc = doc.DefaultLanguage; loc.SetProperty("BookCode", doc.Book.BookCode); loc.SetProperty("LanguageName", "Default"); loc.Save(fw); loc.Modified = false; } } } lastSaved = DateTime.Now; }
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"); }
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); }
private void buttonOK_Click(object sender, EventArgs e) { ListBox lb = listBox1; if (lb.SelectedIndex >= 0 && lb.SelectedIndex < lb.Items.Count) { object obj = lb.Items[lb.SelectedIndex]; if (obj is MNBookLanguage) { mainForm.OnSave(); MNLocalisation data = new MNLocalisation(); data.Load((obj as MNBookLanguage).FilePath, true); mainForm.SetLocalisationData(data); mainForm.SetFileName((obj as MNBookLanguage).FilePath); } } }
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"); } }
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; }
/// <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(); PresentData(data, ""); } }
private void toolStripMenuItem6_Click(object sender, EventArgs e) { // create language file from folder // we need: // - book code // - directory path DialogGenerateLangFile d = new DialogGenerateLangFile(); d.SetBookCode(MNNotificationCenter.CurrentDocument.Book.BookCode); d.SetBookFileName(MNNotificationCenter.CurrentFileName); if (d.ShowDialog() == System.Windows.Forms.DialogResult.OK) { string inDir = d.GetInputDirectory(); string outFile = d.GetOutputFileName(); MNLocalisation file = new MNLocalisation(); file.SetProperty("BookCode", MNNotificationCenter.CurrentDocument.Book.BookCode); file.SetProperty("LanguageName", Path.GetFileName(inDir)); foreach (string objectFileName in Directory.GetFiles(inDir)) { string extension = Path.GetExtension(objectFileName); if (extension.Equals(".mp3")) { MNReferencedSound sound = new MNReferencedSound(); sound.InitializeWithFile(objectFileName); sound.Name = Path.GetFileNameWithoutExtension(objectFileName); file.Sounds.Add(sound); file.Modified = true; } } file.Save(outFile); } }
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); } }
public DialogStyleName() { Document = null; InitializeComponent(); }
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; } }
/*protected override void WndProc(ref Message m) * { * if (m.Msg == WM_SIZING) * { * RECT rc = (RECT)Marshal.PtrToStructure(m.LParam, typeof(RECT)); * * Size newSize = AdjustSizeForm(2); * * switch (m.WParam.ToInt32()) // Resize handle * { * case WMSZ_LEFT: * case WMSZ_RIGHT: * // Left or right handles, adjust height * rc.Bottom = rc.Top + AdjustSizeForm(1).Height; * break; * * case WMSZ_TOP: * case WMSZ_BOTTOM: * // Top or bottom handles, adjust width * rc.Right = rc.Left + AdjustSizeForm(2).Width; * break; * * case WMSZ_LEFT + WMSZ_TOP: * case WMSZ_LEFT + WMSZ_BOTTOM: * // Top-left or bottom-left handles, adjust width * rc.Left = rc.Right - AdjustSizeForm(2).Width; * break; * * case WMSZ_RIGHT + WMSZ_TOP: * // Top-right handle, adjust height * //rc.Top = rc.Bottom - newSize.Height; * rc.Right = rc.Left + AdjustSizeForm(2).Width; * break; * * case WMSZ_RIGHT + WMSZ_BOTTOM: * // Bottom-right handle, adjust height * // rc.Bottom = rc.Top + newSize.Height; * rc.Right = rc.Left + AdjustSizeForm(2).Width; * break; * } * * Marshal.StructureToPtr(rc, m.LParam, true); * } * base.WndProc(ref m); * }*/ public void dialogDidSelectLanguage(MNLocalisation loc) { }