public bool TryGetValue(string strSourceWord, out MapOfSourceWordElements mapOfSourceWordElements) { // this is a helper to find the proper MapOfSourceWordElements based on the // source word. First we have to find the map to look into // first get the map for the number of words in the source string (e.g. "ke picche" would be map=2) Debug.Assert(!String.IsNullOrEmpty(strSourceWord)); int nMapValue = strSourceWord.Split(AdaptItKBReader.CaSplitChars, StringSplitOptions.RemoveEmptyEntries).Length; return(TryGetValue(nMapValue, out mapOfSourceWordElements)); }
public bool TryGetValue(int nMapValue, out MapOfSourceWordElements mapOfSourceWordElements) { var strXPath = FormatXpath(MapOfSourceWordElements.CstrElementNameNumOfWordsPerPhraseMap, MapOfSourceWordElements.CstrAttributeNameNumOfWordsPerPhrase, nMapValue.ToString()); var elem = Xml.XPathSelectElement(strXPath); if (elem == null) { mapOfSourceWordElements = null; return(false); } mapOfSourceWordElements = new MapOfSourceWordElements(elem, nMapValue, this); return(true); }
internal ModifyTargetWordsForm(string strSourceWord, MapOfSourceWordElements mapOfSourceWordElements, AdaptItKBReader.LanguageInfo liTargetLang, char[] achTrim) { InitializeComponent(); _mapOfSourceWordElements = mapOfSourceWordElements; _achTrim = achTrim; targetFormDisplayControl.TargetWordFont = liTargetLang.FontToUse; targetFormDisplayControl.TargetWordRightToLeft = liTargetLang.RightToLeft; targetFormDisplayControl.CallToSetModified = SetModified; SourceWordElement sourceWordElement; if (mapOfSourceWordElements.TryGetValue(strSourceWord, out sourceWordElement)) { targetFormDisplayControl.Initialize(sourceWordElement, DeleteSourceWord); } }
public SourceWordElement AddCouplet(string strLhs, string strRhs) { Debug.Assert(!String.IsNullOrEmpty(strLhs) && !String.IsNullOrEmpty(strRhs)); string[] astrLhsWords = strLhs.Split(AdaptItKBReader.CaSplitChars, StringSplitOptions.RemoveEmptyEntries); if (astrLhsWords.Length == 0) { throw new ApplicationException(Resources.IDS_CantHaveEmptySourceWord); } MapOfSourceWordElements mapOfSourceWordElements; if (!TryGetValue(astrLhsWords.Length, out mapOfSourceWordElements)) { mapOfSourceWordElements = MapOfSourceWordElements.CreateNewMapOfSourceWordElements(astrLhsWords.Length, this); Xml.Add(mapOfSourceWordElements.Xml); } return(mapOfSourceWordElements.AddCouplet(strLhs, strRhs)); }
public void Add(MapOfSourceWordElements elemMap) { Xml.Add(elemMap.Xml); }
public static SourceWordElement CreateNewSourceWordElement(string strSourceWordForm, MapOfSourceWordElements mapOfSourceWordElements) { /* * <TU f="0" k="Δ"> * <RS n="1" a="ασδγδ" /> * </TU> */ var xml = new XElement(CstrElementNameSourceWord, new XAttribute(CstrAttributeNameForce, "0"), // means 'false' (don't ask) new XAttribute(CstrAttributeNameSourceWord, strSourceWordForm)); return(new SourceWordElement(xml, mapOfSourceWordElements)); }
public SourceWordElement(XElement elem, MapOfSourceWordElements parentMap) { _elem = elem; ParentMap = parentMap; }