本文整理汇总了C#中TomShane.Neoforce.Controls.Renderer.Draw方法的典型用法代码示例。如果您正苦于以下问题:C# Renderer.Draw方法的具体用法?C# Renderer.Draw怎么用?C# Renderer.Draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TomShane.Neoforce.Controls.Renderer
的用法示例。
在下文中一共展示了Renderer.Draw方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawControl
protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime time)
{
//Draw the lifebar
renderer.Draw(m_BarImage, rect, Color.White);
//For each life
for (int i = 0; i < m_Life; i++) {
//Calculate position
Rectangle LifeRect = new Rectangle(rect.Left, rect.Top, m_LifeImage.Width, m_LifeImage.Height);
LifeRect.X += Global.LIFE_X + (i * (m_LifeImage.Width - 2));
LifeRect.Y += Global.LIFE_Y;
//Draw it
renderer.Draw(m_LifeImage, LifeRect, Color.White);
}
}
示例2: DrawControl
protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
{
_policyRect.X = rect.X;
_policyRect.Y = rect.Y;
if (Policy != null)
{
if (MainWindow.Game.Human.Policies.Contains(Policy))
renderer.Draw(_button44gold, _policyRect, Color.White);
else if (MainWindow.Game.Human.PoliciesInReach.Contains(Policy))
renderer.Draw(_button44, _policyRect, Color.Gray);
else
renderer.Draw(_button44, _policyRect, Color.White);
renderer.Draw(Policy.Image, _policyRect, Color.White);
}
}
示例3: DrawControl
protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
{
if (Player != null)
{
_iconRect.X = rect.X;
_iconRect.Y = rect.Y;
renderer.Draw(Player.Leader.Image, _iconRect, Color.White);
renderer.DrawString(_font, Player.Leader.Title, rect.X + 24, rect.Y, Color.White);
renderer.DrawString(_font, Player.Score.ToString(), rect.X + rect.Width - 20, rect.Y, Color.White);
}
_seperatorRect.X = rect.X;
_seperatorRect.Y = rect.Y + rect.Height - 2;
renderer.Draw(bar340x2, _seperatorRect, Color.White);
}
示例4: DrawControl
protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
{
base.DrawControl(renderer, rect, gameTime);
clipRect.X = rect.X + 1;
clipRect.Y = rect.Y + 1;
renderer.Draw(_clipImg, clipRect, Color.White);
clipRect.Y += 5;
renderer.DrawString(_policyTitleFont, PolicyType.Title, clipRect, Color.White, Alignment.TopCenter);
}
示例5: DrawControl
protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
{
if( MainWindow.Game.Human.Technologies.Contains( Tech ))
renderer.Draw(_backgroundReached, rect, Color.White);
else if( MainWindow.Game.Human.CurrentResearch == Tech )
renderer.Draw(_backgroundActive, rect, Color.White);
else if( MainWindow.Game.Human.PossibleTechnologies.Contains( Tech ) )
renderer.Draw(_backgroundPossible, rect, Color.White);
else
renderer.Draw(_backgroundNoReach, rect, Color.White);
if( Tech != null )
{
_techIconRect.X = rect.X + 2;
_techIconRect.Y = rect.Y;
renderer.Draw(Tech.Image, _techIconRect, Color.White);
_techTitleRect.X = rect.X + 70;
_techTitleRect.Y = rect.Y + 5;
renderer.DrawString(_font, Tech.Title,_techTitleRect, Color.White,Alignment.MiddleLeft );
}
}
示例6: Render
public override void Render(Renderer renderer, GameTime gameTime)
{
if (_backgroundBuffer == null)
UpdateBackground(Width, Height);
// if buffer is still empty, something wrong
if (_backgroundBuffer == null)
return;
base.Render(renderer, gameTime);
if (Visible)
{
renderer.Begin(BlendingMode.Default);
renderer.Draw(_backgroundBuffer, this.AbsoluteRect, AlphaColor);
renderer.End();
}
}
示例7: DrawPart
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
private void DrawPart(Renderer renderer, Rectangle rect, BevelBorder pos, BevelStyle style, bool all)
{
SkinLayer layer = Skin.Layers["Control"];
Color c1 = Utilities.ParseColor(layer.Attributes["LightColor"].Value);
Color c2 = Utilities.ParseColor(layer.Attributes["DarkColor"].Value);
Color c3 = Utilities.ParseColor(layer.Attributes["FlatColor"].Value);
if (Color != UndefinedColor) c3 = Color;
Texture2D img = Skin.Layers["Control"].Image.Resource;
int x1 = 0; int y1 = 0; int w1 = 0; int h1 = 0;
int x2 = 0; int y2 = 0; int w2 = 0; int h2 = 0;
if (style == BevelStyle.Bumped || style == BevelStyle.Etched)
{
if (all && (pos == BevelBorder.Top || pos == BevelBorder.Bottom))
{
rect = new Rectangle(rect.Left + 1, rect.Top, rect.Width - 2, rect.Height);
}
else if (all && (pos == BevelBorder.Left))
{
rect = new Rectangle(rect.Left, rect.Top, rect.Width, rect.Height - 1);
}
switch (pos)
{
case BevelBorder.Left:
{
x1 = rect.Left; y1 = rect.Top; w1 = 1; h1 = rect.Height;
x2 = x1 + 1; y2 = y1; w2 = w1; h2 = h1;
break;
}
case BevelBorder.Top:
{
x1 = rect.Left; y1 = rect.Top; w1 = rect.Width; h1 = 1;
x2 = x1; y2 = y1 + 1; w2 = w1; h2 = h1;
break;
}
case BevelBorder.Right:
{
x1 = rect.Left + rect.Width - 2; y1 = rect.Top; w1 = 1; h1 = rect.Height;
x2 = x1 + 1; y2 = y1; w2 = w1; h2 = h1;
break;
}
case BevelBorder.Bottom:
{
x1 = rect.Left; y1 = rect.Top + rect.Height - 2; w1 = rect.Width; h1 = 1;
x2 = x1; y2 = y1 + 1; w2 = w1; h2 = h1;
break;
}
}
}
else
{
switch (pos)
{
case BevelBorder.Left:
{
x1 = rect.Left; y1 = rect.Top; w1 = 1; h1 = rect.Height;
break;
}
case BevelBorder.Top:
{
x1 = rect.Left; y1 = rect.Top; w1 = rect.Width; h1 = 1;
break;
}
case BevelBorder.Right:
{
x1 = rect.Left + rect.Width - 1; y1 = rect.Top; w1 = 1; h1 = rect.Height;
break;
}
case BevelBorder.Bottom:
{
x1 = rect.Left; y1 = rect.Top + rect.Height - 1; w1 = rect.Width; h1 = 1;
break;
}
}
}
switch (Style)
{
case BevelStyle.Bumped:
{
renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c1);
renderer.Draw(img, new Rectangle(x2, y2, w2, h2), c2);
break;
}
case BevelStyle.Etched:
{
renderer.Draw(img, new Rectangle(x1, y1, w1, h1), c2);
renderer.Draw(img, new Rectangle(x2, y2, w2, h2), c1);
break;
}
case BevelStyle.Raised:
{
Color c = c1;
if (pos == BevelBorder.Left || pos == BevelBorder.Top) c = c1;
else c = c2;
//.........这里部分代码省略.........
示例8: DrawControl
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
{
base.DrawControl(renderer, rect, gameTime);
if (ReadOnly && Focused)
{
SkinLayer lr = Skin.Layers[0];
Rectangle rc = new Rectangle(rect.Left + lr.ContentMargins.Left,
rect.Top + lr.ContentMargins.Top,
Width - lr.ContentMargins.Horizontal - btnDown.Width - btnUp.Width,
Height - lr.ContentMargins.Vertical);
renderer.Draw(Manager.Skin.Images["ListBox.Selection"].Resource, rc, Color.FromNonPremultiplied(255, 255, 255, 128));
}
}
示例9: DrawControl
/// <summary>
/// Draws the image box control.
/// </summary>
/// <param name="renderer">Render management object.</param>
/// <param name="rect">Destination rectangle where the image box will be drawn.</param>
/// <param name="gameTime">Snapshot of the application's timing values.</param>
protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
{
if (image != null)
{
if (sizeMode == SizeMode.Normal)
{
renderer.Draw(image, rect.X, rect.Y, sourceRect, Color);
}
else if (sizeMode == SizeMode.Auto)
{
renderer.Draw(image, rect.X, rect.Y, sourceRect, Color);
}
else if (sizeMode == SizeMode.Stretched)
{
renderer.Draw(image, rect, sourceRect, Color);
}
else if (sizeMode == SizeMode.Centered)
{
int x = (rect.Width / 2) - (image.Width / 2);
int y = (rect.Height / 2) - (image.Height / 2);
renderer.Draw(image, x, y, sourceRect, Color);
}
}
}
示例10: DrawSelection
/// <summary>
/// Draws the text box's selection overlay to highlight selected text.
/// </summary>
/// <param name="renderer">Render management object.</param>
/// <param name="rect">Region where the selection overlay should be drawn.</param>
private void DrawSelection(Renderer renderer, Rectangle rect)
{
if (!selection.IsEmpty)
{
int s = selection.Start;
int e = selection.End;
// Get selection's starting line index, ending line index, starting column index, and ending column index.
int sl = GetPosY(s);
int el = GetPosY(e);
int sc = GetPosX(s);
int ec = GetPosX(e);
// Selection height is the height of a single line of text.
int hgt = font.LineSpacing;
int start = sl;
int end = el;
// Adjust start and end positions to account for vertical scroll values.
if (start < vert.Value) start = vert.Value;
if (end > vert.Value + linesDrawn) end = vert.Value + linesDrawn;
// Draw each line of the selection.
for (int i = start; i <= end; i++)
{
Rectangle r = Rectangle.Empty;
if (mode == TextBoxMode.Normal)
{
int m = ClientArea.Height - font.LineSpacing;
r = new Rectangle(rect.Left - horz.Value + (int)font.MeasureString(Lines[i].Substring(0, sc)).X, rect.Top + m / 2,
(int)font.MeasureString(Lines[i].Substring(0, ec + 0)).X - (int)font.MeasureString(Lines[i].Substring(0, sc)).X, hgt);
}
else if (sl == el)
{
r = new Rectangle(rect.Left - horz.Value + (int)font.MeasureString(Lines[i].Substring(0, sc)).X, rect.Top + (i - vert.Value) * hgt,
(int)font.MeasureString(Lines[i].Substring(0, ec + 0)).X - (int)font.MeasureString(Lines[i].Substring(0, sc)).X, hgt);
}
else
{
if (i == sl) r = new Rectangle(rect.Left - horz.Value + (int)font.MeasureString(Lines[i].Substring(0, sc)).X, rect.Top + (i - vert.Value) * hgt, (int)font.MeasureString(Lines[i]).X - (int)font.MeasureString(Lines[i].Substring(0, sc)).X, hgt);
else if (i == el) r = new Rectangle(rect.Left - horz.Value, rect.Top + (i - vert.Value) * hgt, (int)font.MeasureString(Lines[i].Substring(0, ec + 0)).X, hgt);
else r = new Rectangle(rect.Left - horz.Value, rect.Top + (i - vert.Value) * hgt, (int)font.MeasureString(Lines[i]).X, hgt);
}
renderer.Draw(Manager.Skin.Images["Control"].Resource, r, Color.FromNonPremultiplied(160, 160, 160, 128));
}
}
}
示例11: DrawControl
/// <summary>
/// Draws the window and all child controls.
/// </summary>
/// <param name="renderer">Render management object.</param>
/// <param name="rect">Destination region where the window will be drawn.</param>
/// <param name="gameTime">Snapshot of the application's timing values.</param>
protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
{
SkinLayer l1 = captionVisible ? Skin.Layers[lrCaption] : Skin.Layers[lrFrameTop];
SkinLayer l2 = Skin.Layers[lrFrameLeft];
SkinLayer l3 = Skin.Layers[lrFrameRight];
SkinLayer l4 = Skin.Layers[lrFrameBottom];
SkinLayer l5 = Skin.Layers[lrIcon];
LayerStates s1, s2, s3, s4;
SpriteFont f1 = l1.Text.Font.Resource;
Color c1 = l1.Text.Colors.Enabled;
// Window has focus?
if ((Focused || (Manager.FocusedControl != null && Manager.FocusedControl.Root == this.Root)) && ControlState != ControlState.Disabled)
{
s1 = l1.States.Focused;
s2 = l2.States.Focused;
s3 = l3.States.Focused;
s4 = l4.States.Focused;
c1 = l1.Text.Colors.Focused;
}
// Window is disabled?
else if (ControlState == ControlState.Disabled)
{
s1 = l1.States.Disabled;
s2 = l2.States.Disabled;
s3 = l3.States.Disabled;
s4 = l4.States.Disabled;
c1 = l1.Text.Colors.Disabled;
}
// Window not active or child control has focus?
else
{
s1 = l1.States.Enabled;
s2 = l2.States.Enabled;
s3 = l3.States.Enabled;
s4 = l4.States.Enabled;
c1 = l1.Text.Colors.Enabled;
}
// Draw the window layer.
renderer.DrawLayer(Skin.Layers[lrWindow], rect, Skin.Layers[lrWindow].States.Enabled.Color, Skin.Layers[lrWindow].States.Enabled.Index);
// Need to draw the window border?
if (borderVisible)
{
// Draw caption layer or top frame layer, then draw the left, right, and bottom frame layers.
renderer.DrawLayer(l1, new Rectangle(rect.Left, rect.Top, rect.Width, l1.Height), s1.Color, s1.Index);
renderer.DrawLayer(l2, new Rectangle(rect.Left, rect.Top + l1.Height, l2.Width, rect.Height - l1.Height - l4.Height), s2.Color, s2.Index);
renderer.DrawLayer(l3, new Rectangle(rect.Right - l3.Width, rect.Top + l1.Height, l3.Width, rect.Height - l1.Height - l4.Height), s3.Color, s3.Index);
renderer.DrawLayer(l4, new Rectangle(rect.Left, rect.Bottom - l4.Height, rect.Width, l4.Height), s4.Color, s4.Index);
// Draw the window icon if there is one and the window caption is displayed.
if (iconVisible && (icon != null || l5 != null) && captionVisible)
{
Texture2D i = (icon != null) ? icon : l5.Image.Resource;
renderer.Draw(i, GetIconRect(), Color.White);
}
int icosize = 0;
if (l5 != null && iconVisible && captionVisible)
{
icosize = l1.Height - l1.ContentMargins.Vertical + 4 + l5.OffsetX;
}
// Draw the close button if visible.
int closesize = 0;
if (btnClose.Visible)
{
closesize = btnClose.Width - (btnClose.Skin.Layers[lrButton].OffsetX);
}
// Create the rectangle defining the remaining caption area to draw text in.
Rectangle r = new Rectangle(rect.Left + l1.ContentMargins.Left + icosize,
rect.Top + l1.ContentMargins.Top,
rect.Width - l1.ContentMargins.Horizontal - closesize - icosize,
l1.Height - l1.ContentMargins.Top - l1.ContentMargins.Bottom);
int ox = l1.Text.OffsetX;
int oy = l1.Text.OffsetY;
// Draw the window title in the caption area remaining.
renderer.DrawString(f1, Text, r, c1, l1.Text.Alignment, ox, oy, true);
}
}
示例12: DrawControl
////////////////////////////////////////////////////////////////////////////
protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
{
if (Left + Width > 1600)
Left = 1600 - Width;
if (Top + Height + 40 > 850)
Top = 850 - Height - 20;
rect.Width = Math.Max(rect.Width, rLine.Width + 20);
renderer.DrawLayer(this, Skin.Layers[0], rect);
if (lines != null)
{
int y = 5;
foreach (LineInfo line in lines)
{
// prepare bounding rect
rLine.X = rect.X + 5;
rLine.Y = rect.Y + y;
rLine.Height = line.LineHeight;
renderer.DrawString(this, Skin.Layers[0], line.StrippedText, rLine, true);
foreach (IconPosition icon in line.Icons)
renderer.Draw(_iconDict[icon.IconName], icon.Rect, Color.White);
foreach (LinkPosition link in line.Links)
renderer.DrawString(Skin.Layers[0].Text.Font.Resource, link.Link, link.Rect.X + 2, link.Rect.Y + y - 3, Color.DarkRed);
y += line.LineHeight;
}
}
}
示例13: DrawSelection
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
private void DrawSelection(Renderer renderer, Rectangle rect)
{
if (!selection.IsEmpty)
{
int s = selection.Start;
int e = selection.End;
int sl = GetPosY(s);
int el = GetPosY(e);
int sc = GetPosX(s);
int ec = GetPosX(e);
int hgt = font.LineSpacing;
int start = sl;
int end = el;
if (start < vert.Value) start = vert.Value;
if (end > vert.Value + linesDrawn) end = vert.Value + linesDrawn;
for (int i = start; i <= end; i++)
{
Rectangle r = Rectangle.Empty;
if (mode == TextBoxMode.Normal)
{
int m = ClientArea.Height - font.LineSpacing;
r = new Rectangle(rect.Left - horz.Value + (int)font.MeasureString(Lines[i].Substring(0, sc)).X, rect.Top + m / 2,
(int)font.MeasureString(Lines[i].Substring(0, ec + 0)).X - (int)font.MeasureString(Lines[i].Substring(0, sc)).X, hgt);
}
else if (sl == el)
{
r = new Rectangle(rect.Left - horz.Value + (int)font.MeasureString(Lines[i].Substring(0, sc)).X, rect.Top + (i - vert.Value) * hgt,
(int)font.MeasureString(Lines[i].Substring(0, ec + 0)).X - (int)font.MeasureString(Lines[i].Substring(0, sc)).X, hgt);
}
else
{
if (i == sl) r = new Rectangle(rect.Left - horz.Value + (int)font.MeasureString(Lines[i].Substring(0, sc)).X, rect.Top + (i - vert.Value) * hgt, (int)font.MeasureString(Lines[i]).X - (int)font.MeasureString(Lines[i].Substring(0, sc)).X, hgt);
else if (i == el) r = new Rectangle(rect.Left - horz.Value, rect.Top + (i - vert.Value) * hgt, (int)font.MeasureString(Lines[i].Substring(0, ec + 0)).X, hgt);
else r = new Rectangle(rect.Left - horz.Value, rect.Top + (i - vert.Value) * hgt, (int)font.MeasureString(Lines[i]).X, hgt);
}
renderer.Draw(Manager.Skin.Images["Control"].Resource, r, Color.FromNonPremultiplied(160, 160, 160, 128));
}
}
}
示例14: DrawControl
protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
{
if (_buffer == null)
UpdateBackground(rect.Width, rect.Height);
// if buffer is still empty, something wrong
if (_buffer == null)
return;
// completely transparent, don't draw anything
if (Alpha == 0)
return;
if (Enabled)
{
if (Hovered)
renderer.Draw(_bufferGlow, rect, AlphaColor);
else
renderer.Draw(_buffer, rect, AlphaColor);
}
else
renderer.Draw(_bufferDisabled, rect, AlphaColor);
}
示例15: DrawControl
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
protected override void DrawControl(Renderer renderer, Rectangle rect, GameTime gameTime)
{
SkinLayer l = Skin.Layers[0];
// We render background of the tooltip
renderer.DrawLayer(this, l, rect);
Rectangle rc1 = Rectangle.Empty;
if (image != null)
{
// Now we draw image in the left top corner of the tooltip
rc1 = new Rectangle(l.ContentMargins.Left, l.ContentMargins.Top + 4, IconSize, IconSize);
renderer.Draw(image, rc1, Color.White);
}
// Text is rendered next to the image
rect = new Rectangle(rc1.Right, rect.Top + 4, rect.Width, rect.Height);
// We alter text alignment from the default skin
l.Text.Alignment = Alignment.TopLeft;
renderer.DrawString(this, l, Text, rect, true);
}