Phase 5-UI: Views sind echte Forms + Launcher-Offen-Status
- ModuleView liefert jetzt ein Form (CreateForm statt CreateControl); die 4 Views (Terminal, Settings, Jobs, Dashboard) von UserControl auf Form umgestellt (im Designer als Fenster bearbeitbar). ViewHostForm entfernt. - ShellUiHost verwaltet offene Forms: Einzelinstanz, bereits offenes Fenster wird in den Vordergrund geholt, OpenStateChanged-Event. - LauncherForm: Fenster-Buttons an View-IDs gebunden; offene Fenster werden am Button markiert (Checked), erneuter Klick holt das Fenster nach vorn. - Build 0 Fehler. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
ff1db2aea0
commit
ad5ba34b56
+28
-15
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@@ -19,6 +20,7 @@ namespace PolyTraderSharp.Ui
|
||||
private readonly IServiceProvider _services;
|
||||
private readonly TradingState _state;
|
||||
private readonly System.Windows.Forms.Timer _statusTimer = new() { Interval = 1000 };
|
||||
private readonly Dictionary<string, ToolStripButton> _viewButtons;
|
||||
private frm_main? _legacyForm;
|
||||
|
||||
public LauncherForm(ShellUiHost uiHost, IServiceProvider services)
|
||||
@@ -29,19 +31,40 @@ namespace PolyTraderSharp.Ui
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
btn_settings.Click += (_, _) => OpenView("core.settings");
|
||||
btn_terminal.Click += (_, _) => OpenView("core.terminal");
|
||||
btn_jobs.Click += (_, _) => OpenView("core.jobs");
|
||||
btn_dashboard.Click += (_, _) => OpenView("core.dashboard");
|
||||
// Fenster-Buttons an stabile View-IDs binden (Views werden per DI registriert).
|
||||
_viewButtons = new Dictionary<string, ToolStripButton>
|
||||
{
|
||||
["core.dashboard"] = btn_dashboard,
|
||||
["core.settings"] = btn_settings,
|
||||
["core.terminal"] = btn_terminal,
|
||||
["core.jobs"] = btn_jobs,
|
||||
};
|
||||
foreach (var (id, btn) in _viewButtons)
|
||||
{
|
||||
var viewId = id;
|
||||
btn.Click += (_, _) => _uiHost.OpenView(viewId);
|
||||
}
|
||||
|
||||
btn_liveTrading.Click += (_, _) => CycleLiveTrading();
|
||||
btn_demoTrading.Click += (_, _) => CycleDemoTrading();
|
||||
miLegacy.Click += (_, _) => OpenLegacy();
|
||||
miBeenden.Click += (_, _) => Close();
|
||||
|
||||
// Offen-Status der Fenster spiegeln (Button „checked", wenn Fenster offen).
|
||||
_uiHost.OpenStateChanged += UpdateWindowButtonStates;
|
||||
|
||||
_statusTimer.Tick += (_, _) => UpdateStatus();
|
||||
_statusTimer.Start();
|
||||
UpdateStatus();
|
||||
UpdateTradingToggles();
|
||||
UpdateWindowButtonStates();
|
||||
}
|
||||
|
||||
private void UpdateWindowButtonStates()
|
||||
{
|
||||
if (IsDisposed) return;
|
||||
foreach (var (id, btn) in _viewButtons)
|
||||
btn.Checked = _uiHost.IsOpen(id);
|
||||
}
|
||||
|
||||
private void CycleLiveTrading()
|
||||
@@ -91,17 +114,6 @@ namespace PolyTraderSharp.Ui
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Öffnet die Ansicht mit der angegebenen ID (bzw. fokussiert das offene Fenster).</summary>
|
||||
private void OpenView(string viewId)
|
||||
{
|
||||
var view = _uiHost.Views.FirstOrDefault(v => v.Id == viewId);
|
||||
if (view != null)
|
||||
_uiHost.OpenView(view);
|
||||
else
|
||||
MessageBox.Show($"Ansicht '{viewId}' ist (noch) nicht registriert.", "Hinweis",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
|
||||
private void UpdateStatus()
|
||||
{
|
||||
string trading = _state.GlobalTradingPaused
|
||||
@@ -116,6 +128,7 @@ namespace PolyTraderSharp.Ui
|
||||
|
||||
// Toggle-Buttons mit externem State synchron halten (z.B. Änderungen aus der Legacy-UI).
|
||||
UpdateTradingToggles();
|
||||
UpdateWindowButtonStates();
|
||||
}
|
||||
|
||||
private void OpenLegacy()
|
||||
|
||||
Reference in New Issue
Block a user