当前位置: 首页>>代码示例>>C#>>正文


C# UserControl.Measure方法代码示例

本文整理汇总了C#中System.Windows.Controls.UserControl.Measure方法的典型用法代码示例。如果您正苦于以下问题:C# UserControl.Measure方法的具体用法?C# UserControl.Measure怎么用?C# UserControl.Measure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Controls.UserControl的用法示例。


在下文中一共展示了UserControl.Measure方法的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);
            }
        }
开发者ID:modulexcite,项目名称:Avalonia,代码行数:25,代码来源:TestBase.cs

示例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));
 }
开发者ID:barnstws,项目名称:Gu.Wpf.DataGrid2D,代码行数:8,代码来源:DataGridTestExt.cs

示例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);
            }
        }
开发者ID:modulexcite,项目名称:BinDays,代码行数:15,代码来源:TileExporter.cs

示例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");
 }
开发者ID:Antares007,项目名称:Pos,代码行数:11,代码来源:Printer.cs


注:本文中的System.Windows.Controls.UserControl.Measure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。