Пример #1
0
 /// <summary>
 /// 加载Mxd
 /// </summary>
 /// <param name="mapControlDefault">当前视图mapcontrol</param>
 /// <param name="strFilePath">文件路径-可以为相对路径</param>
 /// <param name="mapNameOrIndex">地图名称或者索引,默认为空</param>
 /// <param name="password">文档密码,默认为空</param>
 public static void Load(IMapControlDefault mapControlDefault, string strFilePath, object mapNameOrIndex = null, object password = null)
 {
     if (mapNameOrIndex == null)
     {
         mapNameOrIndex = Type.Missing;
     }
     if (password == null)
     {
         password = Type.Missing;
     }
     if (mapControlDefault.CheckMxFile(strFilePath))
     {
         mapControlDefault.LoadMxFile(strFilePath, mapNameOrIndex, password);
     }
 }
Пример #2
0
 /// <summary>
 /// 加载Mxd
 /// </summary>
 /// <param name="mapControlDefault">当前视图mapcontrol</param>
 /// <param name="strFilePath">文件路径-可以为相对路径</param>
 /// <param name="mapNameOrIndex">地图名称或者索引,默认为空</param>
 /// <param name="password">文档密码,默认为空</param>
 public static void Load(IMapControlDefault mapControlDefault, string strFilePath, object mapNameOrIndex = null, object password = null)
 {
     if (mapNameOrIndex == null)
     {
         mapNameOrIndex = Type.Missing;
     }
     if (password == null)
     {
         password = Type.Missing;
     }
     if (mapControlDefault.CheckMxFile(strFilePath))
     {
         mapControlDefault.LoadMxFile(strFilePath, mapNameOrIndex, password);
     }
 }
Пример #3
0
 public bool LoadMapDocument(IMapControlDefault pMapControl, string sMxDocID)
 {
     try
     {
         if (pMapControl == null)
         {
             MessageBox.Show("地图文档加载失败,控件 MapControl 加载失败。", "错误警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return(false);
         }
         if (string.IsNullOrEmpty(sMxDocID.Trim()))
         {
             MessageBox.Show("地图文档加载失败,文档ID " + sMxDocID + " 错误。", "错误警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return(false);
         }
         string path = null;
         path = UtilFactory.GetConfigOpt().RootPath + @"\" + UtilFactory.GetConfigOpt().GetConfigValue(sMxDocID);
         if (!File.Exists(path))
         {
             MessageBox.Show("地图文档加载失败,文档文件 " + path + " 不存在。", "错误警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return(false);
         }
         if (!pMapControl.CheckMxFile(path))
         {
             MessageBox.Show("地图文档加载失败,文档文件 " + path + " 内存在错误。", "错误警告", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
             return(false);
         }
         pMapControl.LoadMxFile(path, null, null);
         IActiveView activeView = pMapControl.ActiveView;
         if (activeView.GraphicsContainer != null)
         {
             IViewManager manager          = activeView as IViewManager;
             ISelection   elementSelection = manager.ElementSelection;
             activeView.Selection = elementSelection;
         }
         return(true);
     }
     catch (Exception exception)
     {
         this.mErrOpt.ErrorOperate(this.mSubSysName, "FunFactory.CoreFun", "LoadMapDocument", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(false);
     }
 }