예제 #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// This routine is used to estimate the height of an item. The item will be one of
        /// those you have added to the environment using AddLazyItems. Note that the calling
        /// code does NOT ensure that data for displaying the item in question has been loaded.
        /// The first three arguments are as for Display, that is, you are being asked to
        /// estimate how much vertical space is needed to display this item in the available width.
        /// </summary>
        /// <param name="hvo">Item whose height is to be estimated</param>
        /// <param name="frag">Basically indicates what kind of thing the HVO represents (or
        /// else we're in trouble)</param>
        /// <param name="availableWidth"></param>
        /// <returns>Height of an item in points</returns>
        /// ------------------------------------------------------------------------------------
        public int EstimateHeight(int hvo, int frag, int availableWidth)
        {
            CheckDisposed();

            // Find maximum height of all rootsite slaves in view
            int maxHeight = 0;
            int paraHeight;

            if (m_slaves.Count > 0)
            {
                Debug.Assert(m_paraCounter != null,
                             "Need to set ParagraphCounterManager.ParagraphCounterType before creating RootSiteGroup");
                int slaveWidth;
                foreach (IRootSite slave in m_slaves)
                {
                    slaveWidth = slave.GetAvailWidth(null);
                    Debug.Assert(slaveWidth != 0 || !((Control)slave).Visible);
                    slaveWidth = (slaveWidth == 0) ? 1 : slaveWidth;
                    paraHeight = (RootSite.kdxBaselineRootsiteWidth *
                                  ((IHeightEstimator)slave).AverageParaHeight) / slaveWidth;
                    maxHeight = Math.Max(m_paraCounter.GetParagraphCount(hvo, frag) * paraHeight,
                                         maxHeight);
                }
            }
            else
            {
                Debug.Fail("Need to handle this!");
            }

            return(maxHeight);
        }
예제 #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Calculate height for books and sections.
        /// </summary>
        /// <param name="hvo"></param>
        /// <param name="frag"></param>
        /// <param name="dxAvailWidth"></param>
        /// <returns>The estimated height for the specified hvo in points</returns>
        /// ------------------------------------------------------------------------------------
        public int EstimateHeight(int hvo, int frag, int dxAvailWidth)
        {
            int ret = m_paraCounter.GetParagraphCount(hvo, frag) * AverageParaHeight;

            return(ret);
        }