1.工作空间在idesktop软件上可以打开,但是在写的代码里打不开。2.代码应该没有错误,因为放入示例数据的路径就可以打开
以下是完整代码:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
//添加以下代码
using SuperMap.Data;
using SuperMap.Realspace;
using SuperMap.UI;
namespace baimiao1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void MainForm_Load(object sender, EventArgs e)
{
sceneControl1.Scene.Workspace = workspace1;
//ScenceGuide_ listBox. Visible = false;
//控件随父级调整大小
sceneControl1.Dock = DockStyle. Fill;
}
private void button1_Click(object sender, EventArgs e)
{
WorkspaceConnectionInfo workspaceConnectionInfo = new WorkspaceConnectionInfo();
workspaceConnectionInfo.Server = @"C:\Users\Administrator\Desktop\代码及数据\组里的数据\smwu\滑县.smwu";
//2.Type为,是workspace类的另一个一个属性
workspaceConnectionInfo.Type = WorkspaceType.SMWU;//这个文件类型要与上面选取的文件相对应
//打开工作空间
bool isopen = workspace1.Open(workspaceConnectionInfo);//Open函数返回的是布尔变量
if (isopen)
{
//构造一个scene对象,从sceneControl1里面得到一个Scene对象
Scene scene = sceneControl1.Scene;
scene.Open("滑县");//scene的Open方法参数常为场景名称
}
}
private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
sceneControl1.Dispose();
workspace1.Dispose();
}
private void sceneControl1_Load(object sender, EventArgs e)
{
}
}
}