這個星期在做自定義的要素編輯工具欄,不過遇到不少的困難。
現在初步了解到大概用到的下面的介面和類:
iengineeditor
iengineedittask
iengineeditlayers
iengineeditevents
iengineeditproperties
controlseditingsketchtoolclass
controlseditingedittoolclass
controlseditingcopycommandclass
controlseditingpastecommandclass
controlseditingclearcommandclass
現在使用 iengineeditor、iengineedittask、iengineeditlayers這三個介面,再加上command命令和tool可以是實現新建要素、複製、剪下、黏貼、刪除、移動要素。
下面說明一下我實現新建圖形功能的思路:
1、根據workspace和map開啟編輯。
2、設定目標圖層。
3、設定編輯操作的任務型別。
4、啟用sletchtool,controlseditingsketchtoolclass。
5、這時就可以在axmapcontrol中畫圖形了。圖形的點線面型別,sletchtool工具會根據目標圖層的型別自動識別。
使用了全域性變數iengineeditor,保證在其他的模組該變數的值
private iengineeditor m_engineeditor = new engineeditorclass();
private void btnnewfeature_click(object sender, eventargs e)
if(m_engineeditor.editstate==esriengineeditstate.esrienginestatenotediting)
//start editing the workspace of the first feature layer found.
//設定編輯的workspace和編輯物件圖層
ilayer currentlayer = mmap.get_layer(0);
if (currentlayer is ifeaturelayer)
ifeaturelayer featurelayer = currentlayer as ifeaturelayer;
idataset dataset = featurelayer.featureclass as idataset;
iworkspace workspace = dataset.workspace;
m_engineeditor.startediting(workspace, mmap.map);
((iengineeditlayers)m_engineeditor).settargetlayer(featurelayer, 0);
setcurrenttask(ref m_engineeditor, "新建要素");
///
/// 設定編輯的任務型別
///
///
/// 自己命名的任務名稱
public static void setcurrenttask(ref iengineeditor pengineeditor, string taskname)
iengineedittask edittask;
if (pengineeditor.editstate == esriengineeditstate.esrienginestateediting)
switch (taskname)
case "新建要素":
edittask = pengineeditor.gettaskbyuniquename("controltoolsediting_createnewfeaturetask");
if (edittask != null)
pengineeditor.currenttask = edittask;
break;
case "修改圖形":
edittask=pengineeditor.gettaskbyuniquename("reshapepolylineedittask_reshape polyline_csharp");
if (edittask != null)
pengineeditor.currenttask = edittask;
break;
case "修改要素":
edittask= pengineeditor.gettaskbyuniquename("controltoolsediting_modifyfeaturetask");
if (edittask != null)
pengineeditor.currenttask = edittask;
break;
刪除、複製、黏貼的功能,將m_engineeditor 置於開啟編輯的狀態後,直接呼叫下面的命令就好了
controlseditingedittoolclass //用於選擇要素對像
controlseditingcopycommandclass
controlseditingpastecommandclass
controlseditingclearcommandclass
撤銷和重做的功能
///
/// 撒消編輯
///
/// imap 地圖物件
public void mapundoedit(imap m_pmap)
iengineeditproperties ep = new engineeditorclass();
ilayer m_pcurrentlayer = ep.targetlayer;
if (m_pcurrentlayer == null) return;
ifeaturelayer pfeaturelayer = (ifeaturelayer)m_pcurrentlayer;
idataset pdataset = (idataset)pfeaturelayer.featureclass;
if (pdataset == null) return;
iworkspaceedit pworkspaceedit = (iworkspaceedit)pdataset.workspace;
bool bhasundos = false;
pworkspaceedit.hasundos(ref bhasundos);
if (bhasundos)
pworkspaceedit.undoeditoperation();
iactiveview pactiveview = (iactiveview)m_pmap;
pactiveview.refresh();
///
/// 重做
///
/// imap 地圖物件
public void mapredoedit(imap m_pmap)
iengineeditproperties ep = new engineeditorclass();
ilayer m_pcurrentlayer = ep.targetlayer;
if (m_pcurrentlayer == null) return;
ifeaturelayer pfeaturelayer = (ifeaturelayer)m_pcurrentlayer;
idataset pdataset = (idataset)pfeaturelayer.featureclass;
if (pdataset == null) return;
iworkspaceedit pworkspaceedit = (iworkspaceedit)pdataset.workspace;
bool bhasundos = false;
pworkspaceedit.hasundos(ref bhasundos);
if (bhasundos)
pworkspaceedit.redoeditoperation();
iactiveview pactiveview = (iactiveview)m_pmap;
pactiveview.refresh();
C Arcgis Engine開發 點選查詢
根據空間點查詢向量圖層中的要素,這裡先對該空間點建立緩衝區,然後進行空間查詢,如下 點選查詢 空間點 操作圖層 緩衝區半徑 返回查詢結果 public listgetpointselect ipoint ppoint,ifeaturelayer pfeaturelayer,double pradiu...
python定製 python中定製類
1 python中 str 和repr 如果要把乙個類的例項變成 str,就需要實現特殊方法 str classperson object def init self,name,gender self.name name self.gender genderdef str self return p...
deb定製 定製deb安裝包
選擇乙個合適的linux發行版的重要因素就是是否有足夠豐富的軟體以及軟體的維護是否方便。對於正常情況下的使用,ubuntu繼承自debian系的deb已經可以滿足,部分情況下還是無法擺脫需要編譯安裝的情況。對於有點潔癖的管理員,或者需要大規模部署的情況,每台機器的編譯顯然不現實,於是就需要定製deb...