本文整理汇总了C#中Rect.Inflate方法的典型用法代码示例。如果您正苦于以下问题:C# Rect.Inflate方法的具体用法?C# Rect.Inflate怎么用?C# Rect.Inflate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rect
的用法示例。
在下文中一共展示了Rect.Inflate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RectInflate
public void RectInflate ()
{
var r = new Rect (new Size (10, 20));
r.Inflate (4, 6);
Assert.AreEqual (-4, r.X);
Assert.AreEqual (-6, r.Y);
Assert.AreEqual (18, r.Width);
Assert.AreEqual (32, r.Height);
}
示例2: InflateTest1
public void InflateTest1()
{
var rect = new Rect (0, 0, 100, 100);
rect.Inflate (10, 20);
Assert.AreEqual (-10, rect.X);
Assert.AreEqual (-20, rect.Y);
Assert.AreEqual (120, rect.Width);
Assert.AreEqual (140, rect.Height);
}
示例3: InflateTest2
public void InflateTest2()
{
Action test = () => {
double x = TestHelper.NextDouble(double.MinValue + 100);
double y = TestHelper.NextDouble(double.MinValue + 100);
double width = TestHelper.NextDouble(double.MaxValue - 100);
double height = TestHelper.NextDouble(double.MaxValue - 100);
var rect = new Rect(x,y,width,height);
double fWidth = TestHelper.NextDouble(100);
double fHeight = TestHelper.NextDouble(100);
rect.Inflate (fWidth, fHeight);
Assert.AreEqual (x, rect.X + fWidth);
Assert.AreEqual (y, rect.Y + fHeight);
Assert.AreEqual (width, rect.Width - 2 * fWidth);
Assert.AreEqual (height, rect.Height - 2 * fHeight);
Assert.True(rect.Contains(new Rect(x,y,width,height)));
};
test.RunBatch (batchCount);
}
示例4: _IsSpatiallyCombinable
private bool _IsSpatiallyCombinable(Rect rect1, Rect rect2, double inflateH, double inflateV)
{
//Do these rects intersect? If so, we can combine
if (rect1.IntersectsWith(rect2))
{
return true;
}
//Try inflating
rect1.Inflate(inflateH, inflateV);
if (rect1.IntersectsWith(rect2))
{
return true;
}
return false;
}
示例5: OnRender
protected internal override void OnRender(DrawingContext drawingContext)
{
Rect brushRect = new Rect(new Size(this.ActualWidth, this.ActualHeight));
Rect penRect = brushRect;
Pen pen = null;
if (this.BorderBrush != null && !this.BorderThickness.IsEmpty)
{
pen = new Pen(this.BorderBrush, this.BorderThickness.Left);
double penOffset = -(pen.Thickness / 2);
brushRect.Inflate(-pen.Thickness, -pen.Thickness);
penRect.Inflate(penOffset, penOffset);
}
if (this.CornerRadius.TopLeft > 0 || this.CornerRadius.BottomLeft > 0)
{
drawingContext.DrawRoundedRectangle(
this.Background,
pen,
brushRect,
this.CornerRadius.TopLeft,
this.CornerRadius.BottomLeft);
}
else
{
if (this.Background != null)
{
drawingContext.DrawRectangle(this.Background, null, brushRect);
}
if (pen != null)
{
drawingContext.DrawRectangle(null, pen, penRect);
}
}
}