Hi,
I would like to see the exact displacement of the text when moving the annotation in ArcGIS Pro. That's why I thought of stopping and restarting an Event or individual operation every millisecond, where it would always check the position of the mouse cursor.The point is that I keep the left mouse button pressed to move the text, and when I release the button, the text moves to the last position of the cursor.
What I have tried:
protected async override void OnToolMouseDown(MapViewMouseButtonEventArgs e)
{var form1 = Formular();
if (e.ChangedButton == MouseButton.Left)
{await QueuedTask.Run(() =>
{
MapView mapView = MapView.Active;
mapView.Map.SetSelection(null);
const string bodyAnno = "BodyAnno";
var alBodyAnno = AlBodyAnno(bodyAnno);
var mapPoint = MapView.Active.ClientToMap(e.ClientPoint);
var features = mapView.GetFeatures(mapPoint);
if (features.ContainsKey(alBodyAnno))
{
var thisTag = features.FirstOrDefault(t => t.Key == alBodyAnno);
var oidSeznam = thisTag.Value;
foreach (var longOid in oidSeznam)
{
oid = longOid;
}
var filter = Filter(oid);
var anotaceHledana = alBodyAnno.Search(filter);
while (anotaceHledana.MoveNext())
{
var aktual = anotaceHledana.Current;
strana = aktual["STRANA"].ToString();
}
AnotaceZvolena(alBodyAnno, filter);
}
var insp = Insp();
insp.Load(alBodyAnno, oid);
AnnotationProperties annoProperties = insp.GetAnnotationProperties();
shape = annoProperties.Shape;
if (shape == null)
{
form1.ShowDialog();
return;
}
});
}
}
}
protected async override void OnToolMouseUp(MapViewMouseButtonEventArgs e)
{
if (e.ChangedButton == MouseButton.Left)
{
await QueuedTask.Run(() =>
{
var insp = Insp();
const string bodyAnno = "BodyAnno";
var alBodyAnno = AlBodyAnno(bodyAnno);
insp.Load(alBodyAnno, oid);
AnnotationProperties annoProperties = insp.GetAnnotationProperties();
var editace = Editace();
if (shape == null)
{
return;
}
var envelope = shape.Extent;
var mapPointCentroid = GeometryEngine.Instance.Centroid(envelope);
double souradniceStrduX = mapPointCentroid.X;
double souradniceStreduY = mapPointCentroid.Y;
if (strana == "horni" || strana == "dolni")
{
if (shape.GeometryType != GeometryType.GeometryBag)
{
var mapPoint = MapView.Active.ClientToMap(e.ClientPoint);
var souradniceX = mapPoint.X;
var x = souradniceX - souradniceStrduX;
var posun = GeometryEngine.Instance.Move(shape, x, 0);
annoProperties.Shape = posun;
}
}
else
{
if (shape.GeometryType != GeometryType.GeometryBag)
{
var mapPoint = MapView.Active.ClientToMap(e.ClientPoint);
var souradniceY = mapPoint.Y;
var y = souradniceY - souradniceStreduY;
var posun = GeometryEngine.Instance.Move(shape, 0, y);
annoProperties.Shape = posun;
}
}
insp.SetAnnotationProperties(annoProperties);
editace.Modify(insp);
editace.Execute();
oid = 0;
});
}
}
This is how the complete code looks like to move to the final position without seeing the moved text.
And somewhere, I would like to set the OnToolMouseDown Event so that it always checks the position, for example, every millisecond and writes it down so that it can be seen how it moves.
Is there any such option to check cursor position every millisecond?
Thanks for the advice and tips.
David