0

我需要使用 wpf 应用程序绘制类似 3d 管道的图像,并将其嵌入到 wpf 中的自定义控件中。我尝试使用.xaml 文件并绘制了类似管道的东西,但无法获得全尺寸的正确图像。有人可以帮我怎么做..用图形..

4

2 回答 2

4

xml:

<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);
        }
    }
}
于 2013-02-01T13:19:34.930 回答
0

看看Helix 工具包。它对 wpf 3D 有一些很好的控制,包括一个管道示例。

于 2012-10-09T08:45:04.747 回答