打开地图
2015-06-10 11:23:05 访问(1663) 赞(0) 踩(0)
// This method displays an Open File dialog using the Load Map Wizard
private void DisplayOpenFileDialog()
{
// the four commented lines below can replace the rest of the code in this
// subroutine. Other sample apps all use the LoadMapWizard in this way.
// An exception is made here to show how the same task can be accomplished
// with lower-level code -- which can then be customized if necessary.
//
// LoadMapWizard loadMapWizard = new LoadMapWizard();
// loadMapWizard.ShowDbms = true;
// loadMapWizard.Run(this, mapControl1.Map);
// UpdateAllControls();
System.Windows.Forms.OpenFileDialog openFileDialog1
=
new System.Windows.Forms.OpenFileDialog();
openFileDialog1.Multiselect = true;
openFileDialog1.CheckFileExists = true;
openFileDialog1.DefaultExt = "TAB";
openFileDialog1.Filter =
"MapInfo Tables (*.tab)|*.tab|" +
"MapInfo Geoset (*.gst)|*.gst|" +
"MapInfo WorkSpace (*.mws)|*.mws";
string strCantOpenList = null;
if(openFileDialog1.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
foreach(string filename in openFileDialog1.FileNames)
try
{
if (filename.ToLower().EndsWith(MapLoader.FileExtensionGST))
mapControl1.Map.Load(new MapGeosetLoader(filename)); // add geoset
else if (filename.ToLower().EndsWith(MapLoader.FileExtensionWOR))
{
mapControl1.Map.Load(new MapWorkSpaceLoader(filename)); // add workspace
mapControl1.Map.Size = mapControl1.Size;
}
else mapControl1.Map.Load(new MapTableLoader(filename)); // add table
}
catch(MapException me)
{
if (strCantOpenList==null) strCantOpenList = me.Arg;
else strCantOpenList = strCantOpenList + ", " + me.Arg;
}
if (strCantOpenList != null)
MessageBox.Show("The following failed to open: " + strCantOpenList);
// Newly opened tables are generally selectable and can be added to,
// so refresh the status bar to show the latest settings.
// UpdateAllControls();
}
标签:
打开地图 


上一条:
下一条:
相关评论
发表评论