WindowlessComponentGetFirstChildAt Method |
Namespace: Easymap.AddIn.Common
private Easymap.AddIn.Document doc = "Your current document"; private Easymap.Paper paper = null; private void Events_DocumentChanged(object sender, EventArgs e) { //Initialize click event on root (Paper object) paper = doc.Sheets.Item[0].Root; doc.Sheets.Item[0].Root += Root_Click; } void Root_Click(object sender, MouseEventArgs e) { //Get the analysis-layer, which will be used to transform "ptScreen" to parent (coordinatesystem) var analysisLayer = doc.FindElementByCaption("e.g. SymbolAnalysis"); //Get a map, to transform PointF, PointF is the clicked position. Easymap.WindowlessComponent wcMap = (Easymap.WindowlessComponent)doc.FindElementByCaption("Your specified map"); //Transform Point into screen coordinates var ptScreen = wcMap.PointToScreen(e.Point); //Transform Point into coordinatesystem of the parent (MapLayer) var ptCoord = (analysisLayer as Easymap.WindowlessComponent).PointToParent(ptScreen); //Returns one child element from the appropriate analysis (e.g. symbol) var element = (analysisLayer as Easymap.WindowlessComponent).GetFirstChildAt(ptCoord, Easymap.HitTestAccuracy.HitTestAccuracy_Complex); var analysis = (Easymap.AnalysisLayer)analysisLayer; //Returns the key of the appropriate child element of the specified position var key = analysis.GetKeyForChild(element); ... }
void Root_Click(object sender, MouseEventArgs e) { //Get a map, to transform PointF, PointF is the clicked position. Easymap.WindowlessComponent wcMap = (Easymap.WindowlessComponent)doc.FindElementByCaption("Your specified map"); //Transform Point into screen coordinates Easymap.PointF ptScreen = wcMap.PointToScreen(e.Point); //Get a reference layer, which will be tested Easymap.MapLayer mapLayer = (Easymap.MapLayer)doc.FindElementByCaption("postcode region - area"); //Transform Point into coordinatesystem of the parent (MapLayer) var ptCoord = mapLayer.WindowlessComponent.PointToParent(ptScreen); //Get the area determine by the clicked postion var layerElement = (Easymap.LayerElementComponent)mapLayer.WindowlessComponent.GetFirstChildAt(ptCoord, Easymap.HitTestAccuracy.HitTestAccuracy_Complex); string key = layerElement.LayerElement.Key; string areaName = layerElement.LayerElement.Name; ... }