本文整理汇总了C#中Rectangle.Inflate方法的典型用法代码示例。如果您正苦于以下问题:C# Rectangle.Inflate方法的具体用法?C# Rectangle.Inflate怎么用?C# Rectangle.Inflate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rectangle
的用法示例。
在下文中一共展示了Rectangle.Inflate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Colliding
public bool Colliding(Rectangle myRect, Rectangle targetRect)
{
if (this.type == ProjectileID.BoneJavelin && targetRect.Width > 8 && targetRect.Height > 8)
{
targetRect.Inflate(-targetRect.Width / 8, -targetRect.Height / 8);
}
else if (this.type == ProjectileID.StardustCellMinionShot && targetRect.Width > 8 && targetRect.Height > 8)
{
targetRect.Inflate(-targetRect.Width / 8, -targetRect.Height / 8);
}
else if (this.type == ProjectileID.Daybreak && targetRect.Width > 8 && targetRect.Height > 8)
{
targetRect.Inflate(-targetRect.Width / 8, -targetRect.Height / 8);
}
else if (this.type == ProjectileID.SolarFlareRay)
{
myRect.X += (int)this.velocity.X;
myRect.Y += (int)this.velocity.Y;
}
if (myRect.Intersects(targetRect))
{
return true;
}
if (this.type == ProjectileID.ChargedBlasterLaser)
{
float num = 0f;
if (Collision.CheckAABBvLineCollision(targetRect.TopLeft(), targetRect.Size(), base.Center, base.Center + this.velocity * this.localAI[1], 22f * this.scale, ref num))
{
return true;
}
}
else if (this.type == ProjectileID.MoonlordTurretLaser)
{
float num2 = 0f;
if (Collision.CheckAABBvLineCollision(targetRect.TopLeft(), targetRect.Size(), base.Center, base.Center + this.velocity * this.localAI[1], 30f * this.scale, ref num2))
{
return true;
}
}
else if (this.type == ProjectileID.LastPrismLaser)
{
float num3 = 0f;
if (Collision.CheckAABBvLineCollision(targetRect.TopLeft(), targetRect.Size(), base.Center, base.Center + this.velocity * this.localAI[1], 22f * this.scale, ref num3))
{
return true;
}
}
else if (this.type == ProjectileID.PhantasmalDeathray)
{
float num4 = 0f;
if (Collision.CheckAABBvLineCollision(targetRect.TopLeft(), targetRect.Size(), base.Center, base.Center + this.velocity * this.localAI[1], 36f * this.scale, ref num4))
{
return true;
}
}
else if (this.type == ProjectileID.SolarWhipSword)
{
float num5 = 0f;
if (Collision.CheckAABBvLineCollision(targetRect.TopLeft(), targetRect.Size(), base.Center, base.Center + this.velocity, 16f * this.scale, ref num5))
{
return true;
}
}
else if (this.type == ProjectileID.StardustSoldierLaser)
{
float num6 = 0f;
if (Collision.CheckAABBvLineCollision(targetRect.TopLeft(), targetRect.Size(), base.Center, base.Center + this.velocity * this.localAI[1], 22f * this.scale, ref num6))
{
return true;
}
}
else if (this.type == ProjectileID.CultistBossLightningOrbArc || this.type == ProjectileID.VortexLightning)
{
for (int i = 0; i < this.oldPos.Length; i++)
{
myRect.X = (int)this.oldPos[i].X;
myRect.Y = (int)this.oldPos[i].Y;
if (myRect.Intersects(targetRect))
{
return true;
}
}
}
else if (this.type == ProjectileID.CultistBossIceMist && this.ai[1] != 1f)
{
Vector2 vector = new Vector2(0f, -720f).RotatedBy((double)this.velocity.ToRotation(), default(Vector2));
float num7 = this.ai[0] % 45f / 45f;
Vector2 spinningpoint = vector * num7;
for (int j = 0; j < 6; j++)
{
float num8 = (float)j * 6.28318548f / 6f;
Vector2 center = base.Center + spinningpoint.RotatedBy((double)num8, default(Vector2));
if (Utils.CenteredRectangle(center, new Vector2(30f, 30f)).Intersects(targetRect))
{
return true;
}
}
}
return false;
}
示例2: CalculateButtonTextAndImageLayout
//The following layout functions were taken from Mono's Windows.Forms
//implementation, specifically "ThemeWin32Classic.cs",
//then modified to fit the context of this splitButton
private void CalculateButtonTextAndImageLayout(ref Rectangle content_rect, out Rectangle textRectangle, out Rectangle imageRectangle)
{
Size text_size = TextRenderer.MeasureText(Text, Font, content_rect.Size, textFormatFlags);
Size image_size = Image == null ? Size.Empty : Image.Size;
textRectangle = Rectangle.Empty;
imageRectangle = Rectangle.Empty;
switch (TextImageRelation)
{
case TextImageRelation.Overlay:
// Overlay is easy, text always goes here
textRectangle = OverlayObjectRect(ref content_rect, ref text_size, TextAlign); // Rectangle.Inflate(content_rect, -4, -4);
//Offset on Windows 98 style when button is pressed
if (_state == PushButtonState.Pressed && !Application.RenderWithVisualStyles)
textRectangle.Offset(1, 1);
// Image is dependent on ImageAlign
if (Image != null)
imageRectangle = OverlayObjectRect(ref content_rect, ref image_size, ImageAlign);
break;
case TextImageRelation.ImageAboveText:
content_rect.Inflate(-4, -4);
LayoutTextAboveOrBelowImage(content_rect, false, text_size, image_size, out textRectangle, out imageRectangle);
break;
case TextImageRelation.TextAboveImage:
content_rect.Inflate(-4, -4);
LayoutTextAboveOrBelowImage(content_rect, true, text_size, image_size, out textRectangle, out imageRectangle);
break;
case TextImageRelation.ImageBeforeText:
content_rect.Inflate(-4, -4);
LayoutTextBeforeOrAfterImage(content_rect, false, text_size, image_size, out textRectangle, out imageRectangle);
break;
case TextImageRelation.TextBeforeImage:
content_rect.Inflate(-4, -4);
LayoutTextBeforeOrAfterImage(content_rect, true, text_size, image_size, out textRectangle, out imageRectangle);
break;
}
}
示例3: DrawTab
public static void DrawTab(Graphics g, Rectangle r, Corners corner, GradientType gradient, Color darkColor, Color lightColor, Color edgeColor, bool closed)
{
//dims
Point[] points;
GraphicsPath path;
Region Region;
LinearGradientBrush linearBrush;
Brush brush = null;
Pen pen;
r.Inflate(- 1, - 1);
//set brushes
switch (gradient)
{
case GradientType.Flat:
brush = new SolidBrush(darkColor);
break;
case GradientType.Linear:
brush = new LinearGradientBrush(r, darkColor, lightColor, LinearGradientMode.Vertical);
break;
case GradientType.Bell:
linearBrush = new LinearGradientBrush(r, darkColor, lightColor, LinearGradientMode.Vertical);
linearBrush.SetSigmaBellShape((float) (0.17F), (float) (0.67F));
brush = linearBrush;
break;
}
pen = new pen(edgeColor, 1);
//generic points
points = new Point[12] {new Point(r.Left, r.Bottom), new Point(r.Left, r.Bottom - bshift), new Point(r.Left, r.Top + bshift), new Point(r.Left, r.Top), new Point(r.Left + bshift, r.Top), new Point(r.Right - bshift, r.Top), new Point(r.Right, r.Top), new Point(r.Right, r.Top + bshift), new Point(r.Right, r.Bottom - bshift), new Point(r.Right, r.Bottom), new Point(r.Right - bshift, r.Bottom), new Point(r.Left + bshift, r.Bottom)};
path = new GraphicsPath();
switch (corner)
{
case Corners.LeftBottom:
path.AddLine(points[3], points[1]);
path.AddBezier(points[1], points[0], points[0], points[11]);
path.AddLine(points[11], points[9]);
path.AddLine(points[9], points[6]);
path.AddLine(points[6], points[3]);
Region = new Region(path);
g.FillRegion(brush, Region);
g.DrawLine(pen, points[3], points[1]);
g.DrawBezier(pen, points[1], points[0], points[0], points[11]);
g.DrawLine(pen, points[11], points[9]);
g.DrawLine(pen, points[9], points[6]);
if (closed)
{
g.DrawLine(pen, points[6], points[3]);
}
break;
case Corners.LeftTop:
path.AddLine(points[0], points[2]);
path.AddBezier(points[2], points[3], points[3], points[4]);
path.AddLine(points[4], points[6]);
path.AddLine(points[6], points[9]);
path.AddLine(points[9], points[0]);
Region = new Region(path);
g.FillRegion(brush, Region);
g.DrawLine(pen, points[0], points[2]);
g.DrawBezier(pen, points[2], points[3], points[3], points[4]);
g.DrawLine(pen, points[4], points[6]);
g.DrawLine(pen, points[6], points[9]);
if (closed)
{
g.DrawLine(pen, points[9], points[0]);
}
break;
case Corners.Bottom:
path.AddLine(points[1], points[3]);
path.AddBezier(points[1], points[0], points[0], points[11]);
path.AddLine(points[11], points[10]);
path.AddBezier(points[10], points[9], points[9], points[8]);
path.AddLine(points[8], points[6]);
path.AddLine(points[6], points[3]);
Region = new Region(path);
g.FillRegion(brush, Region);
g.DrawLine(pen, points[1], points[3]);
g.DrawBezier(pen, points[1], points[0], points[0], points[11]);
g.DrawLine(pen, points[11], points[10]);
g.DrawBezier(pen, points[10], points[9], points[9], points[8]);
g.DrawLine(pen, points[8], points[6]);
if (closed)
{
g.DrawLine(pen, points[6], points[3]);
}
break;
case Corners.Top:
path.AddLine(points[0], points[2]);
path.AddBezier(points[2], points[3], points[3], points[4]);
path.AddLine(points[4], points[5]);
path.AddBezier(points[5], points[6], points[6], points[7]);
path.AddLine(points[7], points[9]);
path.AddLine(points[9], points[0]);
Region = new Region(path);
g.FillRegion(brush, Region);
//.........这里部分代码省略.........
示例4: InflateTest
public void InflateTest(int x, int y, int width, int height)
{
Rectangle rect = new Rectangle(x, y, width, height);
Rectangle inflatedRect = new Rectangle(x - width, y - height, width + 2 * width, height + 2 * height);
rect.Inflate(width, height);
Assert.Equal(inflatedRect, rect);
Size s = new Size(x, y);
inflatedRect = new Rectangle(rect.X - x, rect.Y - y, rect.Width + 2 * x, rect.Height + 2 * y);
rect.Inflate(s);
Assert.Equal(inflatedRect, rect);
}
示例5: InView
/// <summary>
/// Checks if in the object is in view of the specified <paramref name="camera"/>.
/// </summary>
/// <param name="camera">The <see cref="ICamera2D"/> to check if this object is in view of.</param>
/// <returns>True if the object is in view of the camera, else False.</returns>
public bool InView(ICamera2D camera)
{
// Check if in view by using the _min/_maxParticlePosition
// If both are equal to 0, then it probably has not been updated yet, so return true to be safe
if (_minParticlePosition == Vector2.Zero && _maxParticlePosition == Vector2.Zero)
return true;
// Create a rect of the world position covering the area
Vector2 ownerPos = Owner.Position;
Vector2 min = _minParticlePosition + ownerPos;
Vector2 max = _maxParticlePosition + ownerPos;
Vector2 size = max - min;
Rectangle rect = new Rectangle(min.X, min.Y, size.X, size.Y);
// Inflact the rect's size to cover more area, just to be safe
rect.Inflate(96);
return camera.InView(rect);
}
示例6: DrawDialog
private void DrawDialog(Graphics g, string title, string text)
{
StringFormat format = new StringFormat(StringFormatFlags.NoClip);
format.Alignment = StringAlignment.Near;
format.LineAlignment = StringAlignment.Center;
Rectangle aboutRectangle = new Rectangle((Width / 2) - 90, (Height / 2) - 60, MinimumDialogHeight, 120);
// Box
//
g.FillRectangle(Brushes.SteelBlue, aboutRectangle);
g.DrawRectangle(Pens.Black, aboutRectangle);
//Contents
//
aboutRectangle.Inflate(-5, -5);
aboutRectangle.Y = aboutRectangle.Y + 5;
Font textFont = new Font("Arial", 8f);
//Draw text
//
g.DrawString(text, textFont, Brushes.White, aboutRectangle, format);
//Title
//
aboutRectangle.Inflate(5, -47);
aboutRectangle.Y = (Height / 2) - 60;
g.FillRectangle(Brushes.Black, aboutRectangle);
g.DrawRectangle(Pens.Black, aboutRectangle);
aboutRectangle.Inflate(-5, 0);
g.DrawString(title, textFont, Brushes.White, aboutRectangle, format);
//Close
//
aboutRectangle.Inflate(-78, 0);
aboutRectangle.X = (Width / 2) + 76;
g.FillRectangle(Brushes.Red, aboutRectangle);
g.DrawRectangle(Pens.Black, aboutRectangle);
StringFormat closeFormat = new StringFormat(StringFormatFlags.NoClip | StringFormatFlags.DirectionVertical);
format.Alignment = StringAlignment.Near;
format.LineAlignment = StringAlignment.Center;
Font closeFont = new Font("Verdana", 10.5f, FontStyle.Bold);
aboutRectangle.Inflate(3, -1);
g.DrawString("X",
closeFont,
Brushes.White,
aboutRectangle,
closeFormat);
dialogCloseRectangle = aboutRectangle;
format.Dispose();
closeFormat.Dispose();
textFont.Dispose();
closeFont.Dispose();
}
示例7: InvalidateInkSpaceRectangle
private void InvalidateInkSpaceRectangle(Rectangle rect)
{
using (Graphics g = this.CreateGraphics())
{
Point ul = new Point(rect.Left,rect.Top);
Point lr = new Point(rect.Right,rect.Bottom);
Point[] pts = { ul, lr };
inkoverlay.Renderer.InkSpaceToPixel(g, ref pts);
ul = pts[0]; lr = pts[1];
rect = new Rectangle(ul.X, ul.Y, lr.X-ul.X, lr.Y-ul.Y);
rect.Inflate(7,7);
Invalidate(rect);
}
}
示例8: _bufferedPainter_PaintVisualState
/// <summary>
/// Paints the control (using the Buffered Paint API).
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void _bufferedPainter_PaintVisualState(object sender, BufferedPaintEventArgs<ComboBoxState> e) {
VisualStyleRenderer r = new VisualStyleRenderer(VisualStyleElement.Button.PushButton.Normal);
r.DrawParentBackground(e.Graphics, ClientRectangle, this);
DrawComboBox(e.Graphics, ClientRectangle, e.State);
Rectangle itemBounds = new Rectangle(0, 0, Width - 21, Height);
itemBounds.Inflate(-1, -3);
itemBounds.Offset(2, 0);
// draw the item in the editable portion
DrawItemState state = DrawItemState.ComboBoxEdit;
if (Focused && ShowFocusCues && !DroppedDown) state |= DrawItemState.Focus;
if (!Enabled) state |= DrawItemState.Disabled;
OnDrawItem(new DrawItemEventArgs(e.Graphics, Font, itemBounds, SelectedIndex, state));
}
示例9: UpdateDummies
public static void UpdateDummies()
{
Dictionary<int, Rectangle> nums = new Dictionary<int, Rectangle>();
bool flag = false;
Rectangle rectangle = new Rectangle(0, 0, 32, 48);
rectangle.Inflate(1600, 1600);
int x = rectangle.X;
int y = rectangle.Y;
for (int i = 0; i < 1000; i++)
{
if (TargetDummy.dummies[i] != null)
{
TargetDummy.dummies[i].whoAmI = i;
if (TargetDummy.dummies[i].npc == -1)
{
if (!flag)
{
for (int j = 0; j < 255; j++)
{
if (Main.player[j].active)
{
nums[j] = Main.player[j].getRect();
}
}
flag = true;
}
rectangle.X = TargetDummy.dummies[i].x * 16 + x;
rectangle.Y = TargetDummy.dummies[i].y * 16 + y;
bool flag1 = false;
foreach (KeyValuePair<int, Rectangle> num in nums)
{
if (!num.Value.Intersects(rectangle))
{
continue;
}
flag1 = true;
break;
}
if (flag1)
{
TargetDummy.dummies[i].Activate();
}
}
else if (!Main.npc[TargetDummy.dummies[i].npc].active || Main.npc[TargetDummy.dummies[i].npc].type != 488 || Main.npc[TargetDummy.dummies[i].npc].ai[0] != (float)TargetDummy.dummies[i].x || Main.npc[TargetDummy.dummies[i].npc].ai[1] != (float)TargetDummy.dummies[i].y)
{
TargetDummy.dummies[i].Deactivate();
}
}
}
}
示例10: Inflate
/// <summary>
/// Inflate Shared Method
/// </summary>
///
/// <remarks>
/// Produces a new Rectangle by inflating an existing
/// Rectangle by the specified coordinate values.
/// </remarks>
internal static Rectangle Inflate(Rectangle rect,
Double x, Double y)
{
Rectangle ir = new Rectangle(rect.X, rect.Y, rect.Width, rect.Height);
ir.Inflate(x, y);
return ir;
}
示例11: Update
public override void Update()
{
Rectangle rectangle = new Rectangle(0, 0, 32, 48);
rectangle.Inflate(1600, 1600);
int x = rectangle.X;
int y = rectangle.Y;
if (this.npc == -1)
{
TETrainingDummy.FillPlayerHitboxes();
rectangle.X = this.Position.X * 16 + x;
rectangle.Y = this.Position.Y * 16 + y;
bool flag = false;
foreach (KeyValuePair<int, Rectangle> keyValuePair in TETrainingDummy.playerBox)
{
if (!keyValuePair.Value.Intersects(rectangle))
{
continue;
}
flag = true;
break;
}
if (flag)
{
this.Activate();
}
}
else if (!Main.npc[this.npc].active || Main.npc[this.npc].type != 488 || Main.npc[this.npc].ai[0] != (float)this.Position.X || Main.npc[this.npc].ai[1] != (float)this.Position.Y)
{
this.Deactivate();
return;
}
}
示例12: Colliding
public bool Colliding(Rectangle myRect, Rectangle targetRect)
{
if (this.type == 598 && targetRect.Width > 8 && targetRect.Height > 8)
{
targetRect.Inflate(-targetRect.Width / 8, -targetRect.Height / 8);
}
else if (this.type == 614 && targetRect.Width > 8 && targetRect.Height > 8)
{
targetRect.Inflate(-targetRect.Width / 8, -targetRect.Height / 8);
}
else if (this.type == 636 && targetRect.Width > 8 && targetRect.Height > 8)
{
targetRect.Inflate(-targetRect.Width / 8, -targetRect.Height / 8);
}
else if (this.type == 607)
{
myRect.X += (int)this.velocity.X;
myRect.Y += (int)this.velocity.Y;
}
if (myRect.Intersects(targetRect))
{
return true;
}
if (this.type == 461)
{
float num = 0f;
if (Collision.CheckAABBvLineCollision(targetRect.TopLeft(), targetRect.Size(), base.Center, base.Center + this.velocity * this.localAI[1], 22f * this.scale, ref num))
{
return true;
}
}
else if (this.type == 642)
{
float num2 = 0f;
if (Collision.CheckAABBvLineCollision(targetRect.TopLeft(), targetRect.Size(), base.Center, base.Center + this.velocity * this.localAI[1], 30f * this.scale, ref num2))
{
return true;
}
}
else if (this.type == 632)
{
float num3 = 0f;
if (Collision.CheckAABBvLineCollision(targetRect.TopLeft(), targetRect.Size(), base.Center, base.Center + this.velocity * this.localAI[1], 22f * this.scale, ref num3))
{
return true;
}
}
else if (this.type == 455)
{
float num4 = 0f;
if (Collision.CheckAABBvLineCollision(targetRect.TopLeft(), targetRect.Size(), base.Center, base.Center + this.velocity * this.localAI[1], 36f * this.scale, ref num4))
{
return true;
}
}
else if (this.type == 611)
{
float num5 = 0f;
if (Collision.CheckAABBvLineCollision(targetRect.TopLeft(), targetRect.Size(), base.Center, base.Center + this.velocity, 16f * this.scale, ref num5))
{
return true;
}
}
else if (this.type == 537)
{
float num6 = 0f;
if (Collision.CheckAABBvLineCollision(targetRect.TopLeft(), targetRect.Size(), base.Center, base.Center + this.velocity * this.localAI[1], 22f * this.scale, ref num6))
{
return true;
}
}
else if (this.type == 466 || this.type == 580)
{
for (int i = 0; i < this.oldPos.Length; i++)
{
myRect.X = (int)this.oldPos[i].X;
myRect.Y = (int)this.oldPos[i].Y;
if (myRect.Intersects(targetRect))
{
return true;
}
}
}
else if (this.type == 464 && this.ai[1] != 1f)
{
Vector2 vector = new Vector2(0f, -720f).RotatedBy((double)this.velocity.ToRotation(), default(Vector2));
float num7 = this.ai[0] % 45f / 45f;
Vector2 spinningpoint = vector * num7;
for (int j = 0; j < 6; j++)
{
float num8 = (float)j * 6.28318548f / 6f;
Vector2 center = base.Center + spinningpoint.RotatedBy((double)num8, default(Vector2));
if (Utils.CenteredRectangle(center, new Vector2(30f, 30f)).Intersects(targetRect))
{
return true;
}
}
}
return false;
}
示例13: DrawColorSlider
/// <summary>
/// Draws the colorslider control using passed colors.
/// </summary>
/// <param name="e">The <see cref="T:System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param>
/// <param name="thumbOuterColorPaint">The thumb outer color paint.</param>
/// <param name="thumbInnerColorPaint">The thumb inner color paint.</param>
/// <param name="thumbPenColorPaint">The thumb pen color paint.</param>
/// <param name="barOuterColorPaint">The bar outer color paint.</param>
/// <param name="barInnerColorPaint">The bar inner color paint.</param>
/// <param name="barPenColorPaint">The bar pen color paint.</param>
/// <param name="elapsedOuterColorPaint">The elapsed outer color paint.</param>
/// <param name="elapsedInnerColorPaint">The elapsed inner color paint.</param>
private void DrawColorSlider(PaintEventArgs e, Color thumbOuterColorPaint, Color thumbInnerColorPaint,
Color thumbPenColorPaint, Color barOuterColorPaint, Color barInnerColorPaint,
Color barPenColorPaint, Color elapsedOuterColorPaint, Color elapsedInnerColorPaint)
{
//set up thumbRect aproprietly
if (barOrientation == Orientation.Horizontal)
{
int TrackX = (((trackerValue - barMinimum) * (this.ContentRectangle.Width - thumbSize)) / (barMaximum - barMinimum)) + 2;
thumbRect = new Rectangle(TrackX, 3, thumbSize - 1, this.ContentRectangle.Height - 3);
}
else
{
int TrackY = (((trackerValue - barMinimum) * (this.ContentRectangle.Height - thumbSize)) / (barMaximum - barMinimum));
thumbRect = new Rectangle(3, TrackY, this.ContentRectangle.Width - 3, thumbSize - 1);
}
//adjust drawing rects
barRect = this.ContentRectangle;
thumbHalfRect = thumbRect;
LinearGradientMode gradientOrientation;
if (barOrientation == Orientation.Horizontal)
{
barRect.Inflate(-1, -barRect.Height / 3);
barHalfRect = barRect;
barHalfRect.Height /= 2;
gradientOrientation = LinearGradientMode.Vertical;
thumbHalfRect.Height /= 2;
elapsedRect = barRect;
elapsedRect.Width = thumbRect.Left + thumbSize / 2;
}
else
{
barRect.Inflate(-barRect.Width / 3, -1);
barHalfRect = barRect;
barHalfRect.Width /= 2;
gradientOrientation = LinearGradientMode.Horizontal;
thumbHalfRect.Width /= 2;
elapsedRect = barRect;
elapsedRect.Height = thumbRect.Top + thumbSize / 2;
}
//get thumb shape path
GraphicsPath thumbPath;
if (thumbCustomShape == null)
thumbPath = CreateRoundRectPath(thumbRect, thumbRoundRectSize);
else
{
thumbPath = thumbCustomShape;
Matrix m = new Matrix();
m.Translate(thumbRect.Left - thumbPath.GetBounds().Left, thumbRect.Top - thumbPath.GetBounds().Top);
thumbPath.Transform(m);
}
//draw bar
using (
LinearGradientBrush lgbBar =
new LinearGradientBrush(barHalfRect, barOuterColorPaint, barInnerColorPaint, gradientOrientation)
)
{
lgbBar.WrapMode = WrapMode.TileFlipXY;
e.Graphics.FillRectangle(lgbBar, barRect);
//draw elapsed bar
using (
LinearGradientBrush lgbElapsed =
new LinearGradientBrush(barHalfRect, elapsedOuterColorPaint, elapsedInnerColorPaint,
gradientOrientation))
{
lgbElapsed.WrapMode = WrapMode.TileFlipXY;
if (Selected && drawSemitransparentThumb)
{
Region elapsedReg = new Region(elapsedRect);
elapsedReg.Exclude(thumbPath);
e.Graphics.FillRegion(lgbElapsed, elapsedReg);
}
else
e.Graphics.FillRectangle(lgbElapsed, elapsedRect);
}
//draw bar band
using (Pen barPen = new Pen(barPenColorPaint, 0.5f))
{
e.Graphics.DrawRectangle(barPen, barRect);
}
}
//draw thumb
Color newthumbOuterColorPaint = thumbOuterColorPaint, newthumbInnerColorPaint = thumbInnerColorPaint;
if (Selected && drawSemitransparentThumb)
{
newthumbOuterColorPaint = Color.FromArgb(175, thumbOuterColorPaint);
//.........这里部分代码省略.........
示例14: UpdateGP
protected internal override void UpdateGP()
{
if (gp == null) gp = new GraphicsPath();
else gp.Reset();
// Draw small circle over head/tail midpoint; or a connecting line if they've
// drifted far away.
Point head = EndpointA.Object.CG + Vector.Transform(
Vector.FromPoint(EndpointA.attachloc), EndpointA.Object.displacement);
Point tail = EndpointB.Object.CG + Vector.Transform(
Vector.FromPoint(EndpointB.attachloc), EndpointB.Object.displacement);
Point center;
if (EndpointA.Object.anchored)
{
center = head;
}
else if (EndpointB.Object.anchored)
{
center = tail;
}
else
{
center = Geometry.Midpoint(head,tail);
}
Rectangle rect = new Rectangle(center, Size.Empty);
rect.Inflate(75,75);
if (Geometry.DistanceBetween(head,tail) < 175.0)
gp.AddEllipse(rect);
else
gp.AddLine(head,tail);
}
示例15: Inflate
public static void Inflate(ref Rectangle rect, Size inflateSize)
{
rect.Inflate(inflateSize.Width, inflateSize.Height);
}