示例#1
0
        //-------------------------------------------------------------------------------------------------------------------------------------------------
        //------------------------------------------- DRAWING TEXT  ------------------------------------------------------------------------------
        //-------------------------------------------------------------------------------------------------------------------------------------------------
        public void DrawText(string text, string fontName, float fontSize, Point pDest, Color color, int rotation, bool wordWrap, Rectangle rectDest, float worldScale)
        {
            try
            {
                GorgonLibrary.Graphics.Font textFont = GetGorgonFont(fontName, fontSize);
                if (textFont != null)
                {
                    textSprite.Font = textFont;
                }
                else
                {
                    if (fontName.Equals("DEFAULT"))
                    {
                        textFont = new GorgonLibrary.Graphics.Font(fontName + "_" + fontSize,
                                                                   new System.Drawing.Font(SystemFonts.DefaultFont.FontFamily, fontSize));
                    }
                    else
                    {
                        textFont = new GorgonLibrary.Graphics.Font(fontName + "_" + fontSize,
                                                                   new System.Drawing.Font(fontName, fontSize));
                    }

                    textSprite.Font = textFont;
                }
                textSprite.Bounds   = null;
                textSprite.WordWrap = false;
                textSprite.Color    = color;
                textSprite.Text     = text;
                textSprite.SetAxis((int)((float)rectDest.Width) / 2, (int)((float)rectDest.Height) / 2);
                textSprite.Rotation = rotation;

                if (wordWrap == false)
                {
                    textSprite.Position = new Vector2D((int)((float)pDest.X * worldScale), (int)((float)pDest.Y * worldScale));
                }
                else
                {
                    textSprite.SetPosition((float)(rectDest.X + textSprite.Axis.X) * worldScale, (float)(rectDest.Y + textSprite.Axis.Y) * worldScale);
                    textSprite.Bounds = new Viewport(0, 0, (int)((float)rectDest.Width), 0);

                    textSprite.WordWrap = wordWrap;
                }



                textSprite.SetScale(worldScale, worldScale);
                textSprite.Draw();
            }
            catch (Exception ex)
            {
            }
        }
示例#2
0
 public void SetScale(float scale) => _textSprite?.SetScale(scale);