Files
PolyTraderSharp/src/PolyTrader.App.Avalonia/Shell/ViewIcons.cs
T
RichardandClaude Opus 5 dd8da3fd3f Arbeitsstand gesichert: Deploymentcenter-Integration (D-0 bis D-5) und Einfenster-Shell
Sicherungscommit vor dem Aufraeumen des Repos, damit nachvollziehbar bleibt,
welcher Stand vor der Bereinigung galt. Build gruen, 476 Tests gruen.

Zwei Straenge, die sich ueber .csproj, Program.cs und appsettings.json
ueberschneiden und darum gemeinsam abgelegt werden:

Deploymentcenter-Integration (P3c, Plan D-0 bis D-5 code-seitig fertig):
- Deploymentcenter.Client 2.5.0 als lokales Paket, Source-Mapping erweitert
- DeploymentcenterOptions, DeploymentcenterErrorReporter, LicenseGate/LicenseCli
- WatchdogHeartbeatService auf die Deploymentcenter-API umgestellt
  (version, os, checks, metrics, status stopped)
- Security: MasterKeyResolver, SecretRedactor, FilePermissions
- Directory.Build.props mit zentraler Version 0.1.0 (Packager-Versionsdisziplin)
- deploy/: Packager-Vorlage und systemd-Unit; echte Zugangsdaten bleiben
  ueber .gitignore aussen vor
- setup.json fuer die Erstinstallation
- UMSETZUNGSPLAN-Deploymentcenter-Integration.md; ANALYSE-Linux-Portierung.md
  verweist auf den neuen Plan

Einfenster-Shell (UI-Redesign):
- ShellWindow + ShellNavModel als Seitenleisten-Shell
- WindowMenuBar und WindowMenuModel entfallen
- Modul- und Kernfenster auf die Shell-Einbettung angepasst

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-22 10:42:22 +02:00

77 lines
3.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using Avalonia.Media.Imaging;
using Avalonia.Platform;
using PolyTrader.Core.Modularity;
namespace PolyTrader.App.Avalonia.Shell
{
/// <summary>
/// Löst die toolkit-neutralen <see cref="ModuleView.IconKey"/>-Schlüssel gegen die
/// Avalonia-Bildressourcen auf. Gegenstück zum gleichnamigen Helfer der WinForms-Shell
/// <b>dieselben Schlüssel, dieselben PNG-Dateien</b>, sodass Core und Module unverändert bleiben.
/// </summary>
public static class ViewIcons
{
/// <summary>Symbol-Schlüssel → Dateiname in <c>Resources/</c> (als Avalonia-Asset eingebettet).</summary>
private static readonly Dictionary<string, string> FileByKey = new()
{
["start"] = "dashboard.png",
["dashboard"] = "token_quantifier.png",
["settings"] = "setting_tools.png",
["terminal"] = "error_log.png",
["jobs"] = "system_time.png",
["accounting"] = "coins_in_hand.png",
["copytrading"] = "cross_reference.png",
["resolutionfarming"] = "file_start_workflow.png",
["supervisor"] = "emotion_batman.png",
};
/// <summary>Standard-Symbolschlüssel je View-ID identisch zur WinForms-Shell.</summary>
private static readonly Dictionary<string, string> DefaultKeyByViewId = new()
{
[AvaloniaUiHost.StartViewId] = "start",
["core.dashboard"] = "dashboard",
["core.settings"] = "settings",
["core.terminal"] = "terminal",
["core.jobs"] = "jobs",
["accounting.main"] = "accounting",
["copytrading.main"] = "copytrading",
["resolutionfarming.main"] = "resolutionfarming",
["supervisor.main"] = "supervisor",
};
private static readonly ConcurrentDictionary<string, Bitmap?> Cache = new();
/// <summary>Bild zum Schlüssel, oder <c>null</c> (kein Symbol / Datei fehlt).</summary>
public static Bitmap? Resolve(string? iconKey)
{
if (iconKey == null || !FileByKey.TryGetValue(iconKey, out var file)) return null;
return Cache.GetOrAdd(iconKey, _ =>
{
try
{
var uri = new Uri($"avares://PolyTrader.App.Avalonia/Assets/{file}");
using var stream = AssetLoader.Open(uri);
return new Bitmap(stream);
}
catch
{
// Ein fehlendes Symbol darf die Oberflaeche nie aufhalten Menueeintrag bleibt Text-only.
return null;
}
});
}
/// <summary>Setzt bei allen registrierten Views den Standard-Symbolschlüssel, falls noch keiner gesetzt ist.</summary>
public static void AssignDefaults(IModuleUiHost uiHost)
{
foreach (var view in uiHost.Views)
if (view.IconKey == null && DefaultKeyByViewId.TryGetValue(view.Id, out var key))
view.IconKey = key;
}
}
}