Example #1
0
 private void display()
 {
     if (datcats.Count > 0)
     {
         textblock_user_dc.Text = datcats[index];
         vpmc.clear();
         vpmc.fillListBoxes(mapping.getTBXMappingList(datcats[index]), mapping.getContentList(datcats[index]) as List <string>);
     }
 }
Example #2
0
 /// <summary>
 /// Fills the mappedPicklists Dictionary with a key that is the combination of a data category and a content, and a boolean value.
 /// <para>
 /// Any content values which are mapped to TBX data categories which do not have picklists will be skipped.
 /// </para>
 /// <para>
 /// <code>{ 'part of speech_noun' : false }</code>
 /// </para>
 /// <para>
 /// This means that the content "noun" of "part of speech" has not been mapped to a TBX picklist value yet.
 /// </para>
 /// </summary>
 private void fillMappedPicklistsDict()
 {
     dcs_with_picklists.ForEach(delegate(string dc)
     {
         foreach (string val in mapping.getContentList(dc))
         {
             string[] keys = Methods.getKeyArray(tbx_picklists.Keys);
             if (mapping.getTBXMappingList(dc).Count < 2 || Methods.inArray(ref keys, mapping.getTBXContentMap(dc)?.Get(val)))
             {
                 try
                 {
                     mappedPicklists.Add(dc + "_" + val, false);
                 }
                 catch (System.ArgumentException e)
                 {
                     continue;
                 }
             }
         }
     });
 }
        private void loadDatCats()
        {
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.DtdProcessing = DtdProcessing.Ignore;
            XmlReader reader = XmlReader.Create(filename, settings);

            bool start = false;
            int  level = 0;

            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element && (reader.Name == "body" || reader.Name == "mtf"))
                {
                    start = true;
                }
                if (start == true)
                {
                    if (reader.Name == "back")
                    {
                        start = false;
                        continue;
                    }

                    if (reader.Name == "conceptGrp" || reader.Name == "languageGrp" || reader.Name == "termGrp" ||
                        reader.Name == "termEntry" || reader.Name == "langSet" || reader.Name == "tig" ||
                        reader.Name == "conceptEntry" || reader.Name == "langSec" || reader.Name == "termSec")
                    {
                        switch (reader.Name)
                        {
                        case "conceptGrp":
                        case "termEntry":
                        case "conceptEntry":
                            level = 1;
                            break;

                        case "languageGrp":
                        case "langSet":
                        case "langSec":
                            level = 2;
                            break;

                        case "termGrp":
                        case "tig":
                        case "termSec":
                            level = 3;
                            break;
                        }
                    }

                    if (reader.NodeType == XmlNodeType.Element && reader.HasAttributes && null != reader.GetAttribute("type") && reader.Name != "language")
                    {
                        string dc = reader.GetAttribute("type");
                        if (!Methods.inList(ref datcats, dc))
                        {
                            datcats.Add(dc);
                            mapping.Add(dc);

                            switch (level)
                            {
                            case 1:
                                mapping.levelMap["conceptGrp"].Add(dc);
                                break;

                            case 2:
                                mapping.levelMap["languageGrp"].Add(dc);
                                break;

                            case 3:
                                mapping.levelMap["termGrp"].Add(dc);
                                break;
                            }
                        }

                        //Pull out text for use later with picklists
                        XmlReader textReader = reader.ReadSubtree();

                        while (textReader.Read())
                        {
                            if (textReader.NodeType == XmlNodeType.Text)
                            {
                                List <string> values = mapping.getContentList(dc) as List <string>;
                                if (!Methods.inList(ref values, reader.Value))
                                {
                                    mapping.getContentList(dc).Add(textReader.Value);
                                }
                            }
                        }
                    }
                }
            }

            datcats.Sort();
            textTotal.Text = datcats.Count().ToString();
        }