本文整理匯總了C#中AxMapControl.LoadMxFile方法的典型用法代碼示例。如果您正苦於以下問題:C# AxMapControl.LoadMxFile方法的具體用法?C# AxMapControl.LoadMxFile怎麽用?C# AxMapControl.LoadMxFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類AxMapControl
的用法示例。
在下文中一共展示了AxMapControl.LoadMxFile方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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;
}
}
示例2: OpenMxdFile
/// <summary>
/// 打開mxd文檔
/// path為打開mxd文件的路徑,mapControl加載該地圖文檔的地圖控件名稱
/// 日期2013-12-13
/// lntu_GISer1
/// </summary>
public string OpenMxdFile(string path,AxMapControl mapControl)
{
string filename = openfileDialog(path);
try
{
if (filename != "")
{
mapControl.LoadMxFile(filename);
mapControl.Extent = mapControl.FullExtent;
}
return filename;
}
catch(Exception e)
{
MessageBox.Show(e.Message);
return "";
}
}
示例3: loadMapDocument
//IMapDocument pMapDocument;
/// <summary>
/// 打開工程文檔
/// </summary>
/// <param name="pAxMapControl">axMapControl</param>
private void loadMapDocument(AxMapControl pAxMapControl)
{
OpenFileDialog openFileDialog;
openFileDialog = new OpenFileDialog();
openFileDialog.Title = "打開工程";
openFileDialog.Filter = "工程文檔(*.mxd)|*.mxd";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string sFilePath = openFileDialog.FileName;
//需要添加 判斷原來的AxMapControl中是不是有地圖
if (pAxMapControl.CheckMxFile(sFilePath))
{
pAxMapControl.MousePointer = esriControlsMousePointer.esriPointerHourglass;
pAxMapControl.LoadMxFile(sFilePath, 0, Type.Missing);
pAxMapControl.MousePointer = esriControlsMousePointer.esriPointerDefault;
//加載鷹眼地圖
//loadEagleEyeDocument(filePath);
//pAxMapControl.Extent = pAxMapControl.FullExtent;
}
else
{
MessageBox.Show(sFilePath + "不是有效的工程文檔!");
}
}
}