當前位置: 首頁>>代碼示例>>C#>>正文


C# Viewbox.Measure方法代碼示例

本文整理匯總了C#中System.Windows.Controls.Viewbox.Measure方法的典型用法代碼示例。如果您正苦於以下問題:C# Viewbox.Measure方法的具體用法?C# Viewbox.Measure怎麽用?C# Viewbox.Measure使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Controls.Viewbox的用法示例。


在下文中一共展示了Viewbox.Measure方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: UpdateSize

 public static void UpdateSize(FrameworkElement element, double availableWidth)
 {
     var vbox = new Viewbox { Child = element };
     vbox.Measure(new Size(availableWidth, 2000));
     vbox.Arrange(new Rect(0, 0, availableWidth, 2000));
     vbox.UpdateLayout();
 }
開發者ID:modulexcite,項目名稱:printengine,代碼行數:7,代碼來源:UIUtil.cs

示例2: createImage

 private byte[] createImage(RequestInfo info){
     byte[] result = new byte[0];
     var synchrony = new Thread(new ParameterizedThreadStart(delegate{
         List<PreParser> parserList = new List<PreParser>();
         MeTLLib.MeTLLibEventHandlers.PreParserAvailableEventHandler parserReceiver = (sender, parserAvailableArgs)=>{
             parserList.Add(parserAvailableArgs.parser);
         };
         client.events.PreParserAvailable += parserReceiver;
         var staThread = new Thread(new ParameterizedThreadStart(delegate{
             while (parserList.Count() < 3)
             { }
             var canvas = new InkCanvas();
             foreach (var preParser in parserList.ToList())
                 preParser.Populate(canvas);
             var viewBox = new Viewbox();
             viewBox.Stretch = Stretch.Uniform;
             viewBox.Child = canvas;
             viewBox.Width = info.width;
             viewBox.Height = info.height;
             var size = new Size(info.width, info.height);
             viewBox.Measure(size);
             viewBox.Arrange(new Rect(size));
             viewBox.UpdateLayout();
             viewBox.Dispatcher.Invoke(DispatcherPriority.Background,new ThreadStart(delegate { }));
             RenderTargetBitmap targetBitmap =
                new RenderTargetBitmap(info.width, info.height, 96d, 96d, PixelFormats.Pbgra32);
             targetBitmap.Render(viewBox);
             PngBitmapEncoder encoder = new PngBitmapEncoder();
             encoder.Frames.Add(BitmapFrame.Create(targetBitmap));
             using (var stream = new MemoryStream())
             {
                 encoder.Save(stream);
                 result = stream.ToArray();
             }
             client.events.PreParserAvailable -= parserReceiver;
         }));
         staThread.SetApartmentState(ApartmentState.STA);
         staThread.Start();
         client.AsyncRetrieveHistoryOf(info.slide);
         staThread.Join();
     }));
     synchrony.Start();
     synchrony.Join();
     cache[info] = result;
     return result;
 }
開發者ID:StackableRegiments,項目名稱:metl2011,代碼行數:46,代碼來源:ServiceRoot.cs

示例3: parserToInkCanvas

 private byte[] parserToInkCanvas(PreParser parser, RequestInfo info) { 
     ManualResetEvent waitHandler = new ManualResetEvent(false);
     byte[] result = new byte[0];
     var staThread = new Thread(new ParameterizedThreadStart(delegate
     {
         try
         {
             var canvas = new InkCanvas();
             parser.Populate(canvas);
             var viewBox = new Viewbox();
             viewBox.Stretch = Stretch.Uniform;
             viewBox.Child = canvas;
             viewBox.Width = info.width;
             viewBox.Height = info.height;
             var size = new Size(info.width, info.height);
             viewBox.Measure(size);
             viewBox.Arrange(new Rect(size));
             viewBox.UpdateLayout();
             RenderTargetBitmap targetBitmap =
                new RenderTargetBitmap(info.width, info.height, 96d, 96d, PixelFormats.Pbgra32);
             targetBitmap.Render(viewBox);
             PngBitmapEncoder encoder = new PngBitmapEncoder();
             encoder.Frames.Add(BitmapFrame.Create(targetBitmap));
             using (var stream = new MemoryStream())
             {
                 encoder.Save(stream);
                 result = stream.ToArray();
             }
         }
         catch (Exception e) {
             Trace.TraceInformation("{0}\n{1}", e.Message, e.StackTrace);
         }
         finally { 
             waitHandler.Set();
         }
     }));
     staThread.SetApartmentState(ApartmentState.STA);
     staThread.Start();
     waitHandler.WaitOne();
     return result;
 }
開發者ID:StackableRegiments,項目名稱:metl2011,代碼行數:41,代碼來源:ServiceRoot.cs

示例4: MergeTiles

        private void MergeTiles(FileInfo targetFile, XkcdTile topLeftTile, XkcdTile topRightTile, XkcdTile bottomLeftTile, XkcdTile bottomRightTile)
        {
            if (topLeftTile != null
                || topRightTile != null
                || bottomLeftTile != null
                || bottomRightTile != null)
            {
                Func<XkcdTile, Image> TileToImage = tile => new Image { Source = XkcdTile.ToImageSource(tile) };

                var grid = new UniformGrid { Rows = 2, Columns = 2 };
                grid.Children.Add(TileToImage(topLeftTile));
                grid.Children.Add(TileToImage(topRightTile));
                grid.Children.Add(TileToImage(bottomLeftTile));
                grid.Children.Add(TileToImage(bottomRightTile));

                var viewBox = new Viewbox();
                viewBox.Child = grid;

                viewBox.Measure(new System.Windows.Size(XkcdTile.Width, XkcdTile.Height));
                viewBox.Arrange(new Rect(new System.Windows.Size(XkcdTile.Width, XkcdTile.Height)));

                var renderTarget = new RenderTargetBitmap(XkcdTile.Width, XkcdTile.Height, 96, 96, PixelFormats.Default);
                renderTarget.Render(viewBox);

                var frame = BitmapFrame.Create(renderTarget);
                var encoder = new PngBitmapEncoder { Frames = new[] { frame } };

                using (var fileStream = targetFile.Create())
                {
                    encoder.Save(fileStream);
                }
            }
        }
開發者ID:mareek,項目名稱:XkcdMap,代碼行數:33,代碼來源:XkcdTileMap.cs

示例5: RenderToLMap

		private static void RenderToLMap(Image li, string file) {
			Viewbox viewbox = new Viewbox { Child = li };
			viewbox.Measure(new Size(li.Width, li.Height));
			viewbox.Arrange(new Rect(0, 0, li.Width, li.Height));
			viewbox.UpdateLayout();
			RenderTargetBitmap rtb = new RenderTargetBitmap((int)li.Width, (int)li.Height, 96, 96, PixelFormats.Pbgra32);
			rtb.Render(viewbox);
			PngBitmapEncoder enc = new PngBitmapEncoder();
			enc.Frames.Add(BitmapFrame.Create(rtb));
			using (FileStream stm = File.Create(file)) {
				enc.Save(stm);
			}
		}
開發者ID:paradoxfm,項目名稱:ledx2,代碼行數:13,代碼來源:PlayerUtil.cs


注:本文中的System.Windows.Controls.Viewbox.Measure方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。