本文整理汇总了C#中System.Windows.Controls.Viewbox.Arrange方法的典型用法代码示例。如果您正苦于以下问题:C# Viewbox.Arrange方法的具体用法?C# Viewbox.Arrange怎么用?C# Viewbox.Arrange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Viewbox
的用法示例。
在下文中一共展示了Viewbox.Arrange方法的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();
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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);
}
}