我需要使用wpf应用程序绘制像图像一样的3d管道并将其嵌入到wpf中的自定义控件中...尝试使用.xaml文件并绘制管道之类的东西但是无法获得完整大小的正确image ..可能有人帮我怎么做..带图形..
答案 0 :(得分:4)
XAML:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ht="clr-namespace:HelixToolkit.Wpf;assembly=HelixToolkit.Wpf"
Title="MainWindow" Height="350" Width="525">
<Grid>
<ht:HelixViewport3D x:Name="MainViewPort">
<ht:SunLight />
<ht:GridLinesVisual3D/>
</ht:HelixViewport3D>
</Grid>
</Window>
代码背后的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using HelixToolkit.Wpf;
using System.Windows.Media.Media3D;
namespace WpfApplication1
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
DataContext = this;
DrawMeshes();
}
private void DrawMeshes()
{
int tubeDiameter = 15;
TubeVisual3D tube1 = new TubeVisual3D();
tube1.Path = new Point3DCollection();
tube1.Path.Add(new Point3D(-15, 0, 0));
tube1.Path.Add(new Point3D(15, 0, 0));
tube1.Diameter = tubeDiameter;
tube1.Fill = Brushes.Red;
tube1.IsPathClosed = false;
MainViewPort.Children.Add(tube1);
}
}
}
答案 1 :(得分:0)
查看Helix Toolkit。它对wpf 3D有一些很好的控制,包括一个管道示例。