Files
TeslaSuite/Console/TeslaConsole/ImageCache.cs
T
CydandClaude Opus 4.8 548550b312 Initial commit: TeslaSuite monorepo (TeslaConsole + TeslaLauncher)
Co-locate the two cockpit-pod projects into a single repository:

- Console/  : TeslaConsole, the net48 WinForms operator console (decompiled
              reconstruction) plus its differential + catalog test suite.
- Launcher/ : TeslaLauncher, the net6 pod-side Service + Agent rewrite.

Adds a combined TeslaSuite.sln, root README documenting the shared wire
contract (and its current duplication, the main follow-up), and a root
.gitignore. Histories were not preserved per request; this is a fresh start
from the current working state of both projects.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-29 14:43:28 -05:00

64 lines
1.3 KiB
C#

using System.Collections.Generic;
using System.Drawing;
using TeslaConsole.Properties;
namespace TeslaConsole;
internal class ImageCache
{
private static readonly Bitmap mPodBad16;
private static readonly Bitmap mPodGo16;
private static readonly Bitmap mPodOffline16;
private static readonly Bitmap mPodOnline16;
private static readonly Bitmap mPodQuestion16;
private static readonly Bitmap mPodRun16;
private static Dictionary<string, Image> mCache;
public static Bitmap PodBad16 => mPodBad16;
public static Bitmap PodGo16 => mPodGo16;
public static Bitmap PodOffline16 => mPodOffline16;
public static Bitmap PodOnline16 => mPodOnline16;
public static Bitmap PodQuestion16 => mPodQuestion16;
public static Bitmap PodRun16 => mPodRun16;
static ImageCache()
{
mCache = new Dictionary<string, Image>();
mPodBad16 = Resources.PodBad16;
mPodGo16 = Resources.PodGo16;
mPodOffline16 = Resources.PodOffline16;
mPodOnline16 = Resources.PodOnline16;
mPodQuestion16 = Resources.PodQuestion16;
mPodRun16 = Resources.PodRun16;
}
public static Image GetImage(string path)
{
lock (mCache)
{
if (!mCache.ContainsKey(path))
{
try
{
mCache.Add(path, Image.FromFile(path));
}
catch
{
}
}
return mCache.ContainsKey(path) ? mCache[path] : null;
}
}
}