/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor to use when using an in-memory cache /// </summary> /// <param name="settings">Import settings</param> /// <param name="cache">FDO Cache</param> /// <param name="styleSheet">A stylesheet</param> /// <param name="inMemoryCache"> in-memory cache (use null to test against real DB)</param> /// ------------------------------------------------------------------------------------ public DummyTeImporter(ScrImportSet settings, FdoCache cache, FwStyleSheet styleSheet, ScrInMemoryFdoCache inMemoryCache) : base(settings, cache, styleSheet, new DummyUndoImportManager(inMemoryCache), new TeImportNoUi()) { m_inMemoryCache = inMemoryCache; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes the list of style proxies. /// </summary> /// <param name="styleSheet">The style sheet.</param> /// ------------------------------------------------------------------------------------ public static void Initialize(FwStyleSheet styleSheet) { if (s_styleProxies == null) s_styleProxies = new Dictionary<string, ImportStyleProxy>(); s_styleSheet = styleSheet; }
/// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="DummyPublication"/> class. /// </summary> /// ----------------------------------------------------------------------------------- public DummyScripturePublicationNoDb(IPublication pub, FwStyleSheet stylesheet, DivisionLayoutMgr div, DateTime printDateTime, int filterInstance) : base(stylesheet, filterInstance, pub, TeViewType.PrintLayout, printDateTime) { m_printerDpiX = 720.0f; m_printerDpiY = 1440.0f; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Override to start an undoable UOW. /// </summary> /// ------------------------------------------------------------------------------------ public override void TestSetup() { base.TestSetup(); FwStyleSheet styleSheet = new FwStyleSheet(); styleSheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles); Debug.Assert(m_draftView == null); m_draftView = new TeDummyBasicView(); m_draftView.Cache = Cache; m_draftView.Visible = false; m_draftView.StyleSheet = styleSheet; m_draftView.Width = 300; m_draftView.Height = 290; m_draftView.CallLayout(); var exod = CreateExodusData(); var levi = CreateLeviticusData(); ((TeEditingHelper)m_draftView.EditingHelper).BookFilter.Add(new IScrBook[] { exod, levi }); m_actionHandler.EndUndoTask(); // This should cause a PropChanged to update the view m_actionHandler.BeginUndoTask("Test", "Test"); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:TeBtPublication"/> class. /// </summary> /// <param name="stylesheet">The stylesheet to be used for this publication (can be /// different from the one used for drafting, but should probably have all the same /// styles)</param> /// <param name="filterInstance">number used to make filters unique per main window</param> /// <param name="publication">The publication to get the information from (or /// null to keep the defaults)</param> /// <param name="viewType">Type of the view.</param> /// <param name="printDateTime">Date/Time of the printing</param> /// <param name="helpTopicProvider">The help topic provider.</param> /// <param name="app">The app.</param> /// <param name="btWs">Backtranslation WS</param> /// ------------------------------------------------------------------------------------ public TeBtPublication(FwStyleSheet stylesheet, int filterInstance, IPublication publication, TeViewType viewType, DateTime printDateTime, IHelpTopicProvider helpTopicProvider, IApp app, int btWs) : base(stylesheet, filterInstance, publication, viewType, printDateTime, helpTopicProvider, app, btWs) { }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:FwApplyStyleDlg"/> class. /// </summary> /// <param name="rootSite">The root site.</param> /// <param name="cache">The cache.</param> /// <param name="hvoStylesOwner">The hvo of the object which owns the style.</param> /// <param name="stylesTag">The "flid" in which the styles are owned.</param> /// <param name="normalStyleName">Name of the normal style.</param> /// <param name="customUserLevel">The custom user level.</param> /// <param name="paraStyleName">Name of the currently selected paragraph style.</param> /// <param name="charStyleName">Name of the currently selected character style.</param> /// <param name="hvoRootObject">The hvo of the root object in the current view.</param> /// <param name="app">The application.</param> /// <param name="helpTopicProvider">The help topic provider.</param> /// ------------------------------------------------------------------------------------ public FwApplyStyleDlg(IVwRootSite rootSite, FdoCache cache, int hvoStylesOwner, int stylesTag, string normalStyleName, int customUserLevel, string paraStyleName, string charStyleName, int hvoRootObject, IApp app, IHelpTopicProvider helpTopicProvider) { m_rootSite = rootSite; InitializeComponent(); m_customUserLevel = customUserLevel; m_helpTopicProvider = helpTopicProvider; m_paraStyleName = paraStyleName; m_charStyleName = charStyleName; // Cache is null in tests if (cache == null) return; m_cboTypes.SelectedIndex = 1; // All Styles // Load the style information m_styleTable = new StyleInfoTable(normalStyleName, cache.ServiceLocator.WritingSystemManager); m_styleSheet = new FwStyleSheet(); m_styleSheet.Init(cache, hvoStylesOwner, stylesTag); m_styleListHelper = new StyleListBoxHelper(m_lstStyles); m_styleListHelper.ShowInternalStyles = false; }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { // Dispose managed resources here. if (m_cache != null) { UndoResult ures = 0; while (m_cache.CanUndo) { m_cache.Undo(out ures); if (ures == UndoResult.kuresFailed || ures == UndoResult.kuresError) { Assert.Fail("ures should not be == " + ures.ToString()); } } m_cache.Dispose(); } } // Dispose unmanaged resources here, whether disposing is true or false. m_cache = null; m_styleSheet = null; base.Dispose(disposing); }
public void DefaultFontAndLineHeightUsed() { m_pub.BaseFontSize = 0; m_pub.BaseLineSpacing = 0; m_inMemoryCache.CreateDefaultLangProjStyles(); FwStyleSheet stylesheet = new FwStyleSheet(); stylesheet.Init(Cache, Cache.LangProject.Hvo, (int)LangProject.LangProjectTags.kflidStyles); DummyDivision divLayoutMgr = new DummyDivision(new DummyPrintConfigurer(Cache, null), 1); ReallyStupidPubCtrl pubControl = new ReallyStupidPubCtrl(m_pub, stylesheet, divLayoutMgr, DateTime.Now, true); ITsTextProps normalProps = pubControl.PrintLayoutStylesheet.GetStyleRgch(-1, "Normal"); Assert.IsNotNull(normalProps); int var; Assert.AreEqual(pubControl.DefaultFontSize, normalProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out var)); Assert.AreEqual((int)FwTextPropVar.ktpvMilliPoint, var); Assert.AreEqual(pubControl.DefaultLineHeight, normalProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out var)); Assert.AreEqual((int)FwTextPropVar.ktpvMilliPoint, var); }
private void SetStyleSheet(int hvo) { var text = hvo == 0 ? null : (IStText)Cache.ServiceLocator.GetObject(hvo); IVwStylesheet wantedStylesheet = m_styleSheet; if (text != null && ScriptureServices.ScriptureIsResponsibleFor(text)) { // Use the Scripture stylesheet if (m_teStylesheet == null) { m_flexStylesheet = m_styleSheet; // remember the default. var stylesheet = new FwStyleSheet(); stylesheet.Init(Cache, Cache.LangProject.TranslatedScriptureOA.Hvo, ScriptureTags.kflidStyles); m_teStylesheet = stylesheet; } wantedStylesheet = m_teStylesheet; } else if (m_flexStylesheet != null) { wantedStylesheet = m_flexStylesheet; } if (wantedStylesheet != m_styleSheet) { m_styleSheet = wantedStylesheet; // Todo: set up the comobo; set the main window one. } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Writes this response to the the specified annotation /// </summary> /// ------------------------------------------------------------------------------------ public void WriteToCache(IScrScriptureNote ann, FwStyleSheet styleSheet) { ParagraphCollection parasResponse = new ParagraphCollection(Paragraphs, styleSheet); ParagraphCollection.ParaMatchType type; int matchIndex = FindMatchingResponse(parasResponse, ann.ResponsesOS, out type); switch (type) { case ParagraphCollection.ParaMatchType.Exact: case ParagraphCollection.ParaMatchType.Contains: break; // we can ignore the new response -- it's a subset of the old. case ParagraphCollection.ParaMatchType.IsContained: IStJournalText oldText = ann.ResponsesOS[matchIndex]; oldText.ParagraphsOS.Clear(); parasResponse.WriteToCache(oldText); break; case ParagraphCollection.ParaMatchType.None: IStJournalText newText = ann.Cache.ServiceLocator.GetInstance <IStJournalTextFactory>().Create(); ann.ResponsesOS.Add(newText); parasResponse.WriteToCache(newText); break; } }
///------------------------------------------------------------------------------- /// <summary> /// Constructor for import dialog, requiring a language project. /// Use this constructor at run time. /// </summary> ///------------------------------------------------------------------------------- public ImportDialog(FwStyleSheet styleSheet, FdoCache cache, IScrImportSet settings, IHelpTopicProvider helpTopicProvider, IApp app) : this() { m_StyleSheet = styleSheet; m_helpTopicProvider = helpTopicProvider; m_app = app; m_scr = cache.LangProject.TranslatedScriptureOA; m_importSettings = settings; //InitBookNameList(); // Set the initial values for the controls from the static variables. radImportEntire.Checked = ImportEntire; radImportRange.Checked = !ImportEntire; chkTranslation.Checked = ImportTranslation; chkBackTranslation.Checked = ImportBackTranslation; chkBookIntros.Checked = ImportBookIntros; chkOther.Checked = ImportAnnotations; // Restore any saved settings. if (s_StartRef != null) StartRef = s_StartRef; else SetStartRefToFirstImportableBook(); if (s_EndRef != null) EndRef = s_EndRef; else SetEndRefToLastImportableBook(); // Finish constructing the ScrBookControl objects. InitializeStartAndEndRefControls(); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Clean up any resources being used. /// </summary> /// ----------------------------------------------------------------------------------- protected override void Dispose(bool fDisposing) { System.Diagnostics.Debug.WriteLineIf(!fDisposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** "); base.Dispose(fDisposing); if (fDisposing) { if (components != null) { components.Dispose(); } if (m_draftView != null) { m_draftView.Dispose(); } if (m_isNewCache && (m_cache != null)) { m_cache.Dispose(); // Only if we made it. } if (m_Persistence != null) { m_Persistence.Dispose(); } } m_cache = null; m_draftView = null; m_styleSheet = null; m_rootb = null; m_Persistence = null; }
public void LoadParatextMappings_Normal() { if (ScriptureProvider.VersionInUse >= new Version(8, 0)) { Assert.Ignore("This test uses data that is only valid for Paratext7. The test fails with Paratext8 installed."); } Unpacker.UnPackParatextTestProjects(); var stylesheet = new FwStyleSheet(); stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles); IScrImportSet importSettings = Cache.ServiceLocator.GetInstance <IScrImportSetFactory>().Create(); Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(importSettings); importSettings.ParatextScrProj = "KAM"; ParatextHelper.LoadProjectMappings(importSettings); ScrMappingList mappingList = importSettings.GetMappingListForDomain(ImportDomain.Main); // Test to see that the projects are set correctly Assert.AreEqual(44, mappingList.Count); Assert.AreEqual(MarkerDomain.Default, mappingList[@"\c"].Domain); Assert.AreEqual(MarkerDomain.Default, mappingList[@"\v"].Domain); Assert.AreEqual(@"\f*", mappingList[@"\f"].EndMarker); Assert.IsTrue(mappingList[@"\p"].IsInUse); Assert.IsFalse(mappingList[@"\tb2"].IsInUse); }
public void LoadParatextMappings_MarkMappingsInUse() { if (ScriptureProvider.VersionInUse >= new Version(8, 0)) { Assert.Ignore("This test uses data that is only valid for Paratext7. The test fails with Paratext8 installed."); } var stylesheet = new FwStyleSheet(); stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles); IScrImportSet importSettings = Cache.ServiceLocator.GetInstance <IScrImportSetFactory>().Create(); Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(importSettings); importSettings.ParatextScrProj = "TEV"; ScrMappingList mappingList = importSettings.GetMappingListForDomain(ImportDomain.Main); mappingList.Add(new ImportMappingInfo(@"\hahaha", @"\*hahaha", false, MappingTargetType.TEStyle, MarkerDomain.Default, "laughing", null, null, true, ImportDomain.Main)); mappingList.Add(new ImportMappingInfo(@"\bthahaha", @"\*bthahaha", false, MappingTargetType.TEStyle, MarkerDomain.Default, "laughing", "en", null, true, ImportDomain.Main)); Unpacker.UnPackParatextTestProjects(); ParatextHelper.LoadProjectMappings(importSettings); Assert.IsTrue(mappingList[@"\c"].IsInUse); Assert.IsTrue(mappingList[@"\p"].IsInUse); Assert.IsFalse(mappingList[@"\ipi"].IsInUse); Assert.IsFalse(mappingList[@"\hahaha"].IsInUse, "In-use flag should have been cleared before re-scanning when the P6 project changed."); Assert.IsTrue(mappingList[@"\bthahaha"].IsInUse, "In-use flag should not have been cleared before re-scanning when the P6 project changed because it was in use by the BT."); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="T:FwApplyStyleDlg"/> class. /// </summary> /// <param name="rootSite">The root site.</param> /// <param name="cache">The cache.</param> /// <param name="hvoStylesOwner">The hvo of the object which owns the style.</param> /// <param name="stylesTag">The "flid" in which the styles are owned.</param> /// <param name="normalStyleName">Name of the normal style.</param> /// <param name="customUserLevel">The custom user level.</param> /// <param name="paraStyleName">Name of the currently selected paragraph style.</param> /// <param name="charStyleName">Name of the currently selected character style.</param> /// <param name="hvoRootObject">The hvo of the root object in the current view.</param> /// <param name="app">The application.</param> /// <param name="helpTopicProvider">The help topic provider.</param> /// ------------------------------------------------------------------------------------ public FwApplyStyleDlg(IVwRootSite rootSite, FdoCache cache, int hvoStylesOwner, int stylesTag, string normalStyleName, int customUserLevel, string paraStyleName, string charStyleName, int hvoRootObject, IApp app, IHelpTopicProvider helpTopicProvider) { m_rootSite = rootSite; InitializeComponent(); m_customUserLevel = customUserLevel; m_helpTopicProvider = helpTopicProvider; m_paraStyleName = paraStyleName; m_charStyleName = charStyleName; // Cache is null in tests if (cache == null) { return; } m_cboTypes.SelectedIndex = 1; // All Styles // Load the style information m_styleTable = new StyleInfoTable(normalStyleName, cache.ServiceLocator.WritingSystemManager); m_styleSheet = new FwStyleSheet(); m_styleSheet.Init(cache, hvoStylesOwner, stylesTag); m_styleListHelper = new StyleListBoxHelper(m_lstStyles); m_styleListHelper.ShowInternalStyles = false; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="TeImportManager"/> class. /// </summary> /// <param name="mainWnd">The main window initiating the import</param> /// <param name="styleSheet">The stylesheet.</param> /// <param name="app">The app.</param> /// <param name="fParatextStreamlinedImport">if set to <c>true</c> do a Paratext /// streamlined import (minimal UI).</param> /// ------------------------------------------------------------------------------------ internal TeImportManager(Form mainWnd, FwStyleSheet styleSheet, FwApp app, bool fParatextStreamlinedImport) : this(app.Cache, styleSheet, app, fParatextStreamlinedImport) { m_mainWnd = mainWnd; m_importCallbacks = new DummyImportCallbacks(); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged /// resources; <c>false</c> to release only unmanaged resources. /// </param> /// ----------------------------------------------------------------------------------- protected override void Dispose(bool disposing) { System.Diagnostics.Debug.WriteLineIf(!disposing, "****** Missing Dispose() call for " + GetType().Name + ". ****** "); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { if (components != null) { components.Dispose(); } if (m_styleListHelper != null) { m_styleListHelper.Dispose(); } } m_styleListHelper = null; m_StyleSheet = null; m_mapping = null; m_cache = null; m_scr = null; base.Dispose(disposing); }
public override void Initialize() { CheckDisposed(); base.Initialize(); m_fdoCache = Cache; // Setup the stylesheet. IStStyle captionStyle = AddTestStyle("Caption", ContextValues.Internal, StructureValues.Body, FunctionValues.Prose, false, Cache.LangProject.StylesOC); m_styleSheet = new FwStyleSheet(); ((FwStyleSheet)m_styleSheet).Init(m_fdoCache, m_lp.Hvo, (int)LangProject.LangProjectTags.kflidStyles); Debug.Assert(m_stylesComboBox == null, "m_stylesComboBox is not null."); //if (m_stylesComboBox != null) // m_stylesComboBox.Dispose(); m_stylesComboBox = new ComboBox(); m_styleListHelper = new StyleComboListHelper(m_stylesComboBox); // Set the options to display all of the styles m_styleListHelper.MaxStyleLevel = int.MaxValue; }
/// ----------------------------------------------------------------------------------- /// <summary> /// Creates and opens a <see cref="DummyFootnoteView"/> in a form. Loads scripture /// footnotes from the DB. /// </summary> /// ----------------------------------------------------------------------------------- public void CreateFootnoteView(FdoCache cache) { CheckDisposed(); Cache = cache; FwStyleSheet styleSheet = new FwStyleSheet(); ILangProject lgproj = Cache.LangProject; IScripture scripture = lgproj.TranslatedScriptureOA; styleSheet.Init(Cache, scripture.Hvo, (int)Scripture.ScriptureTags.kflidStyles); m_footnoteView = new DummyFootnoteView(Cache); m_footnoteView.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom; m_footnoteView.Dock = DockStyle.Fill; m_footnoteView.Name = "footnoteView"; // make sure book filter is created before view constructor is created. int nbook = m_footnoteView.BookFilter.BookCount; m_footnoteView.MakeRoot(); m_footnoteView.Visible = true; m_footnoteView.StyleSheet = styleSheet; Controls.Add(m_footnoteView); m_footnoteView.ActivateView(); }
private void RunStyleDialog(string styleName) { using (var dlg = new FwStylesDlg(null, m_cache, m_stylesheet, m_cache.WritingSystemFactory.get_EngineOrNull(m_cache.DefaultUserWs).RightToLeftScript, m_cache.ServiceLocator.WritingSystems.AllWritingSystems.Any(ws => ws.RightToLeftScript), m_stylesheet.GetDefaultBasedOnStyleName(), 0, // customUserLevel m_app.MeasurementSystem, styleName, //m_stylesheet.GetDefaultBasedOnStyleName(), styleName, 0, // hvoRootObject m_app, m_helpTopicProvider)) { dlg.ShowTEStyleTypes = false; dlg.CanSelectParagraphBackgroundColor = false; if (dlg.ShowDialog(this) == DialogResult.OK && dlg.ChangeType != StyleChangeType.None) { m_app.Synchronize(SyncMsg.ksyncStyle); FwStyleSheet stylesheet = new FwStyleSheet(); stylesheet.Init(m_cache, m_cache.LangProject.Hvo, LangProjectTags.kflidStyles); m_stylesheet = stylesheet; m_masterRefreshRequired = true; } } }
private void m_btnStyles_Click(object sender, EventArgs e) { bool fRTL = m_cache.WritingSystemFactory.get_EngineOrNull(m_cache.DefaultUserWs).RightToLeftScript; using (var dlg = new FwStylesDlg(null, m_cache, m_stylesheet as FwStyleSheet, fRTL, m_cache.ServiceLocator.WritingSystems.AllWritingSystems.Any(ws => ws.RightToLeftScript), m_stylesheet.GetDefaultBasedOnStyleName(), 0, // customUserLevel m_app.MeasurementSystem, m_stylesheet.GetDefaultBasedOnStyleName(), String.Empty, 0, // hvoRootObject m_app, m_helpTopicProvider)) { dlg.ShowTEStyleTypes = false; dlg.CanSelectParagraphBackgroundColor = false; if (dlg.ShowDialog(this) == DialogResult.OK && ((dlg.ChangeType & StyleChangeType.DefChanged) > 0 || (dlg.ChangeType & StyleChangeType.Added) > 0 || (dlg.ChangeType & StyleChangeType.RenOrDel) > 0)) { m_app.Synchronize(SyncMsg.ksyncStyle); FwStyleSheet stylesheet = new FwStyleSheet(); stylesheet.Init(m_cache, m_cache.LangProject.Hvo, LangProjectTags.kflidStyles); m_stylesheet = stylesheet; } string stySel = null; if (m_cbStyle.SelectedItem != null) { stySel = m_cbStyle.SelectedItem.ToString(); } FillStylesCombo(stySel); } }
public void PublicationFontAndLineHeightUsed() { m_pub.BaseFontSize = 9000; m_pub.BaseLineSpacing = -11000; FwStyleSheet stylesheet = new FwStyleSheet(); stylesheet.Init(Cache, Cache.LangProject.TranslatedScriptureOA.Hvo, ScriptureTags.kflidStyles); using (DummyDivision divLayoutMgr = new DummyDivision(new DummyPrintConfigurer(Cache, null), 1)) { using (ReallyStupidPubCtrl pubControl = new ReallyStupidPubCtrl(m_pub, stylesheet, divLayoutMgr, DateTime.Now, true)) { ITsTextProps normalProps = pubControl.PrintLayoutStylesheet.GetStyleRgch(-1, "Normal"); Assert.IsNotNull(normalProps); int var; Assert.AreEqual(9000, normalProps.GetIntPropValues((int)FwTextPropType.ktptFontSize, out var)); Assert.AreEqual((int)FwTextPropVar.ktpvMilliPoint, var); Assert.AreEqual(-11000, normalProps.GetIntPropValues((int)FwTextPropType.ktptLineHeight, out var)); Assert.AreEqual((int)FwTextPropVar.ktpvMilliPoint, var); } } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="TeImportManager"/> class. /// </summary> /// <remarks>This version is for testing only</remarks> /// <param name="cache">The cache.</param> /// <param name="styleSheet">The style sheet.</param> /// ------------------------------------------------------------------------------------ protected TeImportManager(FdoCache cache, FwStyleSheet styleSheet) { m_mainWnd = null; m_cache = cache; m_styleSheet = styleSheet; m_bookFilter = null; // not used in testing }
/// ------------------------------------------------------------------------------------ /// <summary> /// Loads the specified file. /// </summary> /// <param name="filename">The name of the OXESA file.</param> /// <param name="cache">The cache.</param> /// <param name="styleSheet">The style sheet.</param> /// <returns>A loaded ScrAnnotationsList</returns> /// ------------------------------------------------------------------------------------ public static XmlScrAnnotationsList LoadFromFile(string filename, FdoCache cache, FwStyleSheet styleSheet) { Exception e; return(LoadFromFile(filename, cache, styleSheet, out e)); }
public void LoadParatextMappings_MarkMappingsInUse() { FwStyleSheet stylesheet = new FwStyleSheet(); stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles); ScrMappingList mappingList = new ScrMappingList(MappingSet.Main, stylesheet); mappingList.Add(new ImportMappingInfo(@"\hahaha", @"\*hahaha", false, MappingTargetType.TEStyle, MarkerDomain.Default, "laughing", null, null, true, ImportDomain.Main)); mappingList.Add(new ImportMappingInfo(@"\bthahaha", @"\*bthahaha", false, MappingTargetType.TEStyle, MarkerDomain.Default, "laughing", "en", null, true, ImportDomain.Main)); Unpacker.UnPackParatextTestProjects(); IParatextAdapter sut = new ParatextProxy(); Assert.IsTrue(sut.LoadProjectMappings("TEV", mappingList, ImportDomain.Main)); Assert.IsTrue(mappingList[@"\c"].IsInUse); Assert.IsTrue(mappingList[@"\p"].IsInUse); Assert.IsFalse(mappingList[@"\ipi"].IsInUse); Assert.IsFalse(mappingList[@"\hahaha"].IsInUse, "In-use flag should have been cleared before re-scanning when the P6 project changed."); Assert.IsTrue(mappingList[@"\bthahaha"].IsInUse, "In-use flag should not have been cleared before re-scanning when the P6 project changed because it was in use by the BT."); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Convert each of the child paragraphs into an ITsString object, and add that object /// to the given list. If the paragraph's writing system cannot be found, then the /// specified default writing system is used. /// </summary> /// ----------------------------------------------------------------------------------- public StTxtParaBldr BuildParagraph(FwStyleSheet styleSheet, int wsDefault) { StTxtParaBldr bldr; int wsPara = (string.IsNullOrEmpty(IcuLocale) ? wsDefault : ScrNoteImportManager.GetWsForLocale(IcuLocale)); bldr = new StTxtParaBldr(styleSheet.Cache); string stylename = (string.IsNullOrEmpty(StyleName) ? ScrStyleNames.Remark : StyleName); bldr.ParaStylePropsProxy = StyleProxyListManager.GetXmlParaStyleProxy( stylename, ContextValues.Annotation, wsDefault); foreach (XmlTextRun run in Runs) { int ws = (string.IsNullOrEmpty(run.IcuLocale) ? wsPara : ScrNoteImportManager.GetWsForLocale(run.IcuLocale)); run.AddToParaBldr(bldr, ws, styleSheet); } // OXES supports mixed text so this is designed to handle text that // is found in the "para" tag but not in any "span" or "a" tag. if (!string.IsNullOrEmpty(m_text)) { XmlTextRun extraText = new XmlTextRun(); extraText.Text = m_text; extraText.AddToParaBldr(bldr, wsPara, styleSheet); } return(bldr); }
/// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { // Dispose managed resources here. if (m_stylesComboBox != null) { m_stylesComboBox.Dispose(); } } // Dispose unmanaged resources here, whether disposing is true or false. m_stylesComboBox = null; m_styleListHelper = null; m_styleSheet = null; m_lp = null; base.Dispose(disposing); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Executes in two distinct scenarios. /// /// 1. If disposing is true, the method has been called directly /// or indirectly by a user's code via the Dispose method. /// Both managed and unmanaged resources can be disposed. /// /// 2. If disposing is false, the method has been called by the /// runtime from inside the finalizer and you should not reference (access) /// other managed objects, as they already have been garbage collected. /// Only unmanaged resources can be disposed. /// </summary> /// <param name="disposing"></param> /// <remarks> /// If any exceptions are thrown, that is fine. /// If the method is being done in a finalizer, it will be ignored. /// If it is thrown by client code calling Dispose, /// it needs to be handled by fixing the bug. /// /// If subclasses override this method, they should call the base implementation. /// </remarks> /// ------------------------------------------------------------------------------------ protected override void Dispose(bool disposing) { //Debug.WriteLineIf(!disposing, "****************** " + GetType().Name + " 'disposing' is false. ******************"); // Must not be run more than once. if (IsDisposed) { return; } if (disposing) { // Dispose managed resources here. if (m_importer != null) { m_importer.Dispose(); } } // Dispose unmanaged resources here, whether disposing is true or false. m_styleSheet = null; // FwStyleSheet should implement IDisposable. m_settings = null; m_importer = null; // TeImporter should implement IDisposable. if (m_ttpVernWS != null) { // Marshal.ReleaseComObject(m_ttpVernWS); m_ttpVernWS = null; } if (m_ttpAnalWS != null) { // Marshal.ReleaseComObject(m_ttpAnalWS); m_ttpAnalWS = null; } base.Dispose(disposing); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { m_stylesheet = new FwStyleSheet(); m_stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles); m_exodus = AddBookToMockedScripture(2, "Exodus"); AddTitleToMockedBook(m_exodus, "Exodus"); IScrSection section = AddSectionToMockedBook(m_exodus); AddSectionHeadParaToSection(section, "Section Heading", ScrStyleNames.SectionHead); IScrTxtPara para = AddParaToMockedSectionContent(section, ScrStyleNames.NormalParagraph); AddRunToMockedPara(para, "1", ScrStyleNames.ChapterNumber); AddRunToMockedPara(para, "1", ScrStyleNames.VerseNumber); AddRunToMockedPara(para, "Verse one. ", null); AddRunToMockedPara(para, "2", ScrStyleNames.VerseNumber); AddRunToMockedPara(para, "Verse two.", null); AddRunToMockedPara(para, "3", ScrStyleNames.VerseNumber); AddRunToMockedPara(para, "Verse three.", null); AddRunToMockedPara(para, "4", ScrStyleNames.VerseNumber); AddRunToMockedPara(para, "Verse four. ", null); AddRunToMockedPara(para, "5", ScrStyleNames.VerseNumber); AddRunToMockedPara(para, "Verse five.", null); AddRunToMockedPara(para, "6", ScrStyleNames.VerseNumber); AddRunToMockedPara(para, "Verse six. ", null); AddRunToMockedPara(para, "7", ScrStyleNames.VerseNumber); AddRunToMockedPara(para, "Verse seven.", null); AddRunToMockedPara(para, "8", ScrStyleNames.VerseNumber); AddRunToMockedPara(para, "Verse seven.", null); AddRunToMockedPara(para, "9", ScrStyleNames.VerseNumber); AddRunToMockedPara(para, "Verse seven.", null); AddRunToMockedPara(para, "10", ScrStyleNames.VerseNumber); AddRunToMockedPara(para, "Verse seven.", null); }
private IScrScriptureNote FindOrCreateAnnotation(FwStyleSheet styleSheet) { FdoCache cache = styleSheet.Cache; ParagraphCollection parasQuote = new ParagraphCollection(Quote, styleSheet, cache.DefaultVernWs); ParagraphCollection parasDiscussion = new ParagraphCollection(Discussion, styleSheet); ParagraphCollection parasRecommendation = new ParagraphCollection(Suggestion, styleSheet); ParagraphCollection parasResolution = new ParagraphCollection(Resolution, styleSheet); if (m_guidType == Guid.Empty) { m_guidType = CmAnnotationDefnTags.kguidAnnConsultantNote; } ScrAnnotationInfo info = new ScrAnnotationInfo(m_guidType, parasDiscussion, parasQuote, parasRecommendation, parasResolution, BeginOffset, BeginScrBCVRef, EndScrBCVRef, m_createdDate); IScrScriptureNote scrNote = ScrNoteImportManager.FindOrCreateAnnotation(info, m_guidBegObj); parasQuote.WriteToCache(scrNote.QuoteOA); parasDiscussion.WriteToCache(scrNote.DiscussionOA); parasRecommendation.WriteToCache(scrNote.RecommendationOA); parasResolution.WriteToCache(scrNote.ResolutionOA); return(scrNote); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Called to make the test data for the tests /// </summary> /// ------------------------------------------------------------------------------------ protected override void CreateTestData() { base.CreateTestData(); m_pub = m_scr.PublicationsOC.ToArray()[0]; Assert.IsNotNull(m_pub); m_realStylesheet = new FwStyleSheet(); m_realStylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles); SetFontSizeLineHeightAndSpaceBeforeAfter(m_realStylesheet, ScrStyleNames.Normal, null, 10000, -12000, -1, -1); SetFontSizeLineHeightAndSpaceBeforeAfter(m_realStylesheet, ScrStyleNames.NormalParagraph, ScrStyleNames.Normal, -1, -1, -1, -1); SetFontSizeLineHeightAndSpaceBeforeAfter(m_realStylesheet, ScrStyleNames.NormalFootnoteParagraph, ScrStyleNames.NormalParagraph, 8000, 10000, -1, -1); SetFontSizeLineHeightAndSpaceBeforeAfter(m_realStylesheet, ScrStyleNames.IntroParagraph, ScrStyleNames.NormalParagraph, 9000, -11000, -1, -1); SetFontSizeLineHeightAndSpaceBeforeAfter(m_realStylesheet, ScrStyleNames.IntroSectionHead, ScrStyleNames.SectionHead, 8000, -10000, -1, -1); SetFontSizeLineHeightAndSpaceBeforeAfter(m_realStylesheet, ScrStyleNames.SectionHead, ScrStyleNames.NormalParagraph, 9000, -1, 8000, 4000); SetFontSizeLineHeightAndSpaceBeforeAfter(m_realStylesheet, ScrStyleNames.MainBookTitle, ScrStyleNames.SectionHead, 20000, -24000, 36000, 12000); m_pub.DivisionsOS.Add(Cache.ServiceLocator.GetInstance <IPubDivisionFactory>().Create()); }
public void LoadParatextMappings_MarkMappingsInUse() { var stylesheet = new FwStyleSheet(); stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles); IScrImportSet importSettings = Cache.ServiceLocator.GetInstance <IScrImportSetFactory>().Create(); importSettings.ParatextScrProj = "TEV"; ScrMappingList mappingList = importSettings.GetMappingListForDomain(ImportDomain.Main); mappingList.Add(new ImportMappingInfo(@"\hahaha", @"\*hahaha", false, MappingTargetType.TEStyle, MarkerDomain.Default, "laughing", null, null, true, ImportDomain.Main)); mappingList.Add(new ImportMappingInfo(@"\bthahaha", @"\*bthahaha", false, MappingTargetType.TEStyle, MarkerDomain.Default, "laughing", "en", null, true, ImportDomain.Main)); Unpacker.UnPackParatextTestProjects(); ParatextHelper.LoadProjectMappings(importSettings); Assert.IsTrue(mappingList[@"\c"].IsInUse); Assert.IsTrue(mappingList[@"\p"].IsInUse); Assert.IsFalse(mappingList[@"\ipi"].IsInUse); Assert.IsFalse(mappingList[@"\hahaha"].IsInUse, "In-use flag should have been cleared before re-scanning when the P6 project changed."); Assert.IsTrue(mappingList[@"\bthahaha"].IsInUse, "In-use flag should not have been cleared before re-scanning when the P6 project changed because it was in use by the BT."); }
public virtual void Initialize() { CheckDisposed(); Debug.Assert(m_fdoCache == null, "m_fdoCache is not null."); //if (m_fdoCache != null) // m_fdoCache.Dispose(); m_fdoCache = GetCache(); FwStyleSheet styleSheet = new FwStyleSheet(); ILangProject lgproj = m_fdoCache.LangProject; IScripture scripture = lgproj.TranslatedScriptureOA; styleSheet.Init(m_fdoCache, scripture.Hvo, (int)Scripture.ScriptureTags.kflidStyles); Debug.Assert(m_basicView == null, "m_basicView is not null."); //if (m_basicView != null) // m_basicView.Dispose(); m_basicView = new DummyBasicView(); m_basicView.Cache = m_fdoCache; m_basicView.Visible = false; m_basicView.StyleSheet = styleSheet; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="DummyImportWizard"/> class. /// </summary> /// <param name="cache">The database cache.</param> /// <param name="scr">The Scripture object.</param> /// <param name="styleSheet">The style sheet.</param> /// ------------------------------------------------------------------------------------ public DummyImportWizard(FdoCache cache, Scripture scr, FwStyleSheet styleSheet) : base("LANG. PROJ. TEST NAME.", scr, styleSheet, cache) { m_lvCurrentMappingList = lvScrMappings; m_btnCurrentModifyButton = m_btnModifyScrMapping; m_btnCurrentDeleteButton = m_btnDeleteScrMapping; }
public override void TestTearDown() { m_phm = null; m_phmBkRef = null; m_stylesheet = null; base.TestTearDown(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="TeImportManager"/> class. /// </summary> /// <param name="mainWnd">The main window we belong to</param> /// <param name="importCallbacks">The import callbacks.</param> /// ------------------------------------------------------------------------------------ protected TeImportManager(FwMainWnd mainWnd, ITeImportCallbacks importCallbacks) { m_mainWnd = mainWnd; m_cache = m_mainWnd.Cache; m_styleSheet = m_mainWnd.StyleSheet; m_importCallbacks = importCallbacks; m_bookFilter = m_importCallbacks.BookFilter; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initialize the FDO cache and open database /// </summary> /// ------------------------------------------------------------------------------------ public override void TestSetup() { base.TestSetup(); m_stylesheet = new FwStyleSheet(); m_stylesheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles); StyleProxyListManager.Initialize(m_stylesheet); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Set up Undo action and initialize the stylesheet /// </summary> /// ------------------------------------------------------------------------------------ public override void TestSetup() { base.TestSetup(); m_styleSheet = new FwStyleSheet(); // Force load of styles IScripture scr = Cache.LangProject.TranslatedScriptureOA; Assert.IsTrue(scr.StylesOC.Count > 0); m_styleSheet.Init(Cache, scr.Hvo, ScriptureTags.kflidStyles); }
/// ------------------------------------------------------------------------------------ /// <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> /// Initialize the FDO cache and open database /// </summary> /// ------------------------------------------------------------------------------------ public override void Initialize() { base.Initialize(); m_scrInMemoryCache.InitializeWritingSystemEncodings(); m_scrInMemoryCache.InitializeAnnotationDefs(); m_scrInMemoryCache.InitializeScrAnnotationCategories(); m_stylesheet = new FwStyleSheet(); m_stylesheet.Init(Cache, m_scr.Hvo, (int)Scripture.ScriptureTags.kflidStyles); StyleProxyListManager.Initialize(m_stylesheet); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor for runtime. /// </summary> /// <param name="mapping">Provides intial values displayed in dialog.</param> /// <param name="styleSheet">Provides the character styles user can pick from.</param> /// <param name="cache">The DB cache</param> /// <param name="fIsAnnotation">if set to <c>true</c> the current tab is for /// annotations.</param> /// <param name="helpTopicProvider">The help topic provider.</param> /// <param name="app">The application</param> /// ------------------------------------------------------------------------------------ public CharacterMappingSettings(ImportMappingInfo mapping, FwStyleSheet styleSheet, FdoCache cache, bool fIsAnnotation, IHelpTopicProvider helpTopicProvider, IApp app) : this() { m_resources = new ResourceManager("SIL.FieldWorks.TE.ScrImportComponents", Assembly.GetExecutingAssembly()); m_cache = cache; m_helpTopicProvider = helpTopicProvider; m_app = app; m_styleSheet = styleSheet; InitializeControls(mapping, fIsAnnotation); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructs a KeyTermsViewWrapper /// </summary> /// <param name="parent">The parent of the split wrapper (can be null). Will be replaced /// with real parent later.</param> /// <param name="cache">The Cache to give to the views</param> /// <param name="draftViewProxy">View proxy for creating the draft view to display in /// the lower right corner</param> /// <param name="settingsRegKey">The parent control's ISettings registry key</param> /// <param name="bookFilterInstance">The book filter instance.</param> /// <param name="sProjectName">The name of the current project</param> /// <param name="stylesheet">The stylesheet.</param> /// <param name="helpTopicProvider">The help topic provider.</param> /// ------------------------------------------------------------------------------------ public KeyTermsViewWrapper(Control parent, FdoCache cache, ViewProxy draftViewProxy, RegistryKey settingsRegKey, int bookFilterInstance, string sProjectName, FwStyleSheet stylesheet, IHelpTopicProvider helpTopicProvider) : base(parent, cache, draftViewProxy, settingsRegKey) { m_bookFilterInstance = bookFilterInstance; Name = "KeyTermsViewWrapper"; // Set up the right view m_rightView.Name = "KeyTermsRightView"; m_sProjectName = sProjectName; m_stylesheet = stylesheet; m_helpTopicProvider = helpTopicProvider; }
public override void TestSetup() { base.TestSetup(); var styleSheet = new FwStyleSheet(); styleSheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles); Debug.Assert(m_basicView == null, "m_basicView is not null."); //if (m_basicView != null) // m_basicView.Dispose(); m_basicView = CreateDummyBasicView(); m_basicView.Cache = Cache; m_basicView.Visible = false; m_basicView.StyleSheet = styleSheet; }
public override void Initialize() { CheckDisposed(); base.Initialize(); FwStyleSheet styleSheet = new FwStyleSheet(); styleSheet.Init(Cache, m_scr.Hvo, (int)Scripture.ScriptureTags.kflidStyles); Debug.Assert(m_basicView == null, "m_basicView is not null."); //if (m_basicView != null) // m_basicView.Dispose(); m_basicView = CreateDummyBasicView(); m_basicView.Cache = Cache; m_basicView.Visible = false; m_basicView.StyleSheet = styleSheet; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructs a new instance of the <see cref="ExportXhtml"/> class. /// </summary> /// <param name="fileName">pathname of the XHTML file to create</param> /// <param name="cache">data source</param> /// <param name="filter">lists the books to export</param> /// <param name="what">tells what to export: everything, filtered list, or single book</param> /// <param name="nBook">if single book, number of the book to export</param> /// <param name="iFirstSection">if single book, index of first section to export</param> /// <param name="iLastSection">if single book, index of last section to export</param> /// <param name="sDescription">The s description.</param> /// <param name="styleSheet">The style sheet.</param> /// <param name="pub">The pub.</param> /// <param name="app">The application</param> /// ------------------------------------------------------------------------------------ public ExportXhtml(string fileName, FdoCache cache, FilteredScrBooks filter, ExportWhat what, int nBook, int iFirstSection, int iLastSection, string sDescription, FwStyleSheet styleSheet, IPublication pub, IApp app) { m_fileName = fileName; m_cache = cache; m_bookFilter = filter; m_what = what; m_nBookSingle = nBook; m_iFirstSection = iFirstSection; m_iLastSection = iLastSection; m_sDescription = sDescription; m_styleSheet = styleSheet; m_pub = pub; m_app = app; m_scr = cache.LangProject.TranslatedScriptureOA; }
/// ------------------------------------------------------------------------------------ /// <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 ExportXhtml(m_fileName, Cache, m_filter, ExportWhat.AllBooks, 1, 0, 0, string.Empty, m_stylesheet, null, null); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Method to test creation of a publication view. /// </summary> /// <param name="pub">The publication.</param> /// <param name="viewType">Type of the Translation Editor view.</param> /// <returns> /// a Scripture publication for the specified view type. /// </returns> /// ------------------------------------------------------------------------------------ internal static DummyScripturePublication Create(IPublication pub, TeViewType viewType, FwStyleSheet stylesheet) { if (viewType == TeViewType.BackTranslationParallelPrint) { Debug.Assert(false, "Not yet implemented."); return null; } DummyScripturePublication pubControl = new DummyScripturePublication(pub.Cache, stylesheet, 567, pub, viewType, DateTime.Now); pubControl.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom; pubControl.Dock = DockStyle.Fill; pubControl.Name = TeEditingHelper.ViewTypeString(viewType); pubControl.Visible = false; return pubControl; }
public override void Initialize() { base.Initialize(); m_styleSheet = new FwStyleSheet(); m_styleSheet.Init(Cache, m_scr.Hvo, (int)Scripture.ScriptureTags.kflidStyles); InitWsInfo(); m_undoImportManager = new UndoImportManager(Cache, null); m_importer = ReflectionHelper.CreateObject("TeImportExport.dll", "SIL.FieldWorks.TE.TeXmlImporter", BindingFlags.NonPublic, new object[] {Cache, m_styleSheet, " ", m_undoImportManager, m_teImportUi}) as TeXmlImporter; ReflectionHelper.CallMethod(m_importer, "Initialize", null); m_stackSectionType = ReflectionHelper.GetField(m_importer, "m_stackSectionType") as Stack<string>; StyleProxyListManager.Initialize(m_styleSheet); }
/// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="NotesMainWnd"/> class. /// </summary> /// <param name="app">The app</param> /// <param name="stylesheet">The stylesheet</param> /// <param name="zoomPercent">The zoom percentage</param> /// ----------------------------------------------------------------------------------- public NotesMainWnd(FwApp app, FwStyleSheet stylesheet, float zoomPercent) : base(app, null) { // // Required for Windows Form Designer support // InitializeComponent(); Name = "NotesMainWnd"; m_zoomPercent = zoomPercent; m_scr = m_app.Cache.LangProject.TranslatedScriptureOA; m_StyleSheet = stylesheet; SetupSideBarInfoBar(); AddFilters(); // Save the max. width for the sidebar and set it to the default width. // m_maxSideBarWidth = m_sideBarContainer.Width; m_sideBarContainer.Width = kDefaultSideBarWidth; }
protected string m_helpTopic = ""; // Default help topic ID public void SetupDialog(HomographConfiguration hc, FdoCache cache, FwStyleSheet stylesheet, IApp app, IHelpTopicProvider helpTopicProvider) { SetHelpTopic("khtpConfigureHomograph"); // Default help topic ID m_helpProvider = new HelpProvider(); m_helpProvider.SetHelpNavigator(this, HelpNavigator.Topic); m_helpProvider.SetShowHelp(this, true); m_cache = cache; m_stylesheet = stylesheet; m_app = app; m_helpTopicProvider = helpTopicProvider; if (m_helpTopicProvider != null) { m_helpProvider.HelpNamespace = m_helpTopicProvider.HelpFile; SetHelpButtonEnabled(); } if (hc.ShowHomographNumber(HomographConfiguration.HeadwordVariant.Main)) { m_radioHide.Checked = false; m_radioBefore.Checked = hc.HomographNumberBefore; m_radioAfter.Checked = !hc.HomographNumberBefore; m_chkShowSenseNumInDict.Checked = hc.ShowSenseNumberRef; m_chkShowSenseNumInReversal.Checked = hc.ShowSenseNumberReversal; } else { m_radioHide.Checked = true; m_radioBefore.Checked = false; m_radioAfter.Checked = false; m_chkShowSenseNumInDict.Checked = false; m_chkShowSenseNumInReversal.Checked = false; } m_chkShowHomographNumInDict.Checked = hc.ShowHomographNumber(HomographConfiguration.HeadwordVariant.DictionaryCrossRef); m_chkShowHomographNumInReversal.Checked = hc.ShowHomographNumber(HomographConfiguration.HeadwordVariant.ReversalCrossRef); EnableControls(); }
protected override void CreateTestData() { m_lp = Cache.LanguageProject; AddTestStyle("Normal", ContextValues.Internal, StructureValues.Undefined, FunctionValues.Prose, false, m_lp.StylesOC); AddTestStyle("Paragraph", ContextValues.Text, StructureValues.Body, FunctionValues.Prose, false, m_lp.StylesOC); AddTestStyle("Section Head", ContextValues.Text, StructureValues.Heading, FunctionValues.Prose, false, m_lp.StylesOC); AddTestStyle("Verse Number", ContextValues.Text, StructureValues.Body, FunctionValues.Verse, true, m_lp.StylesOC); AddTestStyle("Title Main", ContextValues.Title, StructureValues.Body, FunctionValues.Prose, false, m_lp.StylesOC); AddTestStyle("Note General Paragraph", ContextValues.Note, StructureValues.Undefined, FunctionValues.Prose, false, m_lp.StylesOC); AddTestStyle("Note Marker", ContextValues.Internal, StructureValues.Undefined, FunctionValues.Prose, true, m_lp.StylesOC); AddTestStyle(kStyleName, ContextValues.Text, StructureValues.Body, FunctionValues.Prose, true, 2, m_lp.StylesOC); // Setup the stylesheet. var captionStyle = AddTestStyle("Caption", ContextValues.Internal, StructureValues.Body, FunctionValues.Prose, false, m_lp.StylesOC); m_styleSheet = new FwStyleSheet(); m_styleSheet.Init(Cache, m_lp.Hvo, LangProjectTags.kflidStyles); Debug.Assert(m_stylesComboBox == null, "m_stylesComboBox is not null."); //if (m_stylesComboBox != null) // m_stylesComboBox.Dispose(); m_stylesComboBox = new ComboBox(); m_styleListHelper = new StyleComboListHelper(m_stylesComboBox); // Set the options to display all of the styles m_styleListHelper.MaxStyleLevel = int.MaxValue; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initialize the importer /// </summary> /// ------------------------------------------------------------------------------------ public override void TestSetup() { base.TestSetup(); m_styleSheet = new FwStyleSheet(); m_styleSheet.Init(Cache, m_scr.Hvo, ScriptureTags.kflidStyles); InitWsInfo(); DummyTeImporter.s_translatorNoteDefn = Cache.ServiceLocator.GetInstance<ICmAnnotationDefnRepository>().TranslatorAnnotationDefn; DummyTeImporter.s_consultantNoteDefn = Cache.ServiceLocator.GetInstance<ICmAnnotationDefnRepository>().ConsultantAnnotationDefn; m_titus = new BCVRef(56001001); m_settings = m_scr.FindOrCreateDefaultImportSettings(TypeOfImport.Other); m_settings.StartRef = m_titus; m_settings.EndRef = m_titus; m_settings.ImportTranslation = true; InitializeImportSettings(); m_actionHandler.EndUndoTask(); // Let the importer handle the undo/redo m_importer = new DummyTeImporter(m_settings, this, m_styleSheet); m_importer.Initialize(); m_importer.UndoInfo.StartImportingFiles(); }
public override void Initialize() { base.Initialize(); m_styleSheet = new FwStyleSheet(); m_styleSheet.Init(Cache, m_scr.Hvo, (int)Scripture.ScriptureTags.kflidStyles); InitWsInfo(); DummyTeImporter.s_translatorNoteDefn = m_scrInMemoryCache.m_translatorNoteDefn; DummyTeImporter.s_consultantNoteDefn = m_scrInMemoryCache.m_consultantNoteDefn; m_titus = new BCVRef(56001001); m_settings = new DummyScrImportSet(); m_scr.ImportSettingsOC.Add(m_settings); m_settings.ImportTypeEnum = TypeOfImport.Other; m_settings.StartRef = m_titus; m_settings.EndRef = m_titus; m_settings.ImportTranslation = true; InitializeImportSettings(); m_importer = new DummyTeImporter(m_settings, Cache, m_styleSheet, m_scrInMemoryCache); m_importer.Initialize(); }
///------------------------------------------------------------------------------- /// <summary> /// Constructor for import dialog, requiring a language project. /// Use this constructor at run time. /// </summary> ///------------------------------------------------------------------------------- public ImportDialog(FwStyleSheet styleSheet, FdoCache cache, ScrImportSet settings, string helpFile) : this() { m_StyleSheet = styleSheet; m_cache = cache; Scripture scr = (Scripture)cache.LangProject.TranslatedScriptureOA; m_importSettings = settings; m_helpFile = helpFile; //InitBookNameList(); // Set the initial values for the controls from the static variables. radImportEntire.Checked = ImportEntire; radImportRange.Checked = !ImportEntire; chkTranslation.Checked = ImportTranslation; chkBackTranslation.Checked = ImportBackTranslation; chkBookIntros.Checked = ImportBookIntros; chkOther.Checked = ImportAnnotations; // Restore any saved settings. if (s_StartRef.ContainsKey(m_cache)) StartRef = s_StartRef[m_cache]; else SetStartRefToFirstImportableBook(); if (s_EndRef.ContainsKey(m_cache)) EndRef = s_EndRef[m_cache]; else SetEndRefToLastImportableBook(); // Finish constructing the ScrBookControl objects. Paratext.ScrVers versification = scr.Versification; scrPsgFrom.Initialize(new ScrReference(StartRef, versification), scr, m_importSettings.BooksForProject.ToArray()); scrPsgTo.Initialize(new ScrReference(EndRef, versification), scr, m_importSettings.BooksForProject.ToArray()); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Writes this response to the the specified annotation /// </summary> /// ------------------------------------------------------------------------------------ public void WriteToCache(IScrScriptureNote ann, FwStyleSheet styleSheet) { ParagraphCollection parasResponse = new ParagraphCollection(Paragraphs, styleSheet); ParagraphCollection.ParaMatchType type; int matchIndex = FindMatchingResponse(parasResponse, ann.ResponsesOS, out type); switch (type) { case ParagraphCollection.ParaMatchType.Exact: case ParagraphCollection.ParaMatchType.Contains: break; // we can ignore the new response -- it's a subset of the old. case ParagraphCollection.ParaMatchType.IsContained: IStJournalText oldText = ann.ResponsesOS[matchIndex]; oldText.ParagraphsOS.RemoveAll(); parasResponse.WriteToCache(oldText); break; case ParagraphCollection.ParaMatchType.None: IStJournalText newText = new StJournalText(); ann.ResponsesOS.Append(newText); parasResponse.WriteToCache(newText); break; } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor with ContextValues and MarkerDomain as a parameters. /// </summary> /// <param name="sStyleName">Name of the style.</param> /// <param name="styleType">kstCharacter or kstParagraph</param> /// <param name="ws">character or paragraph writing system</param> /// <param name="context">Context that will be used if this is a new style (otherwise existing /// context in DB will be used), see ContextValues for possible types</param> /// <param name="domain">The marker domain to use</param> /// <param name="styleSheet">The style sheet</param> /// ------------------------------------------------------------------------------------ public ImportStyleProxy(string sStyleName, StyleType styleType, int ws, ContextValues context, MarkerDomain domain, FwStyleSheet styleSheet) { m_FwStyleSheet = styleSheet; m_domain = domain; Debug.Assert(m_FwStyleSheet != null); m_ttpFormattingProps = null; m_fIsScriptureStyle = true; //default m_sEndMarker = null; //default if (context == ContextValues.EndMarker) { // this proxy represents an end marker - not a style; set bogus info sStyleName = "End"; //name does not matter styleType = StyleType.kstCharacter; } else if (sStyleName != null) { // Determine whether style exists in the StyleSheet Debug.Assert(ws != 0); m_style = m_FwStyleSheet.FindStyle(sStyleName); if (m_style != null) { // If this is an existing style, the actual type, context, structure, and // function always override the requested values. styleType = m_style.Type; context = (ContextValues)m_style.Context; m_structure = (StructureValues)m_style.Structure; m_function = (FunctionValues)m_style.Function; } } m_sStyleName = sStyleName; m_StyleType = styleType; m_ws = ws; m_Context = context; // //force StartOfFootnote marker to be processed as a para style proxy having para props // if (context == StyleRole.StartOfFootnote) // m_StyleType = StyleType.kstParagraph; //set the text property vars for this proxy SetTextProps(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor with ContextValues and MarkerDomain as a parameters. /// </summary> /// <param name="mapping">The Scr marker mapping.</param> /// <param name="ws">character or paragraph writing system</param> /// <param name="styleSheet">The style sheet</param> /// ------------------------------------------------------------------------------------ public ImportStyleProxy(ImportMappingInfo mapping, int ws, FwStyleSheet styleSheet) : this(mapping.StyleName, mapping.IsInline ? StyleType.kstCharacter : StyleType.kstParagraph, ws, ContextValues.General, mapping.Domain, styleSheet) { Excluded = mapping.IsExcluded; MappingTarget = mapping.MappingTarget; m_annotationType = mapping.NoteType; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Constructor with ContextValues as a parameter. /// </summary> /// <param name="sStyleName">Name of the style.</param> /// <param name="styleType">kstCharacter or kstParagraph</param> /// <param name="ws">character or paragraph writing system</param> /// <param name="context">Context that will be used if this is a new style (otherwise existing /// context in DB will be used), see ContextValues for possible types</param> /// <param name="styleSheet">The style sheet</param> /// ------------------------------------------------------------------------------------ public ImportStyleProxy(string sStyleName, StyleType styleType, int ws, ContextValues context, FwStyleSheet styleSheet) : this(sStyleName, styleType, ws, context, MarkerDomain.Default, styleSheet) { }