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); }
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(); }
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); } }
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); }
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); }
public void PaintPrimitive(IGraphics graphics, float angle, SizeF scale, TextParams textParams) { this.textPrimitiveImpl.PaintPrimitive(graphics, angle, scale, textParams); }
/// <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); }
// helper method which changes the whitespaces with a dummy character public StringFormat CreateStringFormat() { TextParams textParams = this.CreateTextParams(); return(textParams.CreateStringFormat()); }
public SizeF GetTextSize(SizeF proposedSize) { TextParams textParams = this.CreateTextParams(); return(this.textPrimitiveImpl.GetTextSize(proposedSize, textParams)); }
public SizeF GetTextSize() { TextParams textParams = this.CreateTextParams(); return(this.textPrimitiveImpl.GetTextSize(textParams)); }
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(); }
public SizeF GetTextSize(SizeF proposedSize, TextParams textParams) { return(this.textPrimitiveImpl.GetTextSize(proposedSize, textParams)); }
public void PaintPrimitive(Telerik.WinControls.Paint.IGraphics graphics, TextParams textParams) { this.PaintPrimitive(graphics, 0f, new SizeF(1f, 1f), textParams); }
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); }
/// <summary>Retrieves the text size.</summary> public SizeF GetTextSize(TextParams textParams) { return(this.GetTextSize(LayoutUtils.MaxSizeF, textParams)); }
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); }
public void PaintPrimitive(Telerik.WinControls.Paint.IGraphics graphics, TextParams textParams) { this.PaintPrimitive(graphics, 0f, scalingSize, textParams); }
public void PaintPrimitive(IGraphics graphics, TextParams textParams) { this.textPrimitiveImpl.PaintPrimitive(graphics, textParams); }
public SizeF MeasureOverride(SizeF availableSize, TextParams textParams) { return(this.textPrimitiveImpl.MeasureOverride(availableSize, textParams)); }
public void PaintPrimitive(IGraphics graphics, TextParams textParams) { this.PaintPrimitive(graphics, 0.0f, this.scalingSize, textParams); }
public SizeF GetTextSize(TextParams textParams) { return(this.textPrimitiveImpl.GetTextSize(textParams)); }
public void PaintPrimitive(IGraphics graphics, TextParams textParams) { this.PaintPrimitive(graphics, 0.0f, new SizeF(1f, 1f), textParams); }