I have a Customer layer which inherits BaseCustomLayer.
I add it to my MapControl via addLayer but the function public override void Draw(esriDrawPhase drawPhase, IDisplay Display, ITrackCancel trackCancel)
is never hit.
The Custom Layer appears checked in the TOC.
I think I must be missing some initialization one-liner.
Answer
Here's a minimalist custom layer:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.esriSystem;
namespace MapControlApplication1
{
class CustLayer2: BaseCustomLayer
{
public override void Draw(esriDrawPhase drawPhase, IDisplay Display, ITrackCancel trackCancel)
{
System.Diagnostics.Debug.Print("drawing {0} {1}", drawPhase, Environment.TickCount);
}
}
}
I created a new Project and choosing C#>ArcGIS>Extending ArcObjects>Mapcontrol Application, then added a new menuitem on the menu of MainForm with this:
private void testToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
CustLayer2 layer = new CustLayer2();
layer.Name = "cust layer2";
axMapControl1.AddLayer(layer);
}
catch (Exception ex)
{
MessageBox.Show(this, ex.Message);
}
}
When I run I see this output as I pan around the map:
drawing esriDPGeography 441416029
drawing esriDPGeography 441422207
drawing esriDPGeography 441433579
No comments:
Post a Comment