Example #1
0
 private void UpdateCachedObjects(Graphics g)
 {
     using (new PerfCheck("UpdateCachedObjects"))
     {
         using (new PerfCheck("ScriptItemize"))
         {
             RTTextbox.ScriptItemize();
         }
         using (new PerfCheck("Flow"))
         {
             FlowContext flowContext = new FlowContext(Width, FlowHeight);
             flowContext.LineLimit        = LineLimit;
             flowContext.CharTrimLastLine = CharTrimLastLine;
             m_cachedrtparagraphs         = LineBreaker.Flow(RTTextbox, g, FontCache, flowContext, keepLines: true, out m_height);
         }
     }
 }
Example #2
0
        internal static float MeasureFullHeight(TextBox textBox, Graphics g, FontCache fontCache, FlowContext flowContext, out float contentHeight)
        {
            if (flowContext.Width <= 0f)
            {
                contentHeight = 0f;
                return(0f);
            }
            FlowContext flowContext2 = flowContext.Clone();

            flowContext2.Reset();
            flowContext2.Height = float.MaxValue;
            float num = 0f;

            if (textBox.VerticalText)
            {
                flowContext2.LineLimit = false;
                float width     = 0f;
                float nextWidth = 0f;
                float num2      = 0f;
                float num3      = flowContext.Height;
                float num4      = 0f;
                if (flowContext.Height == float.MaxValue)
                {
                    num3 = 0f;
                }
                num2 = (contentHeight = LineBreaker.FlowVertical(textBox, g, fontCache, flowContext2, out width, out nextWidth));
                num  = width;
                num4 = width;
                bool  flag = flowContext2.CharTrimmedRunWidth > 0;
                float num5 = 0f;
                while (num2 < flowContext.Width && width > num3)
                {
                    flowContext2.Reset();
                    flowContext2.Height = Math.Max(nextWidth, num3);
                    flowContext2.Width  = float.MaxValue;
                    num2 = LineBreaker.FlowVertical(textBox, g, fontCache, flowContext2, out width, out nextWidth);
                    if (num2 < flowContext.Width)
                    {
                        num5 = num2 - contentHeight;
                        if (num2 <= contentHeight || num5 <= 0.1f)
                        {
                            if (flag)
                            {
                                contentHeight = num2;
                                num           = flowContext2.Height;
                                break;
                            }
                            if (flowContext2.CharTrimmedRunWidth <= 0)
                            {
                                break;
                            }
                        }
                        contentHeight = num2;
                        num           = flowContext2.Height;
                        num4          = width;
                    }
                    else
                    {
                        num5 = num - flowContext2.Height;
                        if (!(num5 > 0.1f))
                        {
                            break;
                        }
                        nextWidth     = flowContext2.Height + (num - flowContext2.Height) / 2f;
                        contentHeight = num2;
                        width         = num4;
                    }
                    flag = (flowContext2.CharTrimmedRunWidth > 0);
                }
            }
            else
            {
                LineBreaker.Flow(textBox, g, fontCache, flowContext2, keepLines: false, out contentHeight);
                num = contentHeight;
            }
            return(num);
        }