zoukankan      html  css  js  c++  java
  • 增加图例 Legend和删除图例

    private void button1_Click(object sender, System.EventArgs e)
    {
    //Get the GraphicsContainer
    IGraphicsContainer graphicsContainer = axPageLayoutControl1.GraphicsContainer;

    //Get the MapFrame
    IMapFrame mapFrame = (IMapFrame) graphicsContainer.FindFrame(axPageLayoutControl1.ActiveView.FocusMap);
    if (mapFrame == null) return;

    //Create a legend
    UID uID = new UIDClass();
    uID.Value = "esriCarto.Legend";

    //Create a MapSurroundFrame from the MapFrame
    IMapSurroundFrame mapSurroundFrame = mapFrame.CreateSurroundFrame(uID, null);
    if (mapSurroundFrame == null) return;
    if (mapSurroundFrame.MapSurround == null) return;
    //Set the name
    mapSurroundFrame.MapSurround.Name = "Legend";

    //Envelope for the legend
    IEnvelope envelope = new EnvelopeClass();
    envelope.PutCoords(1, 1, 3.4, 2.4);

    //Set the geometry of the MapSurroundFrame
    IElement element = (IElement) mapSurroundFrame;
    element.Geometry = envelope;

    //Add the legend to the PageLayout
    axPageLayoutControl1.AddElement(element, Type.Missing, Type.Missing, "Legend", 0);

    //Refresh the PageLayoutControl
    axPageLayoutControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

    //disable/enable buttons
    cmdDraw.Enabled = false;
    cmdDelete.Enabled = true;
    cmdChangeArea.Enabled = true;
    cmdChangeLine.Enabled = true;
    }

    private void button2_Click(object sender, System.EventArgs e)
    {
    //Find the legend
    IElement element = axPageLayoutControl1.FindElementByName("Legend", 1);

    if(element != null)
    {
    //Delete the legend
    IGraphicsContainer graphicsContainer = axPageLayoutControl1.GraphicsContainer;
    graphicsContainer.DeleteElement(element);
    //Refresh the display
    axPageLayoutControl1.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGraphics, null, null);

    //enable/disable buttons
    cmdDraw.Enabled = true;
    cmdDelete.Enabled = false;
    cmdChangeArea.Enabled = false;
    cmdChangeLine.Enabled = false;
    }
    }

  • 相关阅读:
    网络通信之 字节序转换原理与网络字节序、大端和小端模式
    [C/C++]大小端字节序转换程序
    面向对象和面向过程的区别
    编译libjpeg
    地形系统lod
    c/c++ 代码中使用sse指令集加速
    个人作品- 蘑菇大战
    个人作品- 几何战争
    Obj格式模型 读取
    各大引擎矩阵的矩阵存储方式 ----行矩阵 or 列矩阵
  • 原文地址:https://www.cnblogs.com/gisoracle/p/4827867.html
Copyright © 2011-2022 走看看