Esempio n. 1
0
 private static void AddWritingSystemList(UIListDisplayProperties display, IEnumerable <IWritingSystem> list)
 {
     foreach (IWritingSystem ws in list)
     {
         display.List.Add(ws.DisplayLabel, ws.Handle.ToString(), null, null);
     }
 }
Esempio n. 2
0
        private bool FillList(UIListDisplayProperties display, string areaId)
        {
            // Don't bother refreshing this list.
            if (display.List.Count > 0)
            {
                return(true);
            }
            var         windowConfiguration = (XmlNode)m_mediator.PropertyTable.GetValue("WindowConfiguration");
            StringTable tbl = null;

            if (m_mediator != null && m_mediator.HasStringTable)
            {
                tbl = m_mediator.StringTbl;
            }
            XmlNodeList nodes = windowConfiguration.SelectNodes(GetToolXPath(areaId));

            if (nodes != null)
            {
                foreach (XmlNode node in nodes)
                {
                    string  label          = XmlUtils.GetLocalizedAttributeValue(tbl, node, "label", "???");
                    string  value          = XmlUtils.GetAttributeValue(node, "value", "???");
                    string  imageName      = XmlUtils.GetAttributeValue(node, "icon");               //can be null
                    XmlNode controlElement = node.SelectSingleNode("control");
                    display.List.Add(label, value, imageName, controlElement);
                }
            }
            return(true);
        }
Esempio n. 3
0
        /// <summary>
        /// this is called when XCore wants to display something that relies on the list with the id "WritingSystemList"
        /// </summary>
        /// <param name="parameter">The parameter.</param>
        /// <param name="display">The display.</param>
        /// <returns></returns>
        public bool OnDisplayWritingSystemList(object parameter, ref UIListDisplayProperties display)
        {
            CheckDisposed();

            display.List.Clear();
            FdoCache         cache    = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
            string           wsSet    = parameter as string;
            WritingSystemSet setToUse = m_currentSet;

            if (wsSet != null)
            {
                // JohnT: This is a patch to fix LT-5059. The problem is that the WritingSystemList set
                // (with the pronunciation subset) is used in the Pronuciation field pull-down menu.
                // All other code that I can find currently does not specify it. Therefore, after this
                // menu is displayed once, m_currentSet is set to pronunciation and stays there.
                // It seems that we actually have no current use for any other subset, nor for remembering
                // the most recent one specified. However, in the interests of making the change minimal,
                // and in case there is some anticipated application of tracking the current set which
                // I am not aware of, I made a way for that one menu item to get the list it needs
                // without making a persistent change.
                string tempPrefix = "temp:";
                bool   fTemp      = wsSet.StartsWith(tempPrefix);
                if (fTemp)
                {
                    setToUse = DecodeSetName(wsSet.Substring(tempPrefix.Length));
                }
                else
                {
                    m_currentSet = setToUse = DecodeSetName(wsSet);
                }
            }
            switch (setToUse)
            {
            default:
                throw new NotImplementedException("That writing system set needs to be implemented");

            case WritingSystemSet.All:
                AddWritingSystemList(display, cache.ServiceLocator.WritingSystemManager.LocalWritingSystems);
                break;

            case WritingSystemSet.AllCurrent:
                AddWritingSystemList(display, cache.ServiceLocator.WritingSystems.AllWritingSystems);
                break;

            case WritingSystemSet.CurrentAnalysis:
                AddWritingSystemList(display, cache.ServiceLocator.WritingSystems.CurrentAnalysisWritingSystems);
                break;

            case WritingSystemSet.CurrentVernacular:
                AddWritingSystemList(display, cache.ServiceLocator.WritingSystems.CurrentVernacularWritingSystems);
                break;

            case WritingSystemSet.CurrentPronounciation:
                AddWritingSystemList(display, cache.ServiceLocator.WritingSystems.CurrentPronunciationWritingSystems);
                string sValue = DomainObjectServices.JoinIds(cache.ServiceLocator.WritingSystems.CurrentPronunciationWritingSystems.Select(ws => ws.Handle).ToArray(), ",");
                m_mediator.PropertyTable.SetProperty("PronunciationWritingSystemHvos", sValue);
                break;
            }
            return(true);           //we handled this, no need to ask anyone else.
        }
Esempio n. 4
0
 private static void AddWritingSystemList(UIListDisplayProperties display, IEnumerable <CoreWritingSystemDefinition> list)
 {
     foreach (CoreWritingSystemDefinition ws in list)
     {
         display.List.Add(ws.DisplayLabel, ws.Handle.ToString(CultureInfo.InvariantCulture), null, null);
     }
 }
Esempio n. 5
0
 private void AddWritingSystemList(UIListDisplayProperties display,
                                   FdoReferenceSequence <ILgWritingSystem> list)
 {
     foreach (ILgWritingSystem ws in list)
     {
         display.List.Add(ws.ShortName, ws.Hvo.ToString(), null, null);
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Populate the writing system options for the slice.
 /// </summary>
 /// <param name="parameters"></param>
 /// <param name="display"></param>
 /// <returns></returns>
 public bool OnDisplayWritingSystemOptionsForSlice(object parameter, ref UIListDisplayProperties display)
 {
     CheckDisposed();
     display.List.Clear();
     Mediator.PropertyTable.SetProperty(display.PropertyName, this.GetVisibleWSSPropertyValue(), false);
     AddWritingSystemListWithIcuLocales(display, this.WritingSystemOptionsForDisplay);
     return(true);           //we handled this, no need to ask anyone else.
 }
Esempio n. 7
0
        /// <summary>
        /// Lists area listener was getting too different from other areas, so I made a
        /// separate version of FillList just for the Lists area.
        /// </summary>
        /// <param name="display"></param>
        /// <returns></returns>
        private bool FillListAreaList(UIListDisplayProperties display)
        {
            var customLists    = GetListOfOwnerlessLists();
            var fcustomChanged = customLists.Count != m_ccustomLists;

            // Since we're in the 'Lists' area, don't bother refreshing this
            // list, unless the number of Custom lists has changed. This happens
            // whenever someone adds one.
            if (display.List.Count > 0 && !fcustomChanged)
            {
                return(true);
            }

            // We can get here in the following cases:
            // Case 1: display.List is empty and m_ctotalLists == 0
            //       Load 'windowConfiguration' with all Custom lists,
            //       Update both list counts,
            //       Load 'display' with ALL lists.
            // Case 2: display.List is empty, but m_ctotalLists > 0
            //       We MAY have a recent Custom list addition to add.
            //       If 'fcustomChanged', load the new Custom list into 'windowConfiguration',
            //          and update both list counts,
            //       Load 'display' with ALL lists.
            // Case 3: display.List is loaded, but we have a recent Custom list addition to add.
            //       Load the new Custom list into 'windowConfiguration',
            //       Update both list counts,
            //       Only update 'display' with new Custom list.
            // N.B. This may need changing if we allow the user to DELETE Custom lists someday.
            var windowConfiguration = m_propertyTable.GetValue <XmlNode>("WindowConfiguration");

            UpdateWinConfig(fcustomChanged, customLists, windowConfiguration);

            // Now update 'display'
            var cache    = m_propertyTable.GetValue <LcmCache>("cache");
            var possRepo = cache.ServiceLocator.GetInstance <ICmPossibilityListRepository>();

            if (display.List.Count > 0)
            {
                var node = windowConfiguration.SelectSingleNode(GetListToolsXPath()).LastChild;
                if (node != null)
                {
                    AddToolNodeToDisplay(possRepo, cache, display, node);
                }
            }
            else
            {
                var nodes = windowConfiguration.SelectNodes(GetToolXPath("lists"));
                if (nodes == null)
                {
                    return(true);
                }
                foreach (XmlNode node in nodes)
                {
                    AddToolNodeToDisplay(possRepo, cache, display, node);
                }
            }
            return(true);
        }
Esempio n. 8
0
        private void AddWritingSystemList(UIListDisplayProperties display, Set <NamedWritingSystem> set)
        {
            List <NamedWritingSystem> list = new List <NamedWritingSystem>(set.ToArray());           // A Set doesn't know about sorting, so use a list.

            list.Sort();
            foreach (NamedWritingSystem ws in list)
            {
                display.List.Add(ws.Name, ws.Hvo.ToString(), null, null);
            }
        }
 public static void RemoveAllReversalChoiceFromList(ref UIListDisplayProperties display)
 {
     foreach (XCore.ListItem reversalIndexConfiguration in display.List)
     {
         if (reversalIndexConfiguration.value.EndsWith(DictionaryConfigurationModel.AllReversalIndexesFilenameBase + DictionaryConfigurationModel.FileExtension))
         {
             display.List.Remove(reversalIndexConfiguration);
             break;
         }
     }
 }
 /// <summary>
 /// stores the list values in terms of icu locale
 /// </summary>
 /// <param name="display"></param>
 /// <param name="list"></param>
 private void AddWritingSystemListWithIcuLocales(UIListDisplayProperties display, IEnumerable <IWritingSystem> list)
 {
     string[] active = GetVisibleWSSPropertyValue().Split(',');
     foreach (var ws in list)
     {
         // generally enable all items, but if only one is checked that one is disabled;
         // it can't be turned off.
         bool enabled = (active.Length != 1 || ws.Id != active[0]);
         display.List.Add(ws.DisplayLabel, ws.Id, null, null, enabled);
     }
 }
Esempio n. 11
0
        public bool OnDisplayListsToolsList(object parameters, ref UIListDisplayProperties display)
        {
            CheckDisposed();

            if (FillListAreaList(display))
            {
                // By now the labels in this List are localized, so if we sort we get what
                // we want; a localized sorted list of lists [LT-9579]
                display.List.Sort();
                return(true);
            }
            return(false);
        }
Esempio n. 12
0
        /// <summary>
        /// This is called when XCore wants to display something that relies on the list with the
        /// id "ReversalIndexList"
        /// </summary>
        /// <param name="parameter"></param>
        /// <param name="display"></param>
        /// <returns></returns>
        public bool OnDisplayReversalIndexList(object parameter, ref UIListDisplayProperties display)
        {
            CheckDisposed();

            display.List.Clear();
            var cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");

            // List all existing reversal indexes.  (LT-4479, as amended)
            //IReversalIndex riOwner = this.IReversalIndex;
            foreach (IReversalIndex ri in cache.LanguageProject.LexDbOA.ReversalIndexesOC)
            {
                display.List.Add(ri.ShortName, ri.Guid.ToString(), null, null);
            }
            display.List.Sort();
            return(true);            // We handled this, no need to ask anyone else.
        }
Esempio n. 13
0
        private static void AddToolNodeToDisplay(ICmPossibilityListRepository possRepo, FdoCache cache,
                                                 UIListDisplayProperties display, StringTable tbl, XmlNode node)
        {
            // Modified how this works, so it uses the current UI version of the PossibilityList Name,
            // if possible.
            var localizedLabel = FindMatchingPossibilityListUIName(node, possRepo, cache);

            if (localizedLabel == null)
            {
                localizedLabel = XmlUtils.GetLocalizedAttributeValue(tbl, node, "label", "???");
            }
            var value          = XmlUtils.GetAttributeValue(node, "value", "???");
            var imageName      = XmlUtils.GetAttributeValue(node, "icon");        //can be null
            var controlElement = node.SelectSingleNode("control");

            display.List.Add(localizedLabel, value, imageName, controlElement);
        }
Esempio n. 14
0
        /// <summary>
        /// This is called when XCore wants to display something that relies on the list with the
        /// id "ReversalIndexList"
        /// </summary>
        /// <param name="parameter"></param>
        /// <param name="display"></param>
        /// <returns></returns>
        public bool OnDisplayReversalIndexList(object parameter, ref UIListDisplayProperties display)
        {
            CheckDisposed();

            var configObjectName = XmlUtils.GetOptionalAttributeValue(m_configurationParameters, "configureObjectName", null);

            configObjectName = "ReversalIndex";
            var cache = m_propertyTable.GetValue <LcmCache>("cache");
            var reversalIndexConfigurations = SIL.FieldWorks.XWorks.DictionaryConfigurationUtils.GatherBuiltInAndUserConfigurations(cache, configObjectName);

            // Add menu items that display the configuration name and send PropChanges with
            // the configuration path.
            foreach (var config in reversalIndexConfigurations)
            {
                display.List.Add(config.Key, config.Value, null, null);
            }
            DictionaryConfigurationUtils.RemoveAllReversalChoiceFromList(ref display);

            return(true);            // We handled this, no need to ask anyone else.
        }
Esempio n. 15
0
        public bool OnDisplayGrammarToolsList(object parameters, ref UIListDisplayProperties display)
        {
            CheckDisposed();

            return(FillList(display, "grammar"));
        }
Esempio n. 16
0
        private bool FillListAreaList(UIListDisplayProperties display)
        {
            var customLists    = GetListOfOwnerlessLists();
            var fcustomChanged = customLists.Count != m_ccustomLists;

            // Since we're in the 'Lists' area, don't bother refreshing this
            // list, unless the number of Custom lists has changed. This happens
            // whenever someone adds one.
            if (display.List.Count > 0 && !fcustomChanged)
            {
                return(true);
            }

            // We can get here in the following cases:
            // Case 1: display.List is empty and m_ctotalLists == 0
            //       Load 'windowConfiguration' with all Custom lists,
            //       Update both list counts,
            //       Load 'display' with ALL lists.
            // Case 2: display.List is empty, but m_ctotalLists > 0
            //       We MAY have a recent Custom list addition to add.
            //       If 'fcustomChanged', load the new Custom list into 'windowConfiguration',
            //          and update both list counts,
            //       Load 'display' with ALL lists.
            // Case 3: display.List is loaded, but we have a recent Custom list addition to add.
            //       Load the new Custom list into 'windowConfiguration',
            //       Update both list counts,
            //       Only update 'display' with new Custom list.
            // N.B. This may need changing if we allow the user to DELETE Custom lists someday.
            var windowConfiguration = (XmlNode)m_mediator.PropertyTable.GetValue("WindowConfiguration");

            UpdateWinConfig(fcustomChanged, customLists, windowConfiguration);

            // Now update 'display'
            StringTable tbl   = null;
            FdoCache    cache = null;
            ICmPossibilityListRepository possRepo = null;

            if (m_mediator != null && m_mediator.HasStringTable)
            {
                tbl = m_mediator.StringTbl;
            }
            if (m_mediator != null)
            {
                cache = (FdoCache)m_mediator.PropertyTable.GetValue("cache");
            }
            if (cache != null)
            {
                possRepo = cache.ServiceLocator.GetInstance <ICmPossibilityListRepository>();
            }
            if (display.List.Count > 0)
            {
                var node = windowConfiguration.SelectSingleNode(GetListToolsXPath()).LastChild;
                if (node != null)
                {
                    AddToolNodeToDisplay(possRepo, cache, display, tbl, node);
                }
            }
            else
            {
                var nodes = windowConfiguration.SelectNodes(GetToolXPath("lists"));
                if (nodes != null)
                {
                    foreach (XmlNode node in nodes)
                    {
                        if ((!FwUtils.IsTEInstalled) && XmlUtils.GetOptionalBooleanAttributeValue(node, "bteOnly", false))
                        {
                            continue;
                        }
                        AddToolNodeToDisplay(possRepo, cache, display, tbl, node);
                    }
                }
            }
            return(true);
        }
Esempio n. 17
0
        public bool OnDisplayNotebookToolsList(object parameters, ref UIListDisplayProperties display)
        {
            CheckDisposed();

            return(FillList(display, "notebook"));
        }
Esempio n. 18
0
        public bool OnDisplayTextToolsList(object parameters, ref UIListDisplayProperties display)
        {
            CheckDisposed();

            return(FillList(display, "textsWords"));
        }
Esempio n. 19
0
        /// <summary>
        /// Called when XCore wants to display something that relies on the list with the id
        /// "CombinedStylesList".
        /// </summary>
        public bool OnDisplayCombinedStylesList(object parameter, ref UIListDisplayProperties display)
        {
            CheckDisposed();

            return(false);
        }
Esempio n. 20
0
        public bool OnDisplayLexicalToolsList(object parameters, ref UIListDisplayProperties display)
        {
            CheckDisposed();

            return(FillList(display, "lexicon"));
        }