- LauncherForm: lstView-Ansatz entfernt (lstViews/colName/pnlBottom/btnOpen raus). Fenster werden ueber toolstrip_windows-Buttons geoeffnet/fokussiert: btn_settings -> Settings, btn_terminal -> Terminal (Bindung per stabiler View-ID). - statusStrip_info: Live-Status (Trading, Modul-Anzahl, API WSS/Polling) via 1s-Timer. - toolstrip_quickbar bleibt fuer Schnellaktionen (Trading an/aus) reserviert. - Neue SettingsView (UserControl + Designer): ServerSettings-PropertyGrid + Speichern/Neu laden; Verhalten wie bisheriger Settings-Tab. In Program.cs registriert. - Build 0 Fehler. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
83 lines
3.1 KiB
C#
83 lines
3.1 KiB
C#
using System;
|
|
using System.Linq;
|
|
using System.Windows.Forms;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using PolyTrader.Core.Modularity;
|
|
|
|
namespace PolyTraderSharp.Ui
|
|
{
|
|
/// <summary>
|
|
/// „Startleiste" der PolyTrader.App. Fenster werden über die im Designer platzierten
|
|
/// Buttons in <c>toolstrip_windows</c> geöffnet bzw. in den Vordergrund geholt.
|
|
/// <c>toolstrip_quickbar</c> ist für Schnellaktionen (z.B. Trading an/aus) reserviert,
|
|
/// <c>statusStrip_info</c> zeigt Kernkennzahlen. Der Launcher kennt selbst kein Modul —
|
|
/// Buttons werden per stabiler View-ID an registrierte Views gebunden.
|
|
/// </summary>
|
|
public partial class LauncherForm : Form
|
|
{
|
|
private readonly ShellUiHost _uiHost;
|
|
private readonly IServiceProvider _services;
|
|
private readonly TradingState _state;
|
|
private readonly System.Windows.Forms.Timer _statusTimer = new() { Interval = 1000 };
|
|
private frm_main? _legacyForm;
|
|
|
|
public LauncherForm(ShellUiHost uiHost, IServiceProvider services)
|
|
{
|
|
_uiHost = uiHost;
|
|
_services = services;
|
|
_state = services.GetRequiredService<TradingState>();
|
|
|
|
InitializeComponent();
|
|
|
|
btn_settings.Click += (_, _) => OpenView("core.settings");
|
|
btn_terminal.Click += (_, _) => OpenView("core.terminal");
|
|
miLegacy.Click += (_, _) => OpenLegacy();
|
|
miBeenden.Click += (_, _) => Close();
|
|
|
|
_statusTimer.Tick += (_, _) => UpdateStatus();
|
|
_statusTimer.Start();
|
|
UpdateStatus();
|
|
}
|
|
|
|
/// <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
|
|
? "Pausiert"
|
|
: $"Live={_state.LiveTradingMode} / Demo={_state.DemoTradingMode}";
|
|
lbl_trading.Text = $"Trading: {trading}";
|
|
|
|
int moduleCount = _services.GetServices<IPolyTraderModule>().Count();
|
|
lbl_modules.Text = $"Module: {moduleCount}";
|
|
|
|
lbl_ratelimit.Text = $"API: {(_state.IsAlchemyHealthy ? "WSS aktiv" : "Polling")}";
|
|
}
|
|
|
|
private void OpenLegacy()
|
|
{
|
|
if (_legacyForm != null && !_legacyForm.IsDisposed)
|
|
{
|
|
if (_legacyForm.WindowState == FormWindowState.Minimized)
|
|
_legacyForm.WindowState = FormWindowState.Normal;
|
|
_legacyForm.BringToFront();
|
|
_legacyForm.Activate();
|
|
return;
|
|
}
|
|
|
|
_legacyForm = _services.GetRequiredService<frm_main>();
|
|
_legacyForm.FormClosed += (_, _) => _legacyForm = null;
|
|
_legacyForm.Show();
|
|
}
|
|
}
|
|
}
|