WindowlessComponentGetFirstChildAt Method |
Namespace: Easymap.AddIn.CommonAssembly: EasyMap.AddIn (in EasyMap.AddIn.dll) Version: 12.3.0.0
Syntaxpublic WindowlessComponent GetFirstChildAt(
PointF location,
HitTestAccuracy accuracy
)
Public Function GetFirstChildAt (
location As PointF,
accuracy As HitTestAccuracy
) As WindowlessComponent
Parameters
- location PointF
- Point in Location-Coordinates
- accuracy HitTestAccuracy
- Defines accuracy of HitTest operation
Return Value
WindowlessComponentWindowlessComponent element
Example
This sample code, initialize an click event. The appropriate object (here paper) must be held seperately.
When the event gets fired, we determin if there is an child element of the specified analysis at the clicked position.
If we found something, the first one will be returned and the key will be determined.
private Easymap.AddIn.Document doc = "Your current document";
private Easymap.Paper paper = null;
private void Events_DocumentChanged(object sender, EventArgs e)
{
paper = doc.Sheets.Item[0].Root;
doc.Sheets.Item[0].Root += Root_Click;
}
void Root_Click(object sender, MouseEventArgs e)
{
var analysisLayer = doc.FindElementByCaption("e.g. SymbolAnalysis");
Easymap.WindowlessComponent wcMap = (Easymap.WindowlessComponent)doc.FindElementByCaption("Your specified map");
var ptScreen = wcMap.PointToScreen(e.Point);
var ptCoord = (analysisLayer as Easymap.WindowlessComponent).PointToParent(ptScreen);
var element = (analysisLayer as Easymap.WindowlessComponent).GetFirstChildAt(ptCoord, Easymap.HitTestAccuracy.HitTestAccuracy_Complex);
var analysis = (Easymap.AnalysisLayer)analysisLayer;
var key = analysis.GetKeyForChild(element);
...
}
Determin the LayerElement of specified position.
void Root_Click(object sender, MouseEventArgs e)
{
Easymap.WindowlessComponent wcMap = (Easymap.WindowlessComponent)doc.FindElementByCaption("Your specified map");
Easymap.PointF ptScreen = wcMap.PointToScreen(e.Point);
Easymap.MapLayer mapLayer = (Easymap.MapLayer)doc.FindElementByCaption("postcode region - area");
var ptCoord = mapLayer.WindowlessComponent.PointToParent(ptScreen);
var layerElement = (Easymap.LayerElementComponent)mapLayer.WindowlessComponent.GetFirstChildAt(ptCoord, Easymap.HitTestAccuracy.HitTestAccuracy_Complex);
string key = layerElement.LayerElement.Key;
string areaName = layerElement.LayerElement.Name;
...
}
See Also