本文整理汇总了C#中Rect.Deflate方法的典型用法代码示例。如果您正苦于以下问题:C# Rect.Deflate方法的具体用法?C# Rect.Deflate怎么用?C# Rect.Deflate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rect
的用法示例。
在下文中一共展示了Rect.Deflate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
public override void Render (ConsoleBuffer buffer)
{
if (buffer == null)
throw new ArgumentNullException(nameof(buffer));
Rect renderRectWithoutShadow = new Rect(RenderSize).Deflate(Thickness.Max(Shadow, 0));
//base.Render(buffer);
if (Background != null)
buffer.FillBackgroundRectangle(renderRectWithoutShadow, Background.Value);
buffer.FillForegroundRectangle(new Rect(RenderSize), EffectiveColor);
if (!Shadow.IsEmpty) {
// 3 2 2 1: -1 -1 2 3:
// ▄▄▄▄▄▄▄▄▄ oooo▄▄
// █████████ oooo██
// ███oooo██ █████
// ███oooo██ █████
// ▀▀▀▀▀▀▀▀▀ ▀▀▀▀▀
Thickness shadowLineDelta = new Thickness(0, 1);
Thickness shadowOffset = Thickness.Max(-Shadow - shadowLineDelta, 0);
Rect shadowRect = new Rect(RenderSize).Deflate(shadowOffset);
if (Shadow.Top != 0)
buffer.FillForegroundLine(shadowRect.TopLine, ShadowColor, Chars.LowerHalfBlock);
if (Shadow.Bottom != 0)
buffer.FillForegroundLine(shadowRect.BottomLine, ShadowColor, Chars.UpperHalfBlock);
buffer.FillForegroundRectangle(shadowRect.Deflate(shadowLineDelta), ShadowColor, Chars.FullBlock);
if (ShadowColor == null && ShadowColorMap != null)
buffer.ApplyColorMap(shadowRect, ShadowColorMap,
(ref ConsoleChar c) => c.ForegroundColor = ShadowColorMap[(int)c.BackgroundColor]);
}
buffer.FillForegroundRectangle(renderRectWithoutShadow, EffectiveColor);
buffer.DrawRectangle(renderRectWithoutShadow, EffectiveColor, Stroke);
}
示例2: MainInterop
// --------------------------------------------------------------------------
// Section 9.5 Using F# libraries from C#
// Note: You have to add reference using 'Add Reference' first.
// The 'using' directive is above.
static void MainInterop()
{
// Create an instance of the class
var rc1 = new Rect(0.0f, 100.0f, 0.0f, 50.0f);
// Invoke a functional member of the class
var rc2 = rc1.Deflate(20.0f, 10.0f);
// Prints '(10, 20) - (60, 30)'
Console.WriteLine("({0}, {1}) - ({2}, {3})",
rc2.Left, rc2.Top, rc2.Width, rc2.Height);
}
示例3: Main
static void Main(string[] args)
{
var rc = new Rect(50.0f, 60.0f, 300.0f, 200.0f);
// Note that rc is immutable, you cannot change the values
// once it is created. You can only create new copies with modified
// values.
var rc2 = rc.Deflate(20.0f, 10.0f);
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-us");
var msg = String.Format("{0:f}; {1:f}; {2:f}; {3:f}", rc2.Left, rc2.Top, rc2.Width, rc2.Height);
Console.WriteLine(msg);
// Using a static function from module MyModule
Console.WriteLine(MyModule.Add(1, 2));
Console.ReadLine();
}
示例4: ArrangeOverride
protected override Size ArrangeOverride(Size finalSize)
{
IElement child = this.Child;
if (child != null)
{
var finalRect = new Rect(new Point(), finalSize);
finalRect = finalRect.Deflate(this.BorderThickness);
finalRect = finalRect.Deflate(this.Padding);
child.Arrange(finalRect);
}
return finalSize;
}
示例5: ArrangeToFill
private static void ArrangeToFill(Size availableSize, Margins margins, ILayoutable layoutable)
{
var containerRect = new Rect(new Point(0,0), availableSize);
var marginsCutout = margins.AsThickness();
var withoutMargins = containerRect.Deflate(marginsCutout);
var finalSize = GetConstrainedSize(layoutable, withoutMargins);
var finalRect = withoutMargins.AlignChild(finalSize, Alignment.Middle, Alignment.Middle);
layoutable.Arrange(finalRect);
}