zoukankan      html  css  js  c++  java
  • Map 3D 2013中的AcMapMap.GroupModified 和AcMapMap.LayerModified 事件的参数变化

    By Daniel Du

    在Map 3D Geospatial Platform API中,AcMapMap.GroupModified 和AcMapMap.LayerModified 事件的参数类型由AcMapMappingEventArgs 变成了AcMapMapObjectModifiedEventArgs. 这个变化主要是在参数中增加了一个Modification 属性。通过这个属性我们可以判断是什么东西发生了变化。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;

      }

    }

     

    当我在任务面板里对图层或者图层组进行更改时,就可以收到哪些发生变化的提示信息。

    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.

  • 相关阅读:
    68、成员列表初始化?
    67、类成员初始化方式?构造函数的执行顺序 ?为什么用成员初始化列表会快一 些?
    64、malloc申请的存储空间能用delete释放吗?
    63、new和delete的实现原理, delete是如何知道释放内存的大小的额?
    62、delete p、delete [] p、allocator都有什么作用?
    60、C++模板是什么,你知道底层怎么实现的?
    nyoj--814--又见拦截导弹(动态规划+贪心)
    hdoj--1950--Bridging signals(二分查找+LIS)
    nyoj--214--单调递增子序列(二)(二分查找+LIS)
    hdoj--1010--Tempter of the Bone(搜索+奇偶剪枝)
  • 原文地址:https://www.cnblogs.com/junqilian/p/2598002.html
Copyright © 2011-2022 走看看