Пример #1
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;
        }
Пример #2
0
        /// <summary>
        /// Implement method Update(Subject s) which defined in interface Observer
        /// Observer design pattern is used here to get notification when the selected toc is changed
        /// </summary>
        /// <param name="s">S.</param>
        public void Update(Subject s)
        {
            if (AppDataUtil.Instance.GetOpendContentType() == PublicationContentTypeEnum.TOC)
            {
                TableOfContentTableViewSource source = (TableOfContentTableViewSource)tocTableViewVC.TableView.Source;
                source.Tree = new TOCNodeTree(AppDataUtil.Instance.GetCurPublicationTocRootNode());
                source.HighlightedTOCNode = AppDataUtil.Instance.GetHighlightedTOCNode() ?? AppDataUtil.Instance.GetOpendTOC();
                source.LatestOpendTOCNode = source.HighlightedTOCNode.ParentNode;
                source.DisplayedTocList   = source.Tree.GetDisplayTOCNodeList(source.LatestOpendTOCNode);
                tocTableViewVC.TableView.ReloadData();

                ShowExpireInfoView();
            }
        }