為了增加程序的可讀性、可維護性和擴展性,在編寫礦區突水態勢評價監測系統時,應盡量使用模塊。
C Sharp 是完全的面向對象,同壹解決方案項目內可以隨心所欲地實例化對象庫或是自定義的類。整個解決方案項目中的任何地方都可以調用類中公用的方法,可以靈活的重載、重寫類,並可以方便靈活的繼承接口。充分利用 C Sharp 這些優勢可以極大地提高代碼的效率。
由於系統將頻繁在各個分礦區間加載切換,因此需要自定義壹個公***的空間數據加載類,用以隨時隨地地加載空間地物圖層,加載數據庫 Geodatabase. cs 執行過程中,實例化分色類 Renderer. cs 代碼如下:
using System;
using System. Collections. Generic;
using System. Text;
using ESRI. ArcGIS. esriSystem;
using ESRI. ArcGIS. Carto;
using ESRI. ArcGIS. Controls;
using ESRI. ArcGIS. DataSourcesGDB;
using ESRI. ArcGIS. Geodatabase;
namespace EvalWaterIrush. Symbolization
{
class Geodatabase
{
private IPropertySet pPropertySet = new PropertySetClass( ) ;
private IWorkspaceFactory pWorkspaceFactory =new AccessWorkspaceFactoryClass( ) ;
private IFeatureWorkspace pfeatureWorkspace;
private IFeatureDataset pFeatureDataset;
private IFeatureClassContainer pFeatureClassContainer;
private IFeatureClass pFeatureClass;
#region 遍歷加載空間數據庫要素圖層
/ / 函數重載
/ / 從要素數據集中讀取要素圖層數據
public Geodatabase( AxMapControl axmapcontrol1,AxMapControl axmapcontrol2,string strdb,string strdbset)
{
/ / int ig = 0;
/ / pPropertySet. SetProperty( " geodatabase" ,strdb) ;
… …
… …
… …
renderer = new Renderer( 0,255,0,0,3,255,pFeatureLayer) ;
axmapcontrol1. Map. AddLayer( pFeatureLayer) ;
axmapcontrol1. ActiveView. Refresh( ) ;
}
/ / 函數重載
/ / 從空間數據中讀取要素圖層數據
public Geodatabase( AxMapControl axmapcontrol1,AxMapControl axmapcontrol2,string strdb,string strfeaclass,int i) / / 函數的重載
{
/ / pPropertySet. SetProperty( " geodatabase" ,strdb) ;
……
……
……
pFeatureClass = pFeatureClassContainer. get_Class( 5) ;
pFeatureLayer. FeatureClass = pFeatureClass;
pFeatureLayer. Name = pFeatureClass. AliasName;
renderer = new Renderer( 0,255,0,0,1. 2,255,pFeatureLayer) ;
/ / axmapcontrol1 = " donghuantuo" ;
axmapcontrol1. Map. AddLayer( pFeatureLayer) ;
axmapcontrol1. ActiveView. Refresh( ) ;
}
#endregion
}
}