private void CollectItems() { foreach (UIElement element in this.Children) { MapCanvasItem item = null; int hash = element.GetHashCode(); if (!this.internalItems.TryGetValue(hash, out item)) { item = this.PrepareItem(element); this.internalItems.Add(hash, item); } } }
internal void SetItemPosition(MapCanvasItem canvasItem, Point point) { if (!MapCanvas.VerifyPointIsValid(point)) { return; } double width = canvasItem.Item.DesiredSize.Width; double height = canvasItem.Item.DesiredSize.Height; if (!double.IsNaN(width) && !double.IsNaN(height) && !double.IsInfinity(width) && !double.IsInfinity(height) && (width > 0 || height > 0)) { canvasItem.Item.Arrange(new Rect(point, new Size(Math.Ceiling(width), Math.Ceiling(height)))); } }
/// <summary> /// Arrange item in canvas. /// </summary> /// <param name="item">Item to arrange.</param> internal void ArrangeItem(UIElement element) { MapCanvasItem item = null; this.internalItems.TryGetValue(element.GetHashCode(), out item); if (item != null) { Location location = MapLayer.GetLocation(element); if (location.IsEmpty) { return; } ICoordinateService coordinateService = CoordinateServiceProvider.GetService(this.Map); Point pixel = coordinateService.GeographicToPixel(location); this.SetItemPosition(item, pixel); } }