/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes this CharContextCtrl /// </summary> /// <param name="cache">The cache.</param> /// <param name="wsContainer">The writing system container.</param> /// <param name="ws">The language definition.</param> /// <param name="app">The application.</param> /// <param name="contextFont">The context font.</param> /// <param name="tokenGrid">The token grid.</param> /// ------------------------------------------------------------------------------------ public void Initialize(LcmCache cache, IWritingSystemContainer wsContainer, CoreWritingSystemDefinition ws, IApp app, Font contextFont, DataGridView tokenGrid) { m_cache = cache; m_wsContainer = wsContainer; m_ws = ws; m_app = app; ContextFont = contextFont; TokenGrid = tokenGrid; var isOkToDisplayScripture = m_cache != null && m_cache.ServiceLocator.GetInstance <IScrBookRepository>().AllInstances().Any(); if (isOkToDisplayScripture) { m_scrChecksDllFile = FwDirectoryFinder.BasicEditorialChecksDll; } if (m_ws != null) { if (m_ws.RightToLeftScript) { // Set the order of the columns for right-to-left text. colContextAfter.DisplayIndex = colContextBefore.DisplayIndex; colContextBefore.DisplayIndex = gridContext.ColumnCount - 1; } } }
private string ApplyTransform(string sInputFile, XmlNode node, ProgressDialogWorkingOn dlg) { string sProgressPrompt = XmlUtils.GetManditoryAttributeValue(node, "progressPrompt"); UpdateProgress(sProgressPrompt, dlg); string sXslt = XmlUtils.GetManditoryAttributeValue(node, "file"); string sOutputFile = Path.Combine(m_outputDirectory, Cache.ProjectId.Name + sXslt + "Result." + GetExtensionFromNode(node)); XmlUtils.XSLParameter[] parameterList = CreateParameterList(node); IWritingSystemContainer wsContainer = Cache.ServiceLocator.WritingSystems; if (parameterList != null) { foreach (XmlUtils.XSLParameter param in parameterList) { if (param.Name == "prmVernacularFontSize") { param.Value = GetNormalStyleFontSize(wsContainer.DefaultVernacularWritingSystem.Handle); } if (param.Name == "prmGlossFontSize") { param.Value = GetNormalStyleFontSize(wsContainer.DefaultAnalysisWritingSystem.Handle); } } } XmlUtils.TransformFileToFile(Path.Combine(TransformPath, sXslt), parameterList, sInputFile, sOutputFile); return(sOutputFile); }
private string ApplyTransform(string inputFile, XmlNode node, ProgressDialogWorkingOn dlg) { string progressPrompt = XmlUtils.GetManditoryAttributeValue(node, "progressPrompt"); UpdateProgress(progressPrompt, dlg); string stylesheetName = XmlUtils.GetManditoryAttributeValue(node, "stylesheetName"); string stylesheetAssembly = XmlUtils.GetManditoryAttributeValue(node, "stylesheetAssembly"); string outputFile = Path.Combine(m_outputDirectory, Cache.ProjectId.Name + stylesheetName + "Result." + GetExtensionFromNode(node)); XsltArgumentList argumentList = CreateParameterList(node); IWritingSystemContainer wsContainer = Cache.ServiceLocator.WritingSystems; if (argumentList.GetParam("prmVernacularFontSize", "") != null) { argumentList.RemoveParam("prmVernacularFontSize", ""); argumentList.AddParam("prmVernacularFontSize", "", GetNormalStyleFontSize(wsContainer.DefaultVernacularWritingSystem.Handle)); } if (argumentList.GetParam("prmGlossFontSize", "") != null) { argumentList.RemoveParam("prmGlossFontSize", ""); argumentList.AddParam("prmGlossFontSize", "", GetNormalStyleFontSize(wsContainer.DefaultAnalysisWritingSystem.Handle)); } var xmlReaderSettings = new XmlReaderSettings { DtdProcessing = DtdProcessing.Parse }; using (var writer = new StreamWriter(outputFile)) using (var reader = XmlReader.Create(inputFile, xmlReaderSettings)) GetTransform(stylesheetName, stylesheetAssembly).Transform(reader, argumentList, writer); return(outputFile); }
/// <summary> /// Shows the new writing system properties dialog. /// </summary> /// <param name="owner">The owner.</param> /// <param name="cache">The cache.</param> /// <param name="wsManager">The ws manager.</param> /// <param name="wsContainer">The ws container.</param> /// <param name="helpTopicProvider">The help topic provider.</param> /// <param name="app">The app.</param> /// <param name="stylesheet">The stylesheet.</param> /// <param name="displayRelatedWss">if set to <c>true</c> related writing systems will be displayed.</param> /// <param name="defaultName">The default language name for the new writing system.</param> /// <param name="newWritingSystems">The new writing systems.</param> /// <returns></returns> public static bool ShowNewDialog(Form owner, FdoCache cache, IWritingSystemManager wsManager, IWritingSystemContainer wsContainer, IHelpTopicProvider helpTopicProvider, IApp app, IVwStylesheet stylesheet, bool displayRelatedWss, string defaultName, out IEnumerable<IWritingSystem> newWritingSystems) { newWritingSystems = null; LanguageSubtag languageSubtag; using (new WaitCursor(owner)) using (var dlg = new LanguageSelectionDlg(wsManager, helpTopicProvider)) { dlg.Text = FwCoreDlgs.kstidLanguageSelectionNewWsCaption; dlg.DefaultLanguageName = defaultName; if (dlg.ShowDialog(owner) != DialogResult.OK) return false; languageSubtag = dlg.LanguageSubtag; } using (new WaitCursor(owner)) using (var wsPropsDlg = new WritingSystemPropertiesDialog(cache, wsManager, wsContainer, helpTopicProvider, app, stylesheet)) { wsPropsDlg.SetupDialog(languageSubtag, displayRelatedWss); if (wsPropsDlg.ShowDialog(owner) == DialogResult.OK) { newWritingSystems = wsPropsDlg.NewWritingSystems; return true; } } return false; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes this CharContextCtrl /// </summary> /// <param name="cache">The cache.</param> /// <param name="wsContainer">The writing system container.</param> /// <param name="ws">The language definition.</param> /// <param name="app">The application.</param> /// <param name="contextFont">The context font.</param> /// <param name="tokenGrid">The token grid.</param> /// ------------------------------------------------------------------------------------ public void Initialize(FdoCache cache, IWritingSystemContainer wsContainer, IWritingSystem ws, IApp app, Font contextFont, DataGridView tokenGrid) { m_cache = cache; m_wsContainer = wsContainer; m_ws = ws; m_app = app; ContextFont = contextFont; TokenGrid = tokenGrid; if (FwUtils.IsTEInstalled) { m_scrChecksDllFile = DirectoryFinder.BasicEditorialChecksDll; } if (m_ws != null) { bool modifyingVernWs = (m_wsContainer.DefaultVernacularWritingSystem != null && m_ws.Id == m_wsContainer.DefaultVernacularWritingSystem.Id); // If TE isn't installed, we can't support creating an inventory // based on Scripture data. cmnuScanScripture.Visible = (FwUtils.IsTEInstalled && File.Exists(m_scrChecksDllFile) && m_cache != null && m_cache.LanguageProject.TranslatedScriptureOA != null && modifyingVernWs); if (m_ws.RightToLeftScript) { // Set the order of the columns for right-to-left text. colContextAfter.DisplayIndex = colContextBefore.DisplayIndex; colContextBefore.DisplayIndex = gridContext.ColumnCount - 1; } } }
/// <summary> /// This sets the original citation form into the dialog. /// </summary> /// <param name="tssCitationForm"></param> /// <param name="le"></param> /// <param name="mediator"></param> /// <param name="propertyTable"></param> public void SetDlgInfo(ITsString tssCitationForm, ILexEntry le, Mediator mediator, XCore.PropertyTable propertyTable) { CheckDisposed(); Debug.Assert(tssCitationForm != null); Debug.Assert(le != null); m_le = le; m_cache = le.Cache; IWritingSystemContainer wsContainer = m_cache.ServiceLocator.WritingSystems; CoreWritingSystemDefinition defVernWs = wsContainer.DefaultVernacularWritingSystem; CoreWritingSystemDefinition defAnalWs = wsContainer.DefaultAnalysisWritingSystem; m_fwtbCitationForm.Font = new Font(defVernWs.DefaultFontName, 10); m_fwtbGloss.Font = new Font(defAnalWs.DefaultFontName, 10); var stylesheet = FontHeightAdjuster.StyleSheetFromPropertyTable(propertyTable); // Set writing system factory and code for the two edit boxes. m_fwtbCitationForm.WritingSystemFactory = m_cache.WritingSystemFactory; m_fwtbCitationForm.WritingSystemCode = defVernWs.Handle; m_fwtbCitationForm.StyleSheet = stylesheet; m_fwtbCitationForm.AdjustStringHeight = false; m_fwtbGloss.WritingSystemFactory = m_cache.WritingSystemFactory; m_fwtbGloss.WritingSystemCode = defAnalWs.Handle; m_fwtbGloss.StyleSheet = stylesheet; m_fwtbGloss.AdjustStringHeight = false; m_fwtbCitationForm.Tss = tssCitationForm; m_fwtbGloss.Text = String.Empty; m_fwtbCitationForm.HasBorder = false; m_msaGroupBox.Initialize(m_cache, mediator, propertyTable, this, new SandboxGenericMSA()); // get the current morph type from the lexical entry. IMoMorphType mmt; foreach (var mf in le.AlternateFormsOS) { mmt = mf.MorphTypeRA; if (mmt != null) { m_msaGroupBox.MorphTypePreference = mmt; break; // Assume the first allomorph's type is good enough. } } m_skipCheck = true; m_skipCheck = false; // Adjust sizes of the two FwTextBoxes if needed, and adjust the locations for the // controls below them. Do the same for the MSAGroupBox. AdjustHeightAndPositions(m_fwtbCitationForm); AdjustHeightAndPositions(m_fwtbGloss); AdjustHeightAndPositions(m_msaGroupBox); }
private static int GetWs(Mediator mediator, FdoCache cache, XmlNode node, string sAttr) { string wsSpec = XmlUtils.GetOptionalAttributeValue(node, sAttr); if (wsSpec != null) { IWritingSystemContainer wsContainer = cache.ServiceLocator.WritingSystems; int ws = 0; switch (wsSpec) { case "vernacular": ws = wsContainer.DefaultVernacularWritingSystem.Handle; break; case "analysis": ws = wsContainer.DefaultAnalysisWritingSystem.Handle; break; case "pronunciation": ws = wsContainer.DefaultPronunciationWritingSystem.Handle; break; case "reversal": string sGuid = (string)mediator.PropertyTable.GetValue("ReversalIndexGuid", null); if (sGuid != null) { try { Guid riGuid = new Guid(sGuid); IReversalIndex ri = cache.ServiceLocator.GetObject(riGuid) as IReversalIndex; ws = cache.ServiceLocator.WritingSystemManager.GetWsFromStr(ri.WritingSystem); } catch { throw new ApplicationException("Couldn't find current reversal index."); } } else { throw new ApplicationException("Couldn't find current reversal index."); } break; default: throw new ApplicationException("ws must be 'vernacular', 'analysis', 'pronunciation', or 'reversal';" + " it said '" + wsSpec + "'."); } return(ws); } return(0); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ private void SetupAnalysisWss() { IWritingSystemContainer wsContainer = Cache.ServiceLocator.WritingSystems; IWritingSystemManager wsManager = Cache.ServiceLocator.WritingSystemManager; //wsContainer.AnalysisWritingSystems.Clear(); wsContainer.AnalysisWritingSystems.Add(wsManager.Get("en")); wsContainer.AnalysisWritingSystems.Add(wsManager.Get("en-fonipa-x-etic")); wsContainer.AnalysisWritingSystems.Add(wsManager.Get("fr")); wsContainer.AnalysisWritingSystems.Add(wsManager.Get("es")); wsContainer.CurrentAnalysisWritingSystems.Add(wsManager.Get("en-fonipa-x-etic")); if (m_dlg == null) { m_dlg = new DummyFwProjPropertiesDlg(Cache); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ private void SetupVernWss() { IWritingSystemContainer wsContainer = Cache.ServiceLocator.WritingSystems; IWritingSystemManager wsManager = Cache.ServiceLocator.WritingSystemManager; //wsContainer.VernacularWritingSystems.Clear(); //wsContainer.CurrentVernacularWritingSystems.Clear(); // Setup so the CurVernWssRS returns the proper sequence. wsContainer.VernacularWritingSystems.Add(wsManager.Get("en")); wsContainer.VernacularWritingSystems.Add(wsManager.Get("en-fonipa-x-etic")); wsContainer.VernacularWritingSystems.Add(wsManager.Get("fr")); wsContainer.VernacularWritingSystems.Add(wsManager.Get("es")); wsContainer.CurrentVernacularWritingSystems.Add(wsManager.Get("en")); if (m_dlg == null) { m_dlg = new DummyFwProjPropertiesDlg(Cache); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes this CharContextCtrl /// </summary> /// <param name="cache">The cache.</param> /// <param name="wsContainer">The writing system container.</param> /// <param name="ws">The language definition.</param> /// <param name="app">The application.</param> /// <param name="contextFont">The context font.</param> /// <param name="tokenGrid">The token grid.</param> /// ------------------------------------------------------------------------------------ public void Initialize(FdoCache cache, IWritingSystemContainer wsContainer, IWritingSystem ws, IApp app, Font contextFont, DataGridView tokenGrid) { m_cache = cache; m_wsContainer = wsContainer; m_ws = ws; m_app = app; ContextFont = contextFont; TokenGrid = tokenGrid; if (FwUtils.IsOkToDisplayScriptureIfPresent) { m_scrChecksDllFile = FwDirectoryFinder.BasicEditorialChecksDll; } if (m_ws != null) { bool modifyingVernWs = (m_wsContainer.DefaultVernacularWritingSystem != null && m_ws.Id == m_wsContainer.DefaultVernacularWritingSystem.Id); // If TE isn't installed, we can't support creating an inventory // based on Scripture data. Likewise if we don't yet have any books (which also guards // against showing the option in the SE edition, unless it has been paired with Paratext). cmnuScanScripture.Visible = (FwUtils.IsOkToDisplayScriptureIfPresent && File.Exists(m_scrChecksDllFile) && m_cache != null && m_cache.LanguageProject.TranslatedScriptureOA != null && m_cache.LanguageProject.TranslatedScriptureOA.ScriptureBooksOS.Count > 0 && modifyingVernWs); if (m_ws.RightToLeftScript) { // Set the order of the columns for right-to-left text. colContextAfter.DisplayIndex = colContextBefore.DisplayIndex; colContextBefore.DisplayIndex = gridContext.ColumnCount - 1; } } }
private void SetWritingSystemBasedArguments(List <XmlUtils.XSLParameter> args) { ILgWritingSystemFactory wsf = m_cache.WritingSystemFactory; IWritingSystemContainer wsContainer = m_cache.ServiceLocator.WritingSystems; IWritingSystem defAnalWs = wsContainer.DefaultAnalysisWritingSystem; using (var myFont = FontHeightAdjuster.GetFontForNormalStyle(defAnalWs.Handle, m_mediator, wsf)) { args.Add(new XmlUtils.XSLParameter("prmAnalysisFont", myFont.FontFamily.Name)); args.Add(new XmlUtils.XSLParameter("prmAnalysisFontSize", myFont.Size + "pt")); } IWritingSystem defVernWs = wsContainer.DefaultVernacularWritingSystem; using (var myFont = FontHeightAdjuster.GetFontForNormalStyle(defVernWs.Handle, m_mediator, wsf)) { args.Add(new XmlUtils.XSLParameter("prmVernacularFont", myFont.FontFamily.Name)); args.Add(new XmlUtils.XSLParameter("prmVernacularFontSize", myFont.Size + "pt")); } string sRTL = defVernWs.RightToLeftScript ? "Y" : "N"; args.Add(new XmlUtils.XSLParameter("prmVernacularRTL", sRTL)); }
private void SetWritingSystemBasedArguments(LcmCache cache, PropertyTable propertyTable, XsltArgumentList argumentList) { ILgWritingSystemFactory wsf = cache.WritingSystemFactory; IWritingSystemContainer wsContainer = cache.ServiceLocator.WritingSystems; CoreWritingSystemDefinition defAnalWs = wsContainer.DefaultAnalysisWritingSystem; using (var myFont = FontHeightAdjuster.GetFontForNormalStyle(defAnalWs.Handle, wsf, propertyTable)) { argumentList.AddParam("prmAnalysisFont", "", myFont.FontFamily.Name); argumentList.AddParam("prmAnalysisFontSize", "", myFont.Size + "pt"); } CoreWritingSystemDefinition defVernWs = wsContainer.DefaultVernacularWritingSystem; using (var myFont = FontHeightAdjuster.GetFontForNormalStyle(defVernWs.Handle, wsf, propertyTable)) { argumentList.AddParam("prmVernacularFont", "", myFont.FontFamily.Name); argumentList.AddParam("prmVernacularFontSize", "", myFont.Size + "pt"); } string sRtl = defVernWs.RightToLeftScript ? "Y" : "N"; argumentList.AddParam("prmVernacularRTL", "", sRtl); }
public Fwr3660ValidCharactersDlg(FdoCache cache, IWritingSystemContainer container, IWritingSystem ws) : base(cache, container, null, null, ws, "dymmy") { }
/// <summary> /// Initializes a new instance of the <see cref="DummyWritingSystemPropertiesDialog"/> class. /// </summary> public DummyWritingSystemPropertiesDialog(WritingSystemManager wsManager, IWritingSystemContainer wsContainer) : base(null, wsManager, wsContainer, null, null) { }
/// <summary> /// Therefore this method, called once we have a cache and object, is our first chance to /// actually create the embedded control. /// </summary> public override void FinishInit() { CheckDisposed(); IWritingSystemContainer wsContainer = Cache.ServiceLocator.WritingSystems; bool fVernRTL = wsContainer.DefaultVernacularWritingSystem.RightToLeftScript; bool fAnalRTL = wsContainer.DefaultAnalysisWritingSystem.RightToLeftScript; System.Xml.XmlAttribute xa = ConfigurationNode.Attributes["layout"]; // To properly fix LT-6239, we need to consider all four mixtures of directionality // involving the vernacular (table) and analysis (slot name) writing systems. // These four possibilities are marked RTL, LTRinRTL, RTLinLTR, and <nothing>. if (fVernRTL && fAnalRTL) { if (xa.Value.EndsWith("RTLinLTR") || xa.Value.EndsWith("LTRinRTL")) { xa.Value = xa.Value.Substring(0, xa.Value.Length - 8); } if (!xa.Value.EndsWith("RTL")) { xa.Value += "RTL"; // both vern and anal are RTL } } else if (fVernRTL && !fAnalRTL) { if (xa.Value.EndsWith("RTLinLTR")) { xa.Value = xa.Value.Substring(0, xa.Value.Length - 8); } else if (xa.Value.EndsWith("RTL") && !xa.Value.EndsWith("LTRinRTL")) { xa.Value = xa.Value.Substring(0, xa.Value.Length - 3); } if (!xa.Value.EndsWith("LTRinRTL")) { xa.Value += "LTRinRTL"; // LTR anal name in RTL vern table } } else if (!fVernRTL && fAnalRTL) { if (xa.Value.EndsWith("LTRinRTL")) { xa.Value = xa.Value.Substring(0, xa.Value.Length - 8); } else if (xa.Value.EndsWith("RTL")) { xa.Value = xa.Value.Substring(0, xa.Value.Length - 3); } if (!xa.Value.EndsWith("RTLinLTR")) { xa.Value += "RTLinLTR"; // RTL anal name in LTR vern table } } else { if (xa.Value.EndsWith("RTLinLTR") || xa.Value.EndsWith("LTRinRTL")) { xa.Value = xa.Value.Substring(0, xa.Value.Length - 8); } else if (xa.Value.EndsWith("RTL")) { xa.Value = xa.Value.Substring(0, xa.Value.Length - 3); } // both vern and anal are LTR (unmarked case) } var ctrl = new InflAffixTemplateControl((FdoCache)Mediator.PropertyTable.GetValue("cache"), Object.Hvo, ConfigurationNode, StringTbl); Control = ctrl; m_menuHandler = InflAffixTemplateMenuHandler.Create(ctrl, ConfigurationNode); #if !Want m_menuHandler.Init(Mediator, null); #else m_menuHandler.Init(null, null); #endif ctrl.SetContextMenuHandler(m_menuHandler.ShowSliceContextMenu); ctrl.Mediator = Mediator; ctrl.SetStringTableValues(Mediator.StringTbl); if (ctrl.RootBox == null) { ctrl.MakeRoot(); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="ValidCharactersDlg"/> class. /// </summary> /// <param name="cache">The cache. Can be <c>null</c> if called from New Project /// dialog.</param> /// <param name="wsContainer">The FDO writing system container. Can't be /// <c>null</c>.</param> /// <param name="helpTopicProvider">The help topic provider.</param> /// <param name="app">The app.</param> /// <param name="ws">The language definition of the writing system for which this /// dialog is setting the valid characters. Can not be <c>null</c>.</param> /// <param name="wsName">The name of the writing system for which this dialog is setting /// the valid characters. Can not be <c>null</c> or <c>String.Empty</c>.</param> /// ------------------------------------------------------------------------------------ public ValidCharactersDlg(FdoCache cache, IWritingSystemContainer wsContainer, IHelpTopicProvider helpTopicProvider, IApp app, IWritingSystem ws, string wsName) : this() { m_ws = ws; m_helpTopicProvider = helpTopicProvider; m_app = app; if (string.IsNullOrEmpty(wsName)) throw new ArgumentException("Parameter must not be null or empty.", "wsName"); if (cache != null) m_wsManager = cache.ServiceLocator.WritingSystemManager; m_chrPropEng = LgIcuCharPropEngineClass.Create(); m_lblWsName.Text = string.Format(m_lblWsName.Text, wsName); // TE-6839: Temporarily remove Unicode tab (not yet implemented). tabCtrlAddFrom.TabPages.Remove(tabCtrlAddFrom.TabPages[kiTabUnicode]); m_fntForSpecialChar = new Font(SystemFonts.IconTitleFont.FontFamily, 8f); Font fnt = new Font(m_ws.DefaultFontName, 16); // Review - each of the following Font property set causes LoadCharsFromFont // to be executed which is an expensive operation as it pinvokes GetGlyphIndices // repeatedly. chrGridWordForming.Font = fnt; chrGridNumbers.Font = fnt; chrGridOther.Font = fnt; txtManualCharEntry.Font = fnt; txtFirstChar.Font = fnt; txtLastChar.Font = fnt; lblFirstCharCode.Top = txtFirstChar.Bottom + 5; lblLastCharCode.Top = txtLastChar.Bottom + 5; lblFirstChar.Top = txtFirstChar.Top + (txtFirstChar.Height - lblFirstChar.Height) / 2; lblLastChar.Top = txtLastChar.Top + (txtLastChar.Height - lblLastChar.Height) / 2; fnt = new Font(m_ws.DefaultFontName, 12); colChar.DefaultCellStyle.Font = fnt; tabData.Controls.Remove(gridCharInventory); var gridcol = gridCharInventory.Columns[3]; m_chkBoxColHdrHandler = new CheckBoxColumnHeaderHandler(gridcol); m_chkBoxColHdrHandler.Label = gridcol.HeaderText; gridcol.HeaderText = String.Empty; contextCtrl.Initialize(cache, wsContainer, m_ws, m_app, fnt, gridCharInventory); contextCtrl.Dock = DockStyle.Fill; contextCtrl.CheckToRun = CharContextCtrl.CheckType.Characters; contextCtrl.ListValidator = RemoveInvalidCharacters; colChar.HeaderCell.SortGlyphDirection = SortOrder.Ascending; gridCharInventory.AutoGenerateColumns = false; colStatus.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleRight; m_validCharsGridMngr.Init(chrGridWordForming, chrGridOther, chrGridNumbers, m_ws, m_app); m_validCharsGridMngr.CharacterGridGotFocus += HandleCharGridGotFocus; m_validCharsGridMngr.CharacterGridSelectionChanged += HandleCharGridSelChange; }
int m_wsToCreate; // default analysis or vernacular ws. public GhostStringSliceView(int hvo, int flid, XmlNode nodeObjProp, FdoCache cache) { Cache = cache; m_hvoObj = hvo; m_flidEmptyProp = flid; m_nodeObjProp = nodeObjProp; // Figure the type of object we are pretending to be. string dstClass = XmlUtils.GetOptionalAttributeValue(nodeObjProp, "ghostClass"); if (dstClass == null) { m_clidDst = cache.DomainDataByFlid.MetaDataCache.GetDstClsId((int)flid); } else { m_clidDst = cache.DomainDataByFlid.MetaDataCache.GetClassId(dstClass); } // And the one property of that imaginary object we are displaying. string stringProp = XmlUtils.GetManditoryAttributeValue(nodeObjProp, "ghost"); // Special case for making a Text if (m_flidEmptyProp == RnGenericRecTags.kflidText) { m_flidStringProp = StTxtParaTags.kflidContents; } else { m_flidStringProp = cache.DomainDataByFlid.MetaDataCache.GetFieldId2(m_clidDst, stringProp, true); } // And what writing system should typing in the field employ? IWritingSystemContainer wsContainer = cache.ServiceLocator.WritingSystems; string stringWs = XmlUtils.GetManditoryAttributeValue(nodeObjProp, "ghostWs"); switch (stringWs) { case "vernacular": m_wsToCreate = wsContainer.DefaultVernacularWritingSystem.Handle; break; case "analysis": m_wsToCreate = wsContainer.DefaultAnalysisWritingSystem.Handle; break; case "pronunciation": // Pronunciation isn't always defined. Fall back to vernacular. if (wsContainer.DefaultPronunciationWritingSystem == null) { m_wsToCreate = wsContainer.DefaultVernacularWritingSystem.Handle; } else { m_wsToCreate = wsContainer.DefaultPronunciationWritingSystem.Handle; } break; default: throw new Exception("ghostWs must be vernacular or analysis or pronunciation"); } }
/// ----------------------------------------------------------------------------------- /// <summary> /// Initializes a new instance of the <see cref="XDumper"/> class. /// </summary> /// ----------------------------------------------------------------------------------- public XDumper(FdoCache cache) { m_cache = cache; m_mdc = m_cache.ServiceLocator.GetInstance<IFwMetaDataCacheManaged>(); m_cmObjectRepository = m_cache.ServiceLocator.GetInstance<ICmObjectRepository>(); m_wsManager = m_cache.ServiceLocator.WritingSystemManager; m_wsContainer = m_cache.ServiceLocator.WritingSystems; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes this CharContextCtrl /// </summary> /// <param name="cache">The cache.</param> /// <param name="wsContainer">The writing system container.</param> /// <param name="ws">The language definition.</param> /// <param name="app">The application.</param> /// <param name="contextFont">The context font.</param> /// <param name="tokenGrid">The token grid.</param> /// ------------------------------------------------------------------------------------ public void Initialize(FdoCache cache, IWritingSystemContainer wsContainer, IWritingSystem ws, IApp app, Font contextFont, DataGridView tokenGrid) { m_cache = cache; m_wsContainer = wsContainer; m_ws = ws; m_app = app; ContextFont = contextFont; TokenGrid = tokenGrid; if (FwUtils.IsOkToDisplayScriptureIfPresent) m_scrChecksDllFile = FwDirectoryFinder.BasicEditorialChecksDll; if (m_ws != null) { bool modifyingVernWs = (m_wsContainer.DefaultVernacularWritingSystem != null && m_ws.Id == m_wsContainer.DefaultVernacularWritingSystem.Id); // If TE isn't installed, we can't support creating an inventory // based on Scripture data. Likewise if we don't yet have any books (which also guards // against showing the option in the SE edition, unless it has been paired with Paratext). cmnuScanScripture.Visible = (FwUtils.IsOkToDisplayScriptureIfPresent && File.Exists(m_scrChecksDllFile) && m_cache != null && m_cache.LanguageProject.TranslatedScriptureOA != null && m_cache.LanguageProject.TranslatedScriptureOA.ScriptureBooksOS.Count > 0 && modifyingVernWs); if (m_ws.RightToLeftScript) { // Set the order of the columns for right-to-left text. colContextAfter.DisplayIndex = colContextBefore.DisplayIndex; colContextBefore.DisplayIndex = gridContext.ColumnCount - 1; } } }
public Fwr3660ValidCharactersDlg(LcmCache cache, IWritingSystemContainer container, CoreWritingSystemDefinition ws) : base(cache, container, null, null, ws, "dymmy") { }
/// <summary> /// Shows the modify writing system properties dialog. /// </summary> /// <param name="owner">The owner.</param> /// <param name="selectedWs">The selected writing system.</param> /// <param name="addNewForLangOfSelectedWs">if set to <c>true</c> a new writing system with the /// same language as the selected writing system will be added.</param> /// <param name="cache">The cache.</param> /// <param name="wsContainer">The ws container.</param> /// <param name="helpTopicProvider">The help topic provider.</param> /// <param name="app">The app.</param> /// <param name="stylesheet">The stylesheet.</param> /// <param name="newWritingSystems">The new writing systems.</param> /// <returns></returns> public static bool ShowModifyDialog(Form owner, IWritingSystem selectedWs, bool addNewForLangOfSelectedWs, FdoCache cache, IWritingSystemContainer wsContainer, IHelpTopicProvider helpTopicProvider, IApp app, IVwStylesheet stylesheet, out IEnumerable<IWritingSystem> newWritingSystems) { newWritingSystems = null; string path; if (!cache.ServiceLocator.WritingSystemManager.CanSave(selectedWs, out path)) { MessageBox.Show(owner, string.Format(FwCoreDlgs.ksCannotSaveWritingSystem, path), FwCoreDlgs.ksError, MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; // nothing changed. } using (new WaitCursor(owner)) using (var wsPropsDlg = new WritingSystemPropertiesDialog(cache, cache.ServiceLocator.WritingSystemManager, wsContainer, helpTopicProvider, app, stylesheet)) { wsPropsDlg.SetupDialog(selectedWs, true); if (addNewForLangOfSelectedWs) wsPropsDlg.AddNewWsForLanguage(); if (!ClientServerServicesHelper.WarnOnOpeningSingleUserDialog(cache)) return false; // nothing changed. if (!SharedBackendServicesHelper.WarnOnOpeningSingleUserDialog(cache)) return false; if (wsPropsDlg.ShowDialog(owner) == DialogResult.OK) { if (wsPropsDlg.IsChanged) { newWritingSystems = wsPropsDlg.NewWritingSystems; return true; } } } return false; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="TeEditingHelper"/> class. /// </summary> /// <param name="callbacks">The callbacks.</param> /// <param name="cache">The cache.</param> /// <param name="filterInstance">The filter instance.</param> /// <param name="viewType">Type of the view.</param> /// <param name="app">The app.</param> /// ------------------------------------------------------------------------------------ public TeEditingHelper(IEditingCallbacks callbacks, FdoCache cache, int filterInstance, TeViewType viewType, IApp app) : base(cache, callbacks) { if (m_cache == null) throw new ArgumentNullException("cache"); m_scr = m_cache.LangProject.TranslatedScriptureOA; m_app = app; IFdoServiceLocator servloc = m_cache.ServiceLocator; m_repoStText = servloc.GetInstance<IStTextRepository>(); m_repoScrTxtPara = servloc.GetInstance<IScrTxtParaRepository>(); m_repoScrBook = servloc.GetInstance<IScrBookRepository>(); m_repoScrSection = servloc.GetInstance<IScrSectionRepository>(); m_repoScrFootnote = servloc.GetInstance<IScrFootnoteRepository>(); m_repoCmTrans = servloc.GetInstance<ICmTranslationRepository>(); m_wsContainer = servloc.WritingSystems; m_repoCmObject = servloc.GetInstance<ICmObjectRepository>(); m_repoSegment = servloc.GetInstance<ISegmentRepository>(); m_viewType = viewType; m_filterInstance = filterInstance; PasteFixTssEvent += RemoveHardFormatting; }
/// <summary> /// Initializes a new instance of the <see cref="T:WritingSystemPropertiesDialog"/> class. /// </summary> /// <param name="cache">The cache.</param> /// <param name="wsManager">The ws manager.</param> /// <param name="wsContainer">The ws container.</param> /// <param name="helpTopicProvider">The help topic provider.</param> /// <param name="app">The app.</param> /// <param name="stylesheet">The stylesheet.</param> public WritingSystemPropertiesDialog(FdoCache cache, IWritingSystemManager wsManager, IWritingSystemContainer wsContainer, IHelpTopicProvider helpTopicProvider, IApp app, IVwStylesheet stylesheet) : this() { m_cache = cache; m_wsManager = wsManager; m_wsContainer = wsContainer; m_helpTopicProvider = helpTopicProvider; m_app = app; m_stylesheet = stylesheet; }