private void LoadPushpins() { VmPoints pins = ((ViewModel)map.DataContext).Pushpins; var imageFilenames = Directory.EnumerateFiles(Path.Combine(new String[] { System.AppDomain.CurrentDomain.BaseDirectory, DATA_FOLDER, POSTERS_FOLDER })).Where(file => Regex.IsMatch(file, @"^.+\.(" + IMAGE_EXTENSIONS + ")$")); foreach (string filename in imageFilenames) { try { string textFilename = Path.Combine(new String[] { System.AppDomain.CurrentDomain.BaseDirectory, DATA_FOLDER, OCR_TEXTS_FOLDER, Path.GetFileNameWithoutExtension(filename) + ".txt" }); Image img = Image.FromFile(filename); Location pos = EXIF.GetLocation(img); img.Dispose(); img = null; VmPoint pin = new VmPoint() { Name = "", //Path.GetFileNameWithoutExtension(filename), Location = pos, Image = /*new BitmapImage*/ (new Uri(filename, UriKind.Absolute)), Text = File.ReadAllText(textFilename) }; pins.Add(pin); } catch { //NOP (ignore images without lat/long EXIF info } } }
public ViewModel() { MapCenter = new Location(37.984971, 23.735747); Pushpins = new VmPoints(); }