Files
pokerfreak/winui/Seiten/ProtokollSeite.cs
T
mmintelandClaude Opus 5.5 9b33942394 Cockpit als native Windows-11-App (WinUI 3, winui/), Optik nach der Mac-App
WinUI 3 / Windows App SDK 1.8, C#/.NET 8, unpackaged. Nur Anzeige und Knoepfe: Daten ueber
/ws (ansicht), Befehle ueber POST /api/steuern; abgeleitete Anzeige kommt aus sicht/abgeleitet.py.
Optisch nach mac/Sources/Cockpit (dunkles Glas, Kapseln, Apple-Systemfarben, Reiterleiste unten).

Reiter: Cash (Modus-Kapsel mit Echtgeld-Rueckfrage, Instrument-Kacheln, Tische/Form/Formate,
Hauptknopf, Not-Aus mit Halten-zum-Loesen, Sitzungsleiste, Werkzeuge, Bereit-Schritte,
Tischkacheln mit Minitisch, Geld, Gerade eben), Haende (Suche, Filter, aufklappbare Zeilen),
Statistik (Ergebnis Uebung/Cash/Archiv mit Kurve/Verteilung/Stakes/Stunden/Stapel/Sitzungen,
Formatvergleich; Stil Anteile/Verlauf/Groessen/Denkzeit), Protokoll (Gedanken, Ereignisse, Geld),
Einstellungen (Allgemein, Humanisierung, Sicherheit; Stimme, Plan-Editor, Streamer folgen).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 21:22:07 +01:00

155 lines
7.3 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.Text.Json.Nodes;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.UI.Xaml.Controls.Primitives;
using Microsoft.UI.Xaml.Media;
using Pokerfreak.Cockpit.Kern;
namespace Pokerfreak.Cockpit.Seiten;
/// <summary>
/// Der Reiter Protokoll (EntscheidungenGeld.swift `ProtokollAnsicht`): Gedanken und Ereignisse als
/// Strom in Festbreitenschrift, anhaltbar zum Lesen; Geld als Liste der Geldbewegungen mit Art-Filter.
/// </summary>
public sealed class ProtokollSeite : UserControl, ISeite
{
private static readonly FontFamily Fest = new("Cascadia Mono, Consolas");
private readonly CockpitZustand _z;
private readonly Segmente _teil = new(new[] { "Gedanken", "Ereignisse", "Geld" }, "protokoll.teil");
private readonly ToggleButton _pause = new()
{
Content = Ui.Zeichen("", 12),
Padding = new Thickness(8, 5, 8, 5),
CornerRadius = new CornerRadius(8),
};
private readonly Auswahl _art = new("Art");
private readonly Border _uebung = Ui.Abzeichen("ÜBUNG", "blau");
private readonly StackPanel _liste = Ui.Spalte(6);
private readonly ScrollViewer _rollen;
private JsonObject? _angehalten;
private string _abdruck = "";
public ProtokollSeite(CockpitZustand z)
{
_z = z;
ToolTipService.SetToolTip(_pause, "Anhalten zum Lesen");
_teil.Gewaehlt += _ => { _abdruck = ""; Zeichnen(); };
_pause.Click += (_, _) => { _angehalten = _pause.IsChecked == true ? _z.Ansicht.Ticker : null; _abdruck = ""; Zeichnen(); };
_art.Geaendert += () => { _abdruck = ""; Zeichnen(); };
var kopf = new Grid { ColumnSpacing = 8, Padding = new Thickness(12) };
kopf.ColumnDefinitions.Add(new ColumnDefinition());
kopf.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
kopf.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
kopf.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
kopf.Children.Add(_teil);
kopf.Children.Add(_pause.Spalte(1).Mit(p => p.VerticalAlignment = VerticalAlignment.Center));
kopf.Children.Add(_art.Spalte(2).Mit(a => a.VerticalAlignment = VerticalAlignment.Center));
kopf.Children.Add(_uebung.Spalte(3));
_liste.Padding = new Thickness(12);
_rollen = new ScrollViewer { Content = _liste, HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled };
var g = new Grid();
g.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
g.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
g.RowDefinitions.Add(new RowDefinition());
g.Children.Add(kopf);
g.Children.Add(new Border { Height = 1, Background = Ui.Weiss(0.08) }.Zeile(1));
g.Children.Add(_rollen.Zeile(2));
Content = g;
}
public void Zeichnen()
{
var geld = _teil.Index == 2;
_pause.Visibility = geld ? Visibility.Collapsed : Visibility.Visible;
_art.Visibility = geld ? Visibility.Visible : Visibility.Collapsed;
_uebung.Visibility = geld && _z.Ansicht.Geld.Wahr("uebung") ? Visibility.Visible : Visibility.Collapsed;
if (geld) GeldZeichnen();
else StromZeichnen(_teil.Index == 0);
}
private void StromZeichnen(bool gedanken)
{
var t = _angehalten ?? _z.Ansicht.Ticker;
var abdruck = (gedanken ? "g" : "e") + (gedanken ? t?["gedanken"] : t?["zeilen"]).Abdruck();
if (abdruck == _abdruck) return;
_abdruck = abdruck;
_liste.Children.Clear();
if (gedanken)
{
foreach (var g in t.Texte("gedanken"))
_liste.Children.Add(FestText(g));
}
else
{
foreach (var z in t.Objekte("zeilen"))
{
var tb = FestText("");
tb.Inlines.Add(new Microsoft.UI.Xaml.Documents.Run { Text = Format.Uhr(z.Zahl("zeit")) + " ", Foreground = Ui.Zweit });
if (z.Text("art") is string art)
tb.Inlines.Add(new Microsoft.UI.Xaml.Documents.Run { Text = art + " ", Foreground = Ui.Akzent });
tb.Inlines.Add(new Microsoft.UI.Xaml.Documents.Run
{
Text = string.Join(" · ", new[] { z.Text("raum"), z.Text("text") }.Where(s => !string.IsNullOrEmpty(s))),
});
_liste.Children.Add(tb);
}
}
if (_liste.Children.Count == 0)
_liste.Children.Add(Teile.Leer("Noch nichts", t.Text("leer") ?? "Der Strom läuft, sobald der Läufer arbeitet.", ""));
}
private static TextBlock FestText(string text) => new()
{
Text = text,
FontFamily = Fest,
FontSize = 11.5,
TextWrapping = TextWrapping.Wrap,
IsTextSelectionEnabled = true,
};
private void GeldZeichnen()
{
var g = _z.Ansicht.Geld;
var alle = g.Objekte("zeilen").ToList();
_art.Werte(alle.Select(z => z.Text("art")).OfType<string>().Distinct().OrderBy(a => a));
var abdruck = "geld" + g?["zeilen"].Abdruck() + _art.Wahl;
if (abdruck == _abdruck) return;
_abdruck = abdruck;
_liste.Children.Clear();
var zeilen = alle.Where(z => _art.Wahl == null || z.Text("art") == _art.Wahl).ToList();
if (zeilen.Count == 0)
{
_liste.Children.Add(Teile.Leer("Keine Geldbewegungen", g.Text("leer") ?? "Buy-in, Nachkauf und Aufstehen erscheinen hier.", ""));
return;
}
foreach (var z in zeilen)
{
var kopf = new Grid { ColumnSpacing = 6 };
foreach (var w in new[] { GridLength.Auto, GridLength.Auto, GridLength.Auto, new GridLength(1, GridUnitType.Star), GridLength.Auto, GridLength.Auto })
kopf.ColumnDefinitions.Add(new ColumnDefinition { Width = w });
kopf.Children.Add(Ui.Text(Format.Uhr(z.Zahl("zeit")), 12, pinsel: Ui.Zweit, zahlen: true).Mit(t => t.VerticalAlignment = VerticalAlignment.Center));
kopf.Children.Add(Ui.Text(z.Text("art") ?? "–", 14, fett: true).Spalte(1));
if (z.WahrOderNull("uebung") == true) kopf.Children.Add(Ui.Abzeichen("Übung", "blau").Spalte(2));
if (z.Zahl("betrag") is double b) kopf.Children.Add(Ui.Text(Format.Zahl(b, 2), 14, zahlen: true).Spalte(4));
if (z.Zahl("betrag_bb") is double bb)
kopf.Children.Add(Ui.Text(Format.Auto(bb) + " bb", 12, pinsel: Ui.Zweit).Spalte(5).Mit(t => t.VerticalAlignment = VerticalAlignment.Center));
var unter = new TextBlock
{
Text = string.Join(" · ", new[] { z.Text("raum"), z.Text("grund") }.Where(s => !string.IsNullOrEmpty(s))),
FontSize = 12,
Foreground = Ui.Zweit,
TextWrapping = TextWrapping.Wrap,
IsTextSelectionEnabled = true,
};
var s = Ui.Spalte(3, kopf, unter);
s.Padding = new Thickness(4, 6, 4, 6);
s.Opacity = z.WahrOderNull("uebung") == true ? 0.75 : 1;
if (_liste.Children.Count > 0) _liste.Children.Add(new Border { Height = 1, Background = Ui.Weiss(0.06) });
_liste.Children.Add(s);
}
}
}