本文整理汇总了C#中Block.Measure方法的典型用法代码示例。如果您正苦于以下问题:C# Block.Measure方法的具体用法?C# Block.Measure怎么用?C# Block.Measure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Block
的用法示例。
在下文中一共展示了Block.Measure方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatePageWithImage
private void CreatePageWithImage(RadFixedDocument document, string imageExtension, EncodedImageData imageData)
{
RadFixedPage page = document.Pages.AddPage();
page.Size = PageSize;
FixedContentEditor editor = new FixedContentEditor(page);
editor.Position.Translate(Margins.Left, Margins.Top);
Block block = new Block();
block.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
block.TextProperties.FontSize = 22;
block.InsertText(string.Format("This is {0} image in {1} color space encoded with {2} filter.", imageExtension, imageData.ColorSpace, imageData.Filters.FirstOrDefault() ?? "None"));
Size blockSize = block.Measure(RemainingPageSize);
editor.DrawBlock(block, RemainingPageSize);
editor.Position.Translate(Margins.Left, blockSize.Height + Margins.Top + 50);
Block imageBlock = new Block();
imageBlock.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
imageBlock.InsertImage(new ImageSource(imageData), new Size(imageData.Width, imageData.Height));
editor.DrawBlock(imageBlock, RemainingPageSize);
}
示例2: ExportContent
private static void ExportContent(ContentControl control, Rect bounds, double angle, RadFixedPage page, Func<Size, Point> positionFunc, string contentString = null)
{
string text = contentString ?? control.Content.ToString();
if (string.IsNullOrWhiteSpace(text)) return;
FixedContentEditor textEditor = new FixedContentEditor(page);
var block = new Block();
// Set the text and graphic properties.
block.TextProperties.FontSize = control.FontSize;
block.TextProperties.RenderingMode = RenderingMode.Fill;
block.TextProperties.TrySetFont(control.FontFamily, control.FontStyle, control.FontWeight);
block.GraphicProperties.FillColor = ColorHelper.GetColor(control.Foreground, control.Opacity, bounds);
block.GraphicProperties.StrokeColor = block.GraphicProperties.FillColor;
// Measure the text.
block.InsertText(text);
var boundsSize = bounds.ToSize();
var availableSize = new Size(boundsSize.Width - control.Padding.Left - control.Padding.Right, boundsSize.Width - control.Padding.Top - control.Padding.Bottom);
var textSize = block.Measure(availableSize);
var position = positionFunc(textSize);
var textGroup = new TransformGroup();
textGroup.Children.Add(new RotateTransform() { Angle = angle, CenterX = textSize.Width / 2, CenterY = textSize.Height / 2 });
textGroup.Children.Add(new TranslateTransform() { X = position.X, Y = position.Y });
textEditor.Position = new MatrixPosition(textGroup.Value);
textEditor.DrawBlock(block, availableSize);
}
示例3: AddPageWithImage
private void AddPageWithImage(string description, ImageSource imageSource)
{
RadFixedPage page = this.document.Pages.AddPage();
page.Size = PageSize;
FixedContentEditor editor = new FixedContentEditor(page);
editor.GraphicProperties.FillColor = new RgbColor(200, 200, 200);
editor.DrawRectangle(new Rect(0, 0, PageSize.Width, PageSize.Height));
editor.Position.Translate(Margins.Left, Margins.Top);
Block block = new Block();
block.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
block.TextProperties.FontSize = 22;
block.InsertText(description);
Size blockSize = block.Measure(RemainingPageSize);
editor.DrawBlock(block, RemainingPageSize);
editor.Position.Translate(Margins.Left, blockSize.Height + Margins.Top + 20);
Block imageBlock = new Block();
imageBlock.HorizontalAlignment = Telerik.Windows.Documents.Fixed.Model.Editing.Flow.HorizontalAlignment.Center;
imageBlock.InsertImage(imageSource);
editor.DrawBlock(imageBlock, RemainingPageSize);
}