//TocViewController
        public async Task OpenPublicationContentAtTOCNode(int bookID, TOCNode tocNode)
        {
            string htmlString = await PublicationContentUtil.Instance.GetContentFromTOC(bookID, tocNode, true);

            //string title = PublicationsDataManager.SharedInstance.CurrentPublication.Name;
            //await PdfUtil.SaveAsPdf (htmlString, title);
            NavigationMode nm;

            if (this.IsHighlighting)
            {
                nm = NavigationMode.NM_Search;
                this.IsHighlighting = false;
            }
            else
            {
                nm = NavigationMode.NM_Contents;
                TOCDataManager.ClearSearchResult();
            }

            PageViewController.AddLoadView();
            PageViewController.CurrentSearchHeader = TOCDataManager.CurrentSearchHeader;
            PageViewController.SearchPageNumber    = this.searchPageNumber;

            TOCDataManager.StartTocID = tocNode.ID;
            TOCDataManager.EndTocID   = tocNode.ID;

            PageViewController.ShowPageContent(htmlString, true, bookID, tocNode.ID.ToString(), tocNode.Title);

            GetFirstPageNumberAtTocID(tocNode.ID);

            AddNavigationPathAtBookIDandTocID(bookID, tocNode.ID, nm);
        }
        public override nfloat GetHeightForRow(UITableView tableView, NSIndexPath indexPath)
        {
            TOCNode node = this.DisplayedTocList[indexPath.Row];
            CGSize  expectedLableSize = TextDisplayUtil.GetStringBoundRect(node.Title, UIFont.SystemFontOfSize(14), new CGSize(260, 600));

            return(((expectedLableSize.Height + 24) > 44) ? (expectedLableSize.Height + 24) : 44);
        }
        public async override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            HighlightedTOCNode = DisplayedTocList[indexPath.Row];
            string str = HighlightedTOCNode.Role;

            if (HighlightedTOCNode.Role == "me" || IsTOCNodeOpened(HighlightedTOCNode))
            {
                LatestOpendTOCNode = HighlightedTOCNode.ParentNode;
            }
            else
            {
                LatestOpendTOCNode = HighlightedTOCNode;
            }
            DisplayedTocList = Tree.GetDisplayTOCNodeList(LatestOpendTOCNode);

            UIView.Animate(0.2, delegate {
                tableView.ReloadData();
                //tableView.ScrollToRow(indexPath, UITableViewScrollPosition.None, false);
            });

            var page = await PageSearchUtil.Instance.GetFirstPageItem(AppDataUtil.Instance.GetCurrentPublication().BookId, HighlightedTOCNode.ID);

            if (page != null)
            {
                Int32 pageNum = page.Identifier;
                NSNotificationCenter.DefaultCenter.PostNotificationName("inputPageNumber", this, new NSDictionary("page", pageNum));
            }

            //display content of toc page in webview
            if (HighlightedTOCNode.Role == "me")
            {
                SetDisplayedTOC(HighlightedTOCNode);
            }
            AppDataUtil.Instance.SetHighlightedTOCNode(HighlightedTOCNode);
        }
        public TableOfContentTableViewSource(TOCNode root)
        {
            Tree = new TOCNodeTree(root);

            if (AppDataUtil.Instance.GetOpendTOC() != null)
            {
                LatestOpendTOCNode = AppDataUtil.Instance.GetOpendTOC().ParentNode;
            }
            else
            {
                var firstNonPageTOCNode = Tree.GetFirstPageNode().ParentNode;
                LatestOpendTOCNode = firstNonPageTOCNode.ParentNode == null ? firstNonPageTOCNode : firstNonPageTOCNode.ParentNode;
            }
            DisplayedTocList = Tree.GetDisplayTOCNodeList(LatestOpendTOCNode);


            if (AppDataUtil.Instance.GetOpendTOC() == null)
            {
                HighlightedTOCNode = Tree.GetFirstPageNode().ParentNode;
                SetDisplayedTOC(Tree.GetFirstPageNode());
            }
            else
            {
                HighlightedTOCNode = AppDataUtil.Instance.GetOpendTOC();
                SetDisplayedTOC(HighlightedTOCNode);
            }

            AppDataUtil.Instance.SetHighlightedTOCNode(HighlightedTOCNode);
        }
        public List <TOCNode> GetPresentNodeList()
        {
            List <TOCNode> result = null;

            if (CurrentTOCNode == null
                // If current node is a top level node, and it is collapsed.
                // Then juse show all its brother.
                || ((!CurrentNodeExpanded) && (CurrentTOCNode.NodeLevel == 1 || CurrentTOCNode.ParentNode == null)))
            {
                result = new List <TOCNode>(rootTocNode.ChildNodes);
                result.Insert(0, null);
                return(result);
            }

            result = new List <TOCNode>();

            // All nodes before the spliterNode (include spliterNodeId), should be expanded;
            // All nodes After the spliterNode (exclude spliterNodeId), should be collapsed;
            TOCNode spliterNode = CurrentNodeExpanded ? CurrentTOCNode : CurrentTOCNode.ParentNode;

            foreach (var subnode in spliterNode.ChildNodes)
            {
                result.Add(subnode);
            }

            while (spliterNode != null && spliterNode.NodeLevel != 0)
            {
                result.Insert(0, spliterNode);
                spliterNode = spliterNode.ParentNode;
            }

            result.Insert(0, null);
            return(result);
        }
        public async Task FetchNextPageAtTocNode()
        {
            //filter duplicate tocNode
            TOCNode currentToc = TOCDataManager.CurrentLeafNode;

            while (TOCDataManager.EndTocID != currentToc.ID)
            {
                currentToc = PublicationContentUtil.Instance.GetNextPageByTreeNode(currentToc);
            }
            currentToc = PublicationContentUtil.Instance.GetNextPageByTreeNode(currentToc);

            TOCDataManager.CurrentLeafNode = currentToc;
            TOCDataManager.EndTocID        = currentToc.ID;

            string htmlString = await PublicationContentUtil.Instance.GetContentFromTOC(BookID, currentToc, false);

            PageViewController.AppendPageContent(htmlString, BookID, currentToc.ID.ToString(), currentToc.Title);

            if (currentToc != null)
            {
                this.InvokeOnMainThread(() =>
                                        HighlightLeafTocNode(currentToc)
                                        );
            }
        }
Beispiel #7
0
        private async Task RestoreToc(NavigationRecord record, TOCAccessMode mode)
        {
            if (record.BookId != Publication.BookId)
            {
                var publications = SessionService.SessionState[ALL_PUBLICATIONS_SESSION_KEY] as List <PublicationViewModel>;
                Publication = publications.FirstOrDefault(x => x.BookId == record.BookId);
                root        = await PublicationUtil.Instance.GetDlBookTOC(Publication.BookId);

                listAll   = root.ChildNodes;
                firstNode = null;
                GetFirstTocNode(listAll, ref firstNode);
                var indexs = await InitialIndexMenu(Publication.BookId);

                IndexMenuCollections = new ObservableCollection <IndexMenuItem>(indexs);
                HasIndex             = IndexMenuCollections == null || IndexMenuCollections.Count == 0 ? false : true;
                Keywords             = string.Empty;
                IsPBO = await PageSearchUtil.Instance.IsPBO(Publication.BookId);
            }
            CurrentTocNode = new TocCurrentNode
            {
                ID   = record.TOCId,
                Role = NodeExpandStatue.Leaf
            };
            var nodes = await InitialBreadcrumMenu(record, mode);

            BreadcrumbNavigator = new ObservableCollection <BreadcrumbNav>(nodes);
        }
 private void HighlightLeafTocNode(TOCNode currentToc)
 {
     TOCDataManager.GetTOCNodeListByCurrentLeafNode(currentToc);
     TOCDataManager.SetHighlightTOCIndexByTocID(currentToc.ID);
     TOCViewController.RefreshTableViewData();
     TOCViewController.ScrollCurrentLeafNodeToVisible();
 }
        public override void RowSelected(UITableView tableView, NSIndexPath indexPath)
        {
            HighlightedTOCNode = DisplayedTocList[indexPath.Row];

            if (HighlightedTOCNode.Role == "me" || IsTOCNodeOpened(HighlightedTOCNode))
            {
                LatestOpendTOCNode = HighlightedTOCNode.ParentNode;
            }
            else
            {
                LatestOpendTOCNode = HighlightedTOCNode;
            }
            DisplayedTocList = Tree.GetDisplayTOCNodeList(LatestOpendTOCNode);

            UIView.Animate(0.2, delegate {
                tableView.ReloadData();
                //tableView.ScrollToRow(indexPath, UITableViewScrollPosition.None, false);
            });

            //display content of toc page in webview
            if (HighlightedTOCNode.Role == "me")
            {
                SetDisplayedTOC(HighlightedTOCNode);
            }
        }
Beispiel #10
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            ExpireInfoView.AddGestureRecognizer(new UITapGestureRecognizer(AppDisplayUtil.Instance.ShowPublicationInfoView));
            ShowExpireInfoView();

            tocTableViewVC = new TableOfContentTableViewController();
            TOCNode rootNode = AppDataUtil.Instance.GetCurPublicationTocRootNode();

            if (rootNode != null && rootNode.ChildNodes != null && rootNode.ChildNodes.Count > 0)
            {
                tocTableViewSource = new TableOfContentTableViewSource(rootNode);
                tocTableViewVC.TableView.Source = tocTableViewSource;
                tocTableViewVC.TableView.TranslatesAutoresizingMaskIntoConstraints = false;
                tocTableViewVC.TableView.TableFooterView = new UIView();                 //hidden redundant line separator

                ContainerView.AddSubview(tocTableViewVC.TableView);
                ContainerView.AddConstraints(new NSLayoutConstraint[] {
                    NSLayoutConstraint.Create(tocTableViewVC.TableView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Top, 1, 0),
                    NSLayoutConstraint.Create(tocTableViewVC.TableView, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Bottom, 1, 0),
                    NSLayoutConstraint.Create(tocTableViewVC.TableView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Leading, 1, 0),
                    NSLayoutConstraint.Create(tocTableViewVC.TableView, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, ContainerView, NSLayoutAttribute.Trailing, 1, 0)
                });

                AppDataUtil.Instance.AddOpenedContentObserver(this);                 //Set current instance as the observer of subject OpendPublication to get notification when opend content changed
            }

            AppDisplayUtil.Instance.TOCVC = this;

            SearchBar.Delegate = new TOCSearchBarDelegate();
            //hide search bar border
            SearchBar.Layer.BorderWidth = 1;
            SearchBar.Layer.BorderColor = UIColor.FromRGB(194, 194, 194).CGColor;
        }
 public TOCNode GetTOCByTOCId(int tocId, TOCNode rootTOCNode)
 {
     if (rootTOCNode != null)
     {
         var isRootNode = (tocId == 0);
         if (isRootNode)
         {
             return(rootTOCNode);
         }
         if (rootTOCNode.HasChildNodes())
         {
             foreach (var item in rootTOCNode.ChildNodes)
             {
                 if (item.ID == tocId)
                 {
                     return(item);
                 }
                 else
                 {
                     rootTOCNode = GetTOCByTOCId(tocId, item);
                     if (rootTOCNode != null)
                     {
                         return(rootTOCNode);
                     }
                 }
             }
         }
     }
     return(null);
 }
Beispiel #12
0
        public void GetTOCNodeListByCurrentLeafNode(TOCNode leafNode)
        {
            List <TOCNode> nodeList = new List <TOCNode> (0);

            nodeList.AddRange(leafNode.ParentNode.ChildNodes);

            if (nodeList != null)
            {
                if (TOCNodeList.Count > 0)
                {
                    TOCNodeList.Clear();
                }
                TOCNodeList.AddRange(nodeList);
                nodeList.Clear();
                nodeList = null;

                if (TOCNodeList.Any())
                {
                    CurrentLevel = TOCNodeList [0].NodeLevel;
                }

                UpdateTOCNodeList();
            }

            CurrentHighlight = -1;
        }
        public override UIView GetViewForHeader(UITableView tableView, nint section)
        {
            UIView  headerView       = new UIView(new CGRect(0, 0, 320, 44));
            UILabel headerTitleLabel = new UILabel(new CGRect(15, 12, 260, 20));

            headerTitleLabel.Text = "Table of Contents";
            headerTitleLabel.Font = UIFont.SystemFontOfSize(14);
            headerView.AddSubview(headerTitleLabel);

            UIView bottomLine = new UIView(new CGRect(15, 43, 305, 1));

            bottomLine.BackgroundColor = UIColor.LightGray.ColorWithAlpha(0.6f);
            headerView.AddSubview(bottomLine);

            UIView sideBar = new UIView(new CGRect(0, 0, 5, 44));

            sideBar.BackgroundColor = UIColor.FromRGB(255, 200, 200);
            headerView.AddSubview(sideBar);

            headerView.BackgroundColor = UIColor.White;


            UITapGestureRecognizer tapHeaderRecoginzer = new UITapGestureRecognizer();

            tapHeaderRecoginzer.AddTarget(delegate() {
                HighlightedTOCNode = Tree.GetFirstPageNode().ParentNode;
                LatestOpendTOCNode = HighlightedTOCNode.ParentNode;
                DisplayedTocList   = Tree.GetDisplayTOCNodeList(LatestOpendTOCNode);
                tableView.ReloadData();
            });
            headerView.UserInteractionEnabled = true;
            headerView.AddGestureRecognizer(tapHeaderRecoginzer);

            return(headerView);
        }
Beispiel #14
0
 public void SetHighlightedTOCNode(TOCNode node)
 {
     if (node != null)
     {
         appDelegate.CurOpendPublication.HighlightedTOCNode = node;
     }
 }
        private void InitTOC()
        {
            //Initialize TOC
            Tree = new TOCNodeTree(AppDataUtil.Instance.GetCurPublicationTocRootNode());

            if (AppDataUtil.Instance.GetOpendTOC() != null)
            {
                LatestOpendTOCNode = AppDataUtil.Instance.GetOpendTOC().ParentNode;
            }
            else
            {
                var firstNonPageTOCNode = Tree.GetFirstPageNode().ParentNode;
                LatestOpendTOCNode = firstNonPageTOCNode.ParentNode == null ? firstNonPageTOCNode : firstNonPageTOCNode.ParentNode;
            }
            DisplayedTocList = Tree.GetDisplayTOCNodeList(LatestOpendTOCNode);
            if (AppDataUtil.Instance.GetOpendTOC() == null)
            {
                HighlightedTOCNode = Tree.GetFirstPageNode().ParentNode;
                SetDisplayedTOC(Tree.GetFirstPageNode());
            }
            else
            {
                HighlightedTOCNode = AppDataUtil.Instance.GetOpendTOC();
                SetDisplayedTOC(HighlightedTOCNode);
            }
        }
        public async Task FetchPrePageAtTocNode()
        {
            TOCNode currentToc = TOCDataManager.CurrentLeafNode;

            if (currentToc == null)
            {
                return;
            }
            while (TOCDataManager.StartTocID != currentToc.ID)
            {
                currentToc = PublicationContentUtil.Instance.GetPreviousPageByTreeNode(currentToc);
            }
            currentToc = PublicationContentUtil.Instance.GetPreviousPageByTreeNode(currentToc);

            TOCDataManager.CurrentLeafNode = currentToc;
            TOCDataManager.StartTocID      = currentToc.ID;

            string htmlString = await PublicationContentUtil.Instance.GetContentFromTOC(BookID, currentToc, false);

            PageViewController.PrependPageContent(htmlString, BookID, currentToc.ID.ToString(), currentToc.Title);

            if (currentToc != null)
            {
                this.InvokeOnMainThread(() =>
                                        HighlightLeafTocNode(currentToc)
                                        );
            }
        }
Beispiel #17
0
        void UpdateTOCNodeList()
        {
            if (TOCNodeList == null)
            {
                return;
            }

            if (TOCNodeList.Count > 0)
            {
                var parentNode = TOCNodeList [0].ParentNode;

                while (parentNode != null)
                {
                    if (parentNode.NodeLevel == 0)
                    {
                        break;
                    }
                    TOCNodeList.Insert(0, parentNode);
                    parentNode = TOCNodeList [0].ParentNode;
                }
            }

            var rootNode = new TOCNode();

            rootNode.Title     = "Table of Contents";
            rootNode.NodeLevel = 0;
            TOCNodeList.Insert(0, rootNode);
        }
Beispiel #18
0
 public void SetOpendTOC(TOCNode node)
 {
     if (node != null)
     {
         appDelegate.CurOpendPublication.OpendTOCNode = node;
         ScrollToHtmlTagId = "";
     }
 }
Beispiel #19
0
 public void SetHighlightedTOCNode(TOCNode node)
 {
     if (node != null)
     {
         tocTableViewSource.SetSelectTOCNode(node);
         tocTableViewVC.TableView.ReloadData();
     }
 }
 private void SetDisplayedTOC(TOCNode node)
 {
     if (node != null)
     {
         AppDataUtil.Instance.SetOpendTOC(node);
         AppDataUtil.Instance.AddBrowserRecord(new ContentBrowserRecord(AppDataUtil.Instance.GetCurrentPublication().BookId, node.ID, 0));                 //add browser record
     }
 }
Beispiel #21
0
 public TOCBreadcrumbs(ObjHolder <Publication> publication, TOCNode rootTocNode)
 {
     this.publication = publication;
     this.rootTocNode = rootTocNode;
     firstPage        = rootTocNode.GetFirstPage();
     lastPage         = rootTocNode.GetLastPage();
     CurrentTOCNode   = null;
 }
        private static TOCNode GetTopLevelNode(TOCNode node)
        {
            while (node.NodeLevel != 1)
            {
                node = node.ParentNode;
            }

            return(node);
        }
Beispiel #23
0
        private bool IsSameParent(int id1, int id2)
        {
            TOCNode node1 = null;
            TOCNode node2 = null;

            GetTocNodeByID(listAll, ref node1, id1);
            GetTocNodeByID(listAll, ref node2, id2);
            return(node1.ParentId == node2.ParentId);
        }
Beispiel #24
0
        public void AddTOCNodeToRTDocument(TOCNode tocNode)
        {
            if (disposed)
            {
                throw new ObjectDisposedException("RTDocumentHelper has been disposed");
            }

            rtDocument.Organization.TableOfContents.Add(tocNode);
        }
        public void AddTOCNodeToRTDocument(TOCNode tocNode)
        {
            if (disposed)
            {
                throw new ObjectDisposedException(Strings.RTDocumentHelperHasBeenDisposed);
            }

            rtDocument.Organization.TableOfContents.Add(tocNode);
        }
Beispiel #26
0
        public TOCNode GetForwardNode()
        {
            TOCNode tocNode = null;

            GetTocNodeByID(listAll, ref tocNode, CurrentTocNode.ID);
            var next = PublicationContentUtil.Instance.GetNextPageByTreeNode(tocNode);

            return(next);
        }
Beispiel #27
0
        public TOCNode GetBackwardNode()
        {
            TOCNode tocNode = null;

            GetTocNodeByID(listAll, ref tocNode, CurrentTocNode.ID);
            var last = PublicationContentUtil.Instance.GetPreviousPageByTreeNode(tocNode);

            return(last);
        }
Beispiel #28
0
        public TOCNodeTree(TOCNode node)
        {
            RootNode = node;

            foreach (var n in node.ChildNodes)
            {
                RecursiveCountTotalNodeLevel(n);
            }
        }
Beispiel #29
0
        public static bool AddTocIDToRTDocument(RTDocument rtDocument, Guid tocID)
        {
            TOCNode tocNode = new TOCNode();

            tocNode.ResourceIdentifier = Guid.Empty;
            tocNode.Identifier         = tocID;
            tocNode.Resource           = null;
            rtDocument.Organization.TableOfContents.Add(tocNode);
            return(true);
        }
Beispiel #30
0
        public void AddTOCNodeToRTDocument(int index, TOCNode tocNode)
        {
            if (disposed)
            {
                throw new ObjectDisposedException("RTDocumentHelper has been disposed");
            }

            //Pri3: This assumes a flat TOC -- does not take parent, or calculate using siblings
            rtDocument.Organization.TableOfContents.Insert(index + 1, tocNode);
        }
        public void AddTOCNodeToRTDocument( TOCNode tocNode )
        {
            if (disposed) throw new ObjectDisposedException(Strings.RTDocumentHelperHasBeenDisposed);

            rtDocument.Organization.TableOfContents.Add( tocNode );
        }
Beispiel #32
0
        public void AddTOCNodeToRTDocument( TOCNode tocNode )
        {
            if (disposed) throw new ObjectDisposedException("RTDocumentHelper has been disposed");

            rtDocument.Organization.TableOfContents.Add( tocNode );
        }
        public void AddTOCNodeToRTDocument( int index, TOCNode tocNode )
        {
            if (disposed) throw new ObjectDisposedException(Strings.RTDocumentHelperHasBeenDisposed);

            //Pri3: This assumes a flat TOC -- does not take parent, or calculate using siblings
            rtDocument.Organization.TableOfContents.Insert(index+1, tocNode);
        }
        private void StripResourceObjectFromTocNode(TOCNode toc)
        {
            if (toc.Children != null)
            {
                for (int i= 0 ; i < toc.Children.Count; i++)
                {
                    StripResourceObjectFromTocNode(toc.Children[i]);
                }
            }

            toc.Resource = null;
        }