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.

  • 相关阅读:
    121. Best Time to Buy and Sell Stock
    玩转算法2.3常见的算法复杂度分析
    数组中的逆序对
    一些基本的代码模板
    230. Kth Smallest Element in a BST
    42. Trapping Rain Water
    api token
    仿百度查询
    baidu jsonp
    How to fix Error: laravel.log could not be opened?
  • 原文地址:https://www.cnblogs.com/junqilian/p/2598002.html
Copyright © 2011-2022 走看看