Пример #1
0
        /// <summary>
        /// Resets the sorter so that it will use the writing system of the given reversal index.
        /// </summary>
        /// <param name="ri"></param>
        private void ResetListSorter(IReversalIndex ri)
        {
            var sorter        = Sorter as GenRecordSorter;
            var writingSystem = (IWritingSystem)Cache.WritingSystemFactory.get_Engine(ri.WritingSystem);

            if (sorter != null)
            {
                var stringFinderComparer = sorter.Comparer as StringFinderCompare;
                if (stringFinderComparer != null)
                {
                    var comparer = new StringFinderCompare(stringFinderComparer.Finder, new WritingSystemComparer(writingSystem));
                    sorter.Comparer = comparer;
                }
            }
            else if (Sorter == null)
            {
                var fakevc = new XmlBrowseViewBaseVc {
                    SuppressPictures = true, Cache = Cache
                };                                                                                              // SuppressPictures to make sure that we don't leak anything as this will not be disposed.
                m_list.Sorter = new GenRecordSorter(new StringFinderCompare(LayoutFinder.CreateFinder(Cache,
                                                                                                      BrowseViewFormCol,
                                                                                                      fakevc,
                                                                                                      (IApp)m_mediator.PropertyTable.GetValue("App")),
                                                                            new WritingSystemComparer(writingSystem)));
            }
        }
Пример #2
0
        /// <summary>
        /// The stored sorter files keep messing us up here, so we need to do a bit of post-deserialization processing.
        /// </summary>
        /// <returns>true if we restored something different from what was already there.</returns>
        protected override bool TryRestoreSorter(XmlNode clerkConfiguration, LcmCache cache)
        {
            var fakevc = new XmlBrowseViewBaseVc {
                SuppressPictures = true, Cache = Cache
            };                                                                                           // SuppressPictures to make sure that we don't leak anything as this will not be disposed.

            if (base.TryRestoreSorter(clerkConfiguration, cache) && Sorter is GenRecordSorter)
            {
                var sorter = (GenRecordSorter)Sorter;
                var stringFinderComparer = sorter.Comparer as StringFinderCompare;
                if (stringFinderComparer != null)
                {
                    var colSpec = ReflectionHelper.GetField(stringFinderComparer.Finder, "m_colSpec") as XmlNode ?? BrowseViewFormCol;
                    sorter.Comparer = new StringFinderCompare(LayoutFinder.CreateFinder(Cache, colSpec, fakevc,
                                                                                        m_propertyTable.GetValue <IApp>("App")),
                                                              stringFinderComparer.SubComparer);
                }
                return(true);
            }
            if (Sorter is GenRecordSorter)            // If we already have a GenRecordSorter, it's probably an existing, valid one.
            {
                return(false);
            }
            // Try to create a sorter based on the current Reversal Index's WritingSystem
            var newGuid = ReversalIndexEntryUi.GetObjectGuidIfValid(m_propertyTable, "ReversalIndexGuid");

            if (newGuid.Equals(Guid.Empty))
            {
                return(false);
            }
            var ri = cache.ServiceLocator.GetObject(newGuid) as IReversalIndex;

            if (ri == null)
            {
                return(false);
            }
            var writingSystem = (CoreWritingSystemDefinition)Cache.WritingSystemFactory.get_Engine(ri.WritingSystem);

            m_list.Sorter = new GenRecordSorter(new StringFinderCompare(LayoutFinder.CreateFinder(Cache, BrowseViewFormCol, fakevc,
                                                                                                  m_propertyTable.GetValue <IApp>("App")),
                                                                        new WritingSystemComparer(writingSystem)));
            return(true);
        }