本文整理匯總了C#中AxMapControl.AddShapeFile方法的典型用法代碼示例。如果您正苦於以下問題:C# AxMapControl.AddShapeFile方法的具體用法?C# AxMapControl.AddShapeFile怎麽用?C# AxMapControl.AddShapeFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類AxMapControl
的用法示例。
在下文中一共展示了AxMapControl.AddShapeFile方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: LoadGeoData
public static void LoadGeoData(AxMapControl axMapControl1, AxMapControl axMapControl2, string strFileN)
{
string strFExtenN = System.IO.Path.GetExtension(strFileN);
switch (strFExtenN)
{
case ".shp":
{
string strPath = System.IO.Path.GetDirectoryName(strFileN);
string strFile = System.IO.Path.GetFileNameWithoutExtension(strFileN);
axMapControl1.AddShapeFile(strPath, strFile);
axMapControl2.ClearLayers();
axMapControl2.AddShapeFile(strPath, strFile);
axMapControl2.Extent = axMapControl2.FullExtent;
break;
}
case ".bmp":
case ".tif":
case ".jpg":
case ".img":
{
IWorkspaceFactory pWSF = new RasterWorkspaceFactoryClass();
string pathName = System.IO.Path.GetDirectoryName(strFileN);
string fileName = System.IO.Path.GetFileName(strFileN);
IWorkspace pWS = pWSF.OpenFromFile(pathName, 0);
IRasterWorkspace pRWS = pWS as IRasterWorkspace;
IRasterDataset pRasterDataSet = pRWS.OpenRasterDataset(fileName);
IRasterPyramid pRasPyramid = pRasterDataSet as IRasterPyramid;
if (pRasPyramid != null)
{
if (!(pRasPyramid.Present))
{
pRasPyramid.Create();
}
}
IRaster pRaster = pRasterDataSet.CreateDefaultRaster();
IRasterLayer pRasterLayer = new RasterLayerClass();
pRasterLayer.CreateFromRaster(pRaster);
ILayer pLayer = pRasterLayer as ILayer;
axMapControl1.AddLayer(pLayer, 0);
axMapControl2.ClearLayers();
axMapControl2.AddLayer(pLayer, 0);
axMapControl2.Extent = axMapControl2.FullExtent;
break;
}
case ".mxd":
{
if (axMapControl1.CheckMxFile(strFExtenN))
{
axMapControl1.LoadMxFile(strFExtenN);
}
else
MessageBox.Show("所選擇的文件不是Mxd文件!", "提示信息");
break;
}
default:
break;
}
}