CacheVecProp() public method

Determine absolutely what the new list of hvos will be.
public CacheVecProp ( int hvoObj, int hvos ) : void
hvoObj int The hvo.
hvos int The hvos.
return void
コード例 #1
0
        /// <summary>
        /// Store the given hvos in the cache as a fake vector property belonging to the
        /// language project.
        /// </summary>
        /// <param name="objs">The objs.</param>
        private void StoreData(IEnumerable <ICmObject> objs)
        {
            var rghvo = (from obj in objs
                         select obj.Hvo).ToArray();

            m_listPublisher.CacheVecProp(m_cache.LanguageProject.Hvo, rghvo);
        }
コード例 #2
0
        ///<summary>
        /// Decorate an ISilDataAccessManaged object with another layer limiting objects to print.
        ///</summary>
        ///<param name="oldSda"></param>
        ///<param name="rootHvo"></param>
        ///<param name="mainFlid"></param>
        ///<param name="selectedObjects"></param>
        ///<returns></returns>
        public static ISilDataAccessManaged CachePrintDecorator(ISilDataAccessManaged oldSda,
                                                                int rootHvo, int mainFlid, int[] selectedObjects)
        {
            var printDecorator = new ObjectListPublisher(oldSda, mainFlid);

            printDecorator.CacheVecProp(rootHvo, selectedObjects);
            return(printDecorator);
        }
コード例 #3
0
		public void SetAndAccessDummyList()
		{
			ILexDb lexDb = Cache.LangProject.LexDbOA;
			ILexEntry entry1 = null;
			ICmResource res1 = null;
			NonUndoableUnitOfWorkHelper.Do(m_actionHandler, () =>
			{
				var leFactory = Cache.ServiceLocator.GetInstance<ILexEntryFactory>();
				entry1 = leFactory.Create();
				ILexEntry entry2 = leFactory.Create();
				res1 = Cache.ServiceLocator.GetInstance<ICmResourceFactory>().Create();
				lexDb.ResourcesOC.Add(res1);
			});

			int hvoRoot = 10578;
			ObjectListPublisher publisher = new ObjectListPublisher(Cache.MainCacheAccessor as ISilDataAccessManaged, ObjectListFlid);
			var values = new int[] {23, 56, 2048};
			Notifiee recorder = new Notifiee();
			publisher.AddNotification(recorder);
			publisher.CacheVecProp(hvoRoot, values);
			Assert.AreEqual(values.Length, publisher.get_VecSize(hvoRoot, ObjectListFlid), "override of vec size");
			//Assert.AreEqual(Cache.LangProject.Texts.Count, publisher.get_VecSize(Cache.LangProject.Hvo, LangProjectTags.kflidTexts), "base vec size");

			Assert.AreEqual(23, publisher.get_VecItem(hvoRoot, ObjectListFlid, 0), "override of vec item");
			Assert.AreEqual(res1.Hvo, publisher.get_VecItem(lexDb.Hvo, LexDbTags.kflidResources, 0), "base vec item");
			Assert.AreEqual(56, publisher.get_VecItem(hvoRoot, ObjectListFlid, 1), "override of vec item, non-zero index");

			VerifyCurrentValue(hvoRoot, publisher, values, "original value");
			Assert.AreEqual(lexDb.ResourcesOC.Count(), publisher.VecProp(lexDb.Hvo, LexDbTags.kflidResources).Length, "base VecProp");

			recorder.CheckChanges(new ChangeInformationTest[] { new ChangeInformationTest(hvoRoot, ObjectListFlid, 0, values.Length, 0) },
				"expected PropChanged from caching HVOs");
			publisher.RemoveNotification(recorder);

			recorder = new Notifiee();
			publisher.AddNotification(recorder);
			publisher.Replace(hvoRoot, 1, new int[] {97, 98}, 0);
			VerifyCurrentValue(hvoRoot, publisher, new int[] {23, 97, 98, 56, 2048}, "after inserting 97, 98" );
			recorder.CheckChanges(new ChangeInformationTest[] { new ChangeInformationTest(hvoRoot, ObjectListFlid, 1, 2, 0) },
				"expected PropChanged from caching HVOs");
			publisher.RemoveNotification(recorder);

			recorder = new Notifiee();
			publisher.AddNotification(recorder);
			publisher.Replace(hvoRoot, 1, new int[0] , 2);
			VerifyCurrentValue(hvoRoot, publisher, new int[] { 23, 56, 2048 }, "after deleting 97, 98");
			recorder.CheckChanges(new ChangeInformationTest[] { new ChangeInformationTest(hvoRoot, ObjectListFlid, 1, 0, 2) },
				"expected PropChanged from caching HVOs");
			publisher.RemoveNotification(recorder);
		}
コード例 #4
0
        private void UpdateResults(int[] hvos)
        {
            int count     = hvos.Length;
            int prevIndex = m_bvMatches.SelectedIndex;
            int prevHvo   = prevIndex == -1 ? 0 : m_bvMatches.AllItems[prevIndex];

            m_listPublisher.CacheVecProp(m_cache.LanguageProject.LexDbOA.Hvo, hvos);
            TabStop = count > 0;
            // Disable the list so that it doesn't steal the focus (LT-9481)
            m_bvMatches.Enabled = false;
            try
            {
                // LT-6366
                if (count == 0)
                {
                    if (m_bvMatches.BrowseView.IsHandleCreated)
                    {
                        m_bvMatches.SelectedIndex = -1;
                    }
                    m_selObject = null;
                }
                else
                {
                    int newIndex = 0;
                    var allItems = m_bvMatches.AllItems;                     // This is an important optimization; each call marshals the whole list!
                    for (int i = 0; i < allItems.Count; i++)
                    {
                        if (allItems[i] == prevHvo)
                        {
                            newIndex = i;
                            break;
                        }
                    }
                    if (m_bvMatches.BrowseView.IsHandleCreated)
                    {
                        m_bvMatches.SelectedIndex = newIndex;
                    }
                    m_selObject = m_cache.ServiceLocator.GetObject(allItems[newIndex]);
                    FireSelectionChanged();
                }
            }
            finally
            {
                m_bvMatches.Enabled = true;
            }
        }
コード例 #5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a view with multiple LexEntry objects.
		/// </summary>
		/// <param name="rghvoEntries"></param>
		/// <param name="cache"></param>
		/// <param name="styleSheet"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		private XmlView CreateSummaryView(List<int> rghvoEntries, FdoCache cache, IVwStylesheet styleSheet)
		{
			// Make a decorator to publish the list of entries as a fake property of the LexDb.
			int kflidEntriesFound = 8999950; // some arbitrary number not conflicting with real flids.
			var sda = new ObjectListPublisher(cache.DomainDataByFlid as ISilDataAccessManaged, kflidEntriesFound);
			int hvoRoot = RootHvo;
			sda.CacheVecProp(hvoRoot, rghvoEntries.ToArray());
			//TODO: Make this method return a GeckoBrowser control, and generate the content here.
			// The name of this property must match the property used by the publishFound layout.
			sda.SetOwningPropInfo(LexDbTags.kflidClass, "LexDb", "EntriesFound");

			// Make an XmlView which displays that object using the specified layout.
			XmlView xv = new XmlView(hvoRoot, "publishFound", null, false, sda);
			xv.Cache = cache;
			xv.Mediator = m_mediator;
			xv.StyleSheet = styleSheet;
			return xv;
		}
コード例 #6
0
        private void UpdateResults(SearchField firstField, IEnumerable <int> results)
        {
            ITsString firstSearchStr = firstField.String;
            // if the firstSearchStr is null we can't get its writing system
            RecordSorter sorter = null;

            if (firstSearchStr != null)
            {
                int ws = firstSearchStr.get_WritingSystemAt(0);
                sorter = CreateFindResultSorter(firstSearchStr, ws);
            }
            int[] hvos;
            if (sorter != null)
            {
                // Convert each ICmObject in results to a IManyOnePathSortItem, and sort
                // using the sorter.
                var records = new ArrayList();
                foreach (int hvo in results.Where(hvo => StartingObject == null || StartingObject.Hvo != hvo))
                {
                    records.Add(new ManyOnePathSortItem(hvo, null, null));
                }
                sorter.Sort(records);
                hvos = records.Cast <IManyOnePathSortItem>().Select(i => i.KeyObject).ToArray();
            }
            else
            {
                hvos = results.Where(hvo => StartingObject == null || StartingObject.Hvo != hvo).ToArray();
            }

            int count     = hvos.Length;
            int prevIndex = m_bvMatches.SelectedIndex;
            int prevHvo   = prevIndex == -1 ? 0 : m_bvMatches.AllItems[prevIndex];

            m_listPublisher.CacheVecProp(m_cache.LanguageProject.LexDbOA.Hvo, hvos);
            TabStop = count > 0;
            // Disable the list so that it doesn't steal the focus (LT-9481)
            m_bvMatches.Enabled = false;
            try
            {
                // LT-6366
                if (count == 0)
                {
                    if (m_bvMatches.BrowseView.IsHandleCreated)
                    {
                        m_bvMatches.SelectedIndex = -1;
                    }
                    m_selObject = null;
                }
                else
                {
                    int newIndex = 0;
                    var allItems = m_bvMatches.AllItems;                     // This is an important optimization; each call marshals the whole list!
                    for (int i = 0; i < allItems.Count; i++)
                    {
                        if (allItems[i] == prevHvo)
                        {
                            newIndex = i;
                            break;
                        }
                    }
                    if (m_bvMatches.BrowseView.IsHandleCreated)
                    {
                        m_bvMatches.SelectedIndex = newIndex;
                    }
                    m_selObject = m_cache.ServiceLocator.GetObject(allItems[newIndex]);
                    FireSelectionChanged();
                }
            }
            finally
            {
                m_bvMatches.Enabled = true;
            }

            if (!m_searchEngine.IsBusy && SearchCompleted != null)
            {
                SearchCompleted(this, new EventArgs());
            }
        }
コード例 #7
0
ファイル: XmlSeqView.cs プロジェクト: bbriggs/FieldWorks
		///<summary>
		/// Decorate an ISilDataAccessManaged object with another layer limiting objects to print.
		///</summary>
		///<param name="oldSda"></param>
		///<param name="rootHvo"></param>
		///<param name="mainFlid"></param>
		///<param name="selectedObjects"></param>
		///<returns></returns>
		public static ISilDataAccessManaged CachePrintDecorator(ISilDataAccessManaged oldSda,
			int rootHvo, int mainFlid, int[] selectedObjects)
		{
			var printDecorator = new ObjectListPublisher(oldSda, mainFlid);
			printDecorator.CacheVecProp(rootHvo, selectedObjects);
			return printDecorator;
		}