/// <summary> /// create new browser record /// </summary> /// <param name="record"></param> public void AddRecord(BrowserRecord record) { //Avoid add duplicate records var existSameRecord = (records != null && records.Count > 0) && (records[currenRecordIndex].GetType() == record.GetType()) && (records[currenRecordIndex].Equals(record)); if (existSameRecord) { return; } bool isLastIndex = (currenRecordIndex == records.Count - 1); if (isLastIndex) { currenRecordIndex++; records.Add(record); } else if (currenRecordIndex < records.Count - 1) { currenRecordIndex++; var backCount = records.Count - currenRecordIndex; records.RemoveRange(currenRecordIndex, backCount); records.Add(record); } }
private void NavigateForward() { BrowserRecord forwardBrowserRecord = AppDataUtil.Instance.Forward(); if (forwardBrowserRecord != null) { List <Publication> cachedPublicationList = PublicationUtil.Instance.GetPublicationOffline(); Publication navigateToP = cachedPublicationList.Find(o => o.BookId == forwardBrowserRecord.BookID); if (forwardBrowserRecord.RecordType == RecordType.ContentRecord) { AppDataUtil.Instance.SetCurrentPublication(navigateToP); ContentBrowserRecord contentBR = (ContentBrowserRecord)forwardBrowserRecord; AppDataUtil.Instance.SetOpendTOC(AppDataUtil.Instance.GetTOCNodeByID(contentBR.TOCID)); } else if (forwardBrowserRecord.RecordType == RecordType.SearchResultRecord) { SearchBrowserRecord searchBR = (SearchBrowserRecord)forwardBrowserRecord; AppDataUtil.Instance.SetCurrentPublication(navigateToP, searchBR.KeyWords); AppDataUtil.Instance.SetOpendTOC(AppDataUtil.Instance.GetTOCNodeByID(searchBR.TOCID)); } else if (forwardBrowserRecord.RecordType == RecordType.AnnotationNavigator) { //TODO, Back to annotation navigator } } }
public static int ContentsTabGetTocId(BrowserRecord record) { switch (record.RecordType) { case RecordType.ContentRecord: return(((ContentBrowserRecord)record).TOCID); case RecordType.SearchResultRecord: return(((SearchBrowserRecord)record).TOCID); default: return(TocIdError); } }
private void SyncStatus(Publication pub) { if (!DataCache.INSTATNCE.Toc.IsCurrentNavigationItem()) { var tocid = NavigationManagerHelper.ContentsTabGetTocId(NavigationManager.Instance.CurrentRecord); if (!NavigationManagerHelper.IsShowContentRecord(tocid)) { BrowserRecord record = DataCache.INSTATNCE.Toc.GetNavigationItem(); if (record == null) { record = NavigationManagerHelper.GetLastReasonableRecord( new List <RecordType> { RecordType.ContentRecord, RecordType.SearchResultRecord }); } if (record == null || (tocid = NavigationManagerHelper.ContentsTabGetTocId(record)) == NavigationManagerHelper.TocIdDefaultPage) { DataCache.INSTATNCE.Toc.CurrentTOCNode = DataCache.INSTATNCE.Toc.GetFirstPage(); } else { DataCache.INSTATNCE.Toc.SetCurrentTOCNodeById(tocid); } tocListAdaptor.RefreshNodeList(); ((ContentActivity)Activity).GetMainFragment().OpenContentPage(); return; } if (tocid == NavigationManagerHelper.TocIdDefaultPage && NavigationManager.Instance.Records.Count > 1) { DataCache.INSTATNCE.Toc.CurrentTOCNode = DataCache.INSTATNCE.Toc.GetFirstPage(); } else { DataCache.INSTATNCE.Toc.SetCurrentTOCNodeById(tocid); } DataCache.INSTATNCE.Toc.BindNavigationItem(); } tocListAdaptor.RefreshNodeList(); ((ContentActivity)Activity).GetMainFragment().OpenContentPage(); return; }
/// <summary> /// create new browser record /// </summary> /// <param name="record"></param> public void AddRecord(BrowserRecord record) { //Avoid add duplicate records if (currenRecordIndex > 0 && records[currenRecordIndex].Equals(record)) { return; } if (currenRecordIndex == records.Count - 1) { currenRecordIndex++; records.Add(record); } else if (currenRecordIndex < records.Count - 1) { currenRecordIndex++; records.RemoveRange(currenRecordIndex, records.Count - currenRecordIndex); records.Add(record); } }