示例#1
0
        /// <summary>
        /// Calculates full relative rectangle of the formula
        /// </summary>
        public virtual void CalculateFullRelativeRectangle()
        {
            IDrawableSymbol symbol = null;
            int             up = 0, down = 0, width = 0;

            for (int i = 0; i < Count; i++)
            {
                symbol = this[i] as IDrawableSymbol;
                symbol.CalculateFullRelativeRectangle();
                Rectangle r = symbol.PureDrawable.FullRelativeRectangle;
                int       w = r.Width;
                if (r.Y < up)
                {
                    up = r.Y;
                }
                if (r.X + r.Height > down)
                {
                    down = r.X + r.Height;
                }
                width += w;
            }
            if (symbol == null)
            {
                fullRelativeRectangle.X      = 0;
                fullRelativeRectangle.Y      = -PureDrawableSymbol.GetHeight(level) / 2;
                fullRelativeRectangle.Width  = PureDrawableSymbol.GetWidth(level);
                fullRelativeRectangle.Height = PureDrawableSymbol.GetHeight(level);
                return;
            }
            fullRelativeRectangle.X      = 0;
            fullRelativeRectangle.Y      = up;
            fullRelativeRectangle.Width  = width;
            fullRelativeRectangle.Height = down - up;
        }
示例#2
0
        /// <summary>
        /// Calculates positions of formula symbols
        /// </summary>
        public void CalculatePositions()
        {
            tempPosition.X = position.X;
            tempPosition.Y = position.Y;
            IDrawableSymbol symbol = null;

            //int up = 0, down = 0, width = 0;
            for (int i = 0; i < Count; i++)
            {
                symbol = this[i] as IDrawableSymbol;
                symbol.PureDrawable.X = tempPosition.X;
                symbol.PureDrawable.Y = tempPosition.Y;
                symbol.CalculatePositions();
                Rectangle r = symbol.PureDrawable.FullRelativeRectangle;
                int       w = r.Width;
                tempPosition.X += w;
            }
            if (symbol == null)
            {
                endRectangle.X = position.X;
                int h = PureDrawableSymbol.GetHeight(level);
                endRectangle.Y      = position.Y - h / 2;
                endRectangle.Height = h;
                int w = (int)(((float)h) * RELATION);
                endRectangle.Width = w;
                return;
            }
            endRectangle.Width  = symbol.PureDrawable.FullRectangle.Width;
            endRectangle.Height = symbol.PureDrawable.FullRectangle.Height;
            endRectangle.X      = tempPosition.X;
            int H = symbol.PureDrawable.RelativeRectangle.Height;
            int W = (int)(((float)H) * RELATION);

            endRectangle.Width = W;
            endRectangle.Y     = tempPosition.Y - H / 2;
        }