Example #1
0
            internal static TextNativeSettings GetTextNativeSettings(TextParams textParams, float scaling)
            {
                var settings = new TextNativeSettings
                {
                    text          = textParams.text,
                    font          = textParams.font,
                    size          = textParams.fontSize,
                    scaling       = scaling,
                    style         = textParams.fontStyle,
                    color         = textParams.fontColor,
                    anchor        = textParams.anchor,
                    wordWrap      = textParams.wordWrap,
                    wordWrapWidth = textParams.wordWrapWidth,
                    richText      = textParams.richText
                };

                settings.color *= textParams.playmodeTintColor;

                return(settings);
            }
        public float GetTextWidth(float fCharSize, int iFontSize, Font rFont, string sText)
        {
            //look for this string in the dictionary first
            TextParams rParams = new TextParams {
                m_CharSize = fCharSize,
                m_FontSize = iFontSize,
                m_Font     = rFont,
                m_Text     = sText
            };

            if (m_StringSizeMap.ContainsKey(rParams))
            {
                return(m_StringSizeMap[rParams].x);
            }

            //add new string to our map
            Vector2 vSize = AddNewString(rParams, fCharSize, iFontSize, rFont, sText);

            return(vSize.x);
        }
 /// <summary>
 /// Returns information about a set of places based on a string — for example "pizza in New York" or "shoe stores near Ottawa". \n
 /// The service responds with a list of places matching the text string and any location bias that has been set. \n
 /// The search response will include a list of places.
 /// </summary>
 /// <param name="key">
 /// Your application's API key. \n
 /// This key identifies your application for purposes of quota management and so that places added from your application are made immediately available to your app. \n
 /// Visit the Google APIs Console to create an API Project and obtain your key.
 /// </param>
 /// <param name="p">The object containing the request parameters.</param>
 /// <returns>Query instance to the Google API.</returns>
 public static OnlineMapsGooglePlaces FindText(string key, TextParams p)
 {
     return(new OnlineMapsGooglePlaces(key, p));
 }
 /// <summary>
 /// Generate an image of a given textual string
 /// </summary>
 /// <param name="parameters">Parameters of generating an image of a given textual string</param>
 /// <returns>Results of generating an image of a given textual string</returns>
 public Task <TextResult> TextAsync(TextParams parameters)
 {
     return(CallAsync(Text, parameters));
 }
 public static TextResult Text(this Cloudinary cloudinary, TextParams parameters)
 {
     return(cloudinary.TextAsync(parameters).ExecSync());
 }
Example #6
0
 public static FormattedTextBlock Parse(TextParams textParams)
 {
     return(TinyHTMLParsers.Parse(textParams.text, textParams.foreColor, textParams.font.Name, textParams.font.Size, textParams.font.Style, textParams.alignment));
 }
Example #7
0
 public SizeF GetTextSize(SizeF proposedSize, TextParams textParams)
 {
     using (StringFormat stringFormat = textParams.CreateStringFormat())
         return(this.GetTextSize(proposedSize, textParams.useCompatibleTextRendering, stringFormat, TextFormatFlags.Default, textParams.textWrap));
 }
Example #8
0
        protected virtual void PaintText(Graphics g, RectangleF rect)
        {
            Padding textPadding = this.TextPadding;

            if (string.IsNullOrEmpty(this.Text) || !this.DrawText)
            {
                return;
            }
            if (this.EnableHtmlTextRendering && this.Text.Contains("<html>"))
            {
                TextPrimitiveHtmlImpl primitiveHtmlImpl = new TextPrimitiveHtmlImpl();
                RadGdiGraphics        radGdiGraphics    = new RadGdiGraphics(g);
                TextParams            textParams        = new TextParams();
                textParams.alignment         = this.TextAlignment;
                textParams.ClipText          = true;
                textParams.font              = this.Font;
                textParams.foreColor         = this.ForeColor;
                textParams.paintingRectangle = rect;
                textParams.rightToLeft       = this.RightToLeft;
                textParams.text              = this.Text;
                textParams.textWrap          = true;
                if (textPadding != Padding.Empty)
                {
                    textParams.paintingRectangle.X      += (float)textPadding.Left;
                    textParams.paintingRectangle.Y      += (float)textPadding.Top;
                    textParams.paintingRectangle.Width  -= (float)textPadding.Horizontal;
                    textParams.paintingRectangle.Height -= (float)textPadding.Vertical;
                }
                primitiveHtmlImpl.PaintPrimitive((IGraphics)radGdiGraphics, textParams);
            }
            else
            {
                using (StringFormat format = new StringFormat())
                {
                    using (SolidBrush solidBrush = new SolidBrush(this.ForeColor))
                    {
                        format.Alignment     = this.GetHorizontalAlignment(this.TextAlignment);
                        format.LineAlignment = this.GetVerticalAlignment(this.TextAlignment);
                        format.Trimming      = this.StringTrimming;
                        format.FormatFlags   = this.StringFormatFlags;
                        if (textPadding != Padding.Empty)
                        {
                            rect.X      += (float)textPadding.Left;
                            rect.Y      += (float)textPadding.Top;
                            rect.Width  -= (float)textPadding.Horizontal;
                            rect.Height -= (float)textPadding.Vertical;
                        }
                        string s = this.Text;
                        if (s.Length > RadGdiGraphics.GdiStringLengthLimit)
                        {
                            s = s.Substring(0, RadGdiGraphics.GdiStringLengthLimit);
                        }
                        try
                        {
                            g.DrawString(s, this.Font, (Brush)solidBrush, rect, format);
                        }
                        catch
                        {
                            try
                            {
                                using (Font font = new Font(this.Font, FontStyle.Regular))
                                    g.DrawString(s, font, (Brush)solidBrush, rect, format);
                            }
                            catch
                            {
                                g.DrawString(s, Control.DefaultFont, (Brush)solidBrush, rect, format);
                            }
                        }
                    }
                }
            }
        }