本文整理汇总了C#中MatterHackers.Agg.UI.GuiWidget.NewGraphics2D方法的典型用法代码示例。如果您正苦于以下问题:C# GuiWidget.NewGraphics2D方法的具体用法?C# GuiWidget.NewGraphics2D怎么用?C# GuiWidget.NewGraphics2D使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatterHackers.Agg.UI.GuiWidget
的用法示例。
在下文中一共展示了GuiWidget.NewGraphics2D方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TopToBottomContainerAppliesExpectedMarginToToggleView
public void TopToBottomContainerAppliesExpectedMarginToToggleView()
{
TestContext.CurrentContext.SetCompatibleWorkingDirectory();
int marginSize = 40;
int dimensions = 300;
GuiWidget outerContainer = new GuiWidget(dimensions, dimensions);
FlowLayoutWidget topToBottomContainer = new FlowLayoutWidget(FlowDirection.TopToBottom)
{
HAnchor = HAnchor.ParentLeftRight,
VAnchor = VAnchor.ParentBottomTop,
};
outerContainer.AddChild(topToBottomContainer);
CheckBox toggleBox = new CheckBox("test");
toggleBox.HAnchor = HAnchor.ParentLeftRight;
toggleBox.VAnchor = VAnchor.ParentBottomTop;
toggleBox.Margin = new BorderDouble(marginSize);
toggleBox.BackgroundColor = RGBA_Bytes.Red;
toggleBox.DebugShowBounds = true;
topToBottomContainer.AddChild(toggleBox);
topToBottomContainer.AnchorAll();
topToBottomContainer.PerformLayout();
outerContainer.DoubleBuffer = true;
outerContainer.BackBuffer.NewGraphics2D().Clear(RGBA_Bytes.White);
outerContainer.OnDraw(outerContainer.NewGraphics2D());
// For troubleshooting or visual validation
OutputImages(outerContainer, outerContainer);
var bounds = toggleBox.BoundsRelativeToParent;
Assert.IsTrue(bounds.Left == marginSize, "Left margin is incorrect");
Assert.IsTrue(bounds.Right == dimensions - marginSize, "Right margin is incorrect");
Assert.IsTrue(bounds.Top == dimensions - marginSize, "Top margin is incorrect");
Assert.IsTrue(bounds.Bottom == marginSize, "Bottom margin is incorrect");
}