當前位置: 首頁>>代碼示例>>C#>>正文


C# AxMapControl.LoadMxFile方法代碼示例

本文整理匯總了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;
     }
 }
開發者ID:Krystal001025,項目名稱:temp,代碼行數:58,代碼來源:GeoMapLoad.cs

示例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 "";
            }
        }
開發者ID:ismethr,項目名稱:gas-geological-map,代碼行數:27,代碼來源:FileMenu.cs

示例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 + "不是有效的工程文檔!");
                }
            }
        }
開發者ID:lovelll,項目名稱:DQHP,代碼行數:31,代碼來源:frmMain.cs


注:本文中的AxMapControl.LoadMxFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。