Example #1
0
        //响应回车时间 改变当前显示比例尺
        void vComboEx_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode != Keys.Enter)
            {
                return;
            }

            DevComponents.DotNetBar.Controls.ComboBoxEx vComboEx = sender as DevComponents.DotNetBar.Controls.ComboBoxEx;
            string strScale = vComboEx.Text;
            double dblSacle = 0;

            Plugin.Application.IAppDBIntegraRef pDBIntegraRef = _hook as Plugin.Application.IAppDBIntegraRef;
            try
            {
                if (double.TryParse(strScale, out dblSacle))
                {
                    pDBIntegraRef.MapControl.Map.MapScale = dblSacle;
                    pDBIntegraRef.MapControl.ActiveView.Refresh();
                }
                else
                {
                    vComboEx.Text = pDBIntegraRef.MapControl.Map.MapScale.ToString();
                }
            }
            catch
            {
            }
        }
Example #2
0
        /// <summary>
        /// 加载栅格库体
        /// </summary>
        /// <param name="m_Hook">主程序hook</param>
        /// <param name="DbEleInfo">矢量库体对应的库体信息XmlElement</param>
        /// <param name="ex">输出错误信息</param>
        public static void AddRasterLayer(Plugin.Application.IAppDBIntegraRef m_Hook, XmlElement DbEleInfo, out Exception ex)
        {
            ex = null;
            try
            {
                IGroupLayer pGroupLayer = new GroupLayerClass();
                pGroupLayer.Name = m_Hook.ProjectTree.SelectedNode.DataKeyString + "_" + m_Hook.ProjectTree.SelectedNode.Text;
                // string rasterDBType = (m_Hook.ProjectTree.SelectedNode.Tag as XmlElement).GetAttribute("存储类型");
                // string rasterDBType = DbEleInfo.GetAttribute("存储类型");
                string     rasterDBType = string.Empty;
                XmlElement RasterEle    = DbEleInfo.SelectSingleNode(".//栅格数据库") as XmlElement;
                rasterDBType = RasterEle.GetAttribute("存储类型").Trim();
                XmlElement elementTemp   = DbEleInfo.SelectSingleNode(".//栅格数据库/连接信息") as XmlElement;
                IWorkspace TempWorkSpace = ModDBOperate.GetDBInfoByXMLNode(elementTemp, "") as IWorkspace;
                if (TempWorkSpace == null)
                {
                    // SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接数据库失败!");
                    ex = new Exception("连接数据库失发生异常");
                    return;
                }
                IRasterWorkspaceEx pRasterWS = TempWorkSpace as IRasterWorkspaceEx;
                if (pRasterWS == null)
                {
                    return;
                }
                string feaclsName = (elementTemp.FirstChild as XmlElement).GetAttribute("名称");
                if (rasterDBType.Trim() == "栅格编目")
                {
                    //栅格编目数据加载
                    IRasterCatalog         pRasterCatalog = pRasterWS.OpenRasterCatalog(feaclsName);
                    IGdbRasterCatalogLayer pGDBRCLayer    = new GdbRasterCatalogLayerClass();
                    if (!pGDBRCLayer.Setup(pRasterCatalog as ITable))
                    {
                        return;
                    }
                    IFeatureLayer mFeaLayer = pGDBRCLayer as IFeatureLayer;
                    pGroupLayer.Add(mFeaLayer as ILayer);
                }
                else if (rasterDBType.Trim() == "栅格数据集")
                {
                    //栅格数据集加载

                    IRasterDataset pRasterDataset = pRasterWS.OpenRasterDataset(feaclsName);
                    IRasterLayer   pRasterLayer   = new RasterLayerClass();
                    pRasterLayer.CreateFromDataset(pRasterDataset);
                    if (pRasterLayer == null)
                    {
                        return;
                    }
                    pGroupLayer.Add(pRasterLayer as ILayer);
                }
                m_Hook.MapControl.Map.AddLayer(pGroupLayer);
            }
            catch (Exception eError)
            {
                ex = eError;
                return;
            }
        }
Example #3
0
 //创建按钮
 public override void OnCreate(Plugin.Application.IApplicationRef hook)
 {
     if (hook == null)
     {
         return;
     }
     m_Hook = hook as Plugin.Application.IAppDBIntegraRef;
 }
Example #4
0
 public override void ClearMessage()
 {
     Plugin.Application.IAppDBIntegraRef pAppFormRef = m_Hook as Plugin.Application.IAppDBIntegraRef;
     if (pAppFormRef != null)
     {
         // pAppFormRef.OperatorTips = string.Empty;
     }
 }
Example #5
0
 public override void OnCreate(Plugin.Application.IApplicationRef hook)
 {
     if (hook == null)
     {
         return;
     }
     m_Hook    = hook as Plugin.Application.IAppDBIntegraRef;
     m_AppUser = (m_Hook as Plugin.Application.IAppFormRef).ConnUser;
 }
Example #6
0
 public override void OnCreate(Plugin.Application.IApplicationRef hook)
 {
     m_Hook = hook as Plugin.Application.IAppDBIntegraRef;
     //added by chulili 20110624
     _hook = hook as Plugin.Application.IAppFormRef;
     //end add
     if (m_Hook == null)
     {
         return;
     }
 }
 public override void OnCreate(Plugin.Application.IApplicationRef hook)
 {
     if (hook == null)
     {
         return;
     }
     //m_Hook = hook as Plugin.Application.IAppPrivilegesRef;
     //changed by chulili 20110722启动于数据源界面 IAppPrivilegesRef->IAppDBIntegraRef
     m_Hook = hook as Plugin.Application.IAppDBIntegraRef;
     _hook  = hook as Plugin.Application.IAppFormRef;
 }
Example #8
0
        //参考比例尺事件 陈亚飞添加

        private void CurScaleCmb_SelectedIndexChanged(object sender, EventArgs e)
        {
            Plugin.Application.IAppDBIntegraRef pDBIntegraRef = _hook as Plugin.Application.IAppDBIntegraRef;
            try
            {
                pDBIntegraRef.MapControl.Map.MapScale = Convert.ToDouble(_hook.CurScaleCmb.SelectedItem.ToString().Trim());
            }
            catch
            {
                _hook.CurScaleCmb.Text = pDBIntegraRef.MapControl.Map.MapScale.ToString("0");
            }
            pDBIntegraRef.MapControl.ActiveView.Refresh();
        }
Example #9
0
        private string _Decimalstr            = "";//added by chulili 20111008 状态栏当前比例尺小数位数格式化参数
        public UCDataSourceManger(Plugin.Application.IAppFormRef hook)
        {
            InitializeComponent();
            //added by chulili 20111010
            m_AppFrmRef = hook;
            Plugin.Application.IAppDBIntegraRef pDBIntegra = hook as Plugin.Application.IAppDBIntegraRef;
            Plugin.Application.IAppFormRef      pAppFrm    = hook as Plugin.Application.IAppFormRef;
            pAppFrm.LayerTree = this.layerTree as object;

            pDBIntegra.CurScaleVisible = true;
            pDBIntegra.MapControl      = this.MapControlLayer.Object  as IMapControlDefault;
            pDBIntegra.TOCControl      = this.axTOCControl.Object as ITOCControlDefault;
            //end added
            InitLayerTree();
            axTOCControl.SetBuddyControl(MapControlLayer.Object);
        }
Example #10
0
 private void UCDataSourceManger_EnabledChanged(object sender, EventArgs e)
 {
     ModPublicFun.DealChangeSave();
     //changed by chulili 20110722启动于数据源界面 IAppPrivilegesRef->IAppDBIntegraRef
     Plugin.Application.IAppDBIntegraRef pRef = m_AppFrmRef as Plugin.Application.IAppDBIntegraRef;
     if (pRef == null)
     {
         return;               // shduan 20110725
     }
     if (this.Enabled == true)
     {
         pRef.CurScaleVisible = true;    //状态栏显示当前比例尺
     }
     else
     {
         m_AppFrmRef.CoorXY   = "";    //取自不同的接口 状态栏不显示X\Y坐标
         pRef.CurScaleVisible = false; //状态栏不显示当前比例尺
     }
     //end changed by chulili
 }
Example #11
0
 private void UCDataSourceManger_VisibleChanged(object sender, EventArgs e)
 {
     //ModPublicFun.DealChangeSave(); //changed by chulili 20110722启动于数据源界面 IAppPrivilegesRef->IAppDBIntegraRef
     Plugin.Application.IAppDBIntegraRef pRef = m_AppFrmRef as Plugin.Application.IAppDBIntegraRef;
     if (pRef == null)
     {
         return;               //shduan 20110725
     }
     if (this.Visible == true)
     {
         pRef.CurScaleVisible = true;
     }
     else
     {
         m_AppFrmRef.CoorXY   = "";  //取自不同的接口
         pRef.CurScaleVisible = false;
     }
     //end changed by chulili
     //如果用户未保存目录,则初始化目录管理列表(将此步骤移动到点击目录管理菜单时比较合适)
     //if (!issave)
     //{
     //    this.RefreshLayerTree();
     //}
 }
Example #12
0
        private void SaveInitState()
        {
            Plugin.Application.IAppDBIntegraRef _pDBIntegra = _hook as Plugin.Application.IAppDBIntegraRef;
            string strTmpPath  = Application.StartupPath + "\\..\\Temp\\Tmpmxd" + System.DateTime.Now.ToString("yyyyMMddHHmmss") + ".mxd";
            string strTmpPath2 = Application.StartupPath + "\\..\\Temp\\Tmpmxd" + System.DateTime.Now.ToString("yyyyMMddHHmmss") + "_.mxd";

            if (!System.IO.Directory.Exists(Application.StartupPath + "\\..\\Temp"))
            {
                System.IO.Directory.CreateDirectory(Application.StartupPath + "\\..\\Temp");
            }
            IMxdContents pMxdC;

            pMxdC = _pDBIntegra.MapControl.Map as IMxdContents;

            IMapDocument pMapDocument = new MapDocumentClass();

            //创建地图文档
            pMapDocument.New(strTmpPath);

            //保存信息
            IActiveView pActiveView = _pDBIntegra.MapControl.Map as IActiveView;

            pMapDocument.ReplaceContents(pMxdC);

            try//yjl20110817 防止保存时,其他程序也在打开这个文档而导致共享冲突从而使系统报错
            {
                pMapDocument.Save(true, true);
                System.Runtime.InteropServices.Marshal.ReleaseComObject(pMapDocument);
                pMapDocument = null;
                pMapDocument = new MapDocumentClass();
                pMapDocument.Open(strTmpPath, "");
                GeoLayerTreeLib.LayerManager.ModuleMap.SetLayersVisibleAttri(pMapDocument, true);
                ModPublicFun.WriteLog("pMapDocument.Save start");
                pMapDocument.SaveAs(strTmpPath2, true, true);
                ModPublicFun.WriteLog("pMapDocument.Save false");
            }
            catch (Exception ex)
            {
                if (ex != null)
                {
                    ModPublicFun.WriteLog(ex.Message);
                }
            }
            pMapDocument.Close();
            System.Runtime.InteropServices.Marshal.ReleaseComObject(pMapDocument);
            pMapDocument = null;
            try
            {
                System.IO.File.Delete(strTmpPath);
            }
            catch (Exception err2)
            {
            }
            if (System.IO.File.Exists(strTmpPath2))
            {
                SysGisTable mSystable            = new SysCommon.Gis.SysGisTable(Plugin.ModuleCommon.TmpWorkSpace);
                Dictionary <string, object> pDic = new Dictionary <string, object>();
                //参数名
                pDic.Add("SETTINGNAME", "初始加载地图文档");
                //参数数据类型
                pDic.Add("DATATYPE", "MxdFile");
                //参数描述
                //pDic.Add("DESCRIPTION", textBoxSettingDescription.Text);
                //参数值(分简单参数值和文件型参数值)

                IMemoryBlobStream pBlobStream = new MemoryBlobStreamClass();
                pBlobStream.LoadFromFile(strTmpPath2);
                pDic.Add("SETTINGVALUE2", pBlobStream);

                Exception err  = null;
                bool      bRes = false;
                if (mSystable.ExistData("SYSSETTING", "SETTINGNAME='初始加载地图文档'"))
                {
                    bRes = mSystable.UpdateRow("SYSSETTING", "SETTINGNAME='初始加载地图文档'", pDic, out err);
                }
                else
                {
                    bRes = mSystable.NewRow("SYSSETTING", pDic, out err);
                }
                if (!bRes)
                {
                    MessageBox.Show("保存出错:" + err.Message);
                }
                try
                {
                    System.IO.File.Delete(strTmpPath2);
                }
                catch (Exception err2)
                {
                }
            }
        }
Example #13
0
        /////////该类实现将各种ArcGis图层加载至数据库集成管理界面的图层控件当中来////////
        /// <summary>
        /// 加载矢量库体
        /// </summary>
        /// <param name="DbEleInfo">矢量库体对应的库体信息XmlElement</param>
        /// <param name="in_MXDFile">符号化mxd文件路径</param>
        /// <param name="ex">输出错误信息</param>
        public static void AddFeaLayer(Plugin.Application.IAppDBIntegraRef m_Hook, XmlElement DbEleInfo, string in_MXDFile, out Exception ex)
        {
            ex = null;
            try
            {
                XmlElement elementTemp   = DbEleInfo.SelectSingleNode(".//现势库/连接信息") as XmlElement;
                IWorkspace TempWorkSpace = ModDBOperate.GetDBInfoByXMLNode(elementTemp, "") as IWorkspace;
                if (TempWorkSpace == null)
                {
                    //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "连接数据库失败!");
                    ex = new Exception("连接数据库失败!");
                    return;
                }
                ILayer player = ModDBOperate.GetGroupLayer(m_Hook.MapControl, m_Hook.ProjectTree.SelectedNode.DataKeyString + "_" + m_Hook.ProjectTree.SelectedNode.Text);
                if (player != null)
                {
                    m_Hook.MapControl.Map.DeleteLayer(player);
                    m_Hook.TOCControl.Update();
                }

                IGroupLayer pGroupLayer = new GroupLayerClass();
                SysCommon.Gis.SysGisDataSet sysGisDataset  = new SysCommon.Gis.SysGisDataSet(TempWorkSpace);
                IFeatureDataset             featureDataset = sysGisDataset.GetFeatureDataset((elementTemp.FirstChild as XmlElement).GetAttribute("名称"), out ex);
                if (ex != null)
                {
                    //SysCommon.Error.ErrorHandle.ShowFrmErrorHandle("提示", "获取数据失败!");
                    ex = new Exception("获取数据发生异常:" + ex.Message);
                    return;
                }

                pGroupLayer.Name = m_Hook.ProjectTree.SelectedNode.DataKeyString + "_" + m_Hook.ProjectTree.SelectedNode.Text;
                List <IDataset> lstDataset = sysGisDataset.GetFeatureClass(featureDataset);
                //遍历要素类,加载图层
                string dbType   = "";
                string userName = "";//用户名

                userName = elementTemp.GetAttribute("用户");
                dbType   = elementTemp.GetAttribute("类型");
                foreach (IDataset dataset in lstDataset)
                {
                    IFeatureClass pFeatureClass = dataset as IFeatureClass;
                    if (pFeatureClass == null)
                    {
                        continue;
                    }
                    IFeatureLayer pFeatureLayer = new FeatureLayerClass();
                    if (pFeatureClass.FeatureType == esriFeatureType.esriFTAnnotation)
                    {
                        pFeatureLayer = new FDOGraphicsLayerClass();
                    }
                    pFeatureLayer.FeatureClass = pFeatureClass;
                    if (dbType.Trim().ToUpper() == "SDE")
                    {
                        if (dataset.Name.ToUpper().Contains(userName.Trim().ToUpper()))
                        {
                            //SDE用户图层名去掉用户名
                            pFeatureLayer.Name = dataset.Name.Substring(userName.Trim().Length + 1);
                        }
                        else
                        {
                            pFeatureLayer.Name = dataset.Name;
                        }
                    }
                    else
                    {
                        pFeatureLayer.Name = dataset.Name;
                    }
                    pFeatureLayer.Visible = false;
                    pGroupLayer.Add(pFeatureLayer as ILayer);
                }
                m_Hook.MapControl.Map.AddLayer(pGroupLayer);
                SysCommon.Gis.ModGisPub.LayersCompose(m_Hook.MapControl);
            }
            catch (Exception eError)
            {
                ex = eError;
                return;
            }
        }