I have a custom tool with snapping type is (snapping to point + snapping to edge), and the second tool having snapping type is snapping to point only, so when i select the first tool it works well, but when i switch to the second it do not work , even if when i return to the first tool, it do not work too. the same as when i start using the second tool , once i switch to the first tool the snapping stops working in all tools.
here is the code of the on click event of the first tool:
public override void OnClick()
{
IHookHelper2 m_hookHelper2 = m_hookHelper as IHookHelper2;
IExtensionManager extensionManager = m_hookHelper2.ExtensionManager;
if (extensionManager != null)
{
UID guid = new UIDClass();
guid.Value = "{E07B4C52-C894-4558-B8D4-D4050018D1DA}"; //Snapping extension.
IExtension extension = extensionManager.FindExtension(guid);
m_SnappingEnvironment = extension as ISnappingEnvironment;
m_SnappingEnvironment.SnappingType = (esriSnappingType)9;// esriSnappingType.esriSnappingTypePoint + esriSnappingType.esriSnappingTypeEdge;
m_Snapper = m_SnappingEnvironment.PointSnapper;
m_SnappingFeedback = new SnappingFeedbackClass();
m_SnappingFeedback.Initialize(m_hookHelper.Hook, m_SnappingEnvironment, true);
ISet excludedLayerSet = new ESRI.ArcGIS.esriSystem.SetClass();
m_Snapper.ExcludedLayers(ref excludedLayerSet);
for (int i = 0; i < dessin.get_instance().mapDocument.get_Map(0).LayerCount; i++)
{
if (dessin.get_instance().mapDocument.get_Layer(0, i).Name != "Point_t" && dessin.get_instance().mapDocument.get_Layer(0, i).Name != "Point_d" && dessin.get_instance().mapDocument.get_Layer(0, i).Name != "line_k")
excludedLayerSet.Add(dessin.get_instance().mapDocument.get_Layer(0, i));
}
m_Snapper.ClearCache();
}
}
public override void OnMouseMove(int Button, int Shift, int X, int Y)
{
if (Button == 4)
return;
//Convert the point from pixels to map units.
m_CurrentMouseCoords = QueryMapPoint(mapDocument.ActiveView.ScreenDisplay, X, Y);
//Test the location against the snap environment.
snapResult = m_Snapper.Snap(m_CurrentMouseCoords);
//Update the snapping feedback.
m_SnappingFeedback.Update(snapResult, 0);
//Update the current location to move the cursor to the snapped location.
if (snapResult != null)
if (snapResult.Location != null)
{
m_CurrentMouseCoords = snapResult.Location;
//MessageBox.Show("sdsd");
}
if (m_linefeedback != null)
{
m_linefeedback.MoveTo(m_CurrentMouseCoords);
}
}
Any help please.