本文整理汇总了C#中System.Windows.Controls.UserControl.Arrange方法的典型用法代码示例。如果您正苦于以下问题:C# UserControl.Arrange方法的具体用法?C# UserControl.Arrange怎么用?C# UserControl.Arrange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.UserControl
的用法示例。
在下文中一共展示了UserControl.Arrange方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderToFile
public void RenderToFile(UserControl target, [CallerMemberName] string testName = "")
{
string path = Path.Combine(testDirectory, testName + ".wpf.out.png");
RenderTargetBitmap bitmap = new RenderTargetBitmap(
(int)target.Width,
(int)target.Height,
96,
96,
PixelFormats.Pbgra32);
Size size = new Size(target.Width, target.Height);
target.Measure(size);
target.Arrange(new Rect(size));
bitmap.Render(target);
File.Delete(path);
using (FileStream fs = new FileStream(path, FileMode.Create))
{
PngBitmapEncoder encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bitmap));
encoder.Save(fs);
}
}
示例2: Initialize
public static void Initialize(this UIElement element)
{
var userControl = new UserControl { Content = element };
userControl.BeginInit(); // hacking different things here
userControl.Measure(new Size(100, 100));
userControl.Arrange(new Rect(new Size(100, 100)));
element.RaiseEvent(new RoutedEventArgs(FrameworkElement.LoadedEvent));
}
示例3: Export
void Export(UserControl tile, int width, int height, string filename)
{
tile.Measure(new Size(width, height));
tile.Arrange(new Rect(0, 0, width, height));
var bmp = new WriteableBitmap(width, height);
bmp.Render(tile, null);
bmp.Invalidate();
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
using (var stream = store.OpenFile(filename, System.IO.FileMode.OpenOrCreate))
{
bmp.SaveJpeg(stream, width, height, 0, 100);
}
}
示例4: PrintReceipt
public void PrintReceipt(UserControl uc)
{
var dialog = new PrintDialog();
var printer = new PrintServer().GetPrintQueues()
.FirstOrDefault(x => x.Name == _printerName);
if (printer != null)
dialog.PrintQueue = printer;
uc.Measure(new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight));
uc.Arrange(new Rect(new Point(0, 0), uc.DesiredSize));
dialog.PrintVisual(uc, "receipt");
}