예제 #1
0
        public SizeF GetTextSize(
            SizeF proposedSize,
            bool autoFitInProposedSize,
            TextParams textParams)
        {
            SizeF        sizeF        = SizeF.Empty;
            StringFormat stringFormat = textParams.CreateStringFormat();
            string       s            = textParams.text.Length <= RadGdiGraphics.GdiStringLengthLimit ? textParams.text : textParams.text.Substring(0, RadGdiGraphics.GdiStringLengthLimit);

            lock (MeasurementGraphics.SyncObject)
            {
                Graphics measurementGraphics = RadGdiGraphics.MeasurementGraphics;
                measurementGraphics.TextRenderingHint = textParams.textRenderingHint;
                string helperString = this.GetHelperString(s);
                sizeF = !autoFitInProposedSize?measurementGraphics.MeasureString(helperString, textParams.font, 0, stringFormat) : measurementGraphics.MeasureString(helperString, textParams.font, proposedSize, stringFormat);
            }
            stringFormat.Dispose();
            this.measuredSize = sizeF;
            return(sizeF);
        }
예제 #2
0
        public void PaintPrimitive(
            IGraphics graphics,
            float angle,
            SizeF scale,
            TextParams textParams)
        {
            if (this.isDirty)
            {
                this.isDirty   = false;
                this.TextBlock = TinyHTMLParsers.Parse(textParams);
            }
            RectangleF        paintingRectangle = textParams.paintingRectangle;
            StringFormat      stringFormat      = textParams.CreateStringFormat();
            Graphics          underlayGraphics  = (Graphics)graphics.UnderlayGraphics;
            TextRenderingHint textRenderingHint = underlayGraphics.TextRenderingHint;

            underlayGraphics.TextRenderingHint = textParams.textRenderingHint;
            this.TextBlock.PaintFormatTextBlock(graphics, paintingRectangle, true, stringFormat, TextFormatFlags.Default, textParams.textWrap, textParams.ClipText);
            underlayGraphics.TextRenderingHint = textRenderingHint;
            stringFormat.Dispose();
        }
예제 #3
0
 public void PaintPrimitive(IGraphics graphics, float angle, SizeF scale, TextParams textParams)
 {
     if (textParams.useCompatibleTextRendering)
     {
         graphics.DrawString(textParams, this.measuredSize);
     }
     else
     {
         TextFormatFlags flags                        = this.CreateTextFormatFlags(textParams);
         Graphics        underlayGraphics             = (Graphics)graphics.UnderlayGraphics;
         System.Drawing.Drawing2D.GraphicsState state = underlayGraphics.Save();
         underlayGraphics.ResetTransform();
         TextRenderer.DrawText(underlayGraphics,
                               textParams.text,
                               textParams.font,
                               Rectangle.Ceiling(textParams.paintingRectangle),
                               textParams.foreColor,
                               flags);
         underlayGraphics.Restore(state);
     }
 }
예제 #4
0
        public SizeF GetTextSize(SizeF proposedSize, TextParams textParams)
        {
            SizeF res = SizeF.Empty;

            if (string.IsNullOrEmpty(textParams.text) || proposedSize.Width == 0)
            {
                return(SizeF.Empty);
            }

            StringFormat sf            = textParams.CreateStringFormat();
            int          avaibleWidth  = (int)(float.IsInfinity(proposedSize.Width) ? int.MaxValue : Math.Floor(proposedSize.Width));
            string       textToMeasure = textParams.text;

            if (textParams.useCompatibleTextRendering)
            {
                //p.p. 29.07.09
                //fix very strange bug with Hebrew and FitToGrid Renedering hint
                lock (MeasurementGraphics.SyncObject)
                {
                    Graphics g = RadGdiGraphics.MeasurementGraphics;
                    g.TextRenderingHint = textParams.textRenderingHint;
                    res = g.MeasureString(textToMeasure, textParams.font, avaibleWidth, sf);

                    res.Height = (float)Math.Round(res.Height);
                    res.Width  = (float)Math.Ceiling(res.Width);

                    //g.Dispose();
                }
            }
            else if (!string.IsNullOrEmpty(textToMeasure))
            {
                TextFormatFlags flags = this.CreateTextFormatFlags(textParams);
                res = TextRenderer.MeasureText(textToMeasure, textParams.font, new Size(avaibleWidth, int.MaxValue), flags);
            }

            sf.Dispose();

            this.measuredSize = res;
            return(res);
        }
예제 #5
0
        public TextFormatFlags CreateTextFormatFlags(TextParams textParams)
        {
            TextFormatFlags textFormatFlags = this.TranslateAlignmentForGDI(this.RtlContentAlignment(textParams));

            if (textParams.autoEllipsis)
            {
                textFormatFlags |= TextFormatFlags.EndEllipsis;
            }
            if (textParams.rightToLeft)
            {
                textFormatFlags |= TextFormatFlags.RightToLeft;
            }
            if (!textParams.useMnemonic)
            {
                textFormatFlags |= TextFormatFlags.NoPrefix;
            }
            if (!textParams.showKeyboardCues)
            {
                textFormatFlags |= TextFormatFlags.HidePrefix;
            }
            return((!textParams.textWrap ? textFormatFlags | TextFormatFlags.SingleLine : textFormatFlags | TextFormatFlags.WordBreak) | TextFormatFlags.PreserveGraphicsTranslateTransform);
        }
예제 #6
0
 public void PaintPrimitive(IGraphics graphics, float angle, SizeF scale, TextParams textParams)
 {
     this.textPrimitiveImpl.PaintPrimitive(graphics, angle, scale, textParams);
 }
예제 #7
0
        /// <summary>Draws the primitive on the screen.</summary>
        public override void PaintPrimitive(IGraphics graphics, float angle, SizeF scale)
        {
            TextParams textParams = this.CreateTextParams();

            this.textPrimitiveImpl.PaintPrimitive(graphics, angle, scale, textParams);
        }
예제 #8
0
        // helper method which changes the whitespaces with a dummy character


        public StringFormat CreateStringFormat()
        {
            TextParams textParams = this.CreateTextParams();

            return(textParams.CreateStringFormat());
        }
예제 #9
0
        public SizeF GetTextSize(SizeF proposedSize)
        {
            TextParams textParams = this.CreateTextParams();

            return(this.textPrimitiveImpl.GetTextSize(proposedSize, textParams));
        }
예제 #10
0
        public SizeF GetTextSize()
        {
            TextParams textParams = this.CreateTextParams();

            return(this.textPrimitiveImpl.GetTextSize(textParams));
        }
예제 #11
0
        public void PaintPrimitive(Telerik.WinControls.Paint.IGraphics graphics, float angle, System.Drawing.SizeF scale, TextParams textParams)
        {
            if (this.isDirty)
            {
                this.isDirty   = false;
                this.TextBlock = TinyHTMLParsers.Parse(textParams);
            }

            RectangleF   paintingRectangle = textParams.paintingRectangle;
            StringFormat format            = textParams.CreateStringFormat();

            this.TextBlock.PaintFormatTextBlock(graphics, paintingRectangle, true, format, TextFormatFlags.Default, textParams.textWrap, textParams.ClipText);
            format.Dispose();
        }
예제 #12
0
 public SizeF GetTextSize(SizeF proposedSize, TextParams textParams)
 {
     return(this.textPrimitiveImpl.GetTextSize(proposedSize, textParams));
 }
예제 #13
0
 public void PaintPrimitive(Telerik.WinControls.Paint.IGraphics graphics, TextParams textParams)
 {
     this.PaintPrimitive(graphics, 0f, new SizeF(1f, 1f), textParams);
 }
예제 #14
0
        internal virtual TextFormatFlags CreateTextFormatFlags(Size constrainingSize, TextParams textParams)
        {
            TextFormatFlags flags = CreateTextFormatFlags(textParams);

            if (!this.MeasureTextCache.TextRequiresWordBreak(textParams.text, textParams.font, constrainingSize, flags))
            {
                flags &= ~(TextFormatFlags.TextBoxControl | TextFormatFlags.WordBreak);
            }
            return(flags);
        }
예제 #15
0
 /// <summary>Retrieves the text size.</summary>
 public SizeF GetTextSize(TextParams textParams)
 {
     return(this.GetTextSize(LayoutUtils.MaxSizeF, textParams));
 }
예제 #16
0
        public System.Drawing.SizeF MeasureOverride(System.Drawing.SizeF availableSize, TextParams textParams)
        {
            if (previousAvailableSize != availableSize)
            {
                this.isDirty          = true;
                previousAvailableSize = availableSize;
            }

            if (this.isDirty)
            {
                this.isDirty   = false;
                this.TextBlock = TinyHTMLParsers.Parse(textParams);
            }

            Size textSize = Size.Ceiling(this.TextBlock.GetTextSize(availableSize, textParams));
            Size res      = LayoutUtils.FlipSizeIf(textParams.textOrientation == Orientation.Vertical, textSize);
            Size minSize  = LayoutUtils.FlipSizeIf(textParams.textOrientation == Orientation.Vertical, textSize);

            res.Width  = Math.Max(res.Width, minSize.Width);
            res.Height = Math.Max(res.Height, minSize.Height);
            return(res);
        }
예제 #17
0
 public void PaintPrimitive(Telerik.WinControls.Paint.IGraphics graphics, TextParams textParams)
 {
     this.PaintPrimitive(graphics, 0f, scalingSize, textParams);
 }
예제 #18
0
 public void PaintPrimitive(IGraphics graphics, TextParams textParams)
 {
     this.textPrimitiveImpl.PaintPrimitive(graphics, textParams);
 }
예제 #19
0
 public SizeF MeasureOverride(SizeF availableSize, TextParams textParams)
 {
     return(this.textPrimitiveImpl.MeasureOverride(availableSize, textParams));
 }
예제 #20
0
 public void PaintPrimitive(IGraphics graphics, TextParams textParams)
 {
     this.PaintPrimitive(graphics, 0.0f, this.scalingSize, textParams);
 }
예제 #21
0
 public SizeF GetTextSize(TextParams textParams)
 {
     return(this.textPrimitiveImpl.GetTextSize(textParams));
 }
예제 #22
0
 public void PaintPrimitive(IGraphics graphics, TextParams textParams)
 {
     this.PaintPrimitive(graphics, 0.0f, new SizeF(1f, 1f), textParams);
 }