本文整理汇总了C#中System.Drawing.Rectangle.InflateBy方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.InflateBy方法的具体用法?C# Rectangle.InflateBy怎么用?C# Rectangle.InflateBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Rectangle
的用法示例。
在下文中一共展示了Rectangle.InflateBy方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Draw
public override void Draw()
{
var image = ChromeProvider.GetImage(Image + "-button", GetImage());
var rect = new Rectangle(RenderBounds.X, RenderBounds.Y, (int)image.size.X, (int)image.size.Y);
if (rect.Contains(Viewport.LastMousePos))
{
rect = rect.InflateBy(3, 3, 3, 3);
var pos = new int2(rect.Left, rect.Top);
var m = pos + new int2(rect.Width, rect.Height);
var br = pos + new int2(rect.Width, rect.Height + 20);
var u = Game.Renderer.Fonts["Regular"].Measure(GetLongDesc().Replace("\\n", "\n"));
br.X -= u.X;
br.Y += u.Y;
br += new int2(-15, 25);
var border = WidgetUtils.GetBorderSizes("dialog4");
WidgetUtils.DrawPanelPartial("dialog4", rect
.InflateBy(0, 0, 0, border[1]),
PanelSides.Top | PanelSides.Left | PanelSides.Right | PanelSides.Center);
WidgetUtils.DrawPanelPartial("dialog4", new Rectangle(br.X, m.Y, pos.X - br.X, br.Y - m.Y)
.InflateBy(0, 0, border[3], 0),
PanelSides.Top | PanelSides.Left | PanelSides.Bottom | PanelSides.Center);
WidgetUtils.DrawPanelPartial("dialog4", new Rectangle(pos.X, m.Y, m.X - pos.X, br.Y - m.Y)
.InflateBy(border[2], border[0], 0, 0),
PanelSides.Right | PanelSides.Bottom | PanelSides.Center);
pos.X = br.X + 8;
pos.Y = m.Y + 8;
Game.Renderer.Fonts["Bold"].DrawText(GetDescription(), pos, Color.White);
pos += new int2(0, 20);
Game.Renderer.Fonts["Regular"].DrawText(GetLongDesc().Replace("\\n", "\n"), pos, Color.White);
}
Game.Renderer.RgbaSpriteRenderer.DrawSprite(image, new int2(RenderBounds.X, RenderBounds.Y));
}
示例2: DrawOuter
public override void DrawOuter()
{
if (!IsVisible())
return;
var rb = RenderBounds;
var scrollbarHeight = rb.Height - 2 * ScrollbarWidth;
var thumbHeight = ContentHeight == 0 ? 0 : Math.Max(MinimumThumbSize, (int)(scrollbarHeight * Math.Min(rb.Height * 1f / ContentHeight, 1f)));
var thumbOrigin = rb.Y + ScrollbarWidth + (int)((scrollbarHeight - thumbHeight) * (-1f * currentListOffset / (ContentHeight - rb.Height)));
if (thumbHeight == scrollbarHeight)
thumbHeight = 0;
backgroundRect = new Rectangle(rb.X, rb.Y, rb.Width - ScrollbarWidth + 1, rb.Height);
upButtonRect = new Rectangle(rb.Right - ScrollbarWidth, rb.Y, ScrollbarWidth, ScrollbarWidth);
downButtonRect = new Rectangle(rb.Right - ScrollbarWidth, rb.Bottom - ScrollbarWidth, ScrollbarWidth, ScrollbarWidth);
scrollbarRect = new Rectangle(rb.Right - ScrollbarWidth, rb.Y + ScrollbarWidth - 1, ScrollbarWidth, scrollbarHeight + 2);
thumbRect = new Rectangle(rb.Right - ScrollbarWidth, thumbOrigin, ScrollbarWidth, thumbHeight);
var upHover = Ui.MouseOverWidget == this && upButtonRect.Contains(Viewport.LastMousePos);
upDisabled = thumbHeight == 0 || currentListOffset >= 0;
var downHover = Ui.MouseOverWidget == this && downButtonRect.Contains(Viewport.LastMousePos);
downDisabled = thumbHeight == 0 || currentListOffset <= Bounds.Height - ContentHeight;
var thumbHover = Ui.MouseOverWidget == this && thumbRect.Contains(Viewport.LastMousePos);
WidgetUtils.DrawPanel(Background, backgroundRect);
WidgetUtils.DrawPanel(Background, scrollbarRect);
ButtonWidget.DrawBackground(Button, upButtonRect, upDisabled, upPressed, upHover, false);
ButtonWidget.DrawBackground(Button, downButtonRect, downDisabled, downPressed, downHover, false);
if (thumbHeight > 0)
ButtonWidget.DrawBackground(Button, thumbRect, false, HasMouseFocus && thumbHover, thumbHover, false);
var upOffset = !upPressed || upDisabled ? 4 : 4 + ButtonDepth;
var downOffset = !downPressed || downDisabled ? 4 : 4 + ButtonDepth;
WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", upPressed || upDisabled ? "up_pressed" : "up_arrow"),
new float2(upButtonRect.Left + upOffset, upButtonRect.Top + upOffset));
WidgetUtils.DrawRGBA(ChromeProvider.GetImage("scrollbar", downPressed || downDisabled ? "down_pressed" : "down_arrow"),
new float2(downButtonRect.Left + downOffset, downButtonRect.Top + downOffset));
var drawBounds = backgroundRect.InflateBy(-1, -1, -1, -1);
Game.Renderer.EnableScissor(drawBounds);
drawBounds.Offset((-ChildOrigin).ToPoint());
foreach (var child in Children)
if (child.Bounds.IntersectsWith(drawBounds))
child.DrawOuter();
Game.Renderer.DisableScissor();
}
示例3: Draw
public override void Draw()
{
if( world.LocalPlayer == null ) return;
if( world.LocalPlayer.WinState != WinState.Undefined ) return;
var radarBin = Ui.Root.Get<RadarBinWidget>(RadarBin);
powerCollection = "power-" + world.LocalPlayer.Country.Race;
// Nothing to draw
if (power.PowerProvided == 0 && power.PowerDrained == 0)
return;
// Draw bar horizontally
var barStart = powerOrigin + radarBin.RadarOrigin;
var barEnd = barStart + new float2(powerSize.Width, 0);
float powerScaleBy = 100;
var maxPower = Math.Max(power.PowerProvided, power.PowerDrained);
while (maxPower >= powerScaleBy) powerScaleBy *= 2;
// Current power supply
var powerLevelTemp = barStart.X + (barEnd.X - barStart.X) * (power.PowerProvided / powerScaleBy);
lastPowerProvidedPos = float2.Lerp(lastPowerProvidedPos.GetValueOrDefault(powerLevelTemp), powerLevelTemp, PowerBarLerpFactor);
var powerLevel = new float2(lastPowerProvidedPos.Value, barStart.Y);
var color = GetPowerColor(power);
var colorDark = Exts.ColorLerp(0.25f, color, Color.Black);
for (int i = 0; i < powerSize.Height; i++)
{
color = (i - 1 < powerSize.Height / 2) ? color : colorDark;
var leftOffset = new float2(0, i);
var rightOffset = new float2(0, i);
// Indent corners
if ((i == 0 || i == powerSize.Height - 1) && powerLevel.X - barStart.X > 1)
{
leftOffset.X += 1;
rightOffset.X -= 1;
}
Game.Renderer.LineRenderer.DrawLine(barStart + leftOffset, powerLevel + rightOffset, color, color);
}
// Power usage indicator
var indicator = ChromeProvider.GetImage( powerCollection, "power-indicator");
var powerDrainedTemp = barStart.X + (barEnd.X - barStart.X) * (power.PowerDrained / powerScaleBy);
lastPowerDrainedPos = float2.Lerp(lastPowerDrainedPos.GetValueOrDefault(powerDrainedTemp), powerDrainedTemp, PowerBarLerpFactor);
var powerDrainLevel = new float2(lastPowerDrainedPos.Value - indicator.size.X / 2, barStart.Y - 1);
Game.Renderer.RgbaSpriteRenderer.DrawSprite(indicator, powerDrainLevel);
// Render the tooltip
var rect = new Rectangle((int) barStart.X, (int) barStart.Y, powerSize.Width, powerSize.Height);
if (rect.InflateBy(0, 5, 0, 5).Contains(Viewport.LastMousePos))
{
var pos = new int2(rect.Left + 5, rect.Top + 5);
var border = WidgetUtils.GetBorderSizes("dialog4");
WidgetUtils.DrawPanel("dialog4", rect.InflateBy(0, 0, 0, 50 + border[1]));
Game.Renderer.Fonts["Bold"].DrawText("Power", pos, Color.White);
pos += new int2(0, 20);
Game.Renderer.Fonts["Regular"].DrawText("Provided: {0}\nDrained: {1}".F(power.PowerProvided, power.PowerDrained), pos, Color.White);
}
}