Пример #1
0
        public void GetSearchResultByKeyWord(int bookID, string keyWord)
        {
            //PublicationResultList = SearchUtil.Search (bookID, ref keyWord, SearchUtil.ContentCategory.All);
            if (PublicationResultList == null || PublicationResultList.Count == 0)
            {
                int ncount = 10;
                PublicationResultList = new List <SearchDisplayResult> (0);
                while (ncount > 0)
                {
                    var value = new SearchDisplayResult();
                    value.TocId          = 1;
                    value.TocTitle       = "Update";
                    value.GuideCardTitle = "What";
                    PublicationResultList.Add(value);

                    ncount--;
                }

                DocumentResultList = new List <SearchDisplayResult> (0);
                DocumentResultList.AddRange(PublicationResultList);
            }
            else
            {
                var value = new SearchDisplayResult();
                value.TocId          = 1;
                value.TocTitle       = "Update";
                value.GuideCardTitle = "What";

                DocumentResultList = new List <SearchDisplayResult> (0);
                DocumentResultList.Add(value);
            }

            GroupLevelItems();
            //UpdateResultListAndRefreshTableView ();
        }
        public async override void SelectionDidChange(NSNotification notification)
        {
            var tableView = (NSTableView)notification.Object;
            int index     = Convert.ToInt32(tableView.SelectedRow);

            if (index <= 0 || index == documentList.Count + 1)
            {
                return;
            }

            SearchDisplayResult resultItem = null;

            if (index > 0 && index <= documentList.Count)
            {
                int rowIndex = index - 1;
                resultItem = documentList [rowIndex];
            }
            else
            {
                int rowIndex = index - 1 - documentList.Count - 1;
                resultItem = publicationList [rowIndex];
            }

            await seachViewController.OpenPublicationContentAtSearchItem(resultItem);
        }
        //"outlineViewSelectionDidChange:"
        public override void SelectionDidChange(NSNotification notification)
        {
            var tableView = (NSOutlineView)notification.Object;
            int selRow    = Convert.ToInt16(tableView.SelectedRow);

            viewController.OpenPublicationAtTocNode(null);
            return;

            int  docCount                  = SearchManager.DocumentResultList.Count;
            int  pubCount                  = SearchManager.PublicationResultList.Count;
            bool isDocumentItem            = selRow - 1 < docCount ? true : false;
            SearchDisplayResult searchItem = null;

            if (isDocumentItem)
            {
                searchItem = SearchManager.DocumentResultList [selRow - 1];
            }
            else
            {
                int index = selRow - 1 - docCount - 1;
                searchItem = SearchManager.PublicationResultList [index];
            }

            if (searchItem != null)
            {
                viewController.OpenPublicationAtTocNode(searchItem);
            }
        }
        public async Task OpenPublicationContentAtSearchItem(SearchDisplayResult resultItem)
        {
            parentPopover.Close();

            int tocID = resultItem.TocId;

            var winController = Utility.GetMainWindowConroller();

            PublicationsDataManager.SharedInstance.CurrentPublication =
                PublicationsDataManager.SharedInstance.GetCurrentPublicationByBookID(BookID);

            var section = resultItem.isDocument ? resultItem.SnippetContent : resultItem.GuideCardTitle;
            var title   = resultItem.isDocument ? resultItem.Head : resultItem.TocTitle;
            var header  = resultItem.isDocument ? resultItem.HeadType + "," + resultItem.HeadSequence : null;

            winController.ContentVC.TOCDataManager.UpdateSearchMatchWordList(SearchResultsData.FoundWordList,
                                                                             SearchResultsData.KeyWordList, section, header);

//			var resultItemData = new SearchNavigationData ();
//			resultItemData.FoundWordList.AddRange(SearchResultsData.KeyWordList);
//			resultItemData.SearchItem.ContentType = resultItem.ContentType;
//			resultItemData.SearchItem.Head = resultItem.Head;
//			resultItemData.SearchItem.HeadSequence = resultItem.HeadSequence;
//			resultItemData.SearchItem.HeadType = resultItem.HeadType;
//			resultItemData.SearchItem.isDocument = resultItem.isDocument;
//			resultItemData.SearchItem.SnippetContent = resultItem.SnippetContent;

            await winController.ContentVC.HighlightContentView(tocID, true);
        }
Пример #5
0
        public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath)
        {
            var cell = tableView.DequeueReusableCell(ResultTableViewCell.Key) as ResultTableViewCell;

            if (cell == null)
            {
                cell = new ResultTableViewCell();
            }

            SearchDisplayResult searchDR = ResListDict[SectionTitleList[indexPath.Section]] [indexPath.Row];

            cell.TextLabel.Font       = UIFont.BoldSystemFontOfSize(14);
            cell.DetailTextLabel.Font = UIFont.SystemFontOfSize(14);

            if (searchDR.isDocument)
            {
                cell.TextLabel.AttributedText       = TextDisplayUtil.GetHighlightedString(searchDR.Head, SearchRes.FoundWordList);
                cell.DetailTextLabel.AttributedText = TextDisplayUtil.GetHighlightedString(searchDR.SnippetContent, SearchRes.FoundWordList);
            }
            else
            {
                cell.TextLabel.AttributedText       = TextDisplayUtil.GetHighlightedString(searchDR.TocTitle, SearchRes.FoundWordList);
                cell.DetailTextLabel.AttributedText = TextDisplayUtil.GetHighlightedString(searchDR.GuideCardTitle, SearchRes.FoundWordList);
            }

            return(cell);
        }
Пример #6
0
        //get the UI display object type
        public NSObject ChildrenItemAtIndex(List <SearchDisplayResult> valueList, int index)
        {
            SearchDisplayResult value = valueList [index];

            var dict = new NSDictionary("key1", value.TocId, "key2", value.TocTitle, "key3", value.GuideCardTitle);

            return(dict);
        }
Пример #7
0
        //get the Index object from children list
        public SearchDisplayResult ObjectAtChildrenList(List <SearchDisplayResult> valueList, int index)
        {
            if (index < 0 || index >= valueList.Count)
            {
                return(null);
            }

            SearchDisplayResult value = valueList [index];

            return(value);
        }
Пример #8
0
        public SearchNavigationData()
        {
            if (FoundWordList == null)
            {
                FoundWordList = new List <string> (0);
            }
            else
            {
                FoundWordList.Clear();
            }

            if (SearchItem == null)
            {
                SearchItem = new SearchDisplayResult();
            }
        }
Пример #9
0
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            SearchDisplayResult searchDR = ResListDict[SectionTitleList[indexPath.Section]] [indexPath.Row];


            if (searchDR.isDocument && searchDR.TocId == AppDataUtil.Instance.GetOpendTOC().ID&& AppDataUtil.Instance.GetOpendContentType() == PublicationContentTypeEnum.TOC)
            {
                NSNotificationCenter.DefaultCenter.PostNotificationName("scrollToHeading", this, new NSDictionary("tocId", searchDR.TocId, "headingType", searchDR.HeadType.ToString(), "headingNum", searchDR.HeadSequence));                 //post notification which supposed to be handled by LNWebview instance
            }
            else
            {
                TOCNode touchedNode = PublicationContentUtil.Instance.GetTOCByTOCId(searchDR.TocId, AppDataUtil.Instance.GetCurPublicationTocRootNode());
                AppDataUtil.Instance.SetOpendTOC(touchedNode);
                AppDataUtil.Instance.HighlightSearchKeyword = string.Join(" ", SearchRes.FoundWordList);
                AppDataUtil.Instance.ScrollToHtmlTagId      = searchDR.Head;
                AppDataUtil.Instance.AddBrowserRecord(new SearchBrowserRecord(AppDataUtil.Instance.GetCurrentPublication().BookId,
                                                                              touchedNode.ID,
                                                                              0, 0, string.Join(" ", SearchRes.KeyWordList), searchDR.HeadType.ToString(),
                                                                              searchDR.HeadSequence
                                                                              ));//add browser search record
            }

            tableView.CellAt(indexPath).Selected = false;
        }
Пример #10
0
 //api with IndexViewController
 public void OpenPublicationAtTocNode(SearchDisplayResult tocNode)
 {
     parentPopover.Close();
 }
Пример #11
0
 public static string GetFirstLine(this SearchDisplayResult result)
 {
     return(result.isDocument ? result.Head : result.TocTitle);
 }
Пример #12
0
 public static string GetSecondLine(this SearchDisplayResult result)
 {
     return(result.isDocument ? result.SnippetContent : result.GuideCardTitle);
 }