本文整理汇总了C#中ClassicalSharp.DrawTextArgs类的典型用法代码示例。如果您正苦于以下问题:C# DrawTextArgs类的具体用法?C# DrawTextArgs怎么用?C# DrawTextArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DrawTextArgs类属于ClassicalSharp命名空间,在下文中一共展示了DrawTextArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawBitmappedText
public override void DrawBitmappedText( ref DrawTextArgs args, int x, int y )
{
using( bitmapWrapper ) {
bitmapWrapper.SetData( curBmp, true, false );
DrawBitmapTextImpl( bitmapWrapper, ref args, x, y );
}
}
示例2: DrawAdvanced
Texture DrawAdvanced( ref DrawTextArgs args, int index, string text )
{
string[] items = Split( index, text );
Size total = Size.Empty;
Size[] partSizes = new Size[items.Length];
for( int i = 0; i < items.Length; i++ ) {
args.Text = items[i];
args.Font = (i & 1) == 0 ? font : underlineFont;
partSizes[i] = game.Drawer2D.MeasureChatSize( ref args );
total.Height = Math.Max( partSizes[i].Height, total.Height );
total.Width += partSizes[i].Width;
}
using( IDrawer2D drawer = game.Drawer2D )
using( Bitmap bmp = IDrawer2D.CreatePow2Bitmap( total ) )
{
drawer.SetBitmap( bmp );
int x = 0;
for( int i = 0; i < items.Length; i++ ) {
args.Text = items[i];
args.Font = (i & 1) == 0 ? font : underlineFont;
Size size = partSizes[i];
drawer.DrawChatText( ref args, x, 0 );
urlBounds[index][i].X = x;
urlBounds[index][i].Width = size.Width;
x += size.Width;
}
return drawer.Make2DTexture( bmp, total, 0, 0 );
}
}
示例3: Init
public override void Init()
{
X = 10;
DrawTextArgs caretArgs = new DrawTextArgs( "_", Color.White, false );
chatCaretTexture = game.Drawer2D.MakeTextTexture( boldFont, 0, 0, ref caretArgs );
string value = chatInputText.GetString();
if( chatInputText.Empty ) {
caretPos = -1;
}
Size size = game.Drawer2D.MeasureSize( value, font, false );
if( caretPos == -1 ) {
chatCaretTexture.X1 = 10 + size.Width;
size.Width += chatCaretTexture.Width;
DrawString( size, value, true );
} else {
string subString = chatInputText.GetSubstring( caretPos );
Size trimmedSize = game.Drawer2D.MeasureSize( subString, font, false );
chatCaretTexture.X1 = 10 + trimmedSize.Width;
Size charSize = game.Drawer2D.MeasureSize( new String( value[caretPos], 1 ), font, false );
chatCaretTexture.Width = charSize.Width;
DrawString( size, value, false );
}
}
示例4: DrawClippedText
public override void DrawClippedText( ref DrawTextArgs args, int x, int y, float maxWidth, float maxHeight )
{
if( !args.SkipPartsCheck )
GetTextParts( args.Text );
Brush shadowBrush = GetOrCreateBrush( FastColour.Black );
StringFormatFlags flags = format.FormatFlags;
format.FormatFlags |= StringFormatFlags.NoWrap;
format.Trimming = StringTrimming.EllipsisCharacter;
float textX = x;
for( int i = 0; i < parts.Count; i++ ) {
TextPart part = parts[i];
Brush textBrush = GetOrCreateBrush( part.TextColour );
RectangleF rect = new RectangleF( textX + Offset, y + Offset, maxWidth, maxHeight );
if( args.UseShadow )
g.DrawString( part.Text, args.Font, shadowBrush, rect, format );
rect = new RectangleF( textX, y, maxWidth, maxHeight );
g.DrawString( part.Text, args.Font, textBrush, rect, format );
textX += g.MeasureString( part.Text, args.Font, Int32.MaxValue, format ).Width;
}
format.Trimming = StringTrimming.None;
format.FormatFlags = flags;
}
示例5: DrawChatText
/// <summary> Draws a string using the specified arguments, using the specified font or
/// the current bitmapped font depending on the 'useFont' argument, at the
/// specified coordinates in the currently bound bitmap. </summary>
public void DrawChatText( ref DrawTextArgs args, int windowX, int windowY )
{
if( !UseBitmappedChat )
DrawText( ref args, windowX, windowY );
else
DrawBitmappedText( ref args, windowX, windowY );
}
示例6: DrawBitmappedText
public override void DrawBitmappedText( ref DrawTextArgs args, int x, int y )
{
if( !args.SkipPartsCheck )
GetTextParts( args.Text );
using( FastBitmap fastBmp = new FastBitmap( curBmp, true ) )
DrawTextImpl( fastBmp, ref args, x, y );
}
示例7: InitRenderingData
protected void InitRenderingData()
{
api = game.Graphics;
using( Font font = new Font( "Arial", 14 ) ) {
DrawTextArgs args = new DrawTextArgs( DisplayName, font, true );
nameTex = game.Drawer2D.MakeBitmappedTextTexture( ref args, 0, 0 );
}
}
示例8: DrawAt
public void DrawAt( IDrawer2D drawer, string text, Font font,
Anchor horAnchor, Anchor verAnchor, int x, int y)
{
DrawTextArgs args = new DrawTextArgs( text, font, true );
Size size = drawer.MeasureSize( ref args );
Width = size.Width; Height = size.Height;
CalculateOffset( x, y, horAnchor, verAnchor );
Redraw( drawer, text, font );
}
示例9: Redraw
public void Redraw( IDrawer2D drawer, string text, Font font )
{
DrawTextArgs args = new DrawTextArgs( text, font, true );
Size size = drawer.MeasureSize( ref args );
Width = size.Width; Height = size.Height;
args.SkipPartsCheck = true;
drawer.DrawText( ref args, X, Y );
Text = text;
}
示例10: SetDrawData
public void SetDrawData( IDrawer2D drawer, string text, Font font,
Anchor horAnchor, Anchor verAnchor, int x, int y)
{
DrawTextArgs args = new DrawTextArgs( text, font, true );
Size size = drawer.MeasureSize( ref args );
Width = size.Width; Height = size.Height;
CalculateOffset( x, y, horAnchor, verAnchor );
Text = text;
this.font = font;
}
示例11: Init
public override void Init()
{
Textures = new Texture[ElementsCount];
DrawTextArgs args = new DrawTextArgs( "I", font, true );
defaultHeight = game.Drawer2D.MeasureSize( ref args ).Height;
for( int i = 0; i < Textures.Length; i++ ) {
Textures[i].Height = defaultHeight;
}
UpdateDimensions();
}
示例12: DrawBitmapTextImpl
protected void DrawBitmapTextImpl( FastBitmap dst, ref DrawTextArgs args, int x, int y )
{
bool underline = args.Font.Style == FontStyle.Underline;
if( args.UseShadow ) {
int offset = ShadowOffset( args.Font.Size );
DrawPart( dst, ref args, x + offset, y + offset, true );
if( underline ) DrawUnderline( dst, x + offset, 0, ref args, true );
}
DrawPart( dst, ref args, x, y, false );
if( underline ) DrawUnderline( dst, x, -2, ref args, false );
}
示例13: Init
public override void Init()
{
Textures = new Texture[ElementsCount];
lines = new string[ElementsCount];
urlBounds = new Rectangle[ElementsCount][];
DrawTextArgs args = new DrawTextArgs( "I", font, true );
defaultHeight = game.Drawer2D.MeasureChatSize( ref args ).Height;
for( int i = 0; i < Textures.Length; i++ )
Textures[i].Height = defaultHeight;
UpdateDimensions();
}
示例14: Redraw
public void Redraw( IDrawer2D drawer )
{
drawer.DrawRect( FastColour.Black, X, Y, Width, Height );
if( Value ) {
DrawTextArgs args = new DrawTextArgs( "X", font, false );
Size size = drawer.MeasureSize( ref args );
args.SkipPartsCheck = true;
drawer.DrawText( ref args, X + (Width - size.Width) / 2,
Y + (Height - size.Height) / 2 );
}
drawer.DrawRectBounds( FastColour.White, 2, X, Y, Width, Height );
}
示例15: MeasureContentSizes
unsafe void MeasureContentSizes( Element e, Font font, Size* sizes )
{
string s = new String( '\0', e.CharsPerItem );
DrawTextArgs args = new DrawTextArgs( s, font, false );
// avoid allocating temporary strings here
fixed( char* ptr = s ) {
for( int i = 0; i < e.Contents.Length; i += e.CharsPerItem ) {
for( int j = 0; j < e.CharsPerItem; j++ )
ptr[j] = e.Contents[i + j];
sizes[i / e.CharsPerItem] = game.Drawer2D.MeasureChatSize( ref args );
}
}
}