AE二次開發(fā)按屬性查詢詳細(xì)步驟_第1頁
AE二次開發(fā)按屬性查詢詳細(xì)步驟_第2頁
AE二次開發(fā)按屬性查詢詳細(xì)步驟_第3頁
AE二次開發(fā)按屬性查詢詳細(xì)步驟_第4頁
AE二次開發(fā)按屬性查詢詳細(xì)步驟_第5頁
已閱讀5頁,還剩4頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、屬性査詢的實現(xiàn)11地理2 吳秀春 2014年5月15 口1、屬性査詢界面設(shè)計仿照Aicmap屬性査詢,新建一個windows窗體,用作屬性査詢。在Fonn匕面添加如卜的 控件。并相應(yīng)的更改控件的名稱和text屬性??丶Q敲好一致,方便后而代碼的閱讀和減 少不必要的調(diào)試更改。(添加23個button控件,4個label控件,2個combobox控件,2個 cheakbox 控件,2 個 listbox 控件)屬住葩C屮屬心蹄r x疊置分折CS聲分析CS 設(shè)計SCAUGIS.es SCAUG貝體控件name和txt屈杵如下表:控件類型控件name屬性控件txt屬性備注ButtonbuttoiiE

2、qual=Buttonbuttoiinoteqiial<>ButtonbuttoiiLikeLike(&K)ButtonbuttonBig<ButtonbuttoiiBigEqual<=ButtonbuttonANDAnd(&N)ButtonbuttonSmall>Buttonbuttonsmalleqiial>=ButtonbuttonOrOr(&0)Buttonbuttonprecent%ButtonbuttonuiiderlineButtonbuttoiikiiohao()ButtonbuttoiiNotNot(&T)B

3、uttonbuttoiilsIs(&L)ButtonbuttonGetAalues獲取唯一值ButtonbuttonClear清除(&E)ButtonbuttoiiApply應(yīng)用(&A)Buttonbuttoncancel關(guān)閉(&C)ButtonButtonButtonButtonLabel圖層(&L):Label方法(&M):LabelSelect FromLabelWhereListboxlistBoxFieldsScrollahvaysvisible 屬 性設(shè)為tnie, Honzontascrollbai* 屬 性設(shè)為true。Listb

4、oxlistBoxAalues同上ComboboxcomboBoxLayerComboboxcomboBoxMethodDropdownstyle 屬性 改為 Dropdoxvulistf Item屬性需要添加內(nèi) 容,在表格下面有。TextboxtextBoxSqlClauseMultiline屬性改為 true,即允許多行。在comboBoxMethod控件Items添加如下內(nèi)容:(可以門行修改)創(chuàng)建新選擇內(nèi)容(Creates a new selection)添加到肖前選擇內(nèi)容(Adds to the cuixent selection)從半前選擇內(nèi)容移除(Subtiacts from th

5、e cuiTent selection)從半前選擇內(nèi)容選擇(Selects from the current selection)2、代碼部分。首先添加命名空間,這里只需要在代碼的開頭添加如下的命名空間就可以了。 using ESRIArcGIS.Controls;using ESRI. ArcGIS.Carto;using ESRIArcCISesriSystem;using ESRIArcGISGeodatdbase;using ESRIArcGIS.Geometry;添加全局變呈private LMapControl 1 m_mapcontrol;private IMap m_map:p

6、rivate IFea:ureLayer m.featurelayer;private ILa-er m_layer;private ILayerFields mlayerfield;private string constr;private string Fieldstr;private string valuesstr;private int Varylnt = 0;添加窗口入口函數(shù)參數(shù),并添加代碼,如下:public 屬性査詢(IMapControl 1 mapcontrol)InitializeComponent 0;this m_mapcontrol. = mapcontrol;th

7、ism_ni8p = mapcontro 1 Map;(名稱根據(jù)你的form的名稱而定,不-定是叫屬性査詢)添加如下三個函數(shù),實現(xiàn)如下三個功能:/通過這個函數(shù)獲紂所有圖層public IEnumLa)rer GetLayersOIEnumLayer layers;if (m_map LayerCount = 0)return null;layers = m_map. get_Layers(null, true);layers ResetO ;return layers;/將得到的圖層轉(zhuǎn)為地理要素public IFeatureLayer GetFeatureLayer (string layer

8、name) if (GetLayersO = null)return null;IEnumLayer layers = GetLayersO;layers Reset 0;ILayer layer = null;while (layer = layersext() != null)if (layer.Name = layername)return layer as IFeatureLayer;return null;加載圖層public void cbxAddLayer0if (GetLayersO = null) return;IEnumLayer layers = GetLayersO ;

9、layers ResetO ;ILayer layer = null;while (layer = layersNext() != null) if (layer is IFeatureLayer)comboBoxLayerItems Add(layer Name);點擊設(shè)計界面添加load IT-件添加load爭件代碼private void 屬性査詢_Load(object sender, EventArgs e)cbxAddLayer0;thiscomboBoxLayerSelectedlndex = 0;thiscomboBoxMethod .Selectedlndex = 0;在設(shè)計

10、界面點擊添加comboBoxLayer的SelectedlndexChanged事件,添加書件代碼.獲取某個圖層 滿足條件的屬性字段:private void comboBoxLayer.SelectedlndexChanged(object sender, EventArgs e) if (GetLayersO = null) return;IEnumLayer layers = GetLayersO ;IField mjfield;int fieldtype;layers Reset 0;listBoxFieldsItemsClear();while (mlayer = layersNex

11、t() != null)if (m.layer. Name != comboBoxLayer.Text) continue; thism_layerfield = m_layer as ILayerFields;for (int i = 0; i < m_layerfield.FieldCount; i卄)m.field = m_layerfieldget_Field(i); fieldtype = (int)m_field .Type;if (fieldtype > 5) continue;thislistBoxFieldsItems Add(m_field ame);this.

12、 m_featurelayer = GetFeatureLayer (comboBoxLayer .Text);點擊獲取唯一值按鈕,添加點擊按鈕事件.獲得當(dāng)前字段的唯一值,代碼如下:private void buttonGetValues.Click(object sender, EventArgs e)tryif (listBoxFieldsSelectedlndex = -1) return; Fieldstr = null;thisFieldstr = listBoxFields.Text;string currentlayername = comboBoxLayer. Text;IEn

13、umLaver layers = GetLayers 0; layers ResetO ;while (m_layer = layersNext() != null)if (currentlayername = m.layer.Name) break;thism_layerfield = m_layer as ILayerFields;IField field = m_layerfield get_FieId(m_layerfie 1 d. FindField(Fieldstr); esriFieldType fieldtype = field .Type;ITable table = m_l

14、ayer as ITable;ITableSort tablesort = new TableSortClassO;tablesort .Table = table;tablesort .Fields = Fieldstr;tablesort set_Ascending(Fieldstr, true);tablesort set_CaseSensitive(Fieldstr, true);tablesort Sort(null);ICursor Cursor = tablesort.Roirs;IDataStatistics DataStatistics = new DataS:atistic

15、sClass();DataStatistics .Cursor = Cursor;DataStatistics .Field = Fieldstr;System CollectionsIEnumeratorpEnumeratorUniqueVa1ues=DataStatistics UniqueValues;int UniqueValuesCount = DataStatistics. UniqueValueCount; this. listBoxValuesItems Clear 0;string currentvalues = null; pEnumeratorUniqueValues R

16、esetO;if (fieldtype = esriFieldTypeesriFieldTypeString)while (pEnumeratorUniqueValues MoveXext 0)currentvalues = pEnumeratorUniqueValues .CurrentToString(); this. listBoxValuesIternsACd("" + currentvalues +;elsewhile (pEnumeratorUniqueValues MoveXext 0)currentvalues = pEnumeratorUniqueValu

17、es .CurrentToString(); this. listBoxValuesItems Add(currentvalues);Fieldstr = null;catch (Exception ex)MessageBox. Show(ex Message);添加listboxfield駄標(biāo)雙擊事件,添加代碼:private void listBoxFieldsMouseDoubleClick(object sender, NfouseEventArgs e) Fieldstr = listBoxFields .Text;textBoxSqlClause.Text = Fieldstr +

18、 "添加listboxvalues鼠標(biāo)雙擊爭件,添加代碼:private void listBoxValues.MouseDoubleClick(object sender, MouseEventArgs e) valuesstr = listBoxValues. Text; textBoxSqlClause.Text +二""+ valuesstr;符號代碼添加示例,詳細(xì)的省略.代碼可以參考程序原型。private void buttonEqual.MouseClick(object sender, MouseEventArgs e)constr =textBo

19、xSqlClause.Text 二 constr;添加驗證按鈕事件,添加代碼private void buttonApply.Click(object sender, EventArgs e)if (textBoxSqlClause. Text =")MessageBox. Showill生成譏句。");return;tryIQuer-Filter2 QueryFilter = new QueryFilterClassO ;QueryFilter .WhereClause = textBoxSqlClause .Text;IFeatureSelection FeatureS

20、election = m_featurelayer as IFeatureSelection; int iSelectedFeaturesCount = FeatureSelectionSelectionSet.Count; esriSelectionResulTEnum SelectMothod;switch (comboBoxMethod Selectedlndex)case 0: SelectMothod = esriSelectionResulrEnunk esriSelectionResultNew; break;case 1: SelectMothod = esriSelectio

21、nResultEnun: esriSelectionResultAdd; break;case2:SelectMothod=esriSelectionResultEnum. esriSelectionResultSubtract; break;case 3: SelectMothod = esriSelectionResuitEnuir esriSelectionResultAnd; break;default:SelectMothod=esriSelectionResultEnum. esriSelectionResultNew; break;執(zhí)行FeatureSelection SelectFeatures(QueryFilter, SelectMothod, false); Varyl

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論