Exemplo n.º 1
0
        public static void Render(TextBox textBox, List <Paragraph> paragraphs, Graphics g, FontCache fontCache, PointF offset, RectangleF layoutRectangle)
        {
            float             dpiX = g.DpiX;
            Win32DCSafeHandle win32DCSafeHandle = new Win32DCSafeHandle(g.GetHdc(), false);

            try
            {
                TextBox.Render(textBox, paragraphs, win32DCSafeHandle, fontCache, offset, layoutRectangle, dpiX);
            }
            finally
            {
                fontCache.ResetGraphics();
                if (!win32DCSafeHandle.IsInvalid)
                {
                    g.ReleaseHdc();
                }
            }
        }
Exemplo n.º 2
0
        public static List <Paragraph> Flow(TextBox textBox, Graphics g, FontCache fontCache, FlowContext flowContext, bool keepLines, out float height)
        {
            List <Paragraph>  list = null;
            float             dpiX = g.DpiX;
            Win32DCSafeHandle win32DCSafeHandle = new Win32DCSafeHandle(g.GetHdc(), false);

            try
            {
                return(LineBreaker.Flow(textBox, win32DCSafeHandle, dpiX, fontCache, flowContext, keepLines, out height));
            }
            finally
            {
                fontCache.ResetGraphics();
                if (!win32DCSafeHandle.IsInvalid)
                {
                    g.ReleaseHdc();
                }
            }
        }
Exemplo n.º 3
0
        public static float FlowVertical(TextBox textBox, Graphics g, FontCache fontCache, FlowContext flowContext, out float width, out float nextWidth)
        {
            width = (nextWidth = 0f);
            List <Paragraph> list               = null;
            int               num               = 0;
            int               val               = 2147483647;
            int               num2              = 0;
            float             result            = 0f;
            int               num3              = 0;
            List <TextLine>   list2             = null;
            float             dpiX              = g.DpiX;
            Win32DCSafeHandle win32DCSafeHandle = new Win32DCSafeHandle(g.GetHdc(), false);

            if (textBox.VerticalText)
            {
                flowContext.VerticalCanGrow = textBox.TextBoxProps.CanGrow;
                num3 = TextBox.ConvertToPixels(flowContext.Height, dpiX);
            }
            else
            {
                num3 = TextBox.ConvertToPixels(flowContext.Width, dpiX);
            }
            try
            {
                list = LineBreaker.Flow(textBox, win32DCSafeHandle, dpiX, fontCache, flowContext, true, out result);
                if (list != null)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        list2 = list[i].TextLines;
                        if (list2 != null)
                        {
                            float num4 = 0f;
                            float num5 = 0f;
                            float num6 = 0f;
                            float num7 = 0f;
                            RPLFormat.Directions direction = textBox.TextBoxProps.Direction;
                            list[i].GetParagraphIndents(direction, dpiX, out num4, out num5, out num6);
                            num7 = num4 + num5;
                            if (list2[0].FirstLine)
                            {
                                num7 += num6;
                            }
                            num2 = Math.Max(num2, (int)num7);
                            for (int j = 0; j < list2.Count; j++)
                            {
                                num = Math.Max(num, list2[j].GetWidth(win32DCSafeHandle, fontCache, false) + (int)num7);
                                val = Math.Min(val, list2[j].GetWidth(win32DCSafeHandle, fontCache, false) + (int)num7);
                            }
                            list[i].TextLines = null;
                        }
                    }
                }
                val = Math.Max(val, num2);
                if (num > 0)
                {
                    int num8 = 0;
                    if (flowContext.VerticalCanGrow && flowContext.ForcedCharTrim)
                    {
                        num8 = flowContext.CharTrimmedRunWidth;
                    }
                    else
                    {
                        num8 = (num - val) / 2;
                        if (num8 == 0)
                        {
                            num8 = num / 2;
                        }
                        else
                        {
                            num8 += val;
                            if (num8 >= num3)
                            {
                                num8 /= 2;
                            }
                        }
                    }
                    width     = TextBox.ConvertToMillimeters(num, dpiX);
                    nextWidth = TextBox.ConvertToMillimeters(num8, dpiX);
                    return(result);
                }
                return(result);
            }
            finally
            {
                fontCache.ResetGraphics();
                if (!win32DCSafeHandle.IsInvalid)
                {
                    g.ReleaseHdc();
                }
            }
        }