Map 3D 2013中的AcMapMap.GroupModified 和AcMapMap.LayerModified 事件的参数变化
By Daniel Du
在Map 3D Geospatial Platform API中,AcMapMap.GroupModified 和AcMapMap.LayerModified 事件的參數(shù)類型由AcMapMappingEventArgs 變成了AcMapMapObjectModifiedEventArgs. 這個變化主要是在參數(shù)中增加了一個Modification 屬性。通過這個屬性我們可以判斷是什么東西發(fā)生了變化。Modification 可能的取值是:
????? /// <summary>
????? /// Name property changed during the event.
????? ///</summary>
????? static const INT32 Name?????????????? = 1;
????? /// <summary>
????? /// Visibility changed during the event.
????? ///</summary>
????? static const INT32 Visibility???????? = 2;
????? /// <summary>
????? /// Layer selectability during the event.
????? ///</summary>
????? static const INT32 LayerSelectability = 4;
????? /// <summary>
????? /// Parent changed during the event.
????? ///</summary>
????? static const INT32 ParentChanged????? = 8;
?
下面是如何使用的示例代碼:
?
[CommandMethod("ListenToLayerChange")]
public void ListenToLayerChange()
{
? AcMapMap currentMap = AcMapMap.GetCurrentMap();
? currentMap.GroupModified +=
??? new GroupModifiedHandler(currentMap_GroupModified);
? currentMap.LayerModified +=
??? new LayerModifiedHandler(currentMap_LayerModified);
?
}
?
void currentMap_LayerModified(object sender,
????????????????????????????? AcMapMapObjectModifiedEventArgs args)
{
? OutputChanges(args.Modification);
}
void currentMap_GroupModified(object sender,
????????????????????????????? AcMapMapObjectModifiedEventArgs args)
{
? OutputChanges(args.Modification);
}
?
private static void OutputChanges(int modification)
{
? Editor ed = Autodesk.AutoCAD.ApplicationServices.Application
??? .DocumentManager.MdiActiveDocument.Editor;
?
? / <summary>
? / Name property changed during the event.
? /</summary>
? //static const INT32 Name?????????????? = 1;
? / <summary>
? / Visibility changed during the event.
? /</summary>
? //static const INT32 Visibility???????? = 2;
? / <summary>
? / Layer selectability during the event.
? /</summary>
? //static const INT32 LayerSelectability = 4;
? / <summary>
? / Parent changed during the event.
? /</summary>
? //static const INT32 ParentChanged????? = 8;
? switch (modification)
? {
??? case 1:
????? ed.WriteMessage("\n Layer or LayerGroup name is changed.");
????? break;
?
??? case 2:
????? ed.WriteMessage(" \nLayer or LayerGroup Visibility? is changed.");
????? break;
?
??? case 4:
????? ed.WriteMessage(" \nLayer or LayerGroup LayerSelectability is changed.");
????? break;
?
??? case 8:
????? ed.WriteMessage(" \nLayer or LayerGroup Parent is changed.");
????? break;
??? default:
????? break;
? }
}
?
當我在任務面板里對圖層或者圖層組進行更改時,就可以收到哪些發(fā)生變化的提示信息。
when I change the name of layer in task pane of Map 3D, the LayerModified event is trigger, with “args.Modification”, I know that it is the layer’s name is changed. Similarly, when I turn on/off a layer, I get a notification of the changes of visibility of layer. And when I drag one layer from one layer group to another, I get a notification saying that the parent of layer is changed.
?
The result output is as below:
-------------------------------------
Command:
Command: netload
Command: LISTENTOLAYERCHANGE
Layer or LayerGroup name is changed.
Layer or LayerGroup Visibility? is changed
Layer or LayerGroup Parent is changed.
Command:
-------------------------------------
Hope this helps.
轉載于:https://www.cnblogs.com/junqilian/archive/2012/07/18/2598002.html
總結
以上是生活随笔為你收集整理的Map 3D 2013中的AcMapMap.GroupModified 和AcMapMap.LayerModified 事件的参数变化的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: POJ-2251 Dungeon Mas
- 下一篇: 自定义浏览文件控件