private void ToolStripOpenWS_Click(object sender, EventArgs e) //打开工作区间
{
bool blnOpen = false;
string strOpenPath = string.Empty; //路径初始化为空
this.openFileDialog1.Title = "打开工作空间";//对话框的标题
this.openFileDialog1.FileName = ""; //将文件名初始化为""
this.openFileDialog1.Filter = "工作空间(.smw)|*.smw";//设置对话框打开文件的类型,过滤器
this.openFileDialog1.InitialDirectory = "..\\..\\..\\Data\\";//对话框打开时的初始文件路径
if (this.openFileDialog1.ShowDialog() == DialogResult.OK)//显示对话框
{
strOpenPath = this.openFileDialog1.FileName;//打开对话框中选择的文件全路径,即将要打开的工作空间全路径
this.ConnectSuperMap();//关联控件
blnOpen = this.axSuperWorkspace1.Open(strOpenPath, "");//打开工作空间
if (!blnOpen)
{
MessageBox.Show("打开工作空间失败");
return;
}
else
{
//设置选中面对象的风格
soSelection objSelection = axSuperMap1.selection;//获得选择集
soStyle objStyle = objSelection.Style; //选择集风格
objStyle.BrushStyle = 0; //填充风格,取值为填充库中的编码
objStyle.PenStyle = 0; //线型,取值为线型的编码
objStyle.BrushColor = System.Convert.ToUInt32(System.Drawing.ColorTranslator.ToOle(Color.FromArgb(255, 190, 189))); //填充颜色
objStyle.PenColor = System.Convert.ToUInt32(System.Drawing.ColorTranslator.ToOle(Color.FromArgb(0, 0, 255)));//线颜色
//释放变量
ReleaseObjects(objStyle);
ReleaseObjects(objSelection);
//刷新工作空间管理器,将打开的工作空间可视化在工作空间管理器中
this.axSuperWkspManager1.Refresh();
}
}
else
{
return;
}
}