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 ); }
public override void Redraw( IDrawer2D drawer ) { if( Window.Minimised ) return; 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 + 2 - size.Width) / 2, // account for border Y + (Height - size.Height) / 2 ); } drawer.DrawRectBounds( FastColour.White, 2, X, Y, Width, Height ); }
public void SetText(string value) { chatInputText.Clear(); chatInputText.Append(0, value); DrawTextArgs args = new DrawTextArgs(value, font, false); Size textSize = game.Drawer2D.MeasureSize(ref args); Size size = new Size(Math.Max(textSize.Width, DesiredMaxWidth), Math.Max(textSize.Height, DesiredMaxHeight)); yOffset = 0; if (textSize.Height < DesiredMaxHeight) { yOffset = DesiredMaxHeight / 2 - textSize.Height / 2; } using (Bitmap bmp = IDrawer2D.CreatePow2Bitmap(size)) using (IDrawer2D drawer = game.Drawer2D) { drawer.SetBitmap(bmp); drawer.DrawRect(backColour, 0, 0, size.Width, size.Height); args.SkipPartsCheck = true; drawer.DrawText(ref args, 0, 0); args.Text = Validator.Range; args.SkipPartsCheck = false; Size hintSize = drawer.MeasureSize(ref args); args.SkipPartsCheck = true; int hintX = size.Width - hintSize.Width; if (textSize.Width < hintX) { drawer.DrawText(ref args, hintX, 0); } chatInputTexture = drawer.Make2DTexture(bmp, size, 0, yOffset); } X = CalcOffset(game.Width, size.Width, XOffset, HorizontalAnchor); Y = CalcOffset(game.Height, size.Height, YOffset, VerticalAnchor); chatCaretTexture.X1 = chatInputTexture.X1 = X; chatCaretTexture.X1 += textSize.Width; chatCaretTexture.Y1 = chatInputTexture.Y1 = Y; chatCaretTexture.Y1 = (Y + size.Height) - chatCaretTexture.Height; Width = size.Width; Height = size.Height; }
public void Redraw( IDrawer2D drawer, string text, Font font ) { Text = text; if( Password ) text = new String( '*', text.Length ); DrawTextArgs args = new DrawTextArgs( text, font, true ); Size size = drawer.MeasureSize( ref args ); Width = Math.Max( ButtonWidth, size.Width + 7 ); FastColour col = Active ? FastColour.White : new FastColour( 160, 160, 160 ); drawer.DrawRectBounds( col, 2, X, Y, Width, Height ); drawer.DrawRect( FastColour.Black, X + 2, Y + 2, Width - 4, Height - 4 ); args.SkipPartsCheck = true; drawer.DrawText( ref args, X + 7, Y + 2 ); }