版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、0 顏色方法public IRgbColor GetRgbColor(int intR, int intG, int intB) IRgbColor pRgbColor = null ;if (intR 255 | intG 255 | intB 255)return pRgbColor;pRgbColor = new RgbColorClass (); pRgbColor.Red = intR;pRgbColor.Green = intG; pRgbColor.Blue = intB;return pRgbColor; 1IMapdocument 加載 mxdif (openFileDial
2、og.ShowDialog() = DialogResult.OK)string sFileName = openFileDialog.FileName;if (string.IsNullOrEmpty(sFileName)return;if (axMapControl.CheckMxFile(sFileName)ClearAllData();IMapDocument pMapDoc = new MapDocumentClass(); pMapDoc.Open(sFileName, );axMapControl.Map = pMapDoc.ActiveView.FocusMap; axMapC
3、ontrol.ActiveView.Refresh();elseMessageBox.Show(選擇了無效的地圖文檔【” + sFileName + ”】!);2 加載 mdb 文件private void AddMdbFile(string sAccessFilePath)if ( string .IsNullOrEmpty(sAccessFilePath)return ;ryIWorkspaceFactory pWksFac = new AccessWorkspaceFactory (); IWorkspace pWks = pWksFac.OpenFromFile(sAccessFile
4、Path, 0);IEnumDataset pEnumDs= pWks.get_Datasets( esriDatasetType .esriDTAny); pEnumDs.Reset();IDataset pDs = pEnumDs.Next();while (pDs != null )if (pDs is IFeatureDataset )IEnumDataset pEnumDs2 = pDs.Subsets; pEnumDs2.Reset();IDataset pDs2 = pEnumDs2.Next();while (pDs2 != null )IFeatureClass pFeaCl
5、s = pDs2 as IFeatureClass ; IFeatureLayer pFeaLyr = new FeatureLayerClass(); pFeaLyr.FeatureClass = pFeaCls; pFeaLyr.Name = pFeaCls.AliasName;axMapControl.Map.AddLayer(pFeaLyr);pDs2 = pEnumDs2.Next();else if (pDs is IFeatureClass )IFeatureClass pFeaCls = pDs as IFeatureClass ; IFeatureLayer pFeaLyr
6、= newFeatureLayerClass(); pFeaLyr.FeatureClass = pFeaCls; pFeaLyr.Name = pFeaCls.AliasName;axMapControl.Map.AddLayer(pFeaLyr);pDs = pEnumDs.Next();axMapControl.ActiveView.Refresh();catch ( Exception ex)3 加載 shapfileprivate void AddShapeFile(string sShpFilePath) if ( string .IsNullOrEmpty(sShpFilePat
7、h)return ;trystring sFolderPath = sShpFilePath.Substring(0, sShpFilePath.LastIndexOf( );tring sFeaClsName = sShpFilePath.Substring(sShpFilePath.LastIndexOf( ) + 1);IWorkspaceFactory pWksFac = new ShapefileWorkspaceFactory (); IFeatureWorkspace pFeaWks =( IFeatureWorkspace )pWksFac.OpenFromFile(sFold
8、erPath, 0); IFeatureClass pFeaCls =pFeaWks.OpenFeatureClass(sFeaClsName);IFeatureLayer pFeaLyr = newFeatureLayerClass(); pFeaLyr.FeatureClass = pFeaCls;pFeaLyr.Name = pFeaCls.AliasName;axMapControl.Map.AddLayer(pFeaLyr);axMapControl.ActiveView.Refresh();catch ( Exception ex)3 右擊 Tocprivate IFeatureL
9、ayer m_SelectFeatureLayer = null ;private void axTOCControl_OnMouseDown(objectsender,toCControlEvents_OnMouseDownEvent e)tryif (e.button = 2) esriTOCControlItem pItem = esriTOCControlItem.esriTOCControlItemNone;IBasicMap pMap = null ; ILayer pLayer = null ; object unk = null ; object data = null ;ax
10、TOCControl.HitTest(e.x, e.y, ref pItem, ref pMap, ref pLayer, ref unk, ref data);if (pItem = esriTOCControlItem.esriTOCControlItemLayer& pLayer != null ) m_SelectFeatureLayer = pLayer as IFeatureLayer; btnCanSelect.Enabled= !m_SelectFeatureLayer.Selectable; btnNotCanSelect.Enabled = m_SelectFeatureL
11、ayer.Selectable;contextMenuStrip.Show( Control .MousePosition);catch ( Exception ex) MessageBoxShow( TOCControl MouseDown Error : e o+ ex.Message);private void btnAttributeTable_Click(object sender, EventArgs e)if (m_SelectFeatureLayer = null)frmAttributeTable frmAttribute = new frmAttributeTable();
12、 frmAttribute.FromLoad(m_SelectFeatureLayer); frmAttribute.ShowDialog();private void btnCanSelect_Click(object sender, EventArgs e)if (m_SelectFeatureLayer != null)m_SelectFeatureLayer.Selectable = true;btnCanSelect.Enabled = false; btnNotCanSelect.Enabled = true;private void btnNotCanSelect_Click(o
13、bject sender, EventArgs e)if (m_SelectFeatureLayer != null)m_SelectFeatureLayer.Selectable = false;btnCanSelect.Enabled = true; btnNotCanSelect.Enabled = false;private void btnRemoveLayer_Click(object sender, EventArgs e) try if (m_SelectFeatureLayer != null)if (MessageBox.Show( 是否刪除【 + m_SelectFeat
14、ureLayer.Name + 】 圖 層 , 移 除 圖 層 , MessageBoxButtons.OKCancel, MessageBoxIcon.Information) = DialogResult.OK) axMapControl.Map.DeleteLayer(m_SelectFeatureLayer as ILayer);axMapControl.ActiveView.Refresh();m_SelectFeatureLayer = null;/ 鷹眼同步 SynchronizeEagleEye(); catch(Exception ex)MessageBox.Show(” 移
15、除圖層出現(xiàn)異常:” + ex.Message);private void btnPanToLayer_Click(object sender, EventArgs e)if (m_SelectFeatureLayer != null)axMapControl.ActiveView.Extent = m_SelectFeatureLayer.AreaOfInterest;axMapControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null, null);4符號化選擇圖層public partial cla
16、ss frmFeatureLayerSelect : DevExpress.XtraEditors. XtraForm / III選?擇?的圖a?形?/ private IFeatureLayer m_FeatureLayer = null ;public IFeatureLayer SelectFeatureLayergetreturn m_FeatureLayer;public frmFeatureLayerSelect() InitializeComponent();III窗?體?初 ?始 o?化?III IIIvparam name=Map地 i? a?窗 ? 口 2 v/param/
17、 vparam name=featureType 要玄素?類OO 型av/param / vparam name=geometryType 圖 a?形 ?類 O O 型a public void FormLoad(IMap Map, esriFeatureType featureType, esriGeometryType geometryType)if (Map = null | Map.LayerCount = 0)return ;this .cboLayer.Properties.Items.Clear();for ( int i = 0; i v Map.LayerCount; i+)
18、IFeatureLayer pFeaLyr = Map.get_Layer(i)as IFeatureLayer;if(pFeaLyr =null | pFeaLyr.FeatureClass =null )continue ;if(featureType = esriFeatureType.esriFTAnnotation &pFeaLyr.FeatureClass.FeatureType =esriFeatureType.esriFTAnnotation)LayerFun pLyrFun = new LayerFun();pLyrFun.FeaClsName = (pFeaLyr.Feat
19、ureClassasIDataset ).Name;pLyrFun.AliasName = pFeaLyr.FeatureClass.AliasName; pLyrFun.FeatureLayer = pFeaLyr;this .cboLayer.Properties.Items.Add(pLyrFun);else if (featureType = esriFeatureType .esriFTSimple)if (pFeaLyr.FeatureClass.ShapeType = geometryType)LayerFun pLyrFun = new LayerFun();pLyrFun.F
20、eaClsName = (pFeaLyr.FeatureClassasIDataset ).Name;pLyrFun.AliasName = pFeaLyr.FeatureClass.AliasName; pLyrFun.FeatureLayer = pFeaLyr;this .cboLayer.Properties.Items.Add(pLyrFun);if ( this .cboLayer.Properties.Items.Count 0)this .cboLayer.SelectedIndex = 0;private void frmFeatureLayerSelect_FormClos
21、ing(object sender, FormClosingEventArgs e)if ( this .DialogResult = DialogResult .OK)object obj = this .cboLayer.SelectedItem;if (obj = null )MessageBoxShow(請?選?擇?需要&符0?號?化?的1 a?層?。?e ;e.Cancel =true ;return ;m_FeatureLayer = (objas LayerFun).FeatureLayer;5多圖層符號化private void btnMultiLayerPoint_ItemC
22、lick(object sender, ItemClickEventArgs e)frmFeatureLayerSelect frm = new frmFeatureLayerSelect (); frm.FormLoad(axMapControl.Map,esriFeatureType .esriFTSimple,esriGeometryType.esriGeometryPoint);if (frm.ShowDialog() = DialogResult .OK)IFeatureLayer pFeaLyr = frm.SelectFeatureLayer; SymbolMultiLayerP
23、oint(pFeaLyr);private void SymbolMultiLayerPoint(IFeatureLayer pFeaLyr)if (pFeaLyr = null | pFeaLyr.FeatureClass = null )return ;tryIGeoFeatureLayer pGeoFeaLyr = pFeaLyr as IGeoFeatureLayer;1111創(chuàng)??建?字0符0?符O?號?ICharacterMarkerSymbol pCharacterMarkerSymbol = new CharacterMarkerSymbolClass();IRgbColor
24、pRgbColor = GetRgbColor(0, 0, 0); IFontDisp pFontDisp = ( IFontDisp )( new StdFontClass (); pFontDisp.Name =arial ;pFontDisp.Italic = true ;pFontDisp.Size = 12; pCharacterMarkerSymbol.Angle = 0; pCharacterMarkerSymbol.CharacterIndex = 97; pCharacterMarkerSymbol.Color = pRgbColor; pCharacterMarkerSym
25、bol.Font = pFontDisp; pCharacterMarkerSymbol.Size = 24;1111 創(chuàng)?建? 圖a?片?符O?號?IPictureMarkerSymbol pPictureMarkerSymbol =newPictureMarkerSymbolClass();string sFilePath = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;sFilePath = sFilePath +.resbmpcity.bmp;if (! File .Exists(sFilePath)r
26、eturn ; pPictureMarkerSymbol.CreateMarkerSymbolFromFile(esriIPictureType.esriIPictu reBitmap, sFilePath);pPictureMarkerSymbol.Angle = 0; pPictureMarkerSymbol.BitmapTransparencyColor = pRgbColor; pPictureMarkerSymbol.Size = 10;1111創(chuàng)?建 ?疊1加?符O?號?IMultiLayerMarkerSymbol pMultiLayerMarkerSymbol =newMult
27、iLayerMarkerSymbolClass();pMultiLayerMarkerSymbol.AddLayer(pCharacterMarkerSymbol);pMultiLayerMarkerSymbol.AddLayer(pPictureMarkerSymbol); pMultiLayerMarkerSymbol.Angle = 0;pMultiLayerMarkerSymbol.Size = 20; pMultiLayerMarkerSymbol.XOffset = 5; pMultiLayerMarkerSymbol.YOffset = 5;1111更T改?符O?號?樣式0?IS
28、ymbol pSymbol = (ISymbol)pMultiLayerMarkerSymbol; ISimpleRenderer pSimpleRender = newSimpleRendererClass(); pSimpleRender.Symb0l = pSymb0l;pGe0FeaLyr.Renderer = pSimpleRender as IFeatureRenderer;axMapC0ntr0l.Refresh();axTOCC0ntr0l.Update();catch ( Excepti0n ex)MessageB0x.Sh0w( 符號化失敗 + ex.Message); 6
29、多圖層線符號化private v0id Symb0lMultiLayerLine(IFeatureLayer pFeaLyr)if (pFeaLyr = null | pFeaLyr.FeatureClass = null )return ;IGe0FeatureLayer pGe0FeaLyr = pFeaLyr as IGe0FeatureLayer;/創(chuàng)?建?簡八單符0?號?1111 創(chuàng)?建? 制?圖a?符O?號?ICart0graphicLineSymb0l pCart0graphicLineSymb0l =newCart0graphicLineSymb0lClass();pCart0
30、graphicLineSymb0l.Cap= esriLineCapStyle.esriLCSR0und;pCart0graphicLineSymb0l.J0in = esriLineJ0inStyle.esriLJSR0und;pCart0graphicLineSymb0l.Width = 2;pRgbC0l0r = GetRgbC0l0r(0, 255, 0);pCart0graphicLineSymb0l.C0l0r = pRgbC0l0r;/設(shè)I 置?線?要&素?符O?號?模?6板?asILineProperties pLineProperties = pCartographicLin
31、eSymbol ILineProperties;pLineProperties.Offset = 0;double dob = new double 6;dob0 = 0;dob1 = 1;dob2 = 2;dob3 = 3;dob4 = 4;dob5 = 5;ITemplate pTemplate =new TemplateClass();pTemplate.Interval = 1;for ( int i = 0; i dob.Length; i = i + 2)pTemplate.AddPatternElement(dobi, dobi + 1);pLineProperties.Temp
32、late = pTemplate;/ 創(chuàng)?建?多圖a?層?符O?號?IMultiLayerLineSymbol pMultiLayerLineSymbol =newMultiLayerLineSymbolClass();pMultiLayerLineSymbol.AddLayer(pSimpleLineSymbol); pMultiLayerLineSymbol.AddLayer(pCartographicLineSymbol);/ 更T改?符O?號?樣式0?ISymbol pSymbol = (ISymbol)pMultiLayerLineSymbol;ISimpleRenderer pSi
33、mpleRender =newSimpleRendererClass();pSimpleRender.Symb0l = pSymb0l;pGe0FeaLyr.Renderer = pSimpleRenderas IFeatureRenderer;/刷?爾?axMapC0ntr0l.Refresh();axTOCC0ntr0l.Update();7 唯一值渲染private v0id btnSimpleRender_ItemClick(0bject sender, ItemClickEventArgs e) frmFeatureLayerSelect frm = new frmFeatureLa
34、yerSelect (); frm.F0rmL0ad(axMapC0ntr0l.Map,esriFeatureType .esriFTSimple, esriGeometryType.esriGeometryPolygon);if (frm.ShowDialog() = DialogResult .OK)IFeatureLayer pFeaLyr = frm.SelectFeatureLayer;UniqueValueRender(pFeaLyr, pFeaLyr.FeatureClass.FeatureCount( null ), pFeaLyr.FeatureClass.OIDFieldN
35、ame);private void UniqueValueRender(IFeatureLayer pFtLayer, int pCount, string pFieldName)IGeoFeatureLayer pGeoFeaturelayer = pFtLayer as IGeoFeatureLayer; IUniqueValueRenderer pUnique =new UniqueValueRendererClass();pUnique.FieldCount = 1;pUnique.set_Field(0, pFieldName);ISimpleFillSymbol pSimFill
36、= newSimpleFillSymbolClass();/給?顏?色|?內(nèi)T部?文?檔 1 | j e請?勿e外aa傳?IFeatureCursor pFtCursor = pFtLayer.FeatureClass.Search( null , false );IFeature pFt = pFtCursor.NextFeature();IFillSymbol pFillSymbol1;IRandomColorRamp pColorRamp =newRandomColorRampClass();pColorRamp.StartHue = 0;pColorRamp.MinValue = 20
37、;pColorRamp.MinSaturation = 15;pColorRamp.EndHue = 360;pColorRamp.MaxValue = 100; pColorRamp.MaxSaturation = 30;pColorRamp.Size = pCount;bool ok = true ;pColorRamp.CreateRamp(out ok);IEnumColors pEnumRamp = pColorRamp.Colors;int pIndex = pFt.Fields.FindField(pFieldName);while (pFt != null )IColor pC
38、olor = pEnumRamp.Next();if (pColor = null )pEnumRamp.Reset();pColor = pEnumRamp.Next();pFillSymbol1.Color = pColor;pUnique.AddValue( Convert .ToString(pFt.get_Value(pIndex), pFieldName, pFillSymbol1as ISymbol);pFt = pFtCursor.NextFeature();pGeoFeaturelayer.Renderer = pUnique as IFeatureRenderer;axMa
39、pControl.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeography, null , null );axTOCControl.Update();9另存為數(shù)據(jù)private void btnSaveAsMap_ItemClick(object sender, ItemClickEventArgs e)trySaveFileDialog saveFileDialog = new SaveFileDialog ();saveFileDialog.Title = saveFileDialog.OverwritePrompt = s
40、aveFileDialog.Filter =模?板?(*mxt)|*mxt;saveFileDialog.RestoreDirectory =另 0存?為a;true ;ArcMap文?檔 i | i (*.mxd)|*.mxd|ArcMaptrue ;DialogResult .OK)if (saveFileDialog.ShowDialog() =string sFilePath = saveFileDialog.FileName;IMapDocument pMapDoc =new MapDocumentClass();pMapDoc.New(sFilePath);pMapDoc.Repl
41、aceContents(axMapControl.MapasIMxdContents);pMapDoc.Save(true , true );pMapDoc.Close();ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(pMapDoc);catch ( Exception ex)MessageBoxShow(”另 0存?為a失o?敗? 1 : e o+ ex.Message);10 保存數(shù)據(jù)private void btnSaveMxd_ItemClick(object sender, ItemClickEventArgs e) 保存 mxd 文檔
42、trystring sFilePath = axMapControl.DocumentFilename; if ( string .IsNullOrEmpty(sFilePath)return ;IMapDocument pMapDoc = new MapDocumentClass();if (axMapControl.CheckMxFile(sFilePath)if (pMapDoc.get_IsReadOnly(sFilePath) MessageBoxShow(”本 a文?檔 i | 是o?只?讀侖的 1? e?不? 能保 a?存?。?e);return ;pMapDoc.New(sFi
43、lePath); pMapDoc.ReplaceContents(axMapControl.Mapas IMxdContents);pMapDoc.Save(pMapDoc.UsesRelativePaths,true );pMapDoc.Close();ESRI.ArcGIS.ADF.ComReleaser.ReleaseCOMObject(pMapDoc);11 選擇圖層using System.Windows.Forms;using ESRI.ArcGIS.Carto;using ESRI.ArcGIS.Geodatabase;using ESRI.ArcGIS.Geometry;nam
44、espace 實(shí)o| 驗(yàn) 丨課?public partial class frmFeatureLayerSelect :DevExpress.XtraEditors. XtraForm/ Ill選?擇?的圖a?形?/ private IFeatureLayer m_FeatureLayer = null public IFeatureLayer SelectFeatureLayergetreturn m_FeatureLayer;public frmFeatureLayerSelect()InitializeComponent();lll Ill 窗?體?初 ?始 o?化?lll Ill vparam name=Map地 i? a?窗 ? 口 2
溫馨提示
- 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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2024年度綠化工程承包合同
- 大班種子課件教學(xué)課件
- 2024山西勞動合同范本
- 2024年度J企業(yè)衛(wèi)星通信技術(shù)服務(wù)合同
- 2024年店面續(xù)租協(xié)議:市中心
- 2024互聯(lián)網(wǎng)銷售涂料產(chǎn)品獨(dú)家代理合同
- 2024年工程進(jìn)度與安全合同
- 2024年建筑修正協(xié)議
- 2024年家用電器維修服務(wù)合同
- 2024雙方關(guān)于影視制作與發(fā)行委托合同
- 高考物理系統(tǒng)性復(fù)習(xí) (能力提高練) 第五節(jié) 實(shí)驗(yàn):探究小車速度隨時間變化的規(guī)律(附解析)
- 眼科護(hù)理中的孕婦與產(chǎn)婦護(hù)理
- 業(yè)主業(yè)主委員會通用課件
- 了解金融市場和金融產(chǎn)品
- 南京理工大學(xué)2015年613物理化學(xué)(含答案)考研真題
- 初中數(shù)學(xué)應(yīng)用題解題思路分享
- 安全生產(chǎn)科技創(chuàng)新與應(yīng)用
- 人工智能在文化傳承與遺產(chǎn)保護(hù)中的價(jià)值實(shí)現(xiàn)
- 2024年汽修廠開業(yè)計(jì)劃書
- ISTA標(biāo)準(zhǔn)-2A、2B、2C系列解讀(圖文)
- 日間手術(shù)應(yīng)急預(yù)案方案
評論
0/150
提交評論