Click or drag to resize

WindowlessComponentGetFirstChildAt Method

Gets first WindowlessComponent element by userdefined parameters.

Namespace:  Easymap.AddIn.Common
Assembly:  EasyMap.AddIn (in EasyMap.AddIn.dll) Version: 12.0.0.0
Syntax
public WindowlessComponent GetFirstChildAt(
	PointF location,
	HitTestAccuracy accuracy
)

Parameters

location
Type: Easymap.AddIn.Common.GraphicsPointF
Point in Location-Coordinates
accuracy
Type: Easymap.AddIn.CommonHitTestAccuracy
Defines accuracy of HitTest operation

Return Value

Type: WindowlessComponent
WindowlessComponent element
Examples
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)
{
   //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);

    ...
}
Determin the LayerElement of specified position.
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;

    ...
}
See Also