本文整理汇总了C#中System.Windows.Controls.Viewport3D.Arrange方法的典型用法代码示例。如果您正苦于以下问题:C# Viewport3D.Arrange方法的具体用法?C# Viewport3D.Arrange怎么用?C# Viewport3D.Arrange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Viewport3D
的用法示例。
在下文中一共展示了Viewport3D.Arrange方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create3DViewPort
private void Create3DViewPort()
{
var hvp3d = new HelixViewport3D();
Viewport3D vp3d = new Viewport3D();
var lights = new DefaultLights();
var tp = new Teapot();
hvp3d.Children.Add(lights);
hvp3d.Children.Add(tp);
vp3d = hvp3d.Viewport;
tata.Children.Add(vp3d); // comenter ca pour test
/* MEGA TEST DE L'ESPACE SUBSAHARIEN */
RenderTargetBitmap bmp = new RenderTargetBitmap(800, 800, 96, 96, PixelFormats.Pbgra32);
var rect = new Rect(0, 0, 800, 800);
vp3d.Measure(new Size(800, 800));
vp3d.Arrange(rect);
vp3d.InvalidateVisual();
bmp.Render(vp3d);
PngBitmapEncoder png = new PngBitmapEncoder();
png.Frames.Add(BitmapFrame.Create(bmp));
String filepath = "C:\\Users\\Remi\\Desktop\\canardmasque.png";
using (Stream stm = File.Create(filepath))
{
png.Save(stm);
}
}
示例2: copyFaceImage
public void copyFaceImage(Viewport3D viewport3d)
{
if (renderEnabled)
renderEnabled = false;
else
return;
int width = 300;
int height = 300;
viewport3d.Width = width;
viewport3d.Height = height;
viewport3d.Measure(new Size(width, height));
viewport3d.Arrange(new System.Windows.Rect(0, 0, width, height));
// bmp = new RenderTargetBitmap((int)viewport3d.ActualWidth, (int)viewport3d.ActualHeight, 96, 96, PixelFormats.Pbgra32);
// bmp.Render(viewport3d);
RenderTargetBitmap bmp = new RenderTargetBitmap((int)viewport3d.ActualWidth,
(int)viewport3d.ActualHeight, 96, 96, PixelFormats.Default);
bmp.Render(viewport3d);
//FaceImage.imageObj = bmp;
// viewport3d.Visibility = Visibility.Collapsed;
// FaceImage.Visibility = Visibility.Visible;
faceGrid[currentMatrixRow, currentMatrixColumn].ImageObj.Source = bmp;
faceGrid[currentMatrixRow, currentMatrixColumn].ImageObj.Visibility = Visibility.Visible;
if (currentMatrixRow < 3) currentMatrixRow++;
else
{
currentMatrixRow = 0;
if (currentMatrixColumn < 3) currentMatrixColumn++;
else
currentMatrixColumn = 0;
}
//this.saveFaceImageToFile(bmp);
//taskFactory.StartNew(() => saveFaceImageToFile(bmp));
}
示例3: Convert_to_Image
public void Convert_to_Image(Canvas can, int pane_number)
{
if (pane_number == -1)
{
//clear hashtable as new plot will overwirte previous image
Canvas_Obj.Clear();
Updates.Clear();
PngBitmapEncoder encoder = new PngBitmapEncoder();
Canvas_Obj[1] = can;
Transform transform = can.LayoutTransform;
// reset current transform incase of scalling or rotating
can.LayoutTransform = null;
// get size of canvas
Size size = new Size(can.Width, can.Height);
// measure and arrange the canvas
can.Measure(size);
can.Arrange(new Rect(size));
// create and render surface and push bitmap to it
RenderTargetBitmap renderBitmap = new RenderTargetBitmap((Int32)size.Width, (Int32)size.Height, 100d, 100d, PixelFormats.Pbgra32);
// now render surface to bitmap
renderBitmap.Render(can);
// puch rendered bitmap into it
encoder.Frames.Add(BitmapFrame.Create(renderBitmap));
encoder1 = encoder;
//passing encoder to plotreceiver module
returnEncoderImage();
//// create image to return
//Image returnImage = new Image();
//// set source of image as frame
//returnImage.Source = encoder.Frames[0];
//// restore previously saved layout
//can.LayoutTransform = transform;
////check if the directory exists or not and if not exist create a new one.
//if (!Directory.Exists(imagepath))
// Directory.CreateDirectory(imagepath);
//// string for saving
//String tempPath = imagepath + "\\image.png";
//// create a file stream for saving image
//using (FileStream outStream = new FileStream(tempPath, FileMode.Create))
//{
// encoder.Save(outStream);
//}
}
#region code
else if (pane_number == -2)
{
Canvas_Obj.Clear();
Updates.Clear();
PngBitmapEncoder encoder = new PngBitmapEncoder();
Canvas_Obj[1] = can;
Viewport3D vi = new Viewport3D();
vi = (Viewport3D)can.Children[0];
Transform transform = vi.LayoutTransform;
//TextBlock txt = new TextBlock() { Text = "Plot3D" };
// reset current transform incase of scalling or rotating
vi.LayoutTransform = null;
// get size of canvas
Size size = new Size(vi.Width, vi.Height);
// measure and arrange the canvas
vi.Measure(size);
vi.Arrange(new Rect(size));
// create and render surface and push bitmap to it
RenderTargetBitmap renderBitmap = new RenderTargetBitmap((Int32)size.Width, (Int32)size.Height, 100d, 100d, PixelFormats.Pbgra32);
// now render surface to bitmap
renderBitmap.Render(vi);
// puch rendered bitmap into it
encoder.Frames.Add(BitmapFrame.Create(renderBitmap));
encoder1 = encoder;
//passing encoder to plotreceiver module
returnEncoderImage();
//// create image to return
//Image returnImage = new Image();
//// set source of image as frame
//.........这里部分代码省略.........