本文整理汇总了C#中AssembledStyles.WithMargins方法的典型用法代码示例。如果您正苦于以下问题:C# AssembledStyles.WithMargins方法的具体用法?C# AssembledStyles.WithMargins怎么用?C# AssembledStyles.WithMargins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AssembledStyles
的用法示例。
在下文中一共展示了AssembledStyles.WithMargins方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PaintPictureBox
public void PaintPictureBox()
{
AssembledStyles styles = new AssembledStyles();
Bitmap bm = new Bitmap(20, 30);
ImageBox box = new ImageBox(styles.WithMargins(new Thickness(72.0 / 96.0 * 2.0))
.WithBorders(new Thickness(72.0 / 96.0 * 3.0))
.WithPads(new Thickness(72.0 / 96.0 * 7.0, 72.0 / 96.0 * 8.0, 72.0 / 96.0 * 11.0, 72.0 / 96.0 * 13.0)), bm);
RootBox root = new RootBox(styles);
BlockBox block = new BlockBox(styles, Color.Yellow, 2000, 4000);
root.AddBox(block);
root.AddBox(box);
LayoutInfo transform = MakeLayoutInfo();
root.Layout(transform);
Assert.That(box.Height, Is.EqualTo(30 + 2*2+3*2+8+13));
Assert.That(box.Width, Is.EqualTo(20 + 2*2 +3*2 + 7 + 11));
Assert.That(box.Ascent, Is.EqualTo(box.Height));
PaintTransform ptrans = new PaintTransform(2, 4, 96, 96, 10, 40, 96, 96);
MockGraphics graphics = new MockGraphics();
root.Paint(graphics, ptrans);
Assert.That(graphics.LastRenderPictureArgs, Is.Not.Null);
Assert.That(graphics.LastRenderPictureArgs.Picture, Is.EqualTo(box.Picture));
Assert.That(graphics.LastRenderPictureArgs.X, Is.EqualTo(2-10 + 2 + 3 + 7));
Assert.That(graphics.LastRenderPictureArgs.Y, Is.EqualTo(4 - 40 + block.Height + 2 + 3 + 8));
Assert.That(graphics.LastRenderPictureArgs.Cx, Is.EqualTo(20));
Assert.That(graphics.LastRenderPictureArgs.Cy, Is.EqualTo(30));
int hmWidth = box.Picture.Width;
int hmHeight = box.Picture.Height;
Assert.That(graphics.LastRenderPictureArgs.XSrc, Is.EqualTo(0));
Assert.That(graphics.LastRenderPictureArgs.YSrc, Is.EqualTo(hmHeight));
Assert.That(graphics.LastRenderPictureArgs.CxSrc, Is.EqualTo(hmWidth));
Assert.That(graphics.LastRenderPictureArgs.CySrc, Is.EqualTo(-hmHeight));
Assert.That(graphics.LastRenderPictureArgs.RcWBounds.left, Is.EqualTo(2 - 10 + 2 + 3 + 7));
Assert.That(graphics.LastRenderPictureArgs.RcWBounds.top, Is.EqualTo(4 - 40 + block.Height + 2 + 3 + 8));
Assert.That(graphics.LastRenderPictureArgs.RcWBounds.right, Is.EqualTo(2 - 10 + 2 + 3 + 7 + 20));
Assert.That(graphics.LastRenderPictureArgs.RcWBounds.bottom, Is.EqualTo(4 - 40 + block.Height + 2 + 3 + 8 + 30));
}