當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。