private void axPageLayoutControl1_OnPageLayoutReplaced(object sender, ESRI.ArcGIS.Controls.IPageLayoutControlEvents_OnPageLayoutReplacedEvent e)
		{
			//Get the file path
			string sFilePath = txbMxPath.Text;
			//Validate and load the Mx document
			if (m_PageLayoutControl.CheckMxFile(sFilePath))
			{
				m_PageLayoutControl.LoadMxFile(sFilePath,Type.Missing);
			}
		}
Exemplo n.º 2
0
 public bool LoadPageLayoutTemplate(IPageLayoutControl pPageControl, string sTemplateID)
 {
     try
     {
         if (pPageControl == null)
         {
             Interaction.MsgBox("地图模板加载失败,控件 PageLayoutControl 加载失败。", MsgBoxStyle.Exclamation, "错误警告");
             return(false);
         }
         if (string.IsNullOrEmpty(Strings.Trim(sTemplateID)))
         {
             Interaction.MsgBox("地图模板加载失败,模板ID " + sTemplateID + " 错误。", MsgBoxStyle.Exclamation, "错误警告");
             return(false);
         }
         string configValue = null;
         configValue = UtilFactory.GetConfigOpt().GetConfigValue(sTemplateID);
         if (string.IsNullOrEmpty(configValue))
         {
             Interaction.MsgBox("地图模板加载失败,目录 " + configValue + " 错误。", MsgBoxStyle.Exclamation, "错误警告");
             return(false);
         }
         if (Strings.Right(configValue, 1) != @"\")
         {
             configValue = configValue + @"\";
         }
         string path = null;
         path = configValue + sTemplateID + ".mxt";
         if (!File.Exists(path))
         {
             Interaction.MsgBox("地图模板加载失败,模板文件 " + path + " 不存在。", MsgBoxStyle.Exclamation, "错误警告");
             return(false);
         }
         if (!pPageControl.CheckMxFile(path))
         {
             Interaction.MsgBox("地图模板加载失败,模板文件 " + path + " 内存在错误。", MsgBoxStyle.Exclamation, "错误警告");
             return(false);
         }
         pPageControl.LoadMxFile(path, null);
         IActiveView activeView = pPageControl.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", "LoadPageLayoutTemplate", exception.GetHashCode().ToString(), exception.Source, exception.Message, "", "", "");
         return(false);
     }
 }