Oakrey.Applications.ControlObjects 4.1.1

dotnet add package Oakrey.Applications.ControlObjects --version 4.1.1
                    
NuGet\Install-Package Oakrey.Applications.ControlObjects -Version 4.1.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Oakrey.Applications.ControlObjects" Version="4.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Oakrey.Applications.ControlObjects" Version="4.1.1" />
                    
Directory.Packages.props
<PackageReference Include="Oakrey.Applications.ControlObjects" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Oakrey.Applications.ControlObjects --version 4.1.1
                    
#r "nuget: Oakrey.Applications.ControlObjects, 4.1.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Oakrey.Applications.ControlObjects@4.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Oakrey.Applications.ControlObjects&version=4.1.1
                    
Install as a Cake Addin
#tool nuget:?package=Oakrey.Applications.ControlObjects&version=4.1.1
                    
Install as a Cake Tool

Oakrey.Applications.ControlObjects

A .NET / WPF library that provides a hierarchy of base classes and interfaces for building interactive, validated control objects. It covers object validation, keyboard gesture binding, device communication, timer-driven and cancelable operations, observable collections with automatic JSON persistence, and supporting WPF converters.

Main features

  • Property-level validation via ValidableObject with per-property error messages and an aggregate IsValid / Errors surface
  • Generic SendingObject<TData> base with reactive IObservable<TData> data stream, IObservable<Exception> error stream, and multi-key gesture support
  • EnableObject<TData> - toggle-based enable/disable with Color and ToolTip bindings
  • TimerObject<TData> - periodic sending driven by a configurable Period (TimeSpan)
  • CancelableObject<TData> - async operation with cooperative cancellation via CancellationToken; exposes visual Color state
  • ISendingDevice<TData> abstraction for downstream hardware or service targets with IObservable<DeviceStatus> status stream
  • SendingObjectCollection<TData, TSendingObject> - ObservableCollection that auto-saves and auto-loads its items as JSON, reacts to device status changes, and routes gestures
  • ICollectionService<TItem> - lightweight add/remove collection interface
  • GestureControlMainViewModelBase - ViewModel base for windows/pages that own multiple gesture controllers; exposes a page-switch observable
  • WPF SelectionHighlightConverter<T> and SelectionHighlightConverterFactoryExtension for reference-equality-based selection highlighting

Architecture

classDiagram
    class ValidableObject {
        +bool IsValid
        +string Errors
        +SetValid()
        +SetInvalid(errorMessage)
    }
    class CollectionObject {
        +string Name
        +string Description
    }
    class SendingObject~TData~ {
        +IObservable~TData~ DataToSend
        +IObservable~Exception~ Error
        +IObservable~string~ Info
        +MultiKeyGesture Gesture
        +ICommand Click
    }
    class EnableObject~TData~ {
        +bool IsEnabled
        +Brush Color
        +string ToolTip
    }
    class TimerObject~TData~ {
        +TimeSpan Period
        +string PeriodString
    }
    class CancelableObject~TData~ {
        +bool IsEnabled
        +Brush Color
        #Task Run(CancellationToken)
    }
    class SendingObjectCollection~TData~ {
        +IEnumerable~IGesture~ Gestures
        #string ConfigFileName
        #bool DisableObjectsWhenDeviceDisconnected
    }

    ValidableObject <|-- CollectionObject
    CollectionObject <|-- SendingObject
    SendingObject <|-- EnableObject
    EnableObject <|-- TimerObject
    SendingObject <|-- CancelableObject
    SendingObjectCollection --> SendingObject : contains
    SendingObjectCollection --> ISendingDevice : routes to

Key types

Type Description
ValidableObject Property-level validation base; implements INotifyPropertyChanged
CollectionObject Adds Name / Description; validates that Name is not empty
SendingObject<TData> Reactive send + error + info streams, multi-key gesture, IDisposable
EnableObject<TData> Toggle enable/disable with WPF-bindable Color and ToolTip
TimerObject<TData> Periodic firing; click toggles the internal System.Timers.Timer
CancelableObject<TData> Async Run with automatic CancellationTokenSource management
ISendingDevice<TData> Target abstraction: SendData, PropagateInfo, PropagateException
DeviceStatus Enum: Disconnected, Connected, DeviceAdded, DeviceRemoved
SendingObjectCollection<TData,T> Observable collection with JSON persistence and device routing
GestureControlMainViewModelBase ViewModel base for pages owning gesture controllers
SelectionHighlightConverter<T> IMultiValueConverter returning Visibility based on reference equality

Requirements

  • .NET 10 or higher
  • Windows 10 version 1809 (build 17763) or higher (WPF dependency)
  • Oakrey.UI 2.0.1
  • Oakrey.Log.Toast 2.1.0
  • System.Drawing.Common 10.0.8

Installation

.NET CLI

dotnet add package Oakrey.Applications.ControlObjects

Package Manager Console

Install-Package Oakrey.Applications.ControlObjects

NuGet Package Manager

Search for Oakrey.Applications.ControlObjects in Tools > NuGet Package Manager > Manage NuGet Packages for Solution.

Configuration

SendingObjectCollection automatically persists its items to a JSON file. The file path is resolved as:

<directory of ISettingsService.AppSettingPath>\<ConfigFileName>

Override the ConfigFileName property in each concrete collection to control the file name. If the file does not exist on first run, an empty collection is written automatically.

Example usage

Define a concrete sending object

public class MyCommand : EnableObject<string>
{
    public override void Disable() => IsEnabled = false;
}

Define a concrete collection

public class MyCommandCollection : SendingObjectCollection<string, MyCommand>
{
    protected override string ConfigFileName => "myCommands.json";

    public MyCommandCollection(
        ISendingDevice<string> device,
        IJsonService jsonService,
        ISettingsService settings)
        : base(device, jsonService, settings) { }
}

Subscribe to outgoing data

foreach (MyCommand cmd in collection)
{
    cmd.DataToSend.Subscribe(data => device.SendData(data, cmd.Name));
    cmd.Error.Subscribe(ex => logger.Error(ex.Message));
}

Implement a ViewModel with gesture support

public class MainViewModel : GestureControlMainViewModelBase
{
    public MainViewModel(IEnumerable<IGestureController> controllers)
        : base(controllers) { }
}

WPF selection highlight in XAML

<Border.Visibility>
    <MultiBinding Converter="{local:SelectionHighlightConverterFactory}">
        <Binding Path="." />
        <Binding Path="DataContext.SelectedItem" RelativeSource="{RelativeSource AncestorType=Window}" />
    </MultiBinding>
</Border.Visibility>

Development notes

  • All SendingObject subclasses implement IDisposable. Ensure collections are disposed when the owning ViewModel is torn down to release Rx subscriptions.
  • CancelableObject.Run returns Task.CompletedTask by default; override it to add async logic. Errors thrown inside Run are forwarded through the Error observable.
  • GestureControlMainViewModelBase implements IAutoConfigurable. Override LoadBasicGestures and LoadSwitchGestures to register application-level shortcuts.
  • TimerObject validates PeriodString on set; it must parse as a TimeSpan between 1 ms and 1 day.

Project information

License

This project is licensed under the MIT License. See the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net10.0-windows10.0.17763 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.1.1 85 5/15/2026
4.1.0 112 3/13/2026
4.0.2 124 2/13/2026
4.0.1 118 2/11/2026
4.0.0 457 11/18/2025
3.0.1 195 10/31/2025
3.0.0 208 10/22/2025
2.0.1 219 10/15/2025
2.0.0 214 10/15/2025
1.1.0 178 10/10/2025
1.0.0 233 9/29/2025