![]() |
VOOZH | about |
dotnet add package Oakrey.Applications.Terminals --version 2.0.4
NuGet\Install-Package Oakrey.Applications.Terminals -Version 2.0.4
<PackageReference Include="Oakrey.Applications.Terminals" Version="2.0.4" />
<PackageVersion Include="Oakrey.Applications.Terminals" Version="2.0.4" />Directory.Packages.props
<PackageReference Include="Oakrey.Applications.Terminals" />Project file
paket add Oakrey.Applications.Terminals --version 2.0.4
#r "nuget: Oakrey.Applications.Terminals, 2.0.4"
#:package Oakrey.Applications.Terminals@2.0.4
#addin nuget:?package=Oakrey.Applications.Terminals&version=2.0.4Install as a Cake Addin
#tool nuget:?package=Oakrey.Applications.Terminals&version=2.0.4Install as a Cake Tool
A .NET 10 WPF library for building terminal-like interfaces in MVVM applications. It provides command history, message management, reactive updates, file export, and built-in integration with Oakrey.Log and Oakrey.Telemetry.
IMessageCollection<TMessage> backed by a ReplaySubject for reactive change notifications.StringMessage and StringAndDirectionMessage (with Direction) ship out of the box; custom types require only implementing IMessage.IMessageViewSettings controls sort order (OldestOnTop / NewestOnTop), displayed message count, and timestamp visibility.SaveToFile command writes messages to a .txt file via a standard save dialog with a configurable file name prefix.ContextCommands collection is data-bindable and ships with "Clear" and "Save to file" entries.Oakrey.Log and Oakrey.Telemetry automatically.classDiagram
class IMessage {
+DateTime Timestamp
}
class StringMessage {
+string Message
+DateTime Timestamp
}
class StringAndDirectionMessage {
+string Message
+Direction Direction
+DateTime Timestamp
}
class IMessageCollection~TMessage~ {
+List~TMessage~ Messages
+AddMessage(TMessage)
+ClearMessages()
+Subscribe(IObserver)
}
class MessageCollection~TMessage~
class IMessageViewSettings {
+SortOrder SortOrder
+int DisplayedMessages
+bool ShowTimestamp
}
class HistoryViewModel {
+string Command
+IStringHistoryProvider History
+AddCommandToHistory()
+HistoryUp()
+HistoryDown()
+Export() string
}
class TerminalViewModel~TMessage~ {
+ObservableCollection~TMessage~ Messages
+ObservableCollection~TMessage~ TerminalMessages
+ObservableCollection~ContextMenuForViewModel~ ContextCommands
+ICommand SendCommand
+ICommand ClearMessages
+ICommand SaveToFile
#DefaultCommand()*
#TraceLine(TMessage)*
+string FilePrefix*
}
IMessage <|.. StringMessage
IMessage <|.. StringAndDirectionMessage
IMessageCollection <|.. MessageCollection
HistoryViewModel <|-- TerminalViewModel
TerminalViewModel o-- IMessageCollection
TerminalViewModel o-- IMessageViewSettings
| Type | Description |
|---|---|
IMessage |
Minimal contract for a timestamped message. |
StringMessage |
Simple string message with a DateTime timestamp. |
StringAndDirectionMessage |
Message with an additional Direction (e.g. inbound/outbound). |
MessageCollection<TMessage> |
Default in-memory IMessageCollection<TMessage> using System.Reactive. |
IMessageViewSettings / MessageViewSettings |
Controls sort order, display count, and timestamp visibility. |
IStringHistoryProvider / CommandHistory |
Navigable, deduplicated command history (capacity 20). |
HistoryViewModel |
WPF ViewModel base with command input and history navigation. |
TerminalViewModel<TMessage> |
Abstract ViewModel base combining history, messages, export, and context menu. |
ContextMenuForViewModel |
Bindable context menu entry pairing a display name with an ICommand. |
NuGet Package Manager
Search for Oakrey.Applications.Terminals in Visual Studio under
Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
.NET CLI
dotnet add package Oakrey.Applications.Terminals
Package Manager Console
Install-Package Oakrey.Applications.Terminals
Inject or create an IMessageViewSettings instance and pass it to your TerminalViewModel subclass:
MessageViewSettings settings = new()
{
SortOrder = SortOrder.NewestOnTop,
DisplayedMessages = 200,
ShowTimestamp = true
};
Implement TerminalViewModel<TMessage> to create a concrete terminal:
public sealed class MyTerminalViewModel : TerminalViewModel<StringMessage>
{
public override string FilePrefix => "my-terminal";
protected override string TraceLine(StringMessage message)
=> $"[{message.Timestamp:HH:mm:ss}] {message.Message}";
protected override void DefaultCommand()
{
if (string.IsNullOrWhiteSpace(Command))
{
return;
}
devices.AddMessage(new StringMessage(Command));
}
}
Bind in XAML:
<ItemsControl ItemsSource="{Binding TerminalMessages}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Message}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<TextBox Text="{Binding Command, UpdateSourceTrigger=PropertyChanged}" />
<Button Content="Send" Command="{Binding SendCommand}" />
<ContextMenu ItemsSource="{Binding ContextCommands}">
<ContextMenu.ItemContainerStyle>
<Style TargetType="MenuItem">
<Setter Property="Header" Value="{Binding DisplayName}" />
<Setter Property="Command" Value="{Binding MessageContextMenuCommand}" />
</Style>
</ContextMenu.ItemContainerStyle>
</ContextMenu>
TerminalViewModel<TMessage> implements IDisposable. Always dispose instances that are no longer needed to unsubscribe from the reactive pipeline.CommandHistory capacity is fixed at 20 entries. Provide a custom IStringHistoryProvider to change this behaviour.MessageCollection<TMessage>.ClearMessages() calls messageSubject.OnNext(messages.Last()) after clearing; ensure the collection is non-empty before clearing or guard accordingly in derived code.Oakrey.Log.LoggerFactory and tracing uses Oakrey.Telemetry.TracingFactory, both resolved by the concrete Type of the ViewModel subclass.MIT - Copyright (c) Oakrey 2016-2025. See LICENSE for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0-windows7.0 net10.0-windows7.0 is compatible. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.