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.