void mediaSelectionEvent(MediaSelectionPayload selection) { mapDeselectAll(); if (selection.Items.Count() == 0) { return; } for (int i = 0; i < selection.Items.Count(); i++) { MediaItem item = selection.Items.ElementAt(i); FrameworkElement elem = mapSelectItem(item); if (elem != null && i == selection.Items.Count() - 1) { item.EnterReadLock(); if (item.Metadata.Latitude != null) { Map.Center = new Location(item.Metadata.Latitude.Value, item.Metadata.Longitude.Value); } item.ExitReadLock(); } } }
void mapAddItem(SelectableMediaItem media) { MediaItem item = media.Item; item.EnterReadLock(); try { if (item.Metadata == null || item.HasGeoTag == false || mapContainsItem(item)) { return; } GeoTagCoordinatePair coord = new GeoTagCoordinatePair(item.Metadata.Latitude, item.Metadata.Longitude); if (!coord.IsEmpty) { Location itemLocation = new Location(coord.LatDecimal.Value, coord.LonDecimal.Value); Border border = new Border(); border.BorderThickness = new Thickness(8); border.Tag = item; border.MaxWidth = 100; border.MaxHeight = 100; if (media.IsSelected) { border.Background = selectedImageBackground; } else { border.Background = defaultImageBackground; } Image image = new Image(); image.Tag = item; image.Source = item.Metadata.Thumbnail.Image; image.PreviewMouseDown += item_PreviewMouseDown; image.ToolTip = item.Metadata.DefaultFormatCaption; border.Child = image; imageLayer.AddChild(border, itemLocation, PositionOrigin.Center); Pushpin pin = new Pushpin(); pin.Tag = item; pin.ToolTip = item.Metadata.DefaultFormatCaption; pin.PreviewMouseDown += item_PreviewMouseDown; pin.Location = itemLocation; if (media.IsSelected) { pin.Background = selectedPushpinBackground; } else { pin.Background = defaultPushpinBackground; } pinLayer.AddChild(pin, itemLocation, PositionOrigin.BottomCenter); } } finally { item.ExitReadLock(); } }