著作権レイヤ


IScreenDisplay以外では描画しないレイヤ
画像化等禁止時かな。
挙動確認してないけど。

using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geometry;

public class CopyrightLayer : ILayer
{
  private ILayer m_Layer = null;

  public CopyrightLayer(ILayer layer)
  {
    this.m_Layer = layer;
  }

  public void Draw(esriDrawPhase DrawPhase, IDisplay Display, ITrackCancel TrackCancel)
  {
    if (Display is IScreenDisplay)
      this.m_Layer.Draw(DrawPhase, Display, TrackCancel);
  }

  public IEnvelope AreaOfInterest
  {
    get { return this.m_Layer.AreaOfInterest; }
  }

  public bool Cached
  {
    get
    {
      return this.m_Layer.Cached;
    }
    set
    {
      this.m_Layer.Cached = value;
    }
  }

  public double MaximumScale
  {
    get
    {
      return this.m_Layer.MaximumScale;
    }
    set
    {
      this.m_Layer.MaximumScale = value;
    }
  }

  public double MinimumScale
  {
    get
    {
      return this.m_Layer.MinimumScale;
    }
    set
    {
      this.m_Layer.MinimumScale = value;
    }
  }

  public string Name
  {
    get
    {
      return this.m_Layer.Name;
    }
    set
    {
      this.m_Layer.Name = value;
    }
  }

  public bool ShowTips
  {
    get
    {
      return this.m_Layer.ShowTips;
    }
    set
    {
      this.m_Layer.ShowTips = value;
    }
  }

  public ISpatialReference SpatialReference
  {
    set { this.m_Layer.SpatialReference = value; }
  }

  public int SupportedDrawPhases
  {
    get { return this.m_Layer.SupportedDrawPhases; }
  }

  public bool Valid
  {
    get { return this.m_Layer.Valid; }
  }

  public bool Visible
  {
    get
    {
      return this.m_Layer.Visible;
    }
    set
    {
      this.m_Layer.Visible = value;
    }
  }

  public string get_TipText(double x, double y, double Tolerance)
  {
    return this.m_Layer.get_TipText(x, y, Tolerance);
  }
}

使う側(これは出ないはず,マップコントロール等ではでるはず)

int inxLayer = 0;
ILayer layer = map.get_Layer(inxLayer);
IMapLayers mapLayers = (IMapLayers)map;
com.ManageLifetime(layer);

CopyrightLayer cpLayer = new CopyrightLayer(layer);
mapLayers.DeleteLayer(layer);
mapLayers.InsertLayer(cpLayer, false, inxLayer);

using (Bitmap img = new Bitmap(400, 400))
using(var g = Graphics.FromImage(img))
{
  var hDc = g.GetHdc().ToInt32();
  var actView = (IActiveView)map;
  var tagRect = new ESRI.ArcGIS.esriSystem.tagRECT();
  tagRect.right = tagRect.bottom = 400;
  actView.Output(hDc, 96, ref tagRect, actView.Extent, null);
          
  g.ReleaseHdc();
  g.Dispose();

  img.Save(@"c:\tmp\test.png");
}
カテゴリー: 開発 タグ: パーマリンク