WinUI: Protokoll mit Suche, Filterchips, Farben; Logzeile je Tisch; Tisch im Status
- Protokoll: Suche (Strg+F) mit Markierung, Chips je Art mit Zahl, Tisch-Filter, Probleme, Technik-Gruppe (Standard aus), Rechtsklick kopieren/filtern, Gedanken aufgeteilt und farbig - Server: ticker liefert name/hand/netto/gruppe/kurz; Chips tragen die letzte Stromzeile des Tisches (log, log_zeit, log_art, log_ton, log_warn); status.raum bei denkt/klickt - Live-Ansicht: unter dem Raster je Tisch eine Zeile mit der letzten Logzeile Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+59
-4
@@ -573,11 +573,65 @@ def tisch_folge(raeume, art=None):
|
||||
return sorted(raeume, key=schluessel)
|
||||
|
||||
|
||||
def chip(kb):
|
||||
"""Ein Tisch-Chip ueber den Kacheln: kurzer Name, Netto (sonst Zustand), Punkt, am Zug."""
|
||||
def chip(kb, log=None):
|
||||
"""Ein Tisch-Chip ueber den Kacheln: kurzer Name, Netto (sonst Zustand), Punkt, am Zug - und die letzte Zeile
|
||||
des Stroms an diesem Tisch (Owner 02.12.: "die aktuelle log line weiss man nicht wo man es zuordnen soll")."""
|
||||
log = log or {}
|
||||
return {"raum": kb["raum"], "titel": kb["kurz_titel"], "zeile": kb["netto"] or kb["zustand"] or "–",
|
||||
"zeile_ton": kb["netto_ton"] if kb["netto"] else "grau", "punkt_ton": kb["zustand_ton"],
|
||||
"am_zug": kb["zug_offen"], "stufe": stufe_von(kb["raum"], _d(kb.get("modus")).get("art"))[2]}
|
||||
"am_zug": kb["zug_offen"], "stufe": stufe_von(kb["raum"], _d(kb.get("modus")).get("art"))[2],
|
||||
"log": log.get("text") or "", "log_zeit": log.get("zeit"), "log_art": log.get("art") or "",
|
||||
"log_ton": log.get("ton") or "", "log_warn": log.get("warn") or ""}
|
||||
|
||||
|
||||
_TISCHNR = re.compile(r"(\d{4,})\b")
|
||||
_LOG_STILL = {"zeiger"} # Zeigerzustaende sagen am Tisch nichts
|
||||
|
||||
|
||||
def _ernst(z):
|
||||
""""rot" Fehler, "orange" Warnung, sonst "" - unabhaengig von Gewinn/Verlust."""
|
||||
text = str(z.get("text") or "").lower()
|
||||
name = str(z.get("name") or "").lower()
|
||||
if any(w in name or w in text for w in ("absturz", "fehler", "abbruch", "abgebrochen", "not-aus", "timeout")):
|
||||
return "rot"
|
||||
if "warn" in name or text.startswith("ereignis warnung") or "sitzt aus" in text or name == "kanal_rueckfall":
|
||||
return "orange"
|
||||
return ""
|
||||
|
||||
|
||||
def log_ton(z):
|
||||
"""Farbe einer Stromzeile: Warnung orange, Fehler rot, Gewinn/Verlust, sonst die Art."""
|
||||
if _ernst(z):
|
||||
return _ernst(z)
|
||||
if z.get("art") == "ergebnis":
|
||||
n = _z(z.get("netto"))
|
||||
return "gruen" if n and n > 0 else "rot" if n and n < 0 else "grau"
|
||||
return {"entscheidung": "blau", "vorhaben": "indigo", "sitzen": "teal", "zeitplan": "lila"}.get(z.get("art"), "grau")
|
||||
|
||||
|
||||
def letzte_logs(teile, raeume):
|
||||
"""Je Raum die juengste Stromzeile (ticker.zeilen ist neu zuerst). Raumnamen im Strom passen genau oder ueber
|
||||
die Tischnummer (die letzten Ziffern)."""
|
||||
nummer = {}
|
||||
for r in raeume:
|
||||
m = _TISCHNR.search(str(r))
|
||||
if m:
|
||||
nummer[m.group(1)] = r
|
||||
out = {}
|
||||
for z in _l(_d(teile.get("ticker")).get("zeilen")):
|
||||
if not isinstance(z, dict) or z.get("art") in _LOG_STILL or not z.get("raum"):
|
||||
continue
|
||||
if z.get("gruppe") == "technik" and not _ernst(z):
|
||||
continue
|
||||
raum = z["raum"]
|
||||
if raum not in raeume:
|
||||
m = _TISCHNR.search(str(raum))
|
||||
raum = nummer.get(m.group(1)) if m else None
|
||||
if raum is None or raum in out:
|
||||
continue
|
||||
text = str(z.get("kurz") or z.get("text") or "").replace(f" ({z['raum']})", "").strip()
|
||||
out[raum] = {"text": text, "zeit": z.get("zeit"), "art": z.get("art"), "ton": log_ton(z), "warn": _ernst(z)}
|
||||
return out
|
||||
|
||||
|
||||
# ---------------------------------------------------------------- Bereit: der Weg zum Spielen
|
||||
@@ -647,7 +701,8 @@ def live(teile, jetzt):
|
||||
art = {x["raum"]: _d(x.get("modus")).get("art") for x in kacheln}
|
||||
rect_je = {r.get("raum"): r.get("rect") for r in _l(_d(teile.get("sitzen")).get("raeume")) if isinstance(r, dict)}
|
||||
lage = raster_lage({r: rect_je.get(r) for r in tisch_folge([x["raum"] for x in kacheln], art)})
|
||||
chips = [dict(chip(x), zeile_nr=lage[x["raum"]][0], spalte_nr=lage[x["raum"]][1])
|
||||
logs = letzte_logs(teile, {x["raum"] for x in kacheln})
|
||||
chips = [dict(chip(x, logs.get(x["raum"])), zeile_nr=lage[x["raum"]][0], spalte_nr=lage[x["raum"]][1])
|
||||
for x in kacheln] # die Liste bleibt (offener Zug zuerst), nur die Plaetze kommen vom Schirm
|
||||
offen = _z(k.get("tische_offen"))
|
||||
plan = _d(k.get("spielplan"))
|
||||
|
||||
+39
-1
@@ -526,6 +526,10 @@ def _status(q, jetzt, lagen, laeuft, not_aus, tische, offen, jz, ende=None):
|
||||
jz = jz if isinstance(jz, dict) else {}
|
||||
zug, en, kl = jz.get("zug") or {}, jz.get("entscheidung") or {}, jz.get("klick") or {}
|
||||
raum = jz.get("raum")
|
||||
s_ohne = s
|
||||
|
||||
def s(z, farbe, satz): # der Tisch, um den es geht: das Cockpit zeigt ihn als Marke vor dem Satz
|
||||
return dict(s_ohne(z, farbe, satz), raum=raum) if raum and z in ("denkt", "klickt") else s_ohne(z, farbe, satz)
|
||||
if zug.get("offen"):
|
||||
if en.get("vorhaben"):
|
||||
return s("klickt", "blau", f"entschieden: {en.get('aktion_text') or en.get('aktion') or 'Zug'} - klickt gleich")
|
||||
@@ -1875,10 +1879,44 @@ def stil(q, jetzt, zeilen=None):
|
||||
"leer": None if zeilen else "noch keine Entscheidungen"}
|
||||
|
||||
|
||||
# Ereignisse fuer die Technik (Takt, Kanaele, Auswahl, Mimik): im Protokoll als eigene Gruppe "technik", die man
|
||||
# ausblendet, und nie die Zeile eines Tisches (Owner 02.12.: Protokoll lesbar, "log line pro tisch")
|
||||
TECHNIK = {"klick_takt", "spur", "aktion_kanal", "setzen_kanal", "kontostand", "guthaben", "auswahl_api",
|
||||
"auswahl_kandidaten", "beitritt_kanal", "desktop_wechsel", "tischwahl_vorlesen", "angeordnet",
|
||||
"aufbau_frei", "rit_angebot", "rit_gesendet", "mimik", "mimik_still", "schliessen_kanal", "sitout_kanal",
|
||||
"warteliste_kanal", "aufgeraeumt", "tischwert"}
|
||||
_FARBE = {"h": "\u2665", "d": "\u2666", "s": "\u2660", "c": "\u2663"}
|
||||
|
||||
|
||||
def _karten_kurz(k):
|
||||
""""Jd Td" -> "J♦T♦" (ein Wort je Karte, unbekanntes bleibt)."""
|
||||
return "".join((w[:-1].replace("T", "10") + _FARBE.get(w[-1].lower(), w[-1])) if len(w) == 2 else w
|
||||
for w in str(k or "").split())
|
||||
|
||||
|
||||
def _ticker_kurz(e):
|
||||
"""Die Zeile in wenigen Worten fuer Tischzeile und Protokoll: Entscheidung "Turn · K♣Q♣ · Check", Ergebnis
|
||||
"verloren (-0,5 BB)"; sonst der Text ohne angehaengten Raumnamen."""
|
||||
art = e.get("art")
|
||||
if art == "entscheidung" and e.get("aktion_text"):
|
||||
return " · ".join(x for x in (e.get("strasse"), _karten_kurz(e.get("karten")), e["aktion_text"]) if x)
|
||||
if art == "ergebnis" and e.get("ergebnis_text"):
|
||||
return "Ergebnis: " + e["ergebnis_text"]
|
||||
text = str(e.get("text") or "")
|
||||
if e.get("raum"):
|
||||
text = text.replace(f" ({e['raum']})", "")
|
||||
return text
|
||||
|
||||
|
||||
def ticker(q, jetzt):
|
||||
ereignisse = [e for e in q.get("strom") or () if isinstance(e, dict) and e.get("text")]
|
||||
# name/hand/aktion/netto/gruppe/kurz: Farbe, Filter und Kurzform im Protokoll, ohne den Text zu raten
|
||||
zeilen = [{"zeit": _zahl(e.get("t")) or _zeit(e.get("zeit")), "art": e.get("art"), "raum": e.get("raum"),
|
||||
"text": e["text"]} for e in reversed(ereignisse[-TICKER_MAX:])]
|
||||
"text": e["text"], "name": e.get("name"), "hand": e.get("hand"), "aktion": e.get("aktion"),
|
||||
"netto": _zahl(e.get("netto_bb")) if _zahl(e.get("netto_bb")) is not None else _zahl(e.get("netto")),
|
||||
"gruppe": "technik" if e.get("name") in TECHNIK or e.get("art") == "sonstiges" else e.get("art"),
|
||||
"kurz": _ticker_kurz(e)}
|
||||
for e in reversed(ereignisse[-TICKER_MAX:])]
|
||||
try:
|
||||
gedanken = list(reversed(strom.gedankenprotokoll(ereignisse)))[:GEDANKEN_MAX]
|
||||
except Exception:
|
||||
|
||||
@@ -136,7 +136,15 @@ public sealed class CockpitZustand
|
||||
return Zuschauen ? ("Zuschauer startet …", "blau")
|
||||
: (a.Sammelt ? "Sammler schließt seine Tische …" : "Zuschauer endet …", "grau");
|
||||
var k = a.Kopf;
|
||||
return (k.Obj("status").Text("satz") ?? k.Text("text") ?? "liest …", k.Obj("status").Text("farbe") ?? "grau");
|
||||
var satz = k.Obj("status").Text("satz") ?? k.Text("text") ?? "liest …";
|
||||
// Denkt/klickt er, steht der Tisch vorn (Owner 02.12.: "die aktuelle log line weiss man nicht wo man es zuordnen soll")
|
||||
if (k.Obj("status").Text("raum") is { Length: > 0 } raum)
|
||||
{
|
||||
var nr = Seiten.Raum.Nummer(raum);
|
||||
satz = Seiten.Raum.Kurz(satz).Replace($" an {nr}", "");
|
||||
satz = $"{nr} · {satz}";
|
||||
}
|
||||
return (satz, k.Obj("status").Text("farbe") ?? "grau");
|
||||
}
|
||||
|
||||
/// <summary>Der Status in wenigen Worten (Server: status.kurz), der ganze Satz als Tooltip - null, wenn es nichts Laengeres gibt.</summary>
|
||||
|
||||
@@ -22,7 +22,9 @@ public sealed class LiveTeil : UserControl
|
||||
private readonly ContentControl _leiste = Breit(), _such = Breit(), _bereit = Breit();
|
||||
private readonly StackPanel _zeilen = Ui.Spalte(0);
|
||||
private readonly Grid _raster = new() { ColumnSpacing = 4, RowSpacing = 4 };
|
||||
private string _rasterAbdruck = "";
|
||||
private string _rasterAbdruck = "", _logAbdruck = "";
|
||||
/// <summary>Je Tisch eine Zeile mit der letzten Zeile des Stroms (Owner 02.12.: "log line pro tisch").</summary>
|
||||
private readonly StackPanel _logs = Ui.Spalte(0);
|
||||
private readonly TextBlock _tischText = Ui.Text("", 12, pinsel: Ui.Zweit);
|
||||
private readonly StackPanel _tische;
|
||||
/// <summary>Platz zwischen Tischliste und Verlauf: im Lauf die Einstellungen der Spielseite.</summary>
|
||||
@@ -68,7 +70,9 @@ public sealed class LiveTeil : UserControl
|
||||
_schliessenFrage = Ui.Getoent(frage, "rot", 0.12, 10, 8);
|
||||
_schliessenFrage.Visibility = Visibility.Collapsed;
|
||||
|
||||
_tische = Ui.Spalte(6, kopf, _schliessenFrage, _raster, Ui.Flaeche(_zeilen, 8, 0.05, 0));
|
||||
var logFlaeche = Ui.Flaeche(_logs, 8, 0.05, 0);
|
||||
logFlaeche.Padding = new Thickness(0, 2, 0, 2);
|
||||
_tische = Ui.Spalte(6, kopf, _schliessenFrage, _raster, logFlaeche, Ui.Flaeche(_zeilen, 8, 0.05, 0));
|
||||
Content = Ui.Spalte(12, _leiste, _bereit, _tische, _such, Einschub, _feed, _geld);
|
||||
}
|
||||
|
||||
@@ -203,6 +207,7 @@ public sealed class LiveTeil : UserControl
|
||||
if (_zeileVon.TryGetValue(c.T("raum"), out var z))
|
||||
z.Setzen(c, kacheln.GetValueOrDefault(c.T("raum")), _z.Fotos.GetValueOrDefault(c.T("raum")));
|
||||
Raster(chips, kacheln);
|
||||
Logs(chips);
|
||||
_tische.Visibility = chips.Count > 0 ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
|
||||
@@ -265,7 +270,8 @@ public sealed class LiveTeil : UserControl
|
||||
Child = inhalt,
|
||||
MinWidth = 0,
|
||||
};
|
||||
ToolTipService.SetToolTip(kachel, c.T("titel"));
|
||||
ToolTipService.SetToolTip(kachel, c.T("log") is { Length: > 0 } lg
|
||||
? $"{c.T("titel")}\n{(c.Zahl("log_zeit") is double lz ? Format.Uhr(lz) + " " : "")}{Raum.Kurz(lg)}" : c.T("titel"));
|
||||
Microsoft.UI.Xaml.Automation.AutomationProperties.SetName(kachel, raum);
|
||||
kachel.Tapped += (_, _) =>
|
||||
{
|
||||
@@ -280,6 +286,67 @@ public sealed class LiveTeil : UserControl
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Unter dem Raster je Tisch eine Zeile: Punkt, Nummer, Limit, dann was zuletzt an diesem Tisch geschah
|
||||
/// (am Zug: orange "am Zug"). So steht jede Logzeile bei ihrem Tisch. Antippen klappt den Tisch auf.</summary>
|
||||
private void Logs(List<JsonObject> chips)
|
||||
{
|
||||
var auf = _zeileVon.FirstOrDefault(p => p.Value.Offen).Key ?? "";
|
||||
var folge = chips.OrderBy(c => c.Zahl("zeile_nr") ?? 0).ThenBy(c => c.Zahl("spalte_nr") ?? 0).ToList();
|
||||
var abdruck = auf + "|" + string.Join("|", folge.Select(c =>
|
||||
$"{c.T("raum")}:{c.T("punkt_ton")}:{c.Wahr("am_zug")}:{c.T("log")}:{c.T("log_ton")}:{c.T("log_warn")}:{c.Text("log_zeit")}:{c.T("zeile")}:{c.T("zeile_ton")}"));
|
||||
if (abdruck == _logAbdruck) return;
|
||||
_logAbdruck = abdruck;
|
||||
_logs.Children.Clear();
|
||||
foreach (var c in folge)
|
||||
{
|
||||
var raum = c.T("raum");
|
||||
bool zug = c.Wahr("am_zug");
|
||||
var nr = Raum.Nummer(raum);
|
||||
var g = new Grid { ColumnSpacing = 6, Padding = new Thickness(8, 4, 10, 4), MinHeight = 26 };
|
||||
g.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
g.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(44) });
|
||||
g.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
g.ColumnDefinitions.Add(new ColumnDefinition());
|
||||
g.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
g.Children.Add(Ui.Punkt(c.T("punkt_ton"), 6));
|
||||
g.Children.Add(Ui.Text(nr == raum ? c.T("titel") : nr, 11.5, fett: true, zahlen: true,
|
||||
pinsel: raum == auf ? Ui.Akzent : null).Mit(t => t.VerticalAlignment = VerticalAlignment.Center).Spalte(1));
|
||||
var log = Raum.Kurz(c.T("log"));
|
||||
var ton = c.T("log_ton");
|
||||
var warn = c.T("log_warn");
|
||||
bool laut = warn.Length > 0;
|
||||
if (laut) ton = warn;
|
||||
var text = new TextBlock { FontSize = 11.5, TextTrimming = TextTrimming.CharacterEllipsis, VerticalAlignment = VerticalAlignment.Center };
|
||||
if (zug)
|
||||
text.Inlines.Add(new Microsoft.UI.Xaml.Documents.Run { Text = "am Zug ", Foreground = Ui.Pinsel("orange"), FontWeight = Microsoft.UI.Text.FontWeights.SemiBold });
|
||||
if (c.Zahl("log_zeit") is double lz)
|
||||
text.Inlines.Add(new Microsoft.UI.Xaml.Documents.Run { Text = Format.Kurz(lz) + " ", Foreground = Ui.Dritt });
|
||||
text.Inlines.Add(new Microsoft.UI.Xaml.Documents.Run
|
||||
{
|
||||
Text = log.Length > 0 ? log : "noch nichts an diesem Tisch",
|
||||
Foreground = log.Length == 0 ? Ui.Dritt : laut || c.T("log_art") == "ergebnis" ? Ui.Pinsel(ton) : Ui.Zweit,
|
||||
});
|
||||
if (!laut && log.Length > 0 && ton is { Length: > 0 } && ton != "grau")
|
||||
g.Children.Add(new Border { Width = 3, Height = 12, CornerRadius = new CornerRadius(1.5), Background = Ui.Pinsel(ton, 0.8), VerticalAlignment = VerticalAlignment.Center }.Spalte(2));
|
||||
else if (laut)
|
||||
g.Children.Add(Ui.Zeichen("\uE7BA", 10, ton).Mit(z => z.VerticalAlignment = VerticalAlignment.Center).Spalte(2));
|
||||
g.Children.Add(text.Spalte(3));
|
||||
g.Children.Add(Ui.Text(c.T("zeile") == "gesessen" ? "" : c.T("zeile"), 11.5, c.T("zeile_ton") is "grau" or "" ? null : c.T("zeile_ton"),
|
||||
fett: true, zahlen: true, pinsel: c.T("zeile_ton") is "grau" or "" ? Ui.Dritt : null).Mit(t => t.VerticalAlignment = VerticalAlignment.Center).Spalte(4));
|
||||
ToolTipService.SetToolTip(g, $"{raum}\n{(c.Zahl("log_zeit") is double z2 ? Format.Uhr(z2) + " " : "")}{(log.Length > 0 ? log : "noch keine Zeile")}");
|
||||
var flaeche = g.Tippen(() =>
|
||||
{
|
||||
if (!_zeileVon.TryGetValue(raum, out var zz)) return;
|
||||
zz.Offen = !zz.Offen;
|
||||
_rasterAbdruck = _logAbdruck = "";
|
||||
Zeichnen();
|
||||
}, 6);
|
||||
if (_logs.Children.Count > 0) _logs.Children.Add(Ui.Linie().Mit(l => l.Margin = new Thickness(8, 0, 8, 0)));
|
||||
if (zug) g.Background = Ui.Pinsel("orange", 0.10);
|
||||
_logs.Children.Add(flaeche);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Filzgrund: dunkles Tischgruen von oben nach unten (aufgeklappt etwas heller).</summary>
|
||||
private static Brush Filz(bool hell) => new LinearGradientBrush
|
||||
{
|
||||
|
||||
+506
-133
@@ -1,101 +1,149 @@
|
||||
using System.Text.Json.Nodes;
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.UI.Text;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Controls.Primitives;
|
||||
using Microsoft.UI.Xaml.Documents;
|
||||
using Microsoft.UI.Xaml.Input;
|
||||
using Microsoft.UI.Xaml.Media;
|
||||
using Pokerfreak.Cockpit.Kern;
|
||||
using Windows.ApplicationModel.DataTransfer;
|
||||
|
||||
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.
|
||||
/// Der Reiter Protokoll (Owner 02.12.: "saubere Farben, Filter, Lesbarkeit, Suche"). Drei Teile:
|
||||
/// Gedanken (je eigener Entscheidung eine Zeile), Ereignisse (der Strom des Laeufers) und Geld.
|
||||
/// Oben Suche, Pause und Menue; bei den Ereignissen eine Leiste mit Filterchips (Tisch, Probleme, je Art mit Zahl).
|
||||
/// Jede Zeile: Zeit links, darueber klein Art und Tisch in der Farbe der Art, darunter der Text; Warnungen und
|
||||
/// Fehler mit getoentem Grund und Farbstrich. Suchtreffer sind markiert. Rechtsklick: kopieren, nur dieser Tisch,
|
||||
/// Art ausblenden. Strg+F springt in die Suche.
|
||||
/// </summary>
|
||||
public sealed class ProtokollSeite : UserControl, ISeite
|
||||
{
|
||||
private static readonly FontFamily Fest = new("Cascadia Mono, Consolas");
|
||||
|
||||
/// <summary>Die Arten des Stroms (betrieb/strom.py) mit Namen und fester Farbe - gleiche Art, gleiche Farbe.</summary>
|
||||
private static readonly (string Art, string Name, string Ton)[] Arten =
|
||||
{
|
||||
("entscheidung", "Entscheidung", "blau"), ("vorhaben", "Vorhaben", "indigo"), ("ergebnis", "Ergebnis", "gruen"),
|
||||
("sitzen", "Sitzen", "teal"), ("ereignis", "Ereignis", "grau"), ("zeitplan", "Zeitplan", "lila"),
|
||||
("gegner", "Gegner", "gelb"), ("showdown", "Showdown", "orange"), ("deal", "Deal", "orange"),
|
||||
("zeiger", "Zeiger", "grau"), ("technik", "Technik", "grau"),
|
||||
};
|
||||
|
||||
private static (string Name, string Ton) ArtVon(string? art)
|
||||
{
|
||||
foreach (var a in Arten) if (a.Art == art) return (a.Name, a.Ton);
|
||||
return (string.IsNullOrEmpty(art) ? "Sonstiges" : char.ToUpperInvariant(art[0]) + art[1..], "grau");
|
||||
}
|
||||
|
||||
/// <summary>Wie ernst eine Zeile ist: "rot" Fehler, "orange" Warnung, sonst null (wie sicht/abgeleitet.py `log_ton`).</summary>
|
||||
internal static string? Ernst(string? art, string? name, string? text)
|
||||
{
|
||||
var t = (text ?? "").ToLowerInvariant();
|
||||
var n = (name ?? "").ToLowerInvariant();
|
||||
if (new[] { "absturz", "fehler", "abbruch", "abgebrochen", "not-aus", "timeout" }.Any(w => n.Contains(w) || t.Contains(w))) return "rot";
|
||||
if (n.Contains("warn") || t.StartsWith("ereignis warnung") || t.Contains("sitzt aus") || n == "kanal_rueckfall") return "orange";
|
||||
return null;
|
||||
}
|
||||
|
||||
private readonly CockpitZustand _z;
|
||||
private readonly Segmente _teil = new(new[] { "Gedanken", "Ereignisse", "Geld" }, "protokoll.teil");
|
||||
private readonly ToggleButton _pause = new()
|
||||
private readonly AutoSuggestBox _suche = new()
|
||||
{
|
||||
Content = Ui.Zeichen("", 12),
|
||||
Padding = new Thickness(8, 5, 8, 5),
|
||||
CornerRadius = new CornerRadius(8),
|
||||
PlaceholderText = "Suchen (Strg+F)",
|
||||
QueryIcon = new SymbolIcon(Symbol.Find),
|
||||
FontSize = 12,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
private readonly ToggleButton _pause = new() { Padding = new Thickness(10, 5, 10, 5), CornerRadius = new CornerRadius(4), MinWidth = 0 };
|
||||
private readonly TextBlock _pauseText = Ui.Text("Live", 12);
|
||||
private readonly FontIcon _pauseZeichen = Ui.Zeichen("\uE769", 11);
|
||||
private readonly Button _menue = new() { Padding = new Thickness(8, 6, 8, 6), CornerRadius = new CornerRadius(4), MinWidth = 0 };
|
||||
private readonly ToggleMenuFlyoutItem _nurSitzung = new() { Text = "Nur laufende Sitzung" };
|
||||
private readonly StackPanel _chips = Ui.Reihe(6);
|
||||
private readonly ScrollViewer _chipLeiste;
|
||||
private readonly Auswahl _art = new("Art");
|
||||
private readonly TextBox _suche = new() { PlaceholderText = "suchen", FontSize = 12, Width = 150 };
|
||||
private readonly Button _filter = new() { Content = Ui.Zeichen("", 12), Padding = new Thickness(8, 5, 8, 5) };
|
||||
private readonly HashSet<string> _versteckt = new();
|
||||
private readonly ToggleButton _nurSitzung = new() { Content = Ui.Zeichen("", 12), Padding = new Thickness(8, 5, 8, 5), CornerRadius = new CornerRadius(8) };
|
||||
private double _sitzungsStart = double.NegativeInfinity;
|
||||
|
||||
/// <summary>Beginn der laufenden Sitzung: das letzte `zeitplan`-Ereignis mit phase "spielen".</summary>
|
||||
private void SitzungMerken(JsonObject t)
|
||||
{
|
||||
_sitzungsStart = double.NegativeInfinity;
|
||||
foreach (var z in t.Objekte("zeilen"))
|
||||
if (z.Text("art") == "zeitplan" && (z.Text("text") ?? "").Contains("phase=spielen"))
|
||||
_sitzungsStart = z.Zahl("zeit") ?? _sitzungsStart;
|
||||
}
|
||||
private static readonly string[] Farben = { "blau", "gruen", "orange", "lila", "teal", "gelb" };
|
||||
|
||||
/// <summary>Gleiche Art, gleiche Farbe - ein Hash auf die Palette, ueber Sitzungen stabil.</summary>
|
||||
private static string Farbe(string? art)
|
||||
{
|
||||
if (string.IsNullOrEmpty(art)) return "grau";
|
||||
var h = 0;
|
||||
foreach (var b in art) h = (h * 31 + b) & 0x7fffffff;
|
||||
return Farben[h % Farben.Length];
|
||||
}
|
||||
|
||||
private bool Sichtbar(JsonObject z)
|
||||
{
|
||||
if (_nurSitzung.IsChecked == true && (z.Zahl("zeit") ?? double.NegativeInfinity) < _sitzungsStart) return false;
|
||||
if (z.Text("art") is string a && _versteckt.Contains(a)) return false;
|
||||
var suche = _suche.Text.Trim().ToLowerInvariant();
|
||||
if (suche.Length == 0) return true;
|
||||
return new[] { z.Text("art"), z.Text("raum"), z.Text("text") }
|
||||
.Any(s => s != null && s.ToLowerInvariant().Contains(suche));
|
||||
}
|
||||
private readonly Border _uebung = Ui.Abzeichen("ÜBUNG", "blau");
|
||||
private readonly StackPanel _liste = Ui.Spalte(6);
|
||||
private readonly TextBlock _stand = Ui.Winzig("", Ui.Dritt);
|
||||
private readonly StackPanel _liste = Ui.Spalte(0);
|
||||
private readonly ScrollViewer _rollen;
|
||||
|
||||
private readonly HashSet<string> _aus;
|
||||
private bool _nurProbleme;
|
||||
private string? _tisch;
|
||||
private double _sitzungsStart = double.NegativeInfinity;
|
||||
private JsonObject? _angehalten;
|
||||
private string _abdruck = "";
|
||||
private string _abdruck = "", _chipAbdruck = "";
|
||||
private List<string> _sichtbar = new(); // die gezeigten Zeilen als Text (Alles kopieren)
|
||||
|
||||
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(); };
|
||||
_suche.TextChanged += (_, _) => { _abdruck = ""; Zeichnen(); };
|
||||
ToolTipService.SetToolTip(_nurSitzung, "Nur die laufende Sitzung zeigen");
|
||||
_nurSitzung.Click += (_, _) => { _abdruck = ""; Zeichnen(); };
|
||||
_filter.Padding = new Thickness(8, 5, 8, 5);
|
||||
_filter.Flyout = new Flyout { Content = new StackPanel() };
|
||||
ToolTipService.SetToolTip(_filter, "Arten ein-/ausblenden");
|
||||
_aus = new HashSet<string>((Merker.Lesen("protokoll.aus") ?? "technik").Split(',', StringSplitOptions.RemoveEmptyEntries));
|
||||
_nurProbleme = Merker.Lesen("protokoll.probleme") == "1";
|
||||
_nurSitzung.IsChecked = Merker.Lesen("protokoll.sitzung") == "1";
|
||||
|
||||
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));
|
||||
kopf.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
kopf.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
kopf.Children.Add(_nurSitzung.Spalte(kopf.ColumnDefinitions.Count - 1).Mit(x => x.VerticalAlignment = VerticalAlignment.Center));
|
||||
kopf.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
kopf.Children.Add(_suche.Spalte(kopf.ColumnDefinitions.Count - 1).Mit(x => x.VerticalAlignment = VerticalAlignment.Center));
|
||||
kopf.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
kopf.Children.Add(_filter.Spalte(5).Mit(x => x.VerticalAlignment = VerticalAlignment.Center));
|
||||
_teil.Gewaehlt += _ => Neu();
|
||||
_suche.TextChanged += (_, _) => Neu();
|
||||
_suche.QuerySubmitted += (_, _) => Neu();
|
||||
|
||||
_liste.Padding = new Thickness(12);
|
||||
_pause.Content = Ui.Reihe(6, _pauseZeichen, _pauseText);
|
||||
ToolTipService.SetToolTip(_pause, "Anhalten zum Lesen - neue Zeilen kommen erst nach dem Fortsetzen");
|
||||
_pause.Click += (_, _) => { _angehalten = _pause.IsChecked == true ? _z.Ansicht.Ticker : null; Neu(); };
|
||||
|
||||
var kopieren = new MenuFlyoutItem { Text = "Gezeigte Zeilen kopieren", Icon = new FontIcon { Glyph = "\uE8C8" } };
|
||||
kopieren.Click += (_, _) => Kopieren(string.Join("\n", _sichtbar));
|
||||
var zuruecksetzen = new MenuFlyoutItem { Text = "Filter zurücksetzen", Icon = new FontIcon { Glyph = "\uE894" } };
|
||||
zuruecksetzen.Click += (_, _) => FilterZurueck();
|
||||
_nurSitzung.Click += (_, _) => { Merker.Schreiben("protokoll.sitzung", _nurSitzung.IsChecked ? "1" : "0"); Neu(); };
|
||||
_menue.Content = Ui.Zeichen("\uE712", 12);
|
||||
_menue.Flyout = new MenuFlyout { Items = { _nurSitzung, new MenuFlyoutSeparator(), zuruecksetzen, kopieren } };
|
||||
ToolTipService.SetToolTip(_menue, "Mehr");
|
||||
_art.Geaendert += Neu;
|
||||
|
||||
var f = new KeyboardAccelerator { Key = Windows.System.VirtualKey.F, Modifiers = Windows.System.VirtualKeyModifiers.Control };
|
||||
f.Invoked += (_, e) => { e.Handled = true; _suche.Focus(FocusState.Keyboard); };
|
||||
var esc = new KeyboardAccelerator { Key = Windows.System.VirtualKey.Escape };
|
||||
esc.Invoked += (_, e) => { if (_suche.Text.Length > 0) { e.Handled = true; _suche.Text = ""; } };
|
||||
// Am Fenster, solange die Seite steht: der Fokus-Anker des Fensters sitzt ausserhalb der Seite, Kuerzel an der
|
||||
// Seite selbst kaemen nie an
|
||||
Loaded += (_, _) =>
|
||||
{
|
||||
if (XamlRoot?.Content is UIElement w && !w.KeyboardAccelerators.Contains(f)) { w.KeyboardAccelerators.Add(f); w.KeyboardAccelerators.Add(esc); }
|
||||
};
|
||||
Unloaded += (_, _) =>
|
||||
{
|
||||
if (XamlRoot?.Content is UIElement w) { w.KeyboardAccelerators.Remove(f); w.KeyboardAccelerators.Remove(esc); }
|
||||
};
|
||||
|
||||
// Kopf: Teile | Suche, Pause, Menue | Filterchips | Stand
|
||||
var werkzeug = new Grid { ColumnSpacing = 6 };
|
||||
werkzeug.ColumnDefinitions.Add(new ColumnDefinition());
|
||||
werkzeug.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
werkzeug.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
werkzeug.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
werkzeug.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
werkzeug.Children.Add(_suche);
|
||||
werkzeug.Children.Add(_art.Spalte(1).Mit(a => a.VerticalAlignment = VerticalAlignment.Center));
|
||||
werkzeug.Children.Add(_uebung.Spalte(2));
|
||||
werkzeug.Children.Add(_pause.Spalte(3).Mit(p => p.VerticalAlignment = VerticalAlignment.Center));
|
||||
werkzeug.Children.Add(_menue.Spalte(4).Mit(p => p.VerticalAlignment = VerticalAlignment.Center));
|
||||
|
||||
_chipLeiste = new ScrollViewer
|
||||
{
|
||||
Content = _chips,
|
||||
HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden,
|
||||
HorizontalScrollMode = ScrollMode.Enabled,
|
||||
VerticalScrollBarVisibility = ScrollBarVisibility.Disabled,
|
||||
VerticalScrollMode = ScrollMode.Disabled,
|
||||
};
|
||||
var kopf = Ui.Spalte(8, _teil, werkzeug, _chipLeiste, _stand);
|
||||
kopf.Padding = new Thickness(12, 12, 12, 8);
|
||||
|
||||
_liste.Padding = new Thickness(6, 4, 10, 12);
|
||||
_rollen = new ScrollViewer { Content = _liste, HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled };
|
||||
var g = new Grid();
|
||||
g.RowDefinitions.Add(new RowDefinition { Height = GridLength.Auto });
|
||||
@@ -107,112 +155,437 @@ public sealed class ProtokollSeite : UserControl, ISeite
|
||||
Content = g;
|
||||
}
|
||||
|
||||
private void Neu() { _abdruck = ""; Zeichnen(); }
|
||||
|
||||
private void FilterZurueck()
|
||||
{
|
||||
_aus.Clear();
|
||||
_nurProbleme = false;
|
||||
_tisch = null;
|
||||
_suche.Text = "";
|
||||
_nurSitzung.IsChecked = false;
|
||||
Merker.Schreiben("protokoll.aus", "");
|
||||
Merker.Schreiben("protokoll.probleme", "0");
|
||||
Merker.Schreiben("protokoll.sitzung", "0");
|
||||
_chipAbdruck = "";
|
||||
Neu();
|
||||
}
|
||||
|
||||
private static void Kopieren(string text)
|
||||
{
|
||||
if (text.Length == 0) return;
|
||||
var p = new DataPackage();
|
||||
p.SetText(text);
|
||||
try { Clipboard.SetContent(p); } catch { }
|
||||
}
|
||||
|
||||
private string Suche => _suche.Text.Trim();
|
||||
|
||||
public void Zeichnen()
|
||||
{
|
||||
var geld = _teil.Index == 2;
|
||||
int teil = _teil.Index;
|
||||
bool geld = teil == 2, ereignisse = teil == 1;
|
||||
_pause.Visibility = geld ? Visibility.Collapsed : Visibility.Visible;
|
||||
_suche.Visibility = _teil.Index == 1 ? Visibility.Visible : Visibility.Collapsed;
|
||||
_filter.Visibility = _teil.Index == 1 ? Visibility.Visible : Visibility.Collapsed;
|
||||
_nurSitzung.Visibility = _teil.Index == 1 ? Visibility.Visible : Visibility.Collapsed;
|
||||
_chipLeiste.Visibility = ereignisse ? Visibility.Visible : Visibility.Collapsed;
|
||||
_menue.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;
|
||||
_pauseText.Text = _pause.IsChecked == true ? "Angehalten" : "Live";
|
||||
_pauseZeichen.Glyph = _pause.IsChecked == true ? "\uE768" : "\uE769";
|
||||
_pauseZeichen.Foreground = Ui.Pinsel(_pause.IsChecked == true ? "orange" : "gruen");
|
||||
if (geld) GeldZeichnen();
|
||||
else StromZeichnen(_teil.Index == 0);
|
||||
else if (ereignisse) EreignisseZeichnen();
|
||||
else GedankenZeichnen();
|
||||
}
|
||||
|
||||
private void StromZeichnen(bool gedanken)
|
||||
// ---- Ereignisse ------------------------------------------------------------------------------
|
||||
|
||||
/// <summary>Beginn der laufenden Sitzung: das letzte `zeitplan`-Ereignis mit phase "spielen".</summary>
|
||||
private void SitzungMerken(JsonObject? t)
|
||||
{
|
||||
var t = _angehalten ?? _z.Ansicht.Ticker;
|
||||
var abdruck = (gedanken ? "g" : "e") + (gedanken ? t?["gedanken"] : t?["zeilen"]).Abdruck();
|
||||
_sitzungsStart = double.NegativeInfinity;
|
||||
foreach (var z in t.Objekte("zeilen"))
|
||||
if (z.Text("art") == "zeitplan" && (z.Text("text") ?? "").Contains("phase=spielen"))
|
||||
_sitzungsStart = Math.Max(_sitzungsStart, z.Zahl("zeit") ?? double.NegativeInfinity);
|
||||
}
|
||||
|
||||
private static string? Problem(JsonObject z) => Ernst(z.Text("art"), z.Text("name"), z.Text("text"));
|
||||
|
||||
/// <summary>Die Gruppe einer Zeile: "technik" (Takt, Kanaele, ...; vom Server) vor der Art.</summary>
|
||||
private static string ArtSchluessel(JsonObject z) => z.Text("gruppe") is { Length: > 0 } g ? g : z.T("art");
|
||||
|
||||
private static string TischVon(JsonObject z) => z.Text("raum") is { Length: > 0 } r ? Raum.Nummer(r) : "";
|
||||
|
||||
/// <summary>Der Text ohne den angehaengten Raumnamen ("... (14R NL ... 1845111).") - der steht schon als Marke.</summary>
|
||||
private static string Klartext(JsonObject z)
|
||||
{
|
||||
var t = z.T("text");
|
||||
if (z.Text("raum") is { Length: > 0 } r) t = t.Replace($" ({r})", "");
|
||||
return Raum.Kurz(t);
|
||||
}
|
||||
|
||||
private bool Passt(JsonObject z, bool mitArt = true)
|
||||
{
|
||||
if (_nurSitzung.IsChecked && (z.Zahl("zeit") ?? double.NegativeInfinity) < _sitzungsStart) return false;
|
||||
if (_tisch != null && TischVon(z) != _tisch) return false;
|
||||
if (_nurProbleme && Problem(z) == null) return false;
|
||||
if (mitArt && _aus.Contains(ArtSchluessel(z))) return false;
|
||||
var s = Suche;
|
||||
return s.Length == 0 || new[] { z.Text("art"), z.Text("raum"), z.Text("text"), z.Text("kurz"), TischVon(z) }
|
||||
.Any(x => x != null && x.Contains(s, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
private void EreignisseZeichnen()
|
||||
{
|
||||
var live = _z.Ansicht.Ticker;
|
||||
var t = _angehalten ?? live;
|
||||
var alle = t.Objekte("zeilen").ToList();
|
||||
SitzungMerken(t);
|
||||
int neu = 0;
|
||||
if (_angehalten != null)
|
||||
{
|
||||
var oben = alle.FirstOrDefault()?.Zahl("zeit") ?? double.NegativeInfinity;
|
||||
neu = live.Objekte("zeilen").Count(z => (z.Zahl("zeit") ?? 0) > oben);
|
||||
}
|
||||
Chips(alle);
|
||||
var abdruck = "e" + t?["zeilen"].Abdruck() + neu;
|
||||
if (abdruck == _abdruck) return;
|
||||
_abdruck = abdruck;
|
||||
_liste.Children.Clear();
|
||||
if (gedanken)
|
||||
{
|
||||
foreach (var g in t.Texte("gedanken"))
|
||||
_liste.Children.Add(FestText(g));
|
||||
}
|
||||
else
|
||||
{
|
||||
SitzungMerken(t);
|
||||
var arten = t.Objekte("zeilen").Select(z => z.Text("art")).Where(a => !string.IsNullOrEmpty(a))
|
||||
.Select(a => a!).Distinct().OrderBy(a => a).ToList();
|
||||
var panel = new StackPanel { Spacing = 4 };
|
||||
foreach (var a in arten)
|
||||
{
|
||||
var cb = new CheckBox { Content = a, IsChecked = !_versteckt.Contains(a) };
|
||||
var wert = a;
|
||||
cb.Click += (_, _) => { if (cb.IsChecked == true) _versteckt.Remove(wert); else _versteckt.Add(wert); _abdruck = ""; Zeichnen(); };
|
||||
panel.Children.Add(cb);
|
||||
}
|
||||
if (panel.Children.Count == 0) panel.Children.Add(Ui.Klein("noch keine Arten"));
|
||||
(_filter.Flyout as Flyout)!.Content = panel;
|
||||
|
||||
foreach (var z in t.Objekte("zeilen").Where(Sichtbar))
|
||||
{
|
||||
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.Pinsel(Farbe(art)), FontWeight = Microsoft.UI.Text.FontWeights.Bold });
|
||||
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);
|
||||
}
|
||||
var zeilen = alle.Where(z => Passt(z)).ToList();
|
||||
_stand.Text = $"{zeilen.Count} von {alle.Count} Zeilen" + (_angehalten != null ? $" · angehalten{(neu > 0 ? $", {neu} neu" : "")}" : "");
|
||||
_stand.Foreground = _angehalten != null ? Ui.Pinsel("orange") : Ui.Dritt;
|
||||
_liste.Children.Clear();
|
||||
_sichtbar = new List<string>();
|
||||
foreach (var z in zeilen)
|
||||
{
|
||||
var (name, ton) = ArtVon(ArtSchluessel(z));
|
||||
var ernst = Problem(z);
|
||||
if (z.Text("art") == "ergebnis" && z.Zahl("netto") is double n) ton = n > 0 ? "gruen" : n < 0 ? "rot" : "grau";
|
||||
var tisch = TischVon(z);
|
||||
var text = Klartext(z);
|
||||
var kurz = z.Text("kurz") is { Length: > 0 } k ? Raum.Kurz(k) : text;
|
||||
// Entscheidung: "Turn · K♣Q♣ · Check" vorn, Konfidenz und Grund leise darunter
|
||||
var mehr = z.T("art") == "entscheidung" && kurz != text ? Nachsatz(text) : "";
|
||||
_sichtbar.Add($"{Format.Uhr(z.Zahl("zeit"))} {name,-12} {tisch,-6} {text}");
|
||||
_liste.Children.Add(Zeile(Format.Uhr(z.Zahl("zeit")), name, ernst ?? ton, tisch, z.Text("raum"), kurz, mehr, ernst, ArtSchluessel(z)));
|
||||
}
|
||||
if (_liste.Children.Count == 0)
|
||||
_liste.Children.Add(Teile.Leer("Noch nichts", t.Text("leer") ?? "Der Strom läuft, sobald der Läufer arbeitet.", ""));
|
||||
_liste.Children.Add(alle.Count == 0
|
||||
? Teile.Leer("Noch nichts", t.Text("leer") ?? "Der Strom läuft, sobald der Läufer arbeitet.", "\uE7C3")
|
||||
: LeerMitFilter());
|
||||
}
|
||||
|
||||
private static TextBlock FestText(string text) => new()
|
||||
/// <summary>Was nach der Aktion im Entscheidungstext steht ("Konfidenz 0,97. Grund: ...").</summary>
|
||||
private static string Nachsatz(string text)
|
||||
{
|
||||
Text = text,
|
||||
FontFamily = Fest,
|
||||
FontSize = 11.5,
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
IsTextSelectionEnabled = true,
|
||||
};
|
||||
var i = text.IndexOf(". Konfidenz", StringComparison.Ordinal);
|
||||
if (i < 0) i = text.IndexOf(". Equity", StringComparison.Ordinal);
|
||||
if (i < 0) i = text.IndexOf(". Grund", StringComparison.Ordinal);
|
||||
return i < 0 ? "" : text[(i + 2)..];
|
||||
}
|
||||
|
||||
private UIElement LeerMitFilter()
|
||||
{
|
||||
var s = Teile.Leer("Kein Treffer", "Die Filter verbergen alle Zeilen.", "\uE71C");
|
||||
s.Children.Add(Teile.Knopf("Filter zurücksetzen", FilterZurueck).Mit(k => k.HorizontalAlignment = HorizontalAlignment.Center));
|
||||
return s;
|
||||
}
|
||||
|
||||
/// <summary>Die Filterleiste: Tisch, Probleme, dann je Art ein Chip mit Zahl (Zahl ohne Art-Filter gezaehlt).</summary>
|
||||
private void Chips(List<JsonObject> alle)
|
||||
{
|
||||
var basis = alle.Where(z => Passt(z, mitArt: false)).ToList();
|
||||
var je = basis.GroupBy(ArtSchluessel).ToDictionary(g => g.Key, g => g.Count());
|
||||
var arten = alle.Select(ArtSchluessel).Distinct()
|
||||
.OrderBy(a => Array.FindIndex(Arten, x => x.Art == a) is var i && i >= 0 ? i : 99).ThenBy(a => a).ToList();
|
||||
var tische = alle.Select(TischVon).Where(x => x.Length > 0).Distinct().OrderBy(x => x).ToList();
|
||||
int probleme = alle.Count(z => Problem(z) != null);
|
||||
var abdruck = string.Join("|", arten.Select(a => $"{a}:{je.GetValueOrDefault(a)}:{_aus.Contains(a)}"))
|
||||
+ $"#{string.Join(",", tische)}#{_tisch}#{_nurProbleme}#{probleme}";
|
||||
if (abdruck == _chipAbdruck) return;
|
||||
_chipAbdruck = abdruck;
|
||||
_chips.Children.Clear();
|
||||
|
||||
// Tisch: Menue mit allen Tischen des Stroms
|
||||
var tischMenue = new MenuFlyout();
|
||||
var alleT = new ToggleMenuFlyoutItem { Text = "Alle Tische", IsChecked = _tisch == null };
|
||||
alleT.Click += (_, _) => { _tisch = null; _chipAbdruck = ""; Neu(); };
|
||||
tischMenue.Items.Add(alleT);
|
||||
if (tische.Count > 0) tischMenue.Items.Add(new MenuFlyoutSeparator());
|
||||
foreach (var x in tische)
|
||||
{
|
||||
var e = new ToggleMenuFlyoutItem { Text = x, IsChecked = _tisch == x };
|
||||
e.Click += (_, _) => { _tisch = x; _chipAbdruck = ""; Neu(); };
|
||||
tischMenue.Items.Add(e);
|
||||
}
|
||||
var tischChip = Chip("\uE8A9", _tisch ?? "Alle Tische", null, _tisch != null, "blau", null, pfeil: true);
|
||||
FlyoutBase.SetAttachedFlyout(tischChip, tischMenue);
|
||||
tischChip.Getippt += () => FlyoutBase.ShowAttachedFlyout(tischChip);
|
||||
_chips.Children.Add(tischChip);
|
||||
|
||||
_chips.Children.Add(Chip("\uE7BA", "Probleme", probleme, _nurProbleme, "orange", () =>
|
||||
{
|
||||
_nurProbleme = !_nurProbleme;
|
||||
Merker.Schreiben("protokoll.probleme", _nurProbleme ? "1" : "0");
|
||||
_chipAbdruck = "";
|
||||
Neu();
|
||||
}));
|
||||
_chips.Children.Add(new Border { Width = 1, Margin = new Thickness(2, 4, 2, 4), Background = Ui.Weiss(0.12) });
|
||||
|
||||
foreach (var a in arten)
|
||||
{
|
||||
var (name, ton) = ArtVon(a);
|
||||
var art = a;
|
||||
_chips.Children.Add(Chip(null, name, je.GetValueOrDefault(a), !_aus.Contains(a), ton, () =>
|
||||
{
|
||||
if (!_aus.Remove(art)) _aus.Add(art);
|
||||
Merker.Schreiben("protokoll.aus", string.Join(",", _aus));
|
||||
_chipAbdruck = "";
|
||||
Neu();
|
||||
}, punkt: true));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Ein Filterchip: Kapsel, an = getoent in der Farbe, aus = nur Rand und blasser Text.</summary>
|
||||
private static Tippflaeche Chip(string? glyph, string text, int? zahl, bool an, string ton, Action? tun,
|
||||
bool punkt = false, bool pfeil = false)
|
||||
{
|
||||
var inhalt = Ui.Reihe(5);
|
||||
if (punkt) inhalt.Children.Add(Ui.Punkt(ton, 6).Mit(p => p.Opacity = an ? 1 : 0.35));
|
||||
if (glyph != null) inhalt.Children.Add(Ui.Zeichen(glyph, 10, an ? ton : "grau"));
|
||||
inhalt.Children.Add(Ui.Text(text, 11.5, pinsel: an ? Ui.Pinsel("") : Ui.Zweit).Mit(t => t.VerticalAlignment = VerticalAlignment.Center));
|
||||
if (zahl is int n)
|
||||
inhalt.Children.Add(Ui.Text(Format.Zahl(n), 10.5, pinsel: an ? Ui.Zweit : Ui.Dritt, zahlen: true)
|
||||
.Mit(t => t.VerticalAlignment = VerticalAlignment.Center));
|
||||
if (pfeil) inhalt.Children.Add(Ui.Zeichen("\uE70D", 8, "grau"));
|
||||
var b = new Border
|
||||
{
|
||||
Height = 26,
|
||||
Padding = new Thickness(9, 0, 10, 0),
|
||||
CornerRadius = new CornerRadius(13),
|
||||
BorderThickness = new Thickness(1),
|
||||
Background = an && !punkt ? Ui.Pinsel(ton, 0.16) : an ? Ui.Weiss(0.07) : null,
|
||||
BorderBrush = an && !punkt ? Ui.Pinsel(ton, 0.45) : Ui.Weiss(an ? 0.10 : 0.08),
|
||||
Child = inhalt.Mit(r => r.VerticalAlignment = VerticalAlignment.Center),
|
||||
};
|
||||
var t = b.Tippen(tun ?? (() => { }), 13);
|
||||
Microsoft.UI.Xaml.Automation.AutomationProperties.SetName(t, text);
|
||||
return t;
|
||||
}
|
||||
|
||||
/// <summary>Eine Zeile: Zeit | (Art · Tisch) / Text. Probleme mit Farbstrich und getoentem Grund.</summary>
|
||||
private Grid Zeile(string zeit, string art, string ton, string tisch, string? raum, string text, string mehr, string? ernst, string artSchluessel)
|
||||
{
|
||||
var g = new Grid { ColumnSpacing = 8, Padding = new Thickness(6, 5, 6, 6), CornerRadius = new CornerRadius(4) };
|
||||
g.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(3) });
|
||||
g.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(52) });
|
||||
g.ColumnDefinitions.Add(new ColumnDefinition());
|
||||
var normal = ernst != null ? Ui.Pinsel(ernst, 0.08) : Ui.Weiss(0);
|
||||
g.Background = normal;
|
||||
g.PointerEntered += (_, _) => g.Background = ernst != null ? Ui.Pinsel(ernst, 0.14) : Ui.Weiss(0.04);
|
||||
g.PointerExited += (_, _) => g.Background = normal;
|
||||
|
||||
g.Children.Add(new Border { CornerRadius = new CornerRadius(2), Background = ernst != null ? Ui.Pinsel(ernst) : null });
|
||||
g.Children.Add(new TextBlock
|
||||
{
|
||||
Text = zeit, FontFamily = Fest, FontSize = 11, Foreground = Ui.Dritt,
|
||||
Margin = new Thickness(0, 1, 0, 0), IsTextSelectionEnabled = true,
|
||||
}.Spalte(1));
|
||||
|
||||
var oben = Ui.Reihe(6, Ui.Text(art.ToUpperInvariant(), 9.5, ton, fett: true).Mit(t => t.CharacterSpacing = 40));
|
||||
if (tisch.Length > 0)
|
||||
{
|
||||
var marke = new Border
|
||||
{
|
||||
Background = Ui.Weiss(0.07), CornerRadius = new CornerRadius(3), Padding = new Thickness(5, 0, 5, 1),
|
||||
Child = Ui.Text(tisch, 10, pinsel: Ui.Zweit, zahlen: true),
|
||||
};
|
||||
var t = marke.Tippen(() => { _tisch = _tisch == tisch ? null : tisch; _chipAbdruck = ""; Neu(); }, 3,
|
||||
_tisch == tisch ? "Wieder alle Tische" : $"Nur {tisch} zeigen\n{raum}");
|
||||
oben.Children.Add(t);
|
||||
}
|
||||
var haupt = new TextBlock
|
||||
{
|
||||
Text = text, FontSize = 12.5, TextWrapping = TextWrapping.Wrap, IsTextSelectionEnabled = true,
|
||||
Foreground = ernst != null ? Ui.Pinsel(ernst) : Ui.Pinsel(""), LineHeight = 17,
|
||||
};
|
||||
Markieren(haupt, text);
|
||||
var spalte = Ui.Spalte(1, oben, haupt);
|
||||
if (mehr.Length > 0)
|
||||
{
|
||||
var leise = new TextBlock { Text = mehr, FontSize = 11, Foreground = Ui.Zweit, TextWrapping = TextWrapping.Wrap, IsTextSelectionEnabled = true };
|
||||
Markieren(leise, mehr);
|
||||
spalte.Children.Add(leise);
|
||||
}
|
||||
g.Children.Add(spalte.Spalte(2));
|
||||
|
||||
var kopie = new MenuFlyoutItem { Text = "Zeile kopieren", Icon = new FontIcon { Glyph = "\uE8C8" } };
|
||||
kopie.Click += (_, _) => Kopieren($"{zeit} {art} {tisch} {text}".Replace(" ", " "));
|
||||
var menue = new MenuFlyout { Items = { kopie } };
|
||||
if (tisch.Length > 0)
|
||||
{
|
||||
var nur = new MenuFlyoutItem { Text = _tisch == tisch ? "Wieder alle Tische" : $"Nur {tisch} zeigen", Icon = new FontIcon { Glyph = "\uE71C" } };
|
||||
nur.Click += (_, _) => { _tisch = _tisch == tisch ? null : tisch; _chipAbdruck = ""; Neu(); };
|
||||
menue.Items.Add(nur);
|
||||
}
|
||||
if (artSchluessel.Length > 0)
|
||||
{
|
||||
var weg = new MenuFlyoutItem { Text = $"{art} ausblenden", Icon = new FontIcon { Glyph = "\uED1A" } };
|
||||
weg.Click += (_, _) => { _aus.Add(artSchluessel); Merker.Schreiben("protokoll.aus", string.Join(",", _aus)); _chipAbdruck = ""; Neu(); };
|
||||
menue.Items.Add(weg);
|
||||
}
|
||||
g.ContextFlyout = menue;
|
||||
return g;
|
||||
}
|
||||
|
||||
/// <summary>Alle Vorkommen der Suche gelb unterlegen.</summary>
|
||||
private void Markieren(TextBlock t, string text)
|
||||
{
|
||||
var s = Suche;
|
||||
if (s.Length == 0) return;
|
||||
var h = new TextHighlighter
|
||||
{
|
||||
Background = Ui.Pinsel("gelb", 0.35),
|
||||
Foreground = Ui.Pinsel(""),
|
||||
};
|
||||
for (int i = text.IndexOf(s, StringComparison.OrdinalIgnoreCase); i >= 0; i = text.IndexOf(s, i + s.Length, StringComparison.OrdinalIgnoreCase))
|
||||
h.Ranges.Add(new TextRange { StartIndex = i, Length = s.Length });
|
||||
if (h.Ranges.Count > 0) t.TextHighlighters.Add(h);
|
||||
}
|
||||
|
||||
// ---- Gedanken --------------------------------------------------------------------------------
|
||||
|
||||
/// <summary>"12:03:44 Hand 123 Flop: Raise 3 BB | Konfidenz 0,8 | Equity 45 % | Grund: ... | Ergebnis: gewonnen (+3 BB)"</summary>
|
||||
private static readonly Regex Gedanke = new(@"^(\d\d:\d\d:\d\d)\s+(.*?):\s(.*)$", RegexOptions.Compiled);
|
||||
|
||||
internal static string AktionTon(string a) =>
|
||||
a.StartsWith("Fold") ? "grau" : a.StartsWith("Check") || a.StartsWith("Call") ? "gruen"
|
||||
: a.StartsWith("Raise") || a.StartsWith("Bet") || a.StartsWith("All") ? "orange" : "";
|
||||
|
||||
private void GedankenZeichnen()
|
||||
{
|
||||
var t = _angehalten ?? _z.Ansicht.Ticker;
|
||||
var alle = t.Texte("gedanken").ToList();
|
||||
var abdruck = "g" + t?["gedanken"].Abdruck();
|
||||
if (abdruck == _abdruck) return;
|
||||
_abdruck = abdruck;
|
||||
var s = Suche;
|
||||
var zeilen = alle.Where(x => s.Length == 0 || x.Contains(s, StringComparison.OrdinalIgnoreCase)).ToList();
|
||||
_stand.Text = $"{zeilen.Count} von {alle.Count} Entscheidungen" + (_angehalten != null ? " · angehalten" : "");
|
||||
_stand.Foreground = _angehalten != null ? Ui.Pinsel("orange") : Ui.Dritt;
|
||||
_liste.Children.Clear();
|
||||
_sichtbar = zeilen;
|
||||
foreach (var roh in zeilen) _liste.Children.Add(GedankenZeile(roh));
|
||||
if (_liste.Children.Count == 0)
|
||||
_liste.Children.Add(alle.Count == 0
|
||||
? Teile.Leer("Noch nichts", t.Text("leer") ?? "Je eigener Entscheidung erscheint hier eine Zeile.", "\uE7C3")
|
||||
: LeerMitFilter());
|
||||
}
|
||||
|
||||
private Grid GedankenZeile(string roh)
|
||||
{
|
||||
var m = Gedanke.Match(roh);
|
||||
var g = new Grid { ColumnSpacing = 8, Padding = new Thickness(6, 6, 6, 7), CornerRadius = new CornerRadius(4) };
|
||||
g.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(3) });
|
||||
g.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(52) });
|
||||
g.ColumnDefinitions.Add(new ColumnDefinition());
|
||||
g.PointerEntered += (_, _) => g.Background = Ui.Weiss(0.04);
|
||||
g.PointerExited += (_, _) => g.Background = null;
|
||||
var kopie = new MenuFlyoutItem { Text = "Zeile kopieren", Icon = new FontIcon { Glyph = "\uE8C8" } };
|
||||
kopie.Click += (_, _) => Kopieren(roh);
|
||||
g.ContextFlyout = new MenuFlyout { Items = { kopie } };
|
||||
if (!m.Success)
|
||||
{
|
||||
var t = new TextBlock { Text = roh, FontSize = 12.5, TextWrapping = TextWrapping.Wrap, IsTextSelectionEnabled = true };
|
||||
Markieren(t, roh);
|
||||
g.Children.Add(t.Spalte(2));
|
||||
return g;
|
||||
}
|
||||
var teile = m.Groups[3].Value.Split(" | ").ToList();
|
||||
var aktion = teile.FirstOrDefault() ?? "";
|
||||
var ergebnis = teile.FirstOrDefault(x => x.StartsWith("Ergebnis: "))?["Ergebnis: ".Length..] ?? "";
|
||||
var grund = teile.FirstOrDefault(x => x.StartsWith("Grund: "))?["Grund: ".Length..] ?? "";
|
||||
var werte = teile.Skip(1).Where(x => !x.StartsWith("Ergebnis: ") && !x.StartsWith("Grund: ")).ToList();
|
||||
string ergTon = ergebnis.StartsWith("gewonnen") ? "gruen" : ergebnis.StartsWith("verloren") ? "rot" : "grau";
|
||||
|
||||
g.Children.Add(new Border { CornerRadius = new CornerRadius(2), Background = Ui.Pinsel(AktionTon(aktion) is { Length: > 0 } at ? at : "grau", 0.8) });
|
||||
g.Children.Add(new TextBlock { Text = m.Groups[1].Value, FontFamily = Fest, FontSize = 11, Foreground = Ui.Dritt, Margin = new Thickness(0, 1, 0, 0) }.Spalte(1));
|
||||
|
||||
var kopf = new Grid { ColumnSpacing = 8 };
|
||||
kopf.ColumnDefinitions.Add(new ColumnDefinition());
|
||||
kopf.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
var titel = new TextBlock { FontSize = 12.5, TextWrapping = TextWrapping.Wrap, IsTextSelectionEnabled = true };
|
||||
titel.Inlines.Add(new Run { Text = m.Groups[2].Value + " ", Foreground = Ui.Zweit });
|
||||
titel.Inlines.Add(new Run { Text = aktion, Foreground = Ui.Pinsel(AktionTon(aktion)), FontWeight = FontWeights.SemiBold });
|
||||
kopf.Children.Add(titel);
|
||||
if (ergebnis.Length > 0)
|
||||
kopf.Children.Add(Ui.Text(ergebnis == "offen" ? "offen" : ergebnis, 11, ergTon, fett: ergebnis != "offen", zahlen: true)
|
||||
.Mit(t => { t.VerticalAlignment = VerticalAlignment.Top; t.MaxWidth = 150; }).Spalte(1));
|
||||
var spalte = Ui.Spalte(2, kopf);
|
||||
if (werte.Count > 0) spalte.Children.Add(Ui.Text(string.Join(" · ", werte), 11, pinsel: Ui.Zweit, zahlen: true));
|
||||
if (grund.Length > 0)
|
||||
{
|
||||
var gt = new TextBlock { Text = grund, FontSize = 11.5, Foreground = Ui.Zweit, TextWrapping = TextWrapping.Wrap, IsTextSelectionEnabled = true };
|
||||
Markieren(gt, grund);
|
||||
spalte.Children.Add(gt);
|
||||
}
|
||||
g.Children.Add(spalte.Spalte(2));
|
||||
return g;
|
||||
}
|
||||
|
||||
// ---- Geld ------------------------------------------------------------------------------------
|
||||
|
||||
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;
|
||||
var abdruck = "geld" + g?["zeilen"].Abdruck() + _art.Wahl + "|" + Suche;
|
||||
if (abdruck == _abdruck) return;
|
||||
_abdruck = abdruck;
|
||||
_liste.Children.Clear();
|
||||
var zeilen = alle.Where(z => _art.Wahl == null || z.Text("art") == _art.Wahl).ToList();
|
||||
var s = Suche;
|
||||
var zeilen = alle.Where(z => _art.Wahl == null || z.Text("art") == _art.Wahl)
|
||||
.Where(z => s.Length == 0 || new[] { z.Text("art"), z.Text("raum"), z.Text("grund") }
|
||||
.Any(x => x != null && x.Contains(s, StringComparison.OrdinalIgnoreCase))).ToList();
|
||||
var summe = zeilen.Where(z => z.WahrOderNull("uebung") != true).Sum(z => z.Zahl("betrag") ?? 0);
|
||||
_stand.Text = $"{zeilen.Count} von {alle.Count} Bewegungen" + (zeilen.Count > 0 ? $" · Summe {Format.Zahl(summe, 2)}" : "");
|
||||
_stand.Foreground = Ui.Dritt;
|
||||
_sichtbar = zeilen.Select(z => $"{Format.Uhr(z.Zahl("zeit"))} {z.T("art")} {Format.Zahl(z.Zahl("betrag"), 2)} {z.T("raum")} {z.T("grund")}").ToList();
|
||||
if (zeilen.Count == 0)
|
||||
{
|
||||
_liste.Children.Add(Teile.Leer("Keine Geldbewegungen", g.Text("leer") ?? "Buy-in, Nachkauf und Aufstehen erscheinen hier.", ""));
|
||||
_liste.Children.Add(alle.Count == 0
|
||||
? Teile.Leer("Keine Geldbewegungen", g.Text("leer") ?? "Buy-in, Nachkauf und Aufstehen erscheinen hier.", "\uE8C7")
|
||||
: LeerMitFilter());
|
||||
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 })
|
||||
foreach (var w in new[] { new GridLength(52), 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));
|
||||
kopf.Children.Add(new TextBlock { Text = Format.Uhr(z.Zahl("zeit")), FontFamily = Fest, FontSize = 11, Foreground = Ui.Dritt, VerticalAlignment = VerticalAlignment.Center });
|
||||
kopf.Children.Add(Ui.Text(z.Text("art") ?? "–", 13, 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") is double b)
|
||||
kopf.Children.Add(Ui.Text(Format.Zahl(b, 2), 13, Teile.Ton(b) ?? "", fett: true, 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));
|
||||
kopf.Children.Add(Ui.Text(Format.Auto(bb) + " bb", 11, pinsel: Ui.Zweit, zahlen: true).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,
|
||||
Text = Raum.Kurz(string.Join(" · ", new[] { z.Text("raum") is { } r ? Raum.Nummer(r) : null, z.Text("grund") }.Where(x => !string.IsNullOrEmpty(x)))),
|
||||
FontSize = 11.5,
|
||||
Foreground = Ui.Zweit,
|
||||
TextWrapping = TextWrapping.Wrap,
|
||||
IsTextSelectionEnabled = true,
|
||||
Margin = new Thickness(58, 0, 0, 0),
|
||||
};
|
||||
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);
|
||||
var zeile = Ui.Spalte(2, kopf, unter);
|
||||
zeile.Padding = new Thickness(6, 7, 6, 7);
|
||||
zeile.Opacity = z.WahrOderNull("uebung") == true ? 0.7 : 1;
|
||||
if (_liste.Children.Count > 0) _liste.Children.Add(Ui.Linie());
|
||||
_liste.Children.Add(zeile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,6 +48,9 @@ public sealed class TischZeile : UserControl
|
||||
private readonly TextBlock _netto = Ui.Text("", 12.5, fett: true, zahlen: true);
|
||||
private readonly FontIcon _pfeil = Ui.Zeichen("", 8);
|
||||
private readonly Border _marke = new() { Width = 3, CornerRadius = new CornerRadius(2), Margin = new Thickness(0, 6, 0, 6) };
|
||||
private readonly TextBlock _log = new() { FontSize = 11, TextTrimming = TextTrimming.CharacterEllipsis, TextWrapping = TextWrapping.NoWrap };
|
||||
private readonly Ellipse _logPunkt = Ui.Punkt("grau", 5);
|
||||
private readonly Grid _logZeile = new() { ColumnSpacing = 6, Padding = new Thickness(21, 0, 10, 6) };
|
||||
private readonly Border _huelle = new() { Padding = new Thickness(8, 0, 8, 8), Visibility = Visibility.Collapsed };
|
||||
private readonly Border _linie = Ui.Linie();
|
||||
private TischKachel? _kachel;
|
||||
@@ -67,7 +70,7 @@ public sealed class TischZeile : UserControl
|
||||
var name = Ui.Reihe(6, _punkt.Mit(p => p.VerticalAlignment = VerticalAlignment.Center),
|
||||
Ui.Text(nr == raum ? titel : nr, 12.5, fett: true, zahlen: true).Mit(t => t.MaxWidth = 110),
|
||||
Ui.Text(Raum.Stufe(raum), 11, pinsel: Ui.Dritt).Mit(t => t.VerticalAlignment = VerticalAlignment.Center));
|
||||
var g = new Grid { ColumnSpacing = 6, Height = 34, Padding = new Thickness(5, 0, 10, 0) };
|
||||
var g = new Grid { ColumnSpacing = 6, Height = 32, Padding = new Thickness(5, 0, 10, 0) };
|
||||
foreach (var b in new[] { GridLength.Auto, new GridLength(94), new GridLength(60), new GridLength(1, GridUnitType.Star), GridLength.Auto, GridLength.Auto })
|
||||
g.ColumnDefinitions.Add(new ColumnDefinition { Width = b });
|
||||
g.Children.Add(_marke);
|
||||
@@ -77,9 +80,16 @@ public sealed class TischZeile : UserControl
|
||||
g.Children.Add(_netto.Spalte(4));
|
||||
g.Children.Add(_pfeil.Spalte(5));
|
||||
foreach (var e in new FrameworkElement[] { name, _karten, _was, _netto, _pfeil }) e.VerticalAlignment = VerticalAlignment.Center;
|
||||
// darunter die letzte Zeile des Stroms an diesem Tisch (Owner 02.12.: "log line pro tisch")
|
||||
_logZeile.ColumnDefinitions.Add(new ColumnDefinition { Width = GridLength.Auto });
|
||||
_logZeile.ColumnDefinitions.Add(new ColumnDefinition());
|
||||
_logZeile.Children.Add(_logPunkt.Mit(p => p.Margin = new Thickness(0, 1, 0, 0)));
|
||||
_logZeile.Children.Add(_log.Spalte(1));
|
||||
_logZeile.Visibility = Visibility.Collapsed;
|
||||
var kopfUndLog = Ui.Spalte(0, g, _logZeile);
|
||||
var s = Ui.Spalte(0);
|
||||
s.Children.Add(_linie);
|
||||
s.Children.Add(g.Tippen(() => Offen = !Offen, 4));
|
||||
s.Children.Add(kopfUndLog.Tippen(() => Offen = !Offen, 4));
|
||||
s.Children.Add(_huelle);
|
||||
Content = s;
|
||||
Visibility = Visibility.Collapsed;
|
||||
@@ -115,7 +125,8 @@ public sealed class TischZeile : UserControl
|
||||
var was = zug ? "am Zug" : kachel.Text("aktion") is { Length: > 0 } a ? a.Replace("Raise auf", "Raise").Replace(" BB", "")
|
||||
: kachel.Text("zustand") is { Length: > 0 } zu && zu != "gesessen" ? zu : "";
|
||||
var zeile = chip.T("zeile");
|
||||
var abdruck = $"{chip.T("punkt_ton")}|{zug}|{string.Join(",", karten)}|{was}|{zeile}|{chip.T("zeile_ton")}";
|
||||
var log = chip.T("log");
|
||||
var abdruck = $"{chip.T("punkt_ton")}|{zug}|{string.Join(",", karten)}|{was}|{zeile}|{chip.T("zeile_ton")}|{log}|{chip.T("log_ton")}|{chip.T("log_warn")}";
|
||||
if (abdruck == _abdruck) return;
|
||||
_abdruck = abdruck;
|
||||
_punkt.Fill = Ui.Pinsel(chip.T("punkt_ton"));
|
||||
@@ -126,8 +137,23 @@ public sealed class TischZeile : UserControl
|
||||
_was.Foreground = zug ? Ui.Pinsel("orange") : Ui.Zweit;
|
||||
_netto.Text = zeile == "gesessen" ? "" : zeile;
|
||||
_netto.Foreground = chip.T("zeile_ton") is "grau" or "" ? Ui.Dritt : Ui.Pinsel(chip.T("zeile_ton"));
|
||||
LogSetzen(log, chip.Zahl("log_zeit"), chip.T("log_warn") is { Length: > 0 } w ? w : chip.T("log_ton"), chip.T("log_warn").Length > 0 || chip.T("log_art") == "ergebnis");
|
||||
ToolTipService.SetToolTip(this, kachel.Text("hinweis") is { Length: > 0 } h ? $"{_raum}\n{h}" : _raum);
|
||||
}
|
||||
|
||||
/// <summary>Die letzte Stromzeile: Uhrzeit leise, Text in Weiss bzw. bei Warnung/Fehler in deren Farbe.</summary>
|
||||
private void LogSetzen(string text, double? zeit, string ton, bool laut)
|
||||
{
|
||||
_logZeile.Visibility = text.Length > 0 ? Visibility.Visible : Visibility.Collapsed;
|
||||
if (text.Length == 0) return;
|
||||
text = Raum.Kurz(text);
|
||||
_log.Inlines.Clear();
|
||||
if (zeit is double t)
|
||||
_log.Inlines.Add(new Microsoft.UI.Xaml.Documents.Run { Text = Format.Kurz(t) + " ", Foreground = Ui.Dritt });
|
||||
_log.Inlines.Add(new Microsoft.UI.Xaml.Documents.Run { Text = text, Foreground = laut ? Ui.Pinsel(ton) : Ui.Zweit });
|
||||
_logPunkt.Fill = Ui.Pinsel(ton is { Length: > 0 } ? ton : "grau", laut ? 1 : 0.7);
|
||||
ToolTipService.SetToolTip(_logZeile, (zeit is double z ? Format.Uhr(z) + " " : "") + text);
|
||||
}
|
||||
|
||||
public void Takt() { if (Offen) _kachel?.Takt(); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user