public void ExportNotationParagraphs_WritingSystems() { IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(m_book.Hvo); StTxtPara para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph); IScrScriptureNote note = m_scrInMemoryCache.AddAnnotation(para, new BCVRef(01001001), NoteType.Translator, "This is some text with espa\u00F1ol."); TsStringAccessor tssaDisc = ((StTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents; ITsStrBldr bldr = tssaDisc.UnderlyingTsString.GetBldr(); bldr.SetProperties(bldr.Length - 8, bldr.Length - 1, StyleUtils.CharStyleTextProps(null, InMemoryFdoCache.s_wsHvos.Es)); tssaDisc.UnderlyingTsString = bldr.GetString(); StringWriter stream = new StringWriter(); XmlTextWriter writer = new XmlTextWriter(stream); m_exporter = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0, "ExportNotationParagraphs_WritingSystems"); ReflectionHelper.SetField(m_exporter, "m_writer", writer); ReflectionHelper.CallMethod(m_exporter, "ExportNotationParagraphs", note.DiscussionOA, "notationDiscussion"); Assert.AreEqual("<notationDiscussion><para xml:lang=\"en\">" + "<span>This is some text with </span>" + "<span xml:lang=\"es\">espa\u00F1ol</span>" + "<span>.</span>" + "</para></notationDiscussion>", stream.ToString()); }
public void ExportNotationParagraphs_Hyperlink() { IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(m_book.Hvo); StTxtPara para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph); IScrScriptureNote note = m_scrInMemoryCache.AddAnnotation(para, new BCVRef(01001001), NoteType.Translator, "This is some text with a hyperlink!"); TsStringAccessor tssaDisc = ((StTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents; tssaDisc.MarkTextAsHyperlink(tssaDisc.Length - 10, tssaDisc.Length - 1, "http://www.myspace.com", m_stylesheet); StringWriter stream = new StringWriter(); XmlTextWriter writer = new XmlTextWriter(stream); m_exporter = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0, "ExportNotationParagraphs_Hyperlink"); ReflectionHelper.SetField(m_exporter, "m_writer", writer); ReflectionHelper.CallMethod(m_exporter, "ExportNotationParagraphs", note.DiscussionOA, "notationDiscussion"); Assert.AreEqual("<notationDiscussion><para xml:lang=\"en\">" + "<span>This is some text with a </span>" + "<a href=\"http://www.myspace.com\">hyperlink</a>" + "<span>!</span>" + "</para></notationDiscussion>", stream.ToString()); }
public void ExportBookSection_IntroWithNotes() { IScrSection introSection = m_scrInMemoryCache.AddIntroSectionToMockedBook(m_book.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(introSection.Hvo, "Introduction", ScrStyleNames.IntroSectionHead); StTxtPara introPara = AddPara(introSection, ScrStyleNames.NormalParagraph); AddVerse(introPara, 0, 0, "Some intro text"); IScrScriptureNote note = m_scrInMemoryCache.AddAnnotation(introPara, new BCVRef(01001000), NoteType.Consultant, "This is a basic note about the intro."); note.ResolutionStatus = NoteStatus.Open; note.BeginOffset = 5; note.EndOffset = 10; DateTime now = DateTime.Now; string strNow = now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss.ff"); note.DateCreated = now; note.DateModified = now; StringWriter stream = new StringWriter(); XmlTextWriter writer = new XmlTextWriter(stream); writer.Formatting = Formatting.None; m_exporter = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0, "ExportBookSection_IntroWithNotes"); ReflectionHelper.SetField(m_exporter, "m_writer", writer); string sCanon = "ot"; ReflectionHelper.CallMethod(m_exporter, "ExportBook", sCanon, m_book, null); XmlDocument actual = new XmlDocument(); actual.Load(new StringReader(stream.ToString())); string strExpected = "<book ID=\"GEN\"><titleGroup short=\"Genesis\"><title type=\"main\">" + "<trGroup><tr>Genesis</tr></trGroup></title></titleGroup>" + "<introduction><section><sectionHead><trGroup><tr>Introduction</tr></trGroup></sectionHead>" + "<p><annotation type=\"consultantNote\" status=\"0\" oxesRef=\"GEN.1.0\" beginOffset=\"5\" endOffset=\"10\">" + "<created>" + strNow + "</created><modified>" + strNow + "</modified>" + "<resolved /><notationDiscussion><para xml:lang=\"en\">" + "<run>This is a basic note about the intro.</run></para></notationDiscussion></annotation>" + "<trGroup><tr><userCS type=\"Paragraph\">Some intro text</userCS></tr></trGroup>" + "<chapterEnd ID=\"GEN.0\"/></p></section></introduction></book>"; XmlDocument expected = new XmlDocument(); expected.Load(new StringReader(strExpected)); string strDifference; if (!XmlHelper.CompareXmlNodes(expected.ChildNodes, actual.ChildNodes, out strDifference)) { Assert.Fail(strDifference); } }
public void ExportBookSection_MultipleBT() { Cache.LangProject.AnalysisWssRC.Add(InMemoryFdoCache.s_wsHvos.Hbo); Cache.LangProject.CurAnalysisWssRS.Append(InMemoryFdoCache.s_wsHvos.Hbo); int wsAnal = Cache.DefaultAnalWs; IScrSection introSection = m_scrInMemoryCache.AddIntroSectionToMockedBook(m_book.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(introSection.Hvo, "Introduccion", ScrStyleNames.IntroSectionHead); StTxtPara introPara = AddPara(introSection, ScrStyleNames.NormalParagraph); AddVerse(introPara, 0, 0, "Texto de introduccion"); // Add a back translation for the default analysis language. CmTranslation trans = (CmTranslation)m_scrInMemoryCache.AddTransToMockedParagraph(introPara, LangProject.kguidTranBackTranslation, wsAnal); trans.Translation.SetAlternative("Default BT", wsAnal); trans.Status.SetAlternative("finished", wsAnal); // Add a back translation for Hebrew. trans.Translation.SetAlternative("Hbo BT", InMemoryFdoCache.s_wsHvos.Hbo); StringWriter stream = new StringWriter(); XmlTextWriter writer = new XmlTextWriter(stream); writer.Formatting = Formatting.None; m_exporter = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0, "ExportBookSection_IntroWithNotes"); // Initialize writing systems for export (required to export back translations), but // called from ExportTE. ReflectionHelper.CallMethod(m_exporter, "InitializeExportWs", null); ReflectionHelper.SetField(m_exporter, "m_writer", writer); string sCanon = "ot"; ReflectionHelper.CallMethod(m_exporter, "ExportBook", sCanon, m_book, null); XmlDocument actual = new XmlDocument(); actual.Load(new StringReader(stream.ToString())); string strExpected = "<book ID=\"GEN\"><titleGroup short=\"Genesis\"><title type=\"main\">" + "<trGroup><tr>Genesis</tr></trGroup></title></titleGroup>" + "<introduction><section><sectionHead><trGroup><tr>Introduction</tr></trGroup></sectionHead>" + "<p><trGroup><tr><userCS type=\"Paragraph\">Some intro text</userCS></tr>" + "<bt xml:lang=\"en\" status=\"finished\">Default BT</bt><bt xml:lang=\"hbo\">Hbo BT</bt></trGroup>" + "<chapterEnd ID=\"GEN.0\"/></p></section></introduction></book>"; XmlDocument expected = new XmlDocument(); expected.Load(new StringReader(strExpected)); string strDifference; if (!XmlHelper.CompareXmlNodes(expected.ChildNodes, actual.ChildNodes, out strDifference)) { Assert.Fail(strDifference); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// test setup /// </summary> /// ------------------------------------------------------------------------------------ public override void TestSetup() { base.TestSetup(); m_fileName = FileUtils.GetTempFile("tmp"); FilteredScrBooks filter = Cache.ServiceLocator.GetInstance<IFilteredScrBookRepository>().GetFilterInstance(123); FileUtils.Delete(m_fileName); // exporter pops up dialog if file exists! m_exporter = new ExportXml(m_fileName, Cache, filter, null, ExportWhat.AllBooks, 0, 0, 0, "This is a test"); }
public void Deinitialize() { CheckDisposed(); m_exporter = null; m_cache.Dispose(); m_cache = null; m_filter = null; File.Delete(m_fileName); m_fileName = null; }
private void cmdExport_Click(object sender, EventArgs e) { FormExport_FormClosing(null, null); if (ValidateParam()) { ExportXml exportXml = new ExportXml(_config, txtXml.Text, txtAccess.Text); bgWorker.RunWorkerAsync(exportXml); _frmLoading.ShowDialog(); } }
public void SaveMap() { if (Support.listObject != null && Support.IsExportXml == false) { for (int i = 0; i < WorkspaceWorking.Children.Count; ++i) { if (WorkspaceWorking.Children[i] is Image) { Image tempRect = (Image)WorkspaceWorking.Children[i]; if ((int)tempRect.Tag != (int)ObjectType.TILE_MAP) { ++Support.Count; OBJECT temp = new OBJECT((int)ObjectType.NORMAL_OBJECT, (int)tempRect.Tag, Support.Count, new VECTOR2D((float)Canvas.GetLeft(WorkspaceWorking.Children[i]), (float)Canvas.GetTop(WorkspaceWorking.Children[i])), new RECTANGLE((float)Canvas.GetLeft(WorkspaceWorking.Children[i]), (float)Canvas.GetTop(WorkspaceWorking.Children[i]), (int)tempRect.Width, (int)tempRect.Height)); VECTOR2D tempPosition = Support.ConvertCoordination(temp); Support.listObject.Add(new OBJECT((int)ObjectType.NORMAL_OBJECT, (int)tempRect.Tag, Support.Count, tempPosition, new RECTANGLE(tempPosition.cX, tempPosition.cY, (int)tempRect.Width, (int)tempRect.Height))); } } else if (WorkspaceWorking.Children[i] is Rectangle && Support.IsImport == true) { ++Support.Count; Rectangle tempImage = (Rectangle)WorkspaceWorking.Children[i]; if (tempImage.Tag != Support.gridLine) { OBJECT temp = new OBJECT((int)ObjectType.VIRTUAL_OBJECT, (int)tempImage.Tag, Support.Count, new VECTOR2D((float)Canvas.GetLeft(WorkspaceWorking.Children[i]), (float)Canvas.GetTop(WorkspaceWorking.Children[i])), new RECTANGLE((float)Canvas.GetLeft(WorkspaceWorking.Children[i]), (float)Canvas.GetTop(WorkspaceWorking.Children[i]), (int)tempImage.Width, (int)tempImage.Height)); VECTOR2D tempPosition = Support.ConvertCoordination(temp); Support.listObject.Add(new OBJECT((int)ObjectType.VIRTUAL_OBJECT, (int)tempImage.Tag, Support.Count, tempPosition, new RECTANGLE(tempPosition.cX, tempPosition.cY, (int)tempImage.Width, (int)tempImage.Height))); } } } Support.IsImport = false; if (Support.quadTree == null) { Support.quadTree = new CNode(0, PositionOfNode.TopLeft, new RECTANGLE(0, 8192, 8192, 8192)); for (int i = 0; i < Support.listObject.Count; ++i) { Support.quadTree.InsertObject(Support.quadTree, Support.listObject[i]); } } ExportXml.getInstance().MWriter.WriteStartDocument(); ExportXml.getInstance().WriteInfomationForMap(); ExportXml.getInstance().writeQuadtreeToXml(Support.quadTree, ExportXml.getInstance().MWriter); ExportXml.getInstance().MWriter.WriteEndDocument(); ExportXml.getInstance().MWriter.Close(); Support.IsExportXml = true; MessageBox.Show("Map đã được tạo thành công, dùng file map.xml để load game nhé ^^", "Thông báo"); } else { MessageBox.Show("Có map đâu mà đòi lưu ! - Muốn lưu hãy tạo map mới ^^", "Thông báo"); } }
public override void Initialize() { CheckDisposed(); m_cache = FdoCache.Create("TestLangProj"); m_filter = new FilteredScrBooks(m_cache, 123); m_filter.ShowAllBooks(); m_fileName = Path.GetTempFileName(); File.Delete(m_fileName); // exporter pops up dialog if file exists! m_exporter = new ExportXml(m_fileName, m_cache, m_filter, ExportWhat.AllBooks, 0, 0, 0, "This is a test"); }
public void ExportScriptureNote_IgnoredCheckingError() { IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(m_book.Hvo); StTxtPara para = AddPara(section, ScrStyleNames.NormalParagraph); IScrScriptureNote note = m_scrInMemoryCache.AddAnnotation(para, new BCVRef(01001001), NoteType.CheckingError, "This is some basic text."); note.AnnotationTypeRA.Name.SetAlternative("Repeated Words", Cache.DefaultAnalWs); note.AnnotationTypeRA.Guid = new Guid(StandardCheckIds.kguidRepeatedWords.ToString()); note.ResolutionStatus = NoteStatus.Closed; DateTime now = DateTime.Now; string strNow = now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss.ff"); note.DateCreated = now; note.DateModified = now; note.DateResolved = now; StringWriter stream = new StringWriter(); XmlTextWriter writer = new XmlTextWriter(stream); m_exporter = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0, "ExportScriptureNote_Resolved"); ReflectionHelper.SetField(m_exporter, "m_writer", writer); ReflectionHelper.CallMethod(m_exporter, "ExportScriptureNote", note); string strExpected = "<annotation subType=\"repeatedWordsCheck\" status=\"1\" oxesRef=\"GEN.1.1\" " + "beginOffset=\"0\" endOffset=\"0\" type=\"pre-typesettingCheck\">" + "<created>" + strNow + "</created>" + "<modified>" + strNow + "</modified>" + "<resolved>" + strNow + "</resolved>" + "<notationDiscussion>" + "<para xml:lang=\"en\">" + "<span>This is some basic text.</span>" + "</para>" + "</notationDiscussion>" + "</annotation>"; XmlDocument actual = new XmlDocument(); actual.Load(new StringReader(stream.ToString())); XmlDocument expected = new XmlDocument(); expected.Load(new StringReader(strExpected)); string strDifference; if (!XmlHelper.CompareXmlNodes(expected.ChildNodes, actual.ChildNodes, out strDifference)) { Assert.Fail(strDifference); } }
private void bgWorker_DoWork(object sender, DoWorkEventArgs e) { try { ExportXml exportXml = e.Argument as ExportXml; exportXml.Export(); } catch (Exception ex) { XTrace.WriteException(ex); e.Result = ex; } }
public void ExportPicture_MultipleWS() { // Create a picture that has a caption with three different writing systems. ITsStrBldr tssBldr = TsStrBldrClass.Create(); ITsPropsBldr propsBldr = TsPropsBldrClass.Create(); propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, InMemoryFdoCache.s_wsHvos.De); tssBldr.ReplaceRgch(0, 0, "photo", 5, propsBldr.GetTextProps()); propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, InMemoryFdoCache.s_wsHvos.Ur); tssBldr.ReplaceRgch(tssBldr.Length, tssBldr.Length, " tasvir", 7, propsBldr.GetTextProps()); propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, Cache.DefaultVernWs); tssBldr.ReplaceRgch(tssBldr.Length, tssBldr.Length, " picture caption", 16, propsBldr.GetTextProps()); CmPicture picture = new CmPicture(m_inMemoryCache.Cache, @"c:\filename.jpg", tssBldr.GetString(), "folder"); // Set up for export StringWriter stream = new StringWriter(); XmlTextWriter writer = new XmlTextWriter(stream); writer.Formatting = Formatting.None; m_exporter = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0, "ExportPicture_MultipleWS"); ReflectionHelper.SetField(m_exporter, "m_writer", writer); // Export the picture to XML ReflectionHelper.CallMethod(m_exporter, "ExportPicture", picture); // Check the results of the exported picture. // Set up expected results. string defaultDir = DirectoryFinder.FWDataDirectory; // TODO (TE-7756): Support OXES export and import of new properties that have been // added to the CmPicture model string strExpected = "<figure src=\"filename.jpg\"><!--path=\"" + defaultDir + "\\filename\"-->" + "<caption><trGroup><tr><foreign xml:lang=\"de\">photo</foreign>" + "<foreign xml:lang=\"ur\"> tasvir</foreign> picture caption</tr></trGroup></caption></figure>"; XmlDocument expected = new XmlDocument(); expected.Load(new StringReader(strExpected)); // Get actual results. XmlDocument actual = new XmlDocument(); actual.Load(new StringReader(stream.ToString())); string strDifference; if (!XmlHelper.CompareXmlNodes(expected.ChildNodes, actual.ChildNodes, out strDifference)) { Assert.Fail(strDifference); } }
public override void Exit() { CheckDisposed(); m_exporter = null; m_filter = null; if (m_fileName != null) { File.Delete(m_fileName); } m_stylesheet = null; m_fileName = null; Options.UseInterlinearBackTranslation = m_saveSegmentedBT; base.Exit(); }
public void ExportNotationParagraphs_Basic() { IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(m_book.Hvo); StTxtPara para = m_scrInMemoryCache.AddParaToMockedSectionContent(section.Hvo, ScrStyleNames.NormalParagraph); IScrScriptureNote note = m_scrInMemoryCache.AddAnnotation(para, new BCVRef(01001001), NoteType.Translator, "This is some basic text."); TsStringAccessor tssaDisc = ((StTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents; StringWriter stream = new StringWriter(); XmlTextWriter writer = new XmlTextWriter(stream); m_exporter = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0, "ExportNotationParagraphs_Basic"); ReflectionHelper.SetField(m_exporter, "m_writer", writer); ReflectionHelper.CallMethod(m_exporter, "ExportNotationParagraphs", note.DiscussionOA, "notationDiscussion"); Assert.AreEqual("<notationDiscussion><para xml:lang=\"en\">" + "<span>This is some basic text.</span>" + "</para></notationDiscussion>", stream.ToString()); }
private static void Main(string[] args) { // Importing the data from JSON and XML files if (!Database.Exists("MassDefectContext")) { ImportJson.SolarSystems(); ImportJson.Stars(); ImportJson.Planets(); ImportJson.Persons(); ImportJson.Anomalies(); ImportJson.AnomalyVictims(); ImportXml.NewAnomalies(); } // Tasks to export JSON files ExportJson.ExportPlanetsWhichAreNotAnomalyOrigins(); ExportJson.ExportPeopleWhichHaveNotBeenVictims(); ExportJson.ExportTopAnomaly(); // Task to export XML file ExportXml.ExtractAllAnomaliesAndPeopleAffected(); }
public override void Initialize() { CheckDisposed(); base.Initialize(); m_fileName = Path.GetTempFileName(); File.Delete(m_fileName); // exporter pops up dialog if file exists! m_scrInMemoryCache.InitializeScripture(); m_scrInMemoryCache.InitializeWritingSystemEncodings(); m_stylesheet = new FwStyleSheet(); m_stylesheet.Init(Cache, m_scr.Hvo, (int)Scripture.ScriptureTags.kflidStyles); m_scrInMemoryCache.InitializeAnnotationDefs(); m_book = m_scrInMemoryCache.AddBookToMockedScripture(1, "Genesis"); m_scrInMemoryCache.AddTitleToMockedBook(m_book.Hvo, "Genesis"); m_filter = new FilteredScrBooks(Cache, 123); m_filter.ShowAllBooks(); m_saveSegmentedBT = Options.UseInterlinearBackTranslation; Options.UseInterlinearBackTranslation = false; m_exporter = new ExportXml(m_fileName, Cache, m_filter, ExportWhat.AllBooks, 0, 0, 0, string.Empty); }
public void ExportNotationParagraphs_Basic() { IScrSection section = AddSectionToMockedBook(m_book); IStTxtPara para = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph); IScrScriptureNote note = AddAnnotation(para, new BCVRef(01001001), NoteType.Translator, "This is some basic text."); using (StringWriter stream = new StringWriter()) { using (XmlTextWriter writer = new XmlTextWriter(stream)) { m_exporter = new ExportXml(null, Cache, null, null, ExportWhat.AllBooks, 0, 0, 0, "ExportNotationParagraphs_Basic"); ReflectionHelper.SetField(m_exporter, "m_writer", writer); ReflectionHelper.CallMethod(m_exporter, "ExportNotationParagraphs", note.DiscussionOA, "notationDiscussion"); Assert.AreEqual("<notationDiscussion><para xml:lang=\"en\">" + "<span>This is some basic text.</span>" + "</para></notationDiscussion>", stream.ToString()); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// lears member variables, cleans up temp files, shuts down the cache, etc. /// </summary> /// <remarks>This method is called after each test</remarks> /// ------------------------------------------------------------------------------------ public override void TestTearDown() { m_exporter = null; m_filter = null; if (m_fileName != null) FileUtils.Delete(m_fileName); m_stylesheet = null; m_fileName = null; base.TestTearDown(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Test setup /// </summary> /// ------------------------------------------------------------------------------------ public override void TestSetup() { base.TestSetup(); m_fileName = FileUtils.GetTempFile("tmp"); FileUtils.Delete(m_fileName); // exporter pops up dialog if file exists! m_stylesheet = new FwStyleSheet(); m_stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles); m_book = AddBookToMockedScripture(1, "Genesis"); AddTitleToMockedBook(m_book, "Genesis"); m_filter = Cache.ServiceLocator.GetInstance<IFilteredScrBookRepository>().GetFilterInstance(123); m_filter.ShowAllBooks(); m_exporter = new ExportXml(m_fileName, Cache, m_filter, null, ExportWhat.AllBooks, 1, 0, 0, string.Empty); }
public void ExportPicture_InsideParaTrGroup() { IWritingSystem wsDe = Cache.ServiceLocator.WritingSystemManager.Get("de"); // Create a picture that has a caption with three different writing systems. ITsStrBldr tssBldr = TsStrBldrClass.Create(); ITsPropsBldr propsBldr = TsPropsBldrClass.Create(); propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, wsDe.Handle); tssBldr.ReplaceRgch(0, 0, "photo", 5, propsBldr.GetTextProps()); propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, Cache.DefaultVernWs); tssBldr.ReplaceRgch(tssBldr.Length, tssBldr.Length, " picture caption", 16, propsBldr.GetTextProps()); ICmPicture picture = Cache.ServiceLocator.GetInstance<ICmPictureFactory>().Create( Path.Combine(Path.GetTempPath(), "filename.jpg"), tssBldr.GetString(), "folder"); IScrSection section = AddSectionToMockedBook(m_book); IScrTxtPara para = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph); AddVerse(para, 0, 0, "Before"); para.Contents = picture.InsertORCAt(para.Contents, para.Contents.Length); AddVerse(para, 0, 0, "After"); // Set up for export using (StringWriter stream = new StringWriter()) using (XmlTextWriter writer = new XmlTextWriter(stream)) { writer.Formatting = Formatting.None; m_exporter = new ExportXml(null, Cache, null, null, ExportWhat.AllBooks, 0, 0, 0, "ExportPicture_InsideParaTrGroup"); ReflectionHelper.CallMethod(m_exporter, "InitializeExportWs", null); ReflectionHelper.SetField(m_exporter, "m_writer", writer); SetBookInfo(m_book); // Export the picture to XML ReflectionHelper.CallMethod(m_exporter, "ExportParagraph", para, null, true); // Check the results of the exported picture. // Set up expected results. string defaultDir = Path.Combine(Path.GetTempPath(), "filename.jpg"); // TODO (TE-7756): Support OXES export and import of new properties that have been // added to the CmPicture model string strExpected = "<p><trGroup><tr>Before<figure src=\"filename.jpg\" oxesRef=\"GEN\" alt=\"photo picture caption (Genesis)\">" + "<!--path=\"" + defaultDir + "\"-->" + "<caption><trGroup><tr><foreign xml:lang=\"de\">photo</foreign>" + " picture caption</tr></trGroup></caption></figure>After</tr></trGroup></p>"; CompareXmlDocuments(strExpected, stream.ToString()); } }
public void ExportScriptureNotesOutOfOrder() { IScrSection section = m_scrInMemoryCache.AddSectionToMockedBook(m_book.Hvo); // Create 2 paragraphs StTxtPara para1 = AddPara(section, ScrStyleNames.NormalParagraph); StTxtPara para2 = AddPara(section, ScrStyleNames.NormalParagraph); // Add an annotation to the second paragraph. Ref. // GEN 1 means annotation is in an introduction paragraph. IScrScriptureNote note1 = m_scrInMemoryCache.AddAnnotation( para2, new BCVRef(01001000), NoteType.Consultant, "Annotation1 for Para2"); // Add an annotation to the first paragraph. // GEN 1 means annotation is in an introduction paragraph. IScrScriptureNote note2 = m_scrInMemoryCache.AddAnnotation( para1, new BCVRef(01001000), NoteType.Consultant, "Annotation2 for Para1"); DateTime now = DateTime.Now; string strNow = now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss.ff"); note1.DateCreated = note2.DateCreated = now; note1.DateModified = note2.DateModified = now; note1.DateResolved = note2.DateResolved = now; StringWriter stream = new StringWriter(); XmlTextWriter writer = new XmlTextWriter(stream); writer.WriteStartElement("TestData"); m_exporter = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0, "ExportScriptureNotesOutOfOrder"); ReflectionHelper.SetField(m_exporter, "m_writer", writer); ReflectionHelper.SetField(m_exporter, "m_iCurrentBook", 1); ReflectionHelper.CallMethod(m_exporter, "ExportAnnotationsForPara", para1.Hvo); ReflectionHelper.CallMethod(m_exporter, "ExportAnnotationsForPara", para2.Hvo); writer.WriteEndElement(); string strExpected = "<TestData>" + "<annotation type=\"consultantNote\" status=\"0\" oxesRef=\"GEN.1.0\" " + "beginOffset=\"0\" endOffset=\"0\">" + "<created>" + strNow + "</created>" + "<modified>" + strNow + "</modified>" + "<resolved />" + "<notationDiscussion>" + "<para xml:lang=\"en\">" + "<span>Annotation2 for Para1</span>" + "</para>" + "</notationDiscussion>" + "</annotation>" + "<annotation type=\"consultantNote\" status=\"0\" oxesRef=\"GEN.1.0\" " + "beginOffset=\"0\" endOffset=\"0\">" + "<created>" + strNow + "</created>" + "<modified>" + strNow + "</modified>" + "<resolved />" + "<notationDiscussion>" + "<para xml:lang=\"en\">" + "<span>Annotation1 for Para2</span>" + "</para>" + "</notationDiscussion>" + "</annotation></TestData>"; XmlDocument actual = new XmlDocument(); actual.Load(new StringReader(stream.ToString())); XmlDocument expected = new XmlDocument(); expected.Load(new StringReader(strExpected)); string strDifference; if (!XmlHelper.CompareXmlNodes(expected.ChildNodes, actual.ChildNodes, out strDifference)) { Assert.Fail(strDifference); } }
public void ExportBookSection_MultipleBT() { IWritingSystem lgHbo = Cache.ServiceLocator.WritingSystemManager.Get("hbo"); int wsAnal = Cache.DefaultAnalWs; IScrSection introSection = AddSectionToMockedBook(m_book, true); AddSectionHeadParaToSection(introSection, "Introduccion", ScrStyleNames.IntroSectionHead); IScrTxtPara introPara = AddParaToMockedSectionContent(introSection, ScrStyleNames.NormalParagraph); AddVerse(introPara, 0, 0, "Texto de introduccion"); // Add a back translation for the default analysis language. ICmTranslation trans = AddBtToMockedParagraph(introPara, wsAnal); trans.Translation.set_String(wsAnal, TsStringUtils.MakeTss("Default BT", wsAnal)); trans.Status.set_String(wsAnal, TsStringUtils.MakeTss("finished", wsAnal)); // Add a back translation for Hebrew. trans.Translation.set_String(lgHbo.Handle, TsStringUtils.MakeTss("Hbo BT", lgHbo.Handle)); using (StringWriter stream = new StringWriter()) using (XmlTextWriter writer = new XmlTextWriter(stream)) { writer.Formatting = Formatting.None; m_exporter = new ExportXml(null, Cache, null, null, ExportWhat.AllBooks, 0, 0, 0, "ExportBookSection_MultipleBT"); // Initialize writing systems for export (required to export back translations), but // called from ExportTE. ReflectionHelper.CallMethod(m_exporter, "InitializeExportWs", null); ReflectionHelper.SetField(m_exporter, "m_writer", writer); string sCanon = "ot"; ReflectionHelper.CallMethod(m_exporter, "ExportBook", sCanon, m_book, null); string strExpected = "<book ID=\"GEN\"><titleGroup short=\"Genesis\"><title type=\"main\">" + "<trGroup><tr>Genesis</tr></trGroup></title></titleGroup>" + "<introduction><section><sectionHead><trGroup><tr>Introduccion</tr></trGroup></sectionHead>" + "<p><trGroup><tr>Texto de introduccion</tr>" + "<bt xml:lang=\"en\" segmented =\"true\" status=\"finished\">Default BT</bt>" + "<bt xml:lang=\"hbo\" segmented =\"true\">Hbo BT</bt></trGroup>" + "</p></section></introduction></book>"; CompareXmlDocuments(strExpected, stream.ToString()); } }
public void ExportBookSection_IntroWithNotes() { IScrSection introSection = AddSectionToMockedBook(m_book, true); AddSectionHeadParaToSection(introSection, "Introduction", ScrStyleNames.IntroSectionHead); IScrTxtPara introPara = AddParaToMockedSectionContent(introSection, ScrStyleNames.NormalParagraph); AddVerse(introPara, 0, 0, "Some intro text"); IScrScriptureNote note = AddAnnotation(introPara, new BCVRef(01001000), NoteType.Consultant, "This is a basic note about the intro."); note.ResolutionStatus = NoteStatus.Open; note.BeginOffset = 5; note.EndOffset = 10; DateTime now = DateTime.Now; string strNow = now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss.ff"); note.DateCreated = now; note.DateModified = now; using (StringWriter stream = new StringWriter()) { using (XmlTextWriter writer = new XmlTextWriter(stream)) { writer.Formatting = Formatting.None; m_exporter = new ExportXml(null, Cache, null, null, ExportWhat.AllBooks, 0, 0, 0, "ExportBookSection_IntroWithNotes"); // Initialize writing systems for export (required to export back translations), but // called from ExportTE. ReflectionHelper.CallMethod(m_exporter, "InitializeExportWs", null); ReflectionHelper.SetField(m_exporter, "m_writer", writer); string sCanon = "ot"; ReflectionHelper.CallMethod(m_exporter, "ExportBook", sCanon, m_book, null); string strExpected = "<book ID=\"GEN\"><titleGroup short=\"Genesis\"><title type=\"main\">" + "<trGroup><tr>Genesis</tr></trGroup></title></titleGroup>" + "<introduction><section><sectionHead><trGroup><tr>Introduction</tr></trGroup></sectionHead>" + "<p><annotation type=\"consultantNote\" status=\"0\" oxesRef=\"GEN.1.0\" beginOffset=\"5\" endOffset=\"10\">" + "<created>" + strNow + "</created><modified>" + strNow + "</modified>" + "<resolved /><notationDiscussion><para xml:lang=\"en\">" + "<span>This is a basic note about the intro.</span></para></notationDiscussion></annotation>" + "<trGroup><tr>Some intro text</tr></trGroup>" + "</p></section></introduction></book>"; CompareXmlDocuments(strExpected, stream.ToString()); } } }
private void click_to_load_file(object sender, RoutedEventArgs e) { Support.IsImport = true; OpenFileDialog openFileDialogSourcePicture = new OpenFileDialog(); openFileDialogSourcePicture.Filter = "XML (*.xml)|*.xml| All File (*.*)|*.*"; openFileDialogSourcePicture.FilterIndex = 1; openFileDialogSourcePicture.RestoreDirectory = true; String pathToImage = ""; if (openFileDialogSourcePicture.ShowDialog() == true) { CTile.CountID = 0; if (Support.map == null) { if (Support.MAPNAME == "1") { pathToImage = @"..\..\Resource\map\map1.png"; } else if (Support.MAPNAME == "2") { pathToImage = @"..\..\Resource\map\map2.png"; } else if (Support.MAPNAME == "3") { pathToImage = @"..\..\Resource\map\map3.png"; } Support.map = new CMap(new BitmapImage(new Uri(pathToImage, UriKind.Relative))); Support.WIDHT_MAP = (int)(Support.map.BitMap.PixelWidth); Support.HEIGHT_MAP = (int)(Support.map.BitMap.PixelHeight); if (Support.GRIDLINE == true) { DestroyGridline(); Support.GRIDLINE = true; CreateGridline(); } if (Support.IsExportXml == true) { Support.IsExportXml = false; ExportXml.getInstance().DestroyWriter(); } WorkspaceWorking.Width = Support.WIDHT_MAP; WorkspaceWorking.Height = Support.HEIGHT_MAP; Support.map.CreateTileMap(); } } if (Support.map != null) { BitmapSource bmpSource; PngBitmapEncoder bmpCreate = new PngBitmapEncoder(); byte[] arrPixel = new byte[((Support.map.TileMap.Count * Support.WIDTH_OF_TILE * Support.map.BitMap.Format.BitsPerPixel) / 8) * Support.HEIGHT_OF_TILE]; int offsetX = 0; int offsetY = 0; for (int i = 0; i < Support.map.TileMap.Count; ++i) { offsetX = Support.map.TileMap[i].ID; Support.map.TileMap[i].ExportBitMap(offsetX, offsetY, arrPixel, (Support.map.TileMap.Count * Support.WIDTH_OF_TILE * Support.map.BitMap.Format.BitsPerPixel / 8)); } FileStream stream = new FileStream(@"..\..\Resource\tilemap\tile_map.png", FileMode.Create); bmpSource = BitmapSource.Create(Support.map.TileMap.Count * Support.WIDTH_OF_TILE, Support.HEIGHT_OF_TILE, 96, 96, Support.map.BitMap.Format, null, arrPixel, ((Support.map.TileMap.Count * Support.WIDTH_OF_TILE * Support.map.BitMap.Format.BitsPerPixel) / 8)); bmpCreate.Frames.Add(BitmapFrame.Create(bmpSource)); bmpCreate.Save(stream); stream.Close(); ConvertFromTileToObject(); AddImageOfObjectToCanvas(); ImportXml.getInstance().loadCanvas(openFileDialogSourcePicture.FileName, WorkspaceWorking); Support.IsBackground = true; } }
public void ExportScripture_NotesOutOfOrder() { IScrSection section = AddSectionToMockedBook(m_book); // Create 2 paragraphs IStTxtPara para1 = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph); IStTxtPara para2 = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph); // Add an annotation to the second paragraph. Ref. // GEN 1 means annotation is in an introduction paragraph. IScrScriptureNote note1 = AddAnnotation( para2, new BCVRef(01001000), NoteType.Consultant, "Annotation1 for Para2"); // Add an annotation to the first paragraph. // GEN 1 means annotation is in an introduction paragraph. IScrScriptureNote note2 = AddAnnotation( para1, new BCVRef(01001000), NoteType.Consultant, "Annotation2 for Para1"); DateTime now = DateTime.Now; string strNow = now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss.ff"); note1.DateCreated = note2.DateCreated = now; note1.DateModified = note2.DateModified = now; note1.DateResolved = note2.DateResolved = now; using (StringWriter stream = new StringWriter()) using (XmlTextWriter writer = new XmlTextWriter(stream)) { writer.WriteStartElement("TestData"); m_exporter = new ExportXml(null, Cache, null, null, ExportWhat.AllBooks, 0, 0, 0, "ExportScripture_NotesOutOfOrder"); ReflectionHelper.SetField(m_exporter, "m_writer", writer); ReflectionHelper.SetField(m_exporter, "m_iCurrentBook", 1); ReflectionHelper.CallMethod(m_exporter, "ExportAnnotationsForObj", para1.Hvo); ReflectionHelper.CallMethod(m_exporter, "ExportAnnotationsForObj", para2.Hvo); writer.WriteEndElement(); string strExpected = "<TestData>" + "<annotation type=\"consultantNote\" status=\"0\" oxesRef=\"GEN.1.0\" " + "beginOffset=\"0\" endOffset=\"0\">" + "<created>" + strNow + "</created>" + "<modified>" + strNow + "</modified>" + "<resolved />" + "<notationDiscussion>" + "<para xml:lang=\"en\">" + "<span>Annotation2 for Para1</span>" + "</para>" + "</notationDiscussion>" + "</annotation>" + "<annotation type=\"consultantNote\" status=\"0\" oxesRef=\"GEN.1.0\" " + "beginOffset=\"0\" endOffset=\"0\">" + "<created>" + strNow + "</created>" + "<modified>" + strNow + "</modified>" + "<resolved />" + "<notationDiscussion>" + "<para xml:lang=\"en\">" + "<span>Annotation1 for Para2</span>" + "</para>" + "</notationDiscussion>" + "</annotation></TestData>"; CompareXmlDocuments(strExpected, stream.ToString()); } }
public void ExportNotationParagraphs_WritingSystems() { IScrSection section = AddSectionToMockedBook(m_book); IStTxtPara para = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph); IScrScriptureNote note = AddAnnotation(para, new BCVRef(01001001), NoteType.Translator, "This is some text with espa\u00F1ol."); ITsStrBldr bldr = ((IStTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents.GetBldr(); int wsEs = Cache.ServiceLocator.WritingSystemManager.GetWsFromStr("es"); bldr.SetProperties(bldr.Length - 9, bldr.Length - 1, StyleUtils.CharStyleTextProps(null, wsEs)); ((IStTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents = bldr.GetString(); using (StringWriter stream = new StringWriter()) using (XmlTextWriter writer = new XmlTextWriter(stream)) { m_exporter = new ExportXml(null, Cache, null, null, ExportWhat.AllBooks, 0, 0, 0, "ExportNotationParagraphs_WritingSystems"); ReflectionHelper.SetField(m_exporter, "m_writer", writer); ReflectionHelper.CallMethod(m_exporter, "ExportNotationParagraphs", note.DiscussionOA, "notationDiscussion"); Assert.AreEqual("<notationDiscussion><para xml:lang=\"en\">" + "<span>This is some text with </span>" + "<span xml:lang=\"es\">espa\u00F1ol</span>" + "<span>.</span>" + "</para></notationDiscussion>", stream.ToString()); } }
public void ExportBookSection_BTIntroWithNotes() { int wsAnal = Cache.DefaultAnalWs; IScrSection introSection = m_scrInMemoryCache.AddIntroSectionToMockedBook(m_book.Hvo); m_scrInMemoryCache.AddSectionHeadParaToSection(introSection.Hvo, "Introduccion", ScrStyleNames.IntroSectionHead); StTxtPara introPara = AddPara(introSection, ScrStyleNames.NormalParagraph); AddVerse(introPara, 0, 0, "Texto de introduccion"); CmTranslation trans = (CmTranslation)m_scrInMemoryCache.AddTransToMockedParagraph(introPara, LangProject.kguidTranBackTranslation, wsAnal); trans.Translation.SetAlternative("Introduction text", wsAnal); ScrScriptureNote note = (ScrScriptureNote)m_scrInMemoryCache.AddAnnotation(trans, 01001000, NoteType.Consultant, "This is a basic note about the BT of an intro."); note.ResolutionStatus = NoteStatus.Open; note.BeginOffset = 0; note.EndOffset = 5; note.WsSelector = wsAnal; DateTime now = DateTime.Now; string strNow = now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss.ff"); note.DateCreated = now; note.DateModified = now; StringWriter stream = new StringWriter(); XmlTextWriter writer = new XmlTextWriter(stream); writer.Formatting = Formatting.None; m_exporter = new ExportXml(null, Cache, null, ExportWhat.AllBooks, 0, 0, 0, "ExportBookSection_IntroWithNotes"); // Initialize writing systems for export (required to export back translations), but // called from ExportTE. ReflectionHelper.CallMethod(m_exporter, "InitializeExportWs", null); ReflectionHelper.SetField(m_exporter, "m_writer", writer); string sCanon = "ot"; ReflectionHelper.CallMethod(m_exporter, "ExportBook", sCanon, m_book, null); XmlDocument actual = new XmlDocument(); actual.Load(new StringReader(stream.ToString())); string strExpected = "<book ID=\"GEN\"><titleGroup short=\"Genesis\"><title type=\"main\">" + "<trGroup><tr>Genesis</tr></trGroup></title></titleGroup>" + "<introduction><section><sectionHead><trGroup><tr>Introduction</tr></trGroup></sectionHead>" + "<p><annotation type=\"consultantNote\" status=\"0\" oxesRef=\"GEN.1.0\" beginOffset=\"0\" " + "endOffset=\"5\" languageInFocus=\"en\">" + "<created>" + strNow + "</created><modified>" + strNow + "</modified>" + "<resolved /><notationDiscussion><para xml:lang=\"en\">" + "<run>This is a basic note about the BT of an intro.</run></para></notationDiscussion></annotation>" + "<trGroup><tr><userCS type=\"Paragraph\">Some intro text</userCS></tr>" + "<bt xml:lang=\"en\">Texto de introduccion</bt></trGroup>" + "<chapterEnd ID=\"GEN.0\"/></p></section></introduction></book>"; XmlDocument expected = new XmlDocument(); expected.Load(new StringReader(strExpected)); string strDifference; if (!XmlHelper.CompareXmlNodes(expected.ChildNodes, actual.ChildNodes, out strDifference)) { Assert.Fail(strDifference); } }
public void ExportNotationParagraphs_Hyperlink() { IScrSection section = AddSectionToMockedBook(m_book); IStTxtPara para = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph); IScrScriptureNote note = AddAnnotation(para, new BCVRef(01001001), NoteType.Translator, "This is some text with a hyperlink!"); ITsStrBldr bldr = ((IStTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents.GetBldr(); var hyperlinkStyle = m_stylesheet.FindStyle(StyleServices.Hyperlink); Assert.IsNotNull(hyperlinkStyle); StringServices.MarkTextInBldrAsHyperlink(bldr, bldr.Length - 10, bldr.Length - 1, "http://www.myspace.com", hyperlinkStyle); ((IStTxtPara)note.DiscussionOA.ParagraphsOS[0]).Contents = bldr.GetString(); using (StringWriter stream = new StringWriter()) using (XmlTextWriter writer = new XmlTextWriter(stream)) { m_exporter = new ExportXml(null, Cache, null, null, ExportWhat.AllBooks, 0, 0, 0, "ExportNotationParagraphs_Hyperlink"); ReflectionHelper.SetField(m_exporter, "m_writer", writer); ReflectionHelper.CallMethod(m_exporter, "ExportNotationParagraphs", note.DiscussionOA, "notationDiscussion"); Assert.AreEqual("<notationDiscussion><para xml:lang=\"en\">" + "<span>This is some text with a </span>" + "<a href=\"http://www.myspace.com\">hyperlink</a>" + "<span>!</span>" + "</para></notationDiscussion>", stream.ToString()); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// test teardown /// </summary> /// ------------------------------------------------------------------------------------ public override void TestTearDown() { m_exporter = null; FileUtils.Delete(m_fileName); m_fileName = null; base.TestTearDown(); }
public void ExportScriptureNote_IgnoredCheckingError() { IScrSection section = AddSectionToMockedBook(m_book); IStTxtPara para = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph); IScrScriptureNote note = AddAnnotation(para, new BCVRef(01001001), NoteType.CheckingError, "This is some basic text."); note.AnnotationTypeRA = Cache.ServiceLocator.GetInstance<ICmAnnotationDefnRepository>().GetObject(StandardCheckIds.kguidRepeatedWords); note.ResolutionStatus = NoteStatus.Closed; DateTime now = DateTime.Now; string strNow = now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss.ff"); note.DateCreated = now; note.DateModified = now; note.DateResolved = now; using (StringWriter stream = new StringWriter()) using (XmlTextWriter writer = new XmlTextWriter(stream)) { m_exporter = new ExportXml(null, Cache, null, null, ExportWhat.AllBooks, 0, 0, 0, "ExportScriptureNote_IgnoredCheckingError"); ReflectionHelper.SetField(m_exporter, "m_writer", writer); ReflectionHelper.CallMethod(m_exporter, "ExportScriptureNote", note); string strExpected = "<annotation subType=\"repeatedWordsCheck\" status=\"1\" oxesRef=\"GEN.1.1\" " + "beginOffset=\"0\" endOffset=\"0\" type=\"pre-typesettingCheck\">" + "<created>" + strNow + "</created>" + "<modified>" + strNow + "</modified>" + "<resolved>" + strNow + "</resolved>" + "<notationDiscussion>" + "<para xml:lang=\"en\">" + "<span>This is some basic text.</span>" + "</para>" + "</notationDiscussion>" + "</annotation>"; CompareXmlDocuments(strExpected, stream.ToString()); } }
public void click_to_load_backgroundmap(object sender, RoutedEventArgs e) { if (Support.map != null) { if (Support.IsSave == false) { MessageBox.Show("Map hiện tại sẽ bị xóa, vui lòng save trước khi tạo mới", "Thông Báo"); } else { Support.IsSave = false; Support.map = null; RemoveAllTileInCanvas(); } } OpenFileDialog openFileDialogSourcePicture = new OpenFileDialog(); openFileDialogSourcePicture.Filter = "PNG (*.png)|*.png| BMP (*.bmp)|*.bmp| All File (*.*)|*.*"; openFileDialogSourcePicture.FilterIndex = 3; openFileDialogSourcePicture.RestoreDirectory = true; if (openFileDialogSourcePicture.ShowDialog() == true) { CTile.CountID = 0; if (Support.map == null) { Support.map = new CMap(new BitmapImage(new Uri(openFileDialogSourcePicture.FileName, UriKind.Absolute))); Support.WIDHT_MAP = (int)(Support.map.BitMap.PixelWidth); Support.HEIGHT_MAP = (int)(Support.map.BitMap.PixelHeight); if (Support.GRIDLINE == true) { DestroyGridline(); Support.GRIDLINE = true; CreateGridline(); } if (Support.IsExportXml == true) { Support.IsExportXml = false; ExportXml.getInstance().DestroyWriter(); } WorkspaceWorking.Width = Support.WIDHT_MAP; WorkspaceWorking.Height = Support.HEIGHT_MAP; Support.map.CreateTileMap(); } } if (Support.map != null) { BitmapSource bmpSource; PngBitmapEncoder bmpCreate = new PngBitmapEncoder(); byte[] arrPixel = new byte[((Support.map.TileMap.Count * Support.WIDTH_OF_TILE * Support.map.BitMap.Format.BitsPerPixel) / 8) * Support.HEIGHT_OF_TILE]; int offsetX = 0; int offsetY = 0; for (int i = 0; i < Support.map.TileMap.Count; ++i) { offsetX = Support.map.TileMap[i].ID; Support.map.TileMap[i].ExportBitMap(offsetX, offsetY, arrPixel, (Support.map.TileMap.Count * Support.WIDTH_OF_TILE * Support.map.BitMap.Format.BitsPerPixel / 8)); } FileStream stream = new FileStream(@"..\..\Resource\tilemap\tile_map.png", FileMode.Create); bmpSource = BitmapSource.Create(Support.map.TileMap.Count * Support.WIDTH_OF_TILE, Support.HEIGHT_OF_TILE, 96, 96, Support.map.BitMap.Format, null, arrPixel, ((Support.map.TileMap.Count * Support.WIDTH_OF_TILE * Support.map.BitMap.Format.BitsPerPixel) / 8)); bmpCreate.Frames.Add(BitmapFrame.Create(bmpSource)); bmpCreate.Save(stream); stream.Close(); ConvertFromTileToObject(); AddImageOfObjectToCanvas(); Support.IsBackground = true; } }
public void ExportScriptureNote_UnknownWsForBt() { IScrSection section = AddSectionToMockedBook(m_book); IStTxtPara para = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph); ICmTranslation trans = AddBtToMockedParagraph(para, Cache.DefaultAnalWs); IScrScriptureNote note = AddAnnotation(trans, new BCVRef(01001001), NoteType.Consultant, "This is some basic text."); note.ResolutionStatus = NoteStatus.Open; DateTime now = DateTime.Now; string strNow = now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss.ff"); note.DateCreated = now; note.DateModified = now; note.WsSelector = -1; // invalid writing system id using (StringWriter stream = new StringWriter()) using (XmlTextWriter writer = new XmlTextWriter(stream)) { m_exporter = new ExportXml(null, Cache, null, null, ExportWhat.AllBooks, 0, 0, 0, "ExportScriptureNote_UnknownWsForBt"); ReflectionHelper.SetField(m_exporter, "m_writer", writer); ReflectionHelper.CallMethod(m_exporter, "ExportScriptureNote", note); string strExpected = "<annotation type=\"consultantNote\" status=\"0\" oxesRef=\"GEN.1.1\" " + "beginOffset=\"0\" endOffset=\"0\">" + "<created>" + strNow + "</created>" + "<modified>" + strNow + "</modified>" + "<resolved />" + "<notationDiscussion>" + "<para xml:lang=\"en\">" + "<span>This is some basic text.</span>" + "</para>" + "</notationDiscussion>" + "</annotation>"; CompareXmlDocuments(strExpected, stream.ToString()); } }
public void ExportParagraph_CharStyleStartingWithSpace() { // Set up vernacular with translation with multiple translations. IScrSection section = AddSectionToMockedBook(m_book); IScrTxtPara para = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph); AddVerse(para, 5, 14, string.Empty); AddRunToMockedPara(para, " Imwe ndimwe cedza ca pa dziko. ", ScrStyleNames.Emphasis); // Set up back translation. ICmTranslation trans = AddBtToMockedParagraph(para, Cache.DefaultAnalWs); AddRunToMockedTrans(trans, Cache.DefaultAnalWs, "1", ScrStyleNames.ChapterNumber); AddRunToMockedTrans(trans, Cache.DefaultAnalWs, "1", ScrStyleNames.VerseNumber); AddSegmentFt(para, 1, "Voces sois a luz do mundo. ", Cache.DefaultAnalWs); // Export the paragraph with segmented back translation turned on. using (StringWriter stream = new StringWriter()) using (XmlTextWriter writer = new XmlTextWriter(stream)) { writer.Formatting = Formatting.None; m_exporter = new ExportXml(null, Cache, null, null, ExportWhat.AllBooks, 0, 0, 0, "ExportParagraph_CharStyleStartingWithSpace"); // Initialize writing systems for export (required to export back translations), but // called from ExportTE. ReflectionHelper.CallMethod(m_exporter, "InitializeExportWs", null); ReflectionHelper.SetField(m_exporter, "m_writer", writer); SetBookInfo(m_book); ReflectionHelper.CallMethod(m_exporter, "ExportParagraph", para, null, true); // Confirm the results. string strExpected = "<p><chapterStart ID=\"GEN.5\" n=\"5\" /><verseStart ID=\"GEN.5.14\" n=\"14\" />" + "<labelTr><emphasis> </emphasis></labelTr>" + "<trGroup><tr><emphasis>Imwe ndimwe cedza ca pa dziko. </emphasis></tr>" + "<bt xml:lang=\"en\" segmented=\"true\">Voces sois a luz do mundo. </bt></trGroup>" + "<verseEnd ID=\"GEN.5.14\" /><chapterEnd ID=\"GEN.5\" /></p>"; CompareXmlDocuments(strExpected, stream.ToString()); } }
public void ExportBookSection_BTIntroWithNotes() { int wsAnal = Cache.DefaultAnalWs; IScrSection introSection = AddSectionToMockedBook(m_book, true); AddSectionHeadParaToSection(introSection, "Introduccion", ScrStyleNames.IntroSectionHead); IScrTxtPara introPara = AddParaToMockedSectionContent(introSection, ScrStyleNames.NormalParagraph); AddVerse(introPara, 0, 0, "Texto de introduccion"); ICmTranslation trans = AddBtToMockedParagraph(introPara, wsAnal); trans.Translation.set_String(wsAnal, TsStringUtils.MakeTss("Introduction text", wsAnal)); IScrScriptureNote note = AddAnnotation(trans, 01001000, NoteType.Consultant, "This is a basic note about the BT of an intro."); note.ResolutionStatus = NoteStatus.Open; note.BeginOffset = 0; note.EndOffset = 5; note.WsSelector = wsAnal; DateTime now = DateTime.Now; string strNow = now.ToUniversalTime().ToString("yyyy-MM-dd HH:mm:ss.ff"); note.DateCreated = now; note.DateModified = now; using (StringWriter stream = new StringWriter()) using (XmlTextWriter writer = new XmlTextWriter(stream)) { writer.Formatting = Formatting.None; m_exporter = new ExportXml(null, Cache, null, null, ExportWhat.AllBooks, 0, 0, 0, "ExportBookSection_BTIntroWithNotes"); // Initialize writing systems for export (required to export back translations), but // called from ExportTE. ReflectionHelper.CallMethod(m_exporter, "InitializeExportWs", null); ReflectionHelper.SetField(m_exporter, "m_writer", writer); string sCanon = "ot"; ReflectionHelper.CallMethod(m_exporter, "ExportBook", sCanon, m_book, null); // Why is the expected text for the translation in English? // The BT is in English, but it is Spanish text that was added as a vernacular. string strExpected = "<book ID=\"GEN\"><titleGroup short=\"Genesis\"><title type=\"main\">" + "<trGroup><tr>Genesis</tr></trGroup></title></titleGroup>" + "<introduction><section><sectionHead><trGroup><tr>Introduccion</tr></trGroup></sectionHead>" + "<p><trGroup><tr>Texto de introduccion</tr>" + "<bt xml:lang=\"en\" segmented=\"true\">Introduction text</bt></trGroup>" + "<annotation type=\"consultantNote\" status=\"0\" oxesRef=\"GEN.1.0\" beginOffset=\"0\" " + "endOffset=\"5\">" + "<created>" + strNow + "</created><modified>" + strNow + "</modified>" + "<resolved /><notationDiscussion><para xml:lang=\"en\">" + "<span>This is a basic note about the BT of an intro.</span></para></notationDiscussion></annotation>" + "</p></section></introduction></book>"; CompareXmlDocuments(strExpected, stream.ToString()); } }
public void ExportParagraph_MultipleSegmentsInVerseWithFootnotes() { // Set up vernacular with translation with multiple translations. IScrBook james = AddBookToMockedScripture(59, "James"); IScrSection section = AddSectionToMockedBook(james); IScrTxtPara para = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph); AddVerse(para, 1, 1, "From James, a servant of the Lord Jesus Christ. Greetings to all God's people. "); IScrFootnote footnote1 = AddFootnote(james, para, 2, "footnote 1"); // add after chapter verse IScrFootnote footnote2 = AddFootnote(james, para, "11XFrom James".Length, "footnote 2"); // X is a spaceholder for footnote // Set up back translation. ICmTranslation trans = AddBtToMockedParagraph(para, Cache.DefaultAnalWs); AddRunToMockedTrans(trans, Cache.DefaultAnalWs, "1", ScrStyleNames.ChapterNumber); AddRunToMockedTrans(trans, Cache.DefaultAnalWs, "1", ScrStyleNames.VerseNumber); AddSegmentFt(para, 1, "Von Jakobus, ein Knecht des Herrn Jesus Christus. ", Cache.DefaultAnalWs); AddSegmentFt(para, 2, "GruBe an das ganze Volk Gottes. ", Cache.DefaultAnalWs); ITsStrBldr tssTransBldr = trans.Translation.get_String(Cache.DefaultAnalWs).GetBldr(); TsStringUtils.InsertOrcIntoPara(footnote1.Guid, FwObjDataTypes.kodtNameGuidHot, tssTransBldr, 2, 2, Cache.DefaultAnalWs); TsStringUtils.InsertOrcIntoPara(footnote2.Guid, FwObjDataTypes.kodtNameGuidHot, tssTransBldr, "11XVon Jakobus".Length, "11XVon Jakobus".Length, Cache.DefaultAnalWs); trans.Translation.set_String(Cache.DefaultAnalWs, tssTransBldr.GetString()); ICmTranslation transFootnote = ((IStTxtPara)footnote1.ParagraphsOS[0]).GetOrCreateBT(); transFootnote.Translation.set_String(Cache.DefaultAnalWs, "fuBnote 1"); transFootnote = ((IStTxtPara)footnote2.ParagraphsOS[0]).GetOrCreateBT(); transFootnote.Translation.set_String(Cache.DefaultAnalWs, "fuBnote 2"); // Export the paragraph with segmented back translation turned on. using (StringWriter stream = new StringWriter()) using (XmlTextWriter writer = new XmlTextWriter(stream)) { writer.Formatting = Formatting.None; m_exporter = new ExportXml(null, Cache, null, null, ExportWhat.SingleBook, 59, 0, 0, "ExportParagraph_MultipleSegmentsInVerseWithFootnotes"); // Initialize writing systems for export (required to export back translations), but // called from ExportTE. ReflectionHelper.CallMethod(m_exporter, "InitializeExportWs", null); ReflectionHelper.SetField(m_exporter, "m_writer", writer); SetBookInfo(james); ReflectionHelper.CallMethod(m_exporter, "ExportParagraph", para, null, true); // Confirm the results. string strExpected = "<p><chapterStart ID=\"JAS.1\" n=\"1\" /><verseStart ID=\"JAS.1.1\" n=\"1\" />" + "<trGroup><tr><note noteID=\"fJAS1\" type=\"general\" canonical=\"true\"><trGroup><tr>footnote 1</tr>" + "<bt xml:lang=\"en\">fuBnote 1</bt></trGroup></note>" + "From James<note noteID=\"fJAS2\" type=\"general\" canonical=\"true\"><trGroup><tr>footnote 2</tr>" + "<bt xml:lang=\"en\">fuBnote 2</bt></trGroup></note>" + ", a servant of the Lord Jesus Christ. </tr>" + "<bt xml:lang=\"en\" segmented=\"true\"><note noteRef=\"fJAS1\"/>Von Jakobus" + "<note noteRef=\"fJAS2\"/>, " + "ein Knecht des Herrn Jesus Christus. </bt></trGroup>" + "<trGroup><tr>Greetings to all God's people. </tr>" + "<bt xml:lang=\"en\" segmented=\"true\">GruBe an das ganze Volk Gottes. </bt></trGroup>" + "<verseEnd ID=\"JAS.1.1\" /><chapterEnd ID=\"JAS.1\" /></p>"; CompareXmlDocuments(strExpected, stream.ToString()); } }
public void ExportParagraph_WithFootnotes() { // Set up vernacular with translation with footnotes that are in the same order as in the // back translation. IScrSection section = AddSectionToMockedBook(m_book); IScrTxtPara para = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph); AddVerse(para, 1, 1, "Mera bhai ne mudj se bataya."); IScrFootnote footnote1 = AddFootnote(m_book, para, "11Mera bhai".Length, "Yohanna"); IScrFootnote footnote2 = AddFootnote(m_book, para, para.Contents.Length, "bat ki"); // Set up back translation. ICmTranslation trans = AddBtToMockedParagraph(para, Cache.DefaultAnalWs); AddRunToMockedTrans(trans, Cache.DefaultAnalWs, "1", ScrStyleNames.ChapterNumber); AddRunToMockedTrans(trans, Cache.DefaultAnalWs, "1", ScrStyleNames.VerseNumber); AddRunToMockedTrans(trans, Cache.DefaultAnalWs, "My brother told me.", null); ITsStrBldr tssTransBldr = trans.Translation.get_String(Cache.DefaultAnalWs).GetBldr(); TsStringUtils.InsertOrcIntoPara(footnote2.Guid, FwObjDataTypes.kodtNameGuidHot, tssTransBldr, "11My brother told".Length, "11My brother told".Length, Cache.DefaultAnalWs); TsStringUtils.InsertOrcIntoPara(footnote1.Guid, FwObjDataTypes.kodtNameGuidHot, tssTransBldr, "11My brother".Length, "11My brother".Length, Cache.DefaultAnalWs); trans.Translation.set_String(Cache.DefaultAnalWs, tssTransBldr.GetString()); ICmTranslation transFootnote = ((IStTxtPara)footnote1.ParagraphsOS[0]).GetOrCreateBT(); transFootnote.Translation.set_String(Cache.DefaultAnalWs, "John"); transFootnote = ((IStTxtPara)footnote2.ParagraphsOS[0]).GetOrCreateBT(); transFootnote.Translation.set_String(Cache.DefaultAnalWs, "said"); // Export the paragraph using (StringWriter stream = new StringWriter()) using (XmlTextWriter writer = new XmlTextWriter(stream)) { writer.Formatting = Formatting.None; m_exporter = new ExportXml(null, Cache, null, null, ExportWhat.AllBooks, 0, 0, 0, "ExportParagraph_WithFootnotes"); // Initialize writing systems for export (required to export back translations), but // called from ExportTE. ReflectionHelper.CallMethod(m_exporter, "InitializeExportWs", null); ReflectionHelper.SetField(m_exporter, "m_writer", writer); SetBookInfo(m_book); ReflectionHelper.CallMethod(m_exporter, "ExportParagraph", para, null, true); // Confirm the results. string strExpected = "<p><chapterStart ID=\"GEN.1\" n=\"1\" /><verseStart ID=\"GEN.1.1\" n=\"1\" />" + "<trGroup><tr>Mera bhai<note noteID=\"fGEN1\" type=\"general\" canonical=\"true\">" + "<trGroup><tr>Yohanna</tr><bt xml:lang=\"en\">John</bt></trGroup></note> ne mudj se bataya." + "<note noteID=\"fGEN2\" type=\"general\" canonical=\"true\">" + "<trGroup><tr>bat ki</tr><bt xml:lang=\"en\">said</bt>" + "</trGroup></note></tr>" + "<bt xml:lang=\"en\" segmented =\"true\">My brother<note noteRef=\"fGEN1\"/> told" + "<note noteRef=\"fGEN2\"/> me.</bt></trGroup>" + "<verseEnd ID=\"GEN.1.1\" /><chapterEnd ID=\"GEN.1\" /></p>"; CompareXmlDocuments(strExpected, stream.ToString()); } }
public void ExportPicture_MultipleWS() { IWritingSystem wsDe = Cache.ServiceLocator.WritingSystemManager.Get("de"); IWritingSystem wsUr = Cache.ServiceLocator.WritingSystemManager.Get("ur"); // Create a picture that has a caption with three different writing systems. ITsStrBldr tssBldr = TsStrBldrClass.Create(); ITsPropsBldr propsBldr = TsPropsBldrClass.Create(); propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, wsDe.Handle); tssBldr.ReplaceRgch(0, 0, "photo", 5, propsBldr.GetTextProps()); propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, wsUr.Handle); tssBldr.ReplaceRgch(tssBldr.Length, tssBldr.Length, " tasvir", 7, propsBldr.GetTextProps()); propsBldr.SetIntPropValues((int)FwTextPropType.ktptWs, 0, Cache.DefaultVernWs); tssBldr.ReplaceRgch(tssBldr.Length, tssBldr.Length, " picture caption", 16, propsBldr.GetTextProps()); ICmPicture picture = Cache.ServiceLocator.GetInstance<ICmPictureFactory>().Create( Path.Combine(Path.GetTempPath(), "filename.jpg"), tssBldr.GetString(), "folder"); // Set up for export using (StringWriter stream = new StringWriter()) using (XmlTextWriter writer = new XmlTextWriter(stream)) { writer.Formatting = Formatting.None; m_exporter = new ExportXml(null, Cache, null, null, ExportWhat.AllBooks, 0, 0, 0, "ExportPicture_MultipleWS"); ReflectionHelper.SetField(m_exporter, "m_writer", writer); // Export the picture to XML ReflectionHelper.CallMethod(m_exporter, "ExportPicture", picture); // Check the results of the exported picture. // Set up expected results. string defaultDir = Path.Combine(Path.GetTempPath(), "filename.jpg"); // TODO (TE-7756): Support OXES export and import of new properties that have been // added to the CmPicture model string strExpected = "<figure src=\"filename.jpg\"><!--path=\"" + defaultDir + "\"-->" + "<caption><trGroup><tr><foreign xml:lang=\"de\">photo</foreign>" + "<foreign xml:lang=\"ur\"> tasvir</foreign> picture caption</tr></trGroup></caption></figure>"; CompareXmlDocuments(strExpected, stream.ToString()); } }
public void ExportParagraph_FootnotesInBtWithDifferentOrder_Segmented() { // Set up vernacular with translation with footnotes that are in a different order // than in the back translation. IScrSection section = AddSectionToMockedBook(m_book); IScrTxtPara para = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph); AddVerse(para, 1, 1, "Me dijo mi mama que si."); IScrFootnote footnote1 = AddFootnote(m_book, para, "11Me dijo".Length, "informo"); IScrFootnote footnote2 = AddFootnote(m_book, para, "11Me dijoX mi mama".Length, "madre"); // Set up back translation. ICmTranslation trans = AddBtToMockedParagraph(para, Cache.DefaultAnalWs); AddRunToMockedTrans(trans, Cache.DefaultAnalWs, "1", ScrStyleNames.ChapterNumber); AddRunToMockedTrans(trans, Cache.DefaultAnalWs, "1", ScrStyleNames.VerseNumber); AddRunToMockedTrans(trans, Cache.DefaultAnalWs, "My mom told me that yes.", null); ITsStrBldr tssTransBldr = trans.Translation.get_String(Cache.DefaultAnalWs).GetBldr(); TsStringUtils.InsertOrcIntoPara(footnote1.Guid, FwObjDataTypes.kodtNameGuidHot, tssTransBldr, "11My mom told".Length, "11My mom told".Length, Cache.DefaultAnalWs); TsStringUtils.InsertOrcIntoPara(footnote2.Guid, FwObjDataTypes.kodtNameGuidHot, tssTransBldr, "11My mom".Length, "11My mom".Length, Cache.DefaultAnalWs); trans.Translation.set_String(Cache.DefaultAnalWs, tssTransBldr.GetString()); ICmTranslation transFootnote = ((IStTxtPara)footnote1.ParagraphsOS[0]).GetOrCreateBT(); transFootnote.Translation.set_String(Cache.DefaultAnalWs, "inform"); transFootnote = ((IStTxtPara)footnote2.ParagraphsOS[0]).GetOrCreateBT(); transFootnote.Translation.set_String(Cache.DefaultAnalWs, "mother"); // Export the paragraph with segmented back translation turned on. using (StringWriter stream = new StringWriter()) using (XmlTextWriter writer = new XmlTextWriter(stream)) { writer.Formatting = Formatting.None; m_exporter = new ExportXml(null, Cache, null, null, ExportWhat.AllBooks, 0, 0, 0, "ExportParagraph_FootnotesInBtWithDifferentOrder_Segmented"); // Initialize writing systems for export (required to export back translations), but // called from ExportTE. ReflectionHelper.CallMethod(m_exporter, "InitializeExportWs", null); ReflectionHelper.SetField(m_exporter, "m_writer", writer); SetBookInfo(m_book); ReflectionHelper.CallMethod(m_exporter, "ExportParagraph", para, null, true); // Confirm the results. string strExpected = "<p><chapterStart ID=\"GEN.1\" n=\"1\" /><verseStart ID=\"GEN.1.1\" n=\"1\" />" + "<trGroup><tr>Me dijo<note noteID=\"fGEN1\" type=\"general\" canonical=\"true\">" + "<trGroup><tr>informo</tr><bt xml:lang=\"en\">inform</bt></trGroup></note> mi mama" + "<note noteID=\"fGEN2\" type=\"general\" canonical=\"true\">" + "<trGroup><tr>madre</tr><bt xml:lang=\"en\">mother</bt>" + "</trGroup></note> que si.</tr>" + "<bt xml:lang=\"en\" segmented=\"true\">My mom<note noteRef=\"fGEN2\"/> told" + "<note noteRef=\"fGEN1\"/> me that yes.</bt></trGroup>" + "<verseEnd ID=\"GEN.1.1\" /><chapterEnd ID=\"GEN.1\" /></p>"; CompareXmlDocuments(strExpected, stream.ToString()); } }
public void ExportParagraph_MultipleSegmentsInVerse() { // Set up vernacular with translation with multiple translations. IScrSection section = AddSectionToMockedBook(m_book); IScrTxtPara para = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph); AddVerse(para, 1, 1, "is jumle me kam alfaz he. us jumla ke alava, ek aur jumla mojud he."); // Set up back translation. ICmTranslation trans = AddBtToMockedParagraph(para, Cache.DefaultAnalWs); AddRunToMockedTrans(trans, Cache.DefaultAnalWs, "1", ScrStyleNames.ChapterNumber); AddRunToMockedTrans(trans, Cache.DefaultAnalWs, "1", ScrStyleNames.VerseNumber); AddSegmentFt(para, 1, "In this sentence, there are few words. ", Cache.DefaultAnalWs); AddSegmentFt(para, 2, "Besides that sentence, one more sentence is present.", Cache.DefaultAnalWs); // Export the paragraph with segmented back translation turned on. using (StringWriter stream = new StringWriter()) using (XmlTextWriter writer = new XmlTextWriter(stream)) { writer.Formatting = Formatting.None; m_exporter = new ExportXml(null, Cache, null, null, ExportWhat.AllBooks, 0, 0, 0, "ExportParagraph_MultipleSegmentsInVerse"); // Initialize writing systems for export (required to export back translations), but // called from ExportTE. ReflectionHelper.CallMethod(m_exporter, "InitializeExportWs", null); ReflectionHelper.SetField(m_exporter, "m_writer", writer); SetBookInfo(m_book); ReflectionHelper.CallMethod(m_exporter, "ExportParagraph", para, null, true); // Confirm the results. string strExpected = "<p><chapterStart ID=\"GEN.1\" n=\"1\" /><verseStart ID=\"GEN.1.1\" n=\"1\" />" + "<trGroup><tr>is jumle me kam alfaz he. </tr>" + "<bt xml:lang=\"en\" segmented=\"true\">In this sentence, there are few words. </bt></trGroup>" + "<trGroup><tr>us jumla ke alava, ek aur jumla mojud he.</tr>" + "<bt xml:lang=\"en\" segmented=\"true\">Besides that sentence, one more sentence is present.</bt></trGroup>" + "<verseEnd ID=\"GEN.1.1\" /><chapterEnd ID=\"GEN.1\" /></p>"; CompareXmlDocuments(strExpected, stream.ToString()); } }