本文整理汇总了C#中Renderer.DrawString方法的典型用法代码示例。如果您正苦于以下问题:C# Renderer.DrawString方法的具体用法?C# Renderer.DrawString怎么用?C# Renderer.DrawString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Renderer
的用法示例。
在下文中一共展示了Renderer.DrawString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw(Renderer renderer)
{
RenderHelper.SmartDrawRectangle(bg, 6, (int)position.X, (int)position.Y, (int)size.X, (int)size.Y, Color.White, renderer);
renderer.DrawString(font, TextLeft, new Rectangle((int)position.X + 4, (int)position.Y, (int)size.X, (int)size.Y), Color.White,
Renderer.TextAlignment.Left);
renderer.DrawString(font, TextRight, new Rectangle((int)position.X + 4, (int)position.Y, (int)size.X - 7, (int)size.Y), Color.White,
Renderer.TextAlignment.Right);
}
示例2: Draw
public override void Draw(Renderer renderer)
{
renderer.Draw(GraphicsEngine.pixel, new Rectangle(0, 0, Main.WindowWidth, Main.WindowHeight), Shortcuts.BG_COLOR * 0.5f);
renderer.DrawString(GUIEngine.font, "Press the sequence (mouse and/or keyboard) you wish to select...",
new Rectangle(0, 0, Main.WindowWidth, Main.WindowHeight), Color.White, Renderer.TextAlignment.Center);
renderer.DrawString(GUIEngine.font, seq.ToString(GUIEngine.font, Main.windowWidth, true),
new Rectangle(0, 50, Main.WindowWidth, Main.WindowHeight), Color.White, Renderer.TextAlignment.Center);
base.Draw(renderer);
}
示例3: DrawToFBO
public override void DrawToFBO(Renderer renderer)
{
renderer.BeginUnscaled();
renderer.Draw(GraphicsEngine.pixel,
new Rectangle(0, 0, (int)size.X, (int)size.Y),
isEnabled ? (isPressed ? pressedColor : (isMouseOver ? mouseOverColor : background)) : disabledColor);
if (textOld != Text)
{
textOld = Text;
stringSize = GUIEngine.font.MeasureString(Text);
}
renderer.DrawString(Font, Text, new Rectangle(MouseOverOffset + 10,
(int)size.Y - 22, (int)size.X, (int)size.Y), foreground, textAlignment);
//inside text
String t = Text.Substring(Text.Length - 1);
var a = bfont.MeasureString(t);
renderer.DrawStringLeft(bfont, t, new Vector2(3 + (size.X - 3 - a.X) / 2, 3 + (lines[3].Position.Y - 3 - a.Y) / 2), Color.White);
renderer.Draw(GraphicsEngine.pixel, new Rectangle(0, 0, 0, 0), Color.White);
renderer.DrawLinesList(lines);
renderer.End();
}
示例4: Draw
public override void Draw(Renderer renderer)
{
if (background != null) background.Draw(renderer);
if (fadeSize.Y != Main.WindowHeight)
renderer.SetScissorRectangle((int)(Main.WindowWidth - fadeSize.X) / 2, (int)(Main.WindowHeight - fadeSize.Y) / 2,
(int)fadeSize.X, (int)fadeSize.Y, false);
RenderHelper.SmartDrawRectangle(bg, 5, 0, 0, Main.WindowWidth, Main.WindowHeight, Color.White, renderer);
foreach (Elements.Control c in controls)
{
c.Draw(renderer);
}
if (fadeSize.X != Main.WindowWidth)
{
renderer.ResetScissorRectangle();
renderer.SetScissorRectangle((int)(Main.WindowWidth - fadeSize.X) / 2, (int)(Main.WindowHeight - fadeSize.Y) / 2,
(int)fadeSize.X, (int)fadeSize.Y, false);
}
if (saves.ItemsCount() == 0)
{
var a = overlayFont.MeasureString("No save files found");
renderer.DrawString(overlayFont, "No save files found",
new Rectangle(0, (int)(saves.Position.Y + (saves.Size.Y - a.Y) / 2), Main.WindowWidth, (int)a.Y),
Color.Gray, Renderer.TextAlignment.Center);
}
if (fadeSize.X != Main.WindowWidth)
renderer.ResetScissorRectangle();
}
示例5: Draw
public override void Draw(Renderer renderer)
{
base.Draw(renderer);
if (saves.ItemsCount() == 0)
{
var a = overlayFont.MeasureString("No save files found");
renderer.DrawString(overlayFont, "No save files found",
new Rectangle((int)saves.Position.X, (int)(saves.Position.Y + (saves.Size.Y - a.Y) / 2), (int)saves.Size.X, (int)a.Y),
Color.Gray, Renderer.TextAlignment.Center);
}
}
示例6: Draw
public override void Draw(Renderer renderer)
{
base.Draw(renderer);
renderer.Draw(tfolder, Position + new Vector2(26, 26), Color.White);
renderer.Draw(GraphicsEngine.pixel, new Rectangle((int)Position.X - 9, (int)Position.Y + 95, (int)Size.X + 9, 1), Color.White);
renderer.Draw(GraphicsEngine.pixel, new Rectangle((int)Position.X - 10 + (int)Size.X + 9, (int)Position.Y + 95, 1, 5), Color.White);
if (saves.ItemsCount() == 0)
{
var a = overlayFont.MeasureString("No save files found");
renderer.DrawString(overlayFont, "No save files found",
new Rectangle((int)saves.Position.X, (int)(saves.Position.Y + (saves.Size.Y - a.Y) / 2), (int)saves.Size.X, (int)a.Y),
Color.Gray, Renderer.TextAlignment.Center);
}
}
示例7: Draw
public override void Draw(Renderer renderer)
{
if (!isVisible) return;
renderer.End();
renderer.BeginUnscaled(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap, DepthStencilState.None,
RasterizerState.CullNone);
var a = font.MeasureString(Text.Substring(0, CurLength));
//arrow
//bg
//text
switch (textDirection)
{
case ArrowLineDirection.RightUp:
renderer.Draw(arrowRU, position, Color.White * opacity);
renderer.Draw(GraphicsEngine.pixel,
new Rectangle((int)(position.X + arrowRU.Width + 2), (int)position.Y, (int)size.X - arrowRU.Width + 2, (int)a.Y),
Settings.BGCOLOR * 0.7f);
renderer.DrawString(font, Text.Substring(0, CurLength), new Vector2(position.X + arrowRU.Width + 2, position.Y),
Color.White * opacity, Renderer.TextAlignment.Left);
break;
case ArrowLineDirection.RightDown:
renderer.Draw(arrowRD, position, Color.White * opacity);
renderer.Draw(GraphicsEngine.pixel,
new Rectangle((int)(position.X + arrowRD.Width + 2), (int)(position.Y + arrowRD.Height - charSize.Y), (int)a.X + 2, (int)a.Y),
Settings.BGCOLOR * 0.7f);
renderer.DrawString(font, Text.Substring(0, CurLength),
new Vector2(position.X + arrowRD.Width + 2, position.Y + arrowRD.Height - charSize.Y),
Color.White * opacity, Renderer.TextAlignment.Left);
break;
case ArrowLineDirection.LeftUp:
renderer.Draw(arrowLU, position + new Vector2(size.X - arrowLU.Width, 0), Color.White * opacity);
renderer.Draw(GraphicsEngine.pixel,
new Rectangle((int)(position.X + size.X - arrowLU.Width - a.X) - 2, (int)position.Y, (int)a.X + 4, (int)a.Y + 2),
Settings.BGCOLOR * 0.7f);
renderer.DrawString(font, Text.Substring(0, CurLength),
new Rectangle((int)position.X, (int)position.Y, (int)size.X - arrowLU.Width, (int)size.Y),
Color.White * opacity, Renderer.TextAlignment.Right);
break;
case ArrowLineDirection.LeftDown:
renderer.Draw(arrowLD, position + new Vector2(size.X - arrowLD.Width, 0), Color.White * opacity);
renderer.Draw(GraphicsEngine.pixel,
new Rectangle((int)(position.X + size.X - arrowLD.Width - a.X) - 2, (int)(position.Y + arrowLD.Height - charSize.Y), (int)a.X + 4, (int)a.Y + 2),
Settings.BGCOLOR * 0.7f);
renderer.DrawString(font, Text.Substring(0, CurLength),
new Rectangle((int)position.X, (int)(position.Y + arrowLD.Height - charSize.Y),
(int)size.X - arrowLD.Width, (int)size.Y),
Color.White * opacity, Renderer.TextAlignment.Right);
break;
default:
break;
}
renderer.End();
renderer.BeginUnscaled();
}
示例8: Draw
public override void Draw(Renderer renderer)
{
if (background != null && (Main.CurState.StartsWith("GUI") ||
(currentState.items.Count > 0 && currentState.items[0] != inGameItems[0] && currentState.items[0] != inGameItems[4].Children[0] &&
currentState.caption != "HANDBOOK")))
{
gameBGOpacity = 0;
background.Draw(renderer);
var atr = GUIEngine.font.MeasureString(currentTip);
renderer.DrawString(GUIEngine.font, ">> " + currentTip + " <<", new Rectangle(0, (int)(Main.WindowHeight - atr.Y), Main.WindowWidth, (int)atr.Y),
new Color(180, 255, 180), Renderer.TextAlignment.Center);
}
else
{
if (gameBGOpacity < 0.5f)
gameBGOpacity += 0.02f;
renderer.Draw(MicroWorld.Graphics.GraphicsEngine.pixel, new Rectangle(0, 0, Main.WindowWidth, Main.WindowHeight),
new Color(45, 57, 107) * gameBGOpacity);
}
renderer.Draw(GraphicsEngine.pixel, new Rectangle(0, 0, 0, 0), Color.White);
renderer.DrawLinesList(new VertexPositionColorTexture[]{
new VertexPositionColorTexture(new Vector3(line1p1.X, line1p1.Y,0), Color.White, new Vector2()),
new VertexPositionColorTexture(new Vector3(line1p2.X, line1p2.Y, 0), Color.White, new Vector2()),
new VertexPositionColorTexture(new Vector3(line2p1.X, line2p1.Y,0), Color.White, new Vector2()),
new VertexPositionColorTexture(new Vector3(line2p2.X, line2p2.Y, 0), Color.White, new Vector2()),
new VertexPositionColorTexture(new Vector3(line3p1.X, line3p1.Y,0), Color.White, new Vector2()),
new VertexPositionColorTexture(new Vector3(line3p2.X, line3p2.Y, 0), Color.White, new Vector2()),
new VertexPositionColorTexture(new Vector3(line4p1.X, line4p1.Y,0), Color.White, new Vector2()),
new VertexPositionColorTexture(new Vector3(line4p2.X, line4p2.Y, 0), Color.White, new Vector2())
});
renderer.SetScissorRectangle(line2p1.X+1, line1p1.Y, Main.WindowWidth, Main.WindowHeight, false);
lock (controls)
{
foreach (Elements.Control c in controls)
{
c.Draw(renderer);
}
}
renderer.DrawString(fontCurrent, currentState.caption, new Vector2(CaptionPosition.X + 10, CaptionPosition.Y + 10), Color.White,
Renderer.TextAlignment.Left);
if (currentFrame != null && currentFrame.isVisible)
{
renderer.SetScissorRectangle(line3p1.X, line3p1.Y, Main.WindowWidth, Main.WindowHeight, false);
renderer.End();
renderer.BeginUnscaled(SpriteSortMode.Immediate, BlendState.AlphaBlend, null,
null, Graphics.GraphicsEngine.s_ScissorsOn, null, Matrix.CreateTranslation(FrameOffset, 0, 0));
currentFrame.Draw(renderer);
}
renderer.ResetScissorRectangle();
}
示例9: Draw
public override void Draw(Renderer renderer)
{
if (!isVisible) return;
Vector2 posold = position;
if (ShouldOffset)
Position = Position + Settings.GameOffset * Settings.GameScale;
//bg
if (BGAsColor)
renderer.Draw(GraphicsEngine.pixel, new Rectangle((int)position.X, (int)position.Y, (int)Size.X, (int)Size.Y), BackgroundColor);
else
RenderHelper.SmartDrawRectangle(Texture, 5, (int)position.X, (int)position.Y, (int)Size.X, (int)Size.Y, BackgroundColor,
renderer);
#region ScissorsInit
float x = position.X < 0 ? 0 : position.X;
float y = position.Y < 0 ? 0 : position.Y;
float w = size.X < 0 ? 0 : size.X;
float h = size.Y < 0 ? 0 : size.Y;
if (x > Main.WindowWidth)
x = Main.WindowWidth;
if (y > Main.WindowHeight)
y = Main.WindowHeight;
if (x + w > Main.WindowWidth)
w = Main.WindowWidth - x;
if (y + h > Main.WindowHeight)
h = Main.WindowHeight - y;
#endregion
renderer.SetScissorRectangle(x, y, w, h, false);
//selection
if (SelectionStart != -1 && SelectionLength != 0)
{
int min = Math.Min(SelectionStart + SelectionLength, selectionStart);
int max = min + Math.Abs(SelectionLength);
var sc = getCoordForCursor(min);
int sci = (int)((sc.Y + TextOffset.Y) / SizePerOneSymbol.Y);
int scj = (int)((sc.X + TextOffset.X) / SizePerOneSymbol.X);
if (scj < 0) scj = 0;
var sc2 = getCoordForCursor(max);
int sc2i = (int)((sc2.Y + TextOffset.Y) / SizePerOneSymbol.Y);
int sc2j = (int)((sc2.X + TextOffset.X) / SizePerOneSymbol.X);
if (sc2j < 0) sc2j = 0;
if (sci == sc2i)//same line
{
renderer.Draw(GraphicsEngine.pixel, new Rectangle((int)(position.X + sc.X), (int)(position.Y + sc.Y),
(int)(sc2.X - sc.X), (int)charSize.Y), SelectionColor);
}
else//multiline
{
renderer.Draw(GraphicsEngine.pixel, new Rectangle((int)(position.X + sc.X), (int)(position.Y + sc.Y),
(int)(Font.MeasureString(DrawTextLines[sci].Substring(scj)).X - sc.X), (int)charSize.Y), SelectionColor);
float c = sc.Y + SizePerOneSymbol.Y;
for (int i = sci + 1; i < sc2i; i++)
{
renderer.Draw(GraphicsEngine.pixel, new Rectangle((int)(position.X), (int)(position.Y + c),
(int)(Font.MeasureString(DrawTextLines[i]).X), (int)charSize.Y), SelectionColor);
c += SizePerOneSymbol.Y;
}
renderer.Draw(GraphicsEngine.pixel, new Rectangle((int)(position.X), (int)(position.Y + sc2.Y),
(int)(sc2.X), (int)charSize.Y), SelectionColor);
}
}
//text
renderer.DrawString(font, DrawText, position - TextOffset, ForegroundColor,
Renderer.TextAlignment.Left);
//cursor
if (Editable && isFocused && Main.Ticks % 60 < 30)
renderer.Draw(GraphicsEngine.pixel, new Rectangle((int)(position.X + cursorPos.X), (int)(position.Y + cursorPos.Y),
1, (int)charSize.Y), CursorColor);
renderer.ResetScissorRectangle();
base.Draw(renderer);
if (ShouldOffset)
position = posold;
}