2018-12-09 17:14:32 +01:00
|
|
|
|
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
2019-03-27 18:39:59 +01:00
|
|
|
|
// <20> 2019 Clemens Fischer
|
2018-12-09 17:14:32 +01:00
|
|
|
|
// Licensed under the Microsoft Public License (Ms-PL)
|
|
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.IO;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using System.Xml;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MapControl.Images
|
|
|
|
|
|
{
|
|
|
|
|
|
public partial class GroundOverlayPanel
|
|
|
|
|
|
{
|
2019-07-13 19:53:03 +02:00
|
|
|
|
private static Task<List<ImageOverlay>> ReadGroundOverlaysFromFileAsync(string docFile)
|
2019-06-17 18:09:28 +02:00
|
|
|
|
{
|
2019-07-13 19:53:03 +02:00
|
|
|
|
return Task.Run(() =>
|
2018-12-09 17:14:32 +01:00
|
|
|
|
{
|
2019-07-13 19:53:03 +02:00
|
|
|
|
docFile = Path.GetFullPath(docFile);
|
2018-12-09 17:14:32 +01:00
|
|
|
|
|
2019-06-15 01:39:07 +02:00
|
|
|
|
var kmlDocument = new XmlDocument();
|
2019-07-13 19:53:03 +02:00
|
|
|
|
kmlDocument.Load(docFile);
|
2018-12-09 17:14:32 +01:00
|
|
|
|
|
2019-06-15 01:39:07 +02:00
|
|
|
|
var imageOverlays = ReadGroundOverlays(kmlDocument).ToList();
|
2019-07-13 19:53:03 +02:00
|
|
|
|
var docDir = Path.GetDirectoryName(docFile);
|
2018-12-09 17:14:32 +01:00
|
|
|
|
|
2019-06-15 01:39:07 +02:00
|
|
|
|
foreach (var imageOverlay in imageOverlays)
|
|
|
|
|
|
{
|
2019-07-13 19:53:03 +02:00
|
|
|
|
imageOverlay.ImageSource = ImageLoader.LoadImage(Path.Combine(docDir, imageOverlay.ImagePath));
|
2018-12-09 17:14:32 +01:00
|
|
|
|
}
|
2019-06-15 01:39:07 +02:00
|
|
|
|
|
|
|
|
|
|
return imageOverlays;
|
2019-07-13 19:53:03 +02:00
|
|
|
|
});
|
2018-12-09 17:14:32 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|