mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2026-01-06 16:50:04 +01:00
Unified ImageFileCache implementations
This commit is contained in:
parent
e98f5b9bff
commit
f8b0bcbeb1
|
|
@ -29,6 +29,7 @@ namespace MapControl.Caching
|
|||
}
|
||||
|
||||
rootDirectory = directory;
|
||||
|
||||
Debug.WriteLine("Created ImageFileCache in " + rootDirectory);
|
||||
}
|
||||
|
||||
|
|
@ -133,6 +134,7 @@ namespace MapControl.Caching
|
|||
if (expiration.HasValue)
|
||||
{
|
||||
Array.Resize(ref buffer, buffer.Length - 16);
|
||||
|
||||
return expiration.Value;
|
||||
}
|
||||
|
||||
|
|
@ -151,5 +153,17 @@ namespace MapControl.Caching
|
|||
|
||||
return expiration;
|
||||
}
|
||||
|
||||
private static void WriteExpiration(Stream stream, DateTime expiration)
|
||||
{
|
||||
stream.Write(Encoding.ASCII.GetBytes(expiresTag), 0, 8);
|
||||
stream.Write(BitConverter.GetBytes(expiration.Ticks), 0, 8);
|
||||
}
|
||||
|
||||
private static async Task WriteExpirationAsync(Stream stream, DateTime expiration)
|
||||
{
|
||||
await stream.WriteAsync(Encoding.ASCII.GetBytes(expiresTag), 0, 8);
|
||||
await stream.WriteAsync(BitConverter.GetBytes(expiration.Ticks), 0, 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ using System;
|
|||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.Storage.Streams;
|
||||
|
||||
|
|
@ -56,8 +55,7 @@ namespace MapControl.Caching
|
|||
using (var stream = File.Create(path))
|
||||
{
|
||||
await stream.AsOutputStream().WriteAsync(buffer);
|
||||
await stream.WriteAsync(Encoding.ASCII.GetBytes(expiresTag), 0, 8);
|
||||
await stream.WriteAsync(BitConverter.GetBytes(expiration.Ticks), 0, 8);
|
||||
await WriteExpirationAsync(stream, expiration);
|
||||
}
|
||||
|
||||
//Debug.WriteLine("ImageFileCache: Wrote {0}, Expires {1}", path, expiration.ToLocalTime());
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ using System.Threading.Tasks;
|
|||
using Windows.UI.Core;
|
||||
using Windows.UI.Xaml.Media;
|
||||
#else
|
||||
using Microsoft.System;
|
||||
using Microsoft.UI.Dispatching;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ using System.Linq;
|
|||
using System.Runtime.Caching;
|
||||
using System.Security.AccessControl;
|
||||
using System.Security.Principal;
|
||||
using System.Text;
|
||||
|
||||
namespace MapControl.Caching
|
||||
{
|
||||
|
|
@ -172,8 +171,7 @@ namespace MapControl.Caching
|
|||
using (var stream = File.Create(path))
|
||||
{
|
||||
stream.Write(buffer, 0, buffer.Length);
|
||||
stream.Write(Encoding.ASCII.GetBytes(expiresTag), 0, 8);
|
||||
stream.Write(BitConverter.GetBytes(imageCacheItem.Expiration.Ticks), 0, 8);
|
||||
WriteExpiration(stream, imageCacheItem.Expiration);
|
||||
}
|
||||
|
||||
var fileInfo = new FileInfo(path);
|
||||
|
|
|
|||
|
|
@ -34,8 +34,8 @@
|
|||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.ProjectReunion" Version="0.5.7" />
|
||||
<PackageReference Include="Microsoft.ProjectReunion.Foundation" Version="0.5.7" />
|
||||
<PackageReference Include="Microsoft.ProjectReunion.WinUI" Version="0.5.7" />
|
||||
<PackageReference Include="Microsoft.ProjectReunion" Version="0.8.0" />
|
||||
<PackageReference Include="Microsoft.ProjectReunion.Foundation" Version="0.8.0" />
|
||||
<PackageReference Include="Microsoft.ProjectReunion.WinUI" Version="0.8.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
xmlns:map="clr-namespace:MapControl;assembly=MapControl.WPF"
|
||||
xmlns:vm="clr-namespace:ViewModel"
|
||||
xmlns:local="clr-namespace:WpfApplication"
|
||||
Title="XAML MapControl - WPF Test Application" Height="600" Width="900"
|
||||
Title="XAML MapControl - WPF Sample Application" Height="600" Width="900"
|
||||
Stylus.IsPressAndHoldEnabled="False">
|
||||
<Window.Resources>
|
||||
<DataTemplate x:Key="PolylineItemTemplate">
|
||||
|
|
|
|||
|
|
@ -24,7 +24,10 @@ namespace WpfApplication
|
|||
//TileImageLoader.Cache = new SQLiteCache(TileImageLoader.DefaultCacheFolder);
|
||||
//TileImageLoader.Cache = null;
|
||||
|
||||
BingMapsTileLayer.ApiKey = File.ReadAllText(@"..\..\..\BingMapsApiKey.txt")?.Trim();
|
||||
var apiKeyPath = Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "MapControl", "BingMapsApiKey.txt");
|
||||
|
||||
BingMapsTileLayer.ApiKey = File.ReadAllText(apiKeyPath)?.Trim();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue