Class ConsoleKindFilter
- Namespace
- McServerLauncher.ViewModels
- Assembly
- McServerLauncher.dll
One category of console line, as a toggle with a count behind it.
public class ConsoleKindFilter : ObservableObject, INotifyPropertyChanged, INotifyPropertyChanging
- Inheritance
-
ConsoleKindFilter
- Implements
- Inherited Members
Remarks
The count is what makes these worth having. A row of on/off switches only helps once you already know what you are looking for; "Errors 3" tells you there is something to look at before you press anything, which is the difference between a filter you search with and one you watch with.
HasUnseen covers the case that follows from it: an error arriving while its own category is switched off would otherwise be completely invisible — filtered out of the list and with nothing on screen changing. The switch says so instead.
Constructors
ConsoleKindFilter(ConsoleLineKind)
public ConsoleKindFilter(ConsoleLineKind kind)
Parameters
kindConsoleLineKind
Properties
Brush
The colour lines of this kind are drawn in, so the switch matches them.
[ExcludeFromCodeCoverage]
public IBrush? Brush { get; set; }
Property Value
- IBrush
Count
How many lines of this kind are in the buffer.
[ExcludeFromCodeCoverage]
public int Count { get; set; }
Property Value
HasUnseen
True when lines of this kind arrived while it was switched off.
[ExcludeFromCodeCoverage]
public bool HasUnseen { get; set; }
Property Value
IsOn
Whether lines of this kind are shown. Everything starts on.
[ExcludeFromCodeCoverage]
public bool IsOn { get; set; }
Property Value
Kind
The category this switch turns on and off.
public ConsoleLineKind Kind { get; }
Property Value
Label
Its name, in the user's language.
public string Label { get; }
Property Value
Tip
The tooltip: what this is, and how much of it there is.
public string Tip { get; }
Property Value
Methods
Matches(ConsoleLine, string?, IReadOnlyDictionary<ConsoleLineKind, ConsoleKindFilter>)
Whether a line survives the search box and the category switches.
public static bool Matches(ConsoleLine line, string? term, IReadOnlyDictionary<ConsoleLineKind, ConsoleKindFilter> kinds)
Parameters
lineConsoleLinetermstringkindsIReadOnlyDictionary<ConsoleLineKind, ConsoleKindFilter>
Returns
Remarks
Both conditions, and the category first: it is a dictionary lookup against a line that is already in hand, while the search is a substring scan over text that can be hundreds of characters long. On two thousand lines rebuilt on every keystroke, the order is the difference between a filter that keeps up with typing and one that does not.
Recount(IEnumerable<ConsoleLine>, IEnumerable<ConsoleKindFilter>)
Counts every kind from scratch.
public static void Recount(IEnumerable<ConsoleLine> lines, IEnumerable<ConsoleKindFilter> filters)
Parameters
linesIEnumerable<ConsoleLine>filtersIEnumerable<ConsoleKindFilter>
Remarks
Used after the buffer is trimmed rather than trying to decrement as lines fall off the top. Two thousand lines is nothing, it happens once every couple of hundred lines, and it cannot drift — which a pair of counters maintained by hand at both ends certainly would, and the symptom would be a switch quietly claiming there are no errors.
VisibleLinesLeaving(IReadOnlyList<ConsoleLine>, int, Func<ConsoleLine, bool>)
How many lines the visible console loses when the first excess of
lines are trimmed off the top.
public static int VisibleLinesLeaving(IReadOnlyList<ConsoleLine> lines, int excess, Func<ConsoleLine, bool> isVisible)
Parameters
linesIReadOnlyList<ConsoleLine>excessintisVisibleFunc<ConsoleLine, bool>
Returns
Remarks
The visible list holds the same lines in the same order, minus the ones the filters hide. So trimming it is not a matter of working out which lines it still ought to contain — it is just the count of the leaving lines that were on screen, dropped from its front.
The difference from rebuilding it matters more than it looks. A rebuilt list announces itself as "everything changed", and a virtualized console answers that by discarding every row it had drawn and drawing them all again — two hundred lines of output apart, for as long as the server is talking. Removing from the front announces what left instead, and the rows already on screen stay where they are.