Pre-beta: image download throttling
This commit is contained in:
parent
01a914c390
commit
88d49acdad
16 changed files with 200 additions and 83 deletions
28
WindowsDesktopUtilities/UNTESTED/WinAudibleImageServer.cs
Normal file
28
WindowsDesktopUtilities/UNTESTED/WinAudibleImageServer.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using Dinah.Core.Drawing;
|
||||
using FileManager;
|
||||
|
||||
namespace WindowsDesktopUtilities
|
||||
{
|
||||
public static class WinAudibleImageServer
|
||||
{
|
||||
private static Dictionary<PictureDefinition, Image> cache { get; } = new Dictionary<PictureDefinition, Image>();
|
||||
|
||||
public static Image GetImage(string pictureId, PictureSize size)
|
||||
{
|
||||
var def = new PictureDefinition(pictureId, size);
|
||||
if (!cache.ContainsKey(def))
|
||||
{
|
||||
(var isDefault, var bytes) = PictureStorage.GetPicture(def);
|
||||
|
||||
var image = ImageReader.ToImage(bytes);
|
||||
if (isDefault)
|
||||
return image;
|
||||
cache[def] = image;
|
||||
}
|
||||
return cache[def];
|
||||
}
|
||||
}
|
||||
}
|
||||
16
WindowsDesktopUtilities/WindowsDesktopUtilities.csproj
Normal file
16
WindowsDesktopUtilities/WindowsDesktopUtilities.csproj
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Library</OutputType>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ApplicationIcon />
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Dinah.Core\Dinah.Core.WindowsDesktop\Dinah.Core.WindowsDesktop.csproj" />
|
||||
<ProjectReference Include="..\FileManager\FileManager.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Loading…
Add table
Add a link
Reference in a new issue