添加引用
由于超图控件是Winform,所以WPF中无法直接添加,需要将其放在容器内才可正常显示,需引用下图中两个程序集。
XAML
引用
xmlns:wfi
="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
Winform容器
<wfi:WindowsFormsHost x:Name="hostSceneControl"></wfi:WindowsFormsHost>
CS代码
private Workspace m_workspace
;
private SceneControl m_sceneControl
;
m_workspace
= new Workspace();
m_sceneControl
= new SceneControl(SuperMap
.Realspace
.SceneType
.Globe
);
hostSceneControl
.Child
= m_sceneControl
;
m_sceneControl
.SendToBack();
string path
= @"******.smwu";
if (File
.Exists(path
))
{
m_sceneControl
.Scene
.Workspace
= m_workspace
;
m_workspace
.Open(new WorkspaceConnectionInfo(path
));
m_sceneControl
.Scene
.Open("World");
}
退出程序
退出时需要释放资源
if (m_sceneControl
!= null)
{
m_sceneControl
.Scene
.Close();
m_sceneControl
.Dispose();
m_sceneControl
= null;
}
转载请注明原文地址: https://lol.8miu.com/read-28034.html