public static MapOfMaps LoadXml(string strFilename)
        {
            if (!File.Exists(strFilename))
            {
                EncConverters.ThrowError(ErrStatus.CantOpenReadMap, strFilename);
            }

            var doc = XDocument.Load(strFilename);

            // determine if this is the new or old KB format (old: {docVersion};
            //  new: {kbVersion})
            var        elemKb = doc.Elements().First();
            XAttribute attr;
            var        strSrcLanguage = ((attr = elemKb.Attribute(CstrAttributeNameSourceLanguageName)) != null)
                                     ? attr.Value
                                     : null;
            var strTgtLanguage = ((attr = elemKb.Attribute(CstrAttributeNameTargetLanguageName)) != null)
                                     ? attr.Value
                                     : null;

            attr = elemKb.Attribute(CstrAttributeNameDocVersion);
            var mapOfMaps = new MapOfMaps(elemKb)
            {
                XDocument   = doc,
                IsKbV2      = (attr == null),
                SrcLangName = strSrcLanguage,
                TgtLangName = strTgtLanguage
            };

            return(mapOfMaps);
        }
        private XElement GetDecendent(string strSourceWord)
        {
            var strXPath = MapOfMaps.FormatXpath(SourceWordElement.CstrElementNameSourceWord,
                                                 SourceWordElement.CstrAttributeNameSourceWord,
                                                 strSourceWord);

            return(Xml.XPathSelectElement(strXPath));
        }
        public static MapOfSourceWordElements CreateNewMapOfSourceWordElements(int nNumOfWordsPerPhrase,
                                                                               MapOfMaps mapOfMaps)
        {
            /*
             * <MAP mn="1">
             * <TU f="0" k="Δ">
             *  <RS n="1" a="ασδγδ" />
             * </TU>
             * </MAP>
             */
            var elem = new XElement(CstrElementNameNumOfWordsPerPhraseMap,
                                    new XAttribute(CstrAttributeNameNumOfWordsPerPhrase, nNumOfWordsPerPhrase));

            return(new MapOfSourceWordElements(elem, nNumOfWordsPerPhrase, mapOfMaps));
        }
        private XElement GetDecendent(string strSourceWord)
        {
            var strXPath = MapOfMaps.FormatXpath(SourceWordElement.CstrElementNameSourceWord,
                                                 SourceWordElement.CstrAttributeNameSourceWord,
                                                 strSourceWord);

            try
            {
                return(Xml.XPathSelectElement(strXPath));
            }
            catch (Exception ex)
            {
                var strError = ex.Message;
                Debug.WriteLine(String.Format("while searching for '{0}', error occurred: {1}", strSourceWord, strError));
                throw;
            }
        }
        internal ViewSourceFormsForm(MapOfMaps mapOfMaps, AdaptItKBReader.LanguageInfo liSourceWordLang,
                                     AdaptItKBReader.LanguageInfo liTargetLang, char[] achTrimSource, char[] achTrimTarget)
        {
            InitializeComponent();
            _mapOfMaps     = mapOfMaps;
            _achTrimSource = achTrimSource;
            _achTrimTarget = achTrimTarget;

            foreach (var strSourceWord in mapOfMaps.ListOfAllSourceWordForms)
            {
                listBoxSourceWordForms.Items.Add(strSourceWord);
            }

            targetFormDisplayControl.TargetWordFont        = liTargetLang.FontToUse;
            targetFormDisplayControl.TargetWordRightToLeft = liTargetLang.RightToLeft;
            targetFormDisplayControl.CallToSetModified     = SetModified;
            textBoxFilter.Font        = listBoxSourceWordForms.Font = liSourceWordLang.FontToUse;
            textBoxFilter.RightToLeft =
                listBoxSourceWordForms.RightToLeft = liSourceWordLang.RightToLeft;
        }
 public MapOfSourceWordElements(XElement elem, int numOfWordsPerPhrase, MapOfMaps parentMapOfMaps)
 {
     _elem = elem;
     NumOfWordsPerPhrase = numOfWordsPerPhrase;
     ParentMapOfMaps     = parentMapOfMaps;
 }